mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 20:47:46 +00:00
nl: fix build
This commit is contained in:
parent
782fad4667
commit
8e430d6952
2 changed files with 6 additions and 3 deletions
|
@ -8,7 +8,8 @@ fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> {
|
||||||
['t'] => { Ok(::NumberingStyle::NumberForNonEmpty) },
|
['t'] => { Ok(::NumberingStyle::NumberForNonEmpty) },
|
||||||
['n'] => { Ok(::NumberingStyle::NumberForNone) },
|
['n'] => { Ok(::NumberingStyle::NumberForNone) },
|
||||||
['p', rest..] => {
|
['p', rest..] => {
|
||||||
match regex::Regex::new(String::from_chars(rest).as_slice()) {
|
let s : String = rest.iter().map(|c| *c).collect();
|
||||||
|
match regex::Regex::new(s.as_slice()) {
|
||||||
Ok(re) => Ok(::NumberingStyle::NumberForRegularExpression(re)),
|
Ok(re) => Ok(::NumberingStyle::NumberForRegularExpression(re)),
|
||||||
Err(_) => Err(String::from_str("Illegal regular expression")),
|
Err(_) => Err(String::from_str("Illegal regular expression")),
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,16 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#![feature(plugin)]
|
||||||
|
|
||||||
#[macro_use] extern crate regex_macros;
|
#[plugin] extern crate regex_macros;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
|
||||||
use std::io::{stdin};
|
use std::io::{stdin};
|
||||||
use std::io::BufferedReader;
|
use std::io::BufferedReader;
|
||||||
use std::io::fs::File;
|
use std::io::fs::File;
|
||||||
|
use std::iter::repeat;
|
||||||
use std::num::Int;
|
use std::num::Int;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use getopts::{optopt, optflag, getopts, usage, OptGroup};
|
use getopts::{optopt, optflag, getopts, usage, OptGroup};
|
||||||
|
@ -282,7 +284,7 @@ fn nl<T: Reader> (reader: &mut BufferedReader<T>, settings: &Settings) {
|
||||||
if settings.number_width > line_no_width {
|
if settings.number_width > line_no_width {
|
||||||
w = settings.number_width - line_no_width;
|
w = settings.number_width - line_no_width;
|
||||||
}
|
}
|
||||||
let fill = String::from_char(w, fill_char);
|
let fill : String = repeat(fill_char).take(w).collect();
|
||||||
match settings.number_format {
|
match settings.number_format {
|
||||||
NumberFormat::Left => {
|
NumberFormat::Left => {
|
||||||
println!("{1}{0}{2}{3}", fill, line_no, settings.number_separator, line)
|
println!("{1}{0}{2}{3}", fill, line_no, settings.number_separator, line)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue