From 2d58ea5f8bf3232a2339d130ad43364f1cd79329 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sat, 8 Dec 2018 21:57:53 +0530 Subject: [PATCH 001/126] pr: print 56 lines of content with 5 blank trailer and header lines --- Cargo.toml | 2 + src/pr/Cargo.toml | 21 +++++++ src/pr/pr.rs | 139 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 src/pr/Cargo.toml create mode 100644 src/pr/pr.rs diff --git a/Cargo.toml b/Cargo.toml index 208fd5d9c..8afd36761 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,7 @@ feat_common_core = [ "nl", "od", "paste", + "pr", "printenv", "printf", "ptx", @@ -285,6 +286,7 @@ od = { optional=true, version="0.0.4", package="uu_od", path="src/uu/od" } paste = { optional=true, version="0.0.4", package="uu_paste", path="src/uu/paste" } pathchk = { optional=true, version="0.0.4", package="uu_pathchk", path="src/uu/pathchk" } pinky = { optional=true, version="0.0.4", package="uu_pinky", path="src/uu/pinky" } +pr = { optional=true, path="src/pr" } printenv = { optional=true, version="0.0.4", package="uu_printenv", path="src/uu/printenv" } printf = { optional=true, version="0.0.4", package="uu_printf", path="src/uu/printf" } ptx = { optional=true, version="0.0.4", package="uu_ptx", path="src/uu/ptx" } diff --git a/src/pr/Cargo.toml b/src/pr/Cargo.toml new file mode 100644 index 000000000..1093462af --- /dev/null +++ b/src/pr/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "pr" +version = "0.0.1" +authors = ["Tilak Patidar "] +build = "../../mkmain.rs" + +[lib] +name = "uu_pr" +path = "pr.rs" + +[dependencies] +getopts = "0.2.18" +time = "0.1.40" + +[dependencies.uucore] +path = "../uucore" +features = ["libc"] + +[[bin]] +name = "pr" +path = "../../uumain.rs" diff --git a/src/pr/pr.rs b/src/pr/pr.rs new file mode 100644 index 000000000..aec6fb208 --- /dev/null +++ b/src/pr/pr.rs @@ -0,0 +1,139 @@ +#![crate_name = "uu_pr"] + +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE file +// that was distributed with this source code. +// + +extern crate getopts; + +//#[macro_use] +//extern crate uucore; +use std::fs::File; +use std::io::{BufRead, BufReader}; +use std::vec::Vec; +//use uucore::fs::is_stdin_interactive; + + +static NAME: &str = "pr"; +static VERSION: &str = env!("CARGO_PKG_VERSION"); +static LINES_PER_PAGE: usize = 66; +static HEADER_LINES_PER_PAGE: usize = 5; +static TRAILER_LINES_PER_PAGE: usize = 5; +static CONTENT_LINES_PER_PAGE: usize = LINES_PER_PAGE - HEADER_LINES_PER_PAGE - TRAILER_LINES_PER_PAGE; + +pub fn uumain(args: Vec) -> i32 { + let mut opts = getopts::Options::new(); + + opts.optopt( + "h", + "", + "Use the string header to replace the file name \ + in the header line.", + "STRING", + ); + opts.optflag("h", "help", "display this help and exit"); + opts.optflag("V", "version", "output version information and exit"); + + let matches = match opts.parse(&args[1..]) { + Ok(m) => m, + Err(e) => panic!("Invalid options\n{}", e), + }; + + if matches.opt_present("version") { + println!("{} {}", NAME, VERSION); + return 0; + } + + + if matches.opt_present("help") || matches.free.is_empty() { + println!("{} {} -- print files", NAME, VERSION); + println!(); + println!("Usage: {} [+page] [-column] [-adFfmprt] [[-e] [char] [gap]] + [-L locale] [-h header] [[-i] [char] [gap]] + [-l lines] [-o offset] [[-s] [char]] [[-n] [char] + [width]] [-w width] [-] [file ...].", NAME); + println!(); + println!( + "{}", + opts.usage( + "The pr utility is a printing and pagination filter + for text files. When multiple input files are spec- + ified, each is read, formatted, and written to stan- + dard output. By default, the input is separated + into 66-line pages, each with + + o A 5-line header with the page number, date, + time, and the pathname of the file. + + o A 5-line trailer consisting of blank lines. + + If standard output is associated with a terminal, + diagnostic messages are suppressed until the pr + utility has completed processing. + + When multiple column output is specified, text col- + umns are of equal width. By default text columns + are separated by at least one . Input lines + that do not fit into a text column are truncated. + Lines are not truncated under single column output." + ) + ); + if matches.free.is_empty() { + return 1; + } + return 0; + } + + let path = &matches.free[0]; + open(&path); + + 0 +} + +fn open(path: &str) -> std::io::Result<()> { + let file = File::open(path)?; + let lines = BufReader::new(file).lines(); + let mut i = 0; + let mut page: i32 = 0; + let mut buffered_content: Vec = Vec::new(); + for line in lines { + if i == CONTENT_LINES_PER_PAGE { + page = page + 1; + i = 0; + print!("{}", print_page(&buffered_content)); + buffered_content.clear(); + } + i = i + 1; + buffered_content.push(line?); + } + if i != 0 { + print!("{}", print_page(&buffered_content)); + buffered_content.clear(); + } + Ok(()) +} + +fn print_page(lines: &Vec) -> String { + let mut page_content: Vec = Vec::new(); + let header_content = header_content(); + let trailer_content = trailer_content(); + assert_eq!(lines.len() <= CONTENT_LINES_PER_PAGE, true, "Only {} lines of content allowed in a pr output page", CONTENT_LINES_PER_PAGE.to_string()); + assert_eq!(header_content.len(), HEADER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr header", HEADER_LINES_PER_PAGE.to_string()); + assert_eq!(trailer_content.len(), TRAILER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr trailer", TRAILER_LINES_PER_PAGE.to_string()); + page_content.extend(header_content); + for x in lines { + page_content.push(x.to_string()); + } + page_content.extend(trailer_content); + page_content.join("\n") +} + +fn header_content() -> Vec { + vec!["".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string()] +} + +fn trailer_content() -> Vec { + vec!["".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string()] +} From 2ee90ab09a61f28d8fb79af6dfb3eebc208a3b55 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sat, 8 Dec 2018 23:03:15 +0530 Subject: [PATCH 002/126] pr: print pr header with file last modified time, path and page number --- src/pr/Cargo.toml | 1 + src/pr/pr.rs | 34 +++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/pr/Cargo.toml b/src/pr/Cargo.toml index 1093462af..12ce16b5b 100644 --- a/src/pr/Cargo.toml +++ b/src/pr/Cargo.toml @@ -11,6 +11,7 @@ path = "pr.rs" [dependencies] getopts = "0.2.18" time = "0.1.40" +chrono = "0.4.6" [dependencies.uucore] path = "../uucore" diff --git a/src/pr/pr.rs b/src/pr/pr.rs index aec6fb208..d661ab1c6 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -7,12 +7,17 @@ // extern crate getopts; +extern crate chrono; //#[macro_use] //extern crate uucore; +use std::fs; use std::fs::File; use std::io::{BufRead, BufReader}; use std::vec::Vec; +use chrono::offset::Local; +use chrono::DateTime; + //use uucore::fs::is_stdin_interactive; @@ -94,6 +99,7 @@ pub fn uumain(args: Vec) -> i32 { fn open(path: &str) -> std::io::Result<()> { let file = File::open(path)?; + let file_last_modified_time = file_last_modified_time(path); let lines = BufReader::new(file).lines(); let mut i = 0; let mut page: i32 = 0; @@ -102,27 +108,30 @@ fn open(path: &str) -> std::io::Result<()> { if i == CONTENT_LINES_PER_PAGE { page = page + 1; i = 0; - print!("{}", print_page(&buffered_content)); + let header = header_content(&file_last_modified_time, path, page); + print!("{}", print_page(&header, &buffered_content)); buffered_content.clear(); } i = i + 1; buffered_content.push(line?); } if i != 0 { - print!("{}", print_page(&buffered_content)); + let header = header_content(&file_last_modified_time, path, page); + print!("{}", print_page(&header, &buffered_content)); buffered_content.clear(); } Ok(()) } -fn print_page(lines: &Vec) -> String { +fn print_page(header_content: &Vec, lines: &Vec) -> String { let mut page_content: Vec = Vec::new(); - let header_content = header_content(); let trailer_content = trailer_content(); assert_eq!(lines.len() <= CONTENT_LINES_PER_PAGE, true, "Only {} lines of content allowed in a pr output page", CONTENT_LINES_PER_PAGE.to_string()); assert_eq!(header_content.len(), HEADER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr header", HEADER_LINES_PER_PAGE.to_string()); assert_eq!(trailer_content.len(), TRAILER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr trailer", TRAILER_LINES_PER_PAGE.to_string()); - page_content.extend(header_content); + for x in header_content { + page_content.push(x.to_string()); + } for x in lines { page_content.push(x.to_string()); } @@ -130,8 +139,19 @@ fn print_page(lines: &Vec) -> String { page_content.join("\n") } -fn header_content() -> Vec { - vec!["".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string()] +fn header_content(last_modified: &String, path: &str, page: i32) -> Vec { + let first_line: String = format!("{} {} Page {}", last_modified, path, page.to_string()); + vec![first_line, "".to_string(), "".to_string(), "".to_string(), "".to_string()] +} + +fn file_last_modified_time(path: &str) -> String { + let file_metadata = fs::metadata(path); + return file_metadata.map(|i| { + return i.modified().map(|x| { + let datetime: DateTime = x.into(); + datetime.format("%b %d %H:%M %Y").to_string() + }).unwrap_or(String::new()); + }).unwrap_or(String::new()); } fn trailer_content() -> Vec { From 9111f168aac0de081c6fdc682eebfcc4a405ab72 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sat, 8 Dec 2018 23:13:01 +0530 Subject: [PATCH 003/126] pr: add -h to print header and -n to print line numbers pr: Add -h to print custom header instead of file name pr: Add -n to print line numbers --- src/pr/pr.rs | 132 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 110 insertions(+), 22 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index d661ab1c6..02403a6c4 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -27,6 +27,36 @@ static LINES_PER_PAGE: usize = 66; static HEADER_LINES_PER_PAGE: usize = 5; static TRAILER_LINES_PER_PAGE: usize = 5; static CONTENT_LINES_PER_PAGE: usize = LINES_PER_PAGE - HEADER_LINES_PER_PAGE - TRAILER_LINES_PER_PAGE; +static NUMBERING_MODE_DEFAULT_SEPARATOR: &str = "\t"; +static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; + +struct OutputOptions { + /// Line numbering mode + number: Option, + header: String, +} + +impl AsRef for OutputOptions { + fn as_ref(&self) -> &OutputOptions { + self + } +} + +struct NumberingMode { + /// Line numbering mode + width: usize, + separator: String, +} + +impl Default for NumberingMode { + fn default() -> NumberingMode { + NumberingMode { + width: NUMBERING_MODE_DEFAULT_WIDTH, + separator: NUMBERING_MODE_DEFAULT_SEPARATOR.to_string(), + } + } +} + pub fn uumain(args: Vec) -> i32 { let mut opts = getopts::Options::new(); @@ -38,7 +68,18 @@ pub fn uumain(args: Vec) -> i32 { in the header line.", "STRING", ); - opts.optflag("h", "help", "display this help and exit"); + + opts.optflagopt( + "n", + "", + "Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies + the first width column positions of each text column or each line of -m output. If char (any nondigit + character) is given, it is appended to the line number to separate it from whatever follows. The default + for char is a . Line numbers longer than width columns are truncated.", + "[char][width]", + ); + + opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = match opts.parse(&args[1..]) { @@ -60,10 +101,7 @@ pub fn uumain(args: Vec) -> i32 { [-l lines] [-o offset] [[-s] [char]] [[-n] [char] [width]] [-w width] [-] [file ...].", NAME); println!(); - println!( - "{}", - opts.usage( - "The pr utility is a printing and pagination filter + let usage: &str = "The pr utility is a printing and pagination filter for text files. When multiple input files are spec- ified, each is read, formatted, and written to stan- dard output. By default, the input is separated @@ -82,9 +120,8 @@ pub fn uumain(args: Vec) -> i32 { umns are of equal width. By default text columns are separated by at least one . Input lines that do not fit into a text column are truncated. - Lines are not truncated under single column output." - ) - ); + Lines are not truncated under single column output."; + println!("{}", opts.usage(usage)); if matches.free.is_empty() { return 1; } @@ -92,38 +129,53 @@ pub fn uumain(args: Vec) -> i32 { } let path = &matches.free[0]; - open(&path); + let header: String = matches.opt_str("h").unwrap_or(path.to_string()); + let numbering_options = matches.opt_str("n").map(|i| { + NumberingMode { + width: i.parse::().unwrap_or(NumberingMode::default().width), + separator: NumberingMode::default().separator, + } + }).or_else(|| { + if matches.opt_present("n") { + return Some(NumberingMode::default()); + } + return None; + }); + + let options = OutputOptions { + number: numbering_options, + header, + }; + + pr(&path, options); 0 } -fn open(path: &str) -> std::io::Result<()> { +fn pr(path: &str, options: OutputOptions) -> std::io::Result<()> { let file = File::open(path)?; let file_last_modified_time = file_last_modified_time(path); let lines = BufReader::new(file).lines(); let mut i = 0; - let mut page: i32 = 0; + let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); for line in lines { if i == CONTENT_LINES_PER_PAGE { page = page + 1; i = 0; - let header = header_content(&file_last_modified_time, path, page); - print!("{}", print_page(&header, &buffered_content)); - buffered_content.clear(); + flush_buffered_page(&file_last_modified_time, &mut buffered_content, &options, page); } i = i + 1; buffered_content.push(line?); } if i != 0 { - let header = header_content(&file_last_modified_time, path, page); - print!("{}", print_page(&header, &buffered_content)); - buffered_content.clear(); + page = page + 1; + flush_buffered_page(&file_last_modified_time, &mut buffered_content, &options, page); } Ok(()) } -fn print_page(header_content: &Vec, lines: &Vec) -> String { +fn print_page(header_content: &Vec, lines: &Vec, options: &OutputOptions, page: usize) -> String { let mut page_content: Vec = Vec::new(); let trailer_content = trailer_content(); assert_eq!(lines.len() <= CONTENT_LINES_PER_PAGE, true, "Only {} lines of content allowed in a pr output page", CONTENT_LINES_PER_PAGE.to_string()); @@ -132,16 +184,52 @@ fn print_page(header_content: &Vec, lines: &Vec) -> String { for x in header_content { page_content.push(x.to_string()); } + + let width: usize = options.as_ref() + .number.as_ref() + .map(|i| i.width) + .unwrap_or(0); + let separator: String = options.as_ref() + .number.as_ref() + .map(|i| i.separator.to_string()) + .unwrap_or(NumberingMode::default().separator); + + let prev_lines = CONTENT_LINES_PER_PAGE * (page - 1); + let mut i = 1; for x in lines { - page_content.push(x.to_string()); + if options.number.is_none() { + page_content.push(x.to_string()); + } else { + let fmtd_line_number: String = get_fmtd_line_number(width, prev_lines + i, &separator); + page_content.push(format!("{}{}", fmtd_line_number, x.to_string())); + } + i = i + 1; } page_content.extend(trailer_content); page_content.join("\n") } -fn header_content(last_modified: &String, path: &str, page: i32) -> Vec { - let first_line: String = format!("{} {} Page {}", last_modified, path, page.to_string()); - vec![first_line, "".to_string(), "".to_string(), "".to_string(), "".to_string()] +fn get_fmtd_line_number(width: usize, line_number: usize, separator: &String) -> String { + format!("{:>width$}{}", take_last_n(&line_number.to_string(), width), separator, width = width) +} + +fn take_last_n(s: &String, n: usize) -> &str { + if s.len() >= n { + &s[s.len() - n..] + } else { + s + } +} + +fn flush_buffered_page(file_last_modified_time: &String, buffered_content: &mut Vec, options: &OutputOptions, page: usize) { + let header = header_content(file_last_modified_time, &options.header, page); + print!("{}", print_page(&header, buffered_content, &options, page)); + buffered_content.clear(); +} + +fn header_content(last_modified: &String, header: &String, page: usize) -> Vec { + let first_line: String = format!("{} {} Page {}", last_modified, header, page.to_string()); + vec!["".to_string(), "".to_string(), first_line, "".to_string(), "".to_string()] } fn file_last_modified_time(path: &str) -> String { From 7f87e42ad16d41db375e975a27b0e39e5c3d6d81 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sun, 9 Dec 2018 19:04:58 +0530 Subject: [PATCH 004/126] pr: add support for multiple files --- src/pr/pr.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 02403a6c4..4bd4d7fb1 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -17,6 +17,7 @@ use std::io::{BufRead, BufReader}; use std::vec::Vec; use chrono::offset::Local; use chrono::DateTime; +use getopts::Matches; //use uucore::fs::is_stdin_interactive; @@ -128,8 +129,23 @@ pub fn uumain(args: Vec) -> i32 { return 0; } - let path = &matches.free[0]; - let header: String = matches.opt_str("h").unwrap_or(path.to_string()); + + let mut files = matches.free.clone(); + if files.is_empty() { + //For stdin + files.push("-".to_owned()); + } + + for f in files { + let header: String = matches.opt_str("h").unwrap_or(f.to_string()); + let options = build_options(&matches, header); + pr(&f, options); + } + + 0 +} + +fn build_options(matches: &Matches, header: String) -> OutputOptions { let numbering_options = matches.opt_str("n").map(|i| { NumberingMode { width: i.parse::().unwrap_or(NumberingMode::default().width), @@ -141,15 +157,10 @@ pub fn uumain(args: Vec) -> i32 { } return None; }); - - let options = OutputOptions { + OutputOptions { number: numbering_options, header, - }; - - pr(&path, options); - - 0 + } } fn pr(path: &str, options: OutputOptions) -> std::io::Result<()> { From e69c9ada343063d2feadce4a989c9970016f240c Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Mon, 10 Dec 2018 18:56:51 +0530 Subject: [PATCH 005/126] pr: read from stdin --- src/pr/Cargo.toml | 3 + src/pr/pr.rs | 158 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 124 insertions(+), 37 deletions(-) diff --git a/src/pr/Cargo.toml b/src/pr/Cargo.toml index 12ce16b5b..c53915747 100644 --- a/src/pr/Cargo.toml +++ b/src/pr/Cargo.toml @@ -17,6 +17,9 @@ chrono = "0.4.6" path = "../uucore" features = ["libc"] +[target.'cfg(unix)'.dependencies] +unix_socket = "0.5.0" + [[bin]] name = "pr" path = "../../uumain.rs" diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 4bd4d7fb1..fe9733274 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -8,18 +8,22 @@ extern crate getopts; extern crate chrono; +#[cfg(unix)] +extern crate unix_socket; -//#[macro_use] -//extern crate uucore; -use std::fs; -use std::fs::File; -use std::io::{BufRead, BufReader}; +#[macro_use] +extern crate uucore; + +use std::io::{BufRead, BufReader, Lines, stdin}; use std::vec::Vec; use chrono::offset::Local; use chrono::DateTime; use getopts::Matches; - -//use uucore::fs::is_stdin_interactive; +use getopts::Options; +use std::io::{self, Read}; +use std::fs::{metadata, File}; +#[cfg(unix)] +use std::os::unix::fs::FileTypeExt; static NAME: &str = "pr"; @@ -58,6 +62,21 @@ impl Default for NumberingMode { } } +enum InputType { + Directory, + File, + StdIn, + SymLink, + #[cfg(unix)] + BlockDevice, + #[cfg(unix)] + CharacterDevice, + #[cfg(unix)] + Fifo, + #[cfg(unix)] + Socket, +} + pub fn uumain(args: Vec) -> i32 { let mut opts = getopts::Options::new(); @@ -93,16 +112,35 @@ pub fn uumain(args: Vec) -> i32 { return 0; } + let mut files = matches.free.clone(); + if files.is_empty() { + //For stdin + files.push("-".to_owned()); + } - if matches.opt_present("help") || matches.free.is_empty() { - println!("{} {} -- print files", NAME, VERSION); - println!(); - println!("Usage: {} [+page] [-column] [-adFfmprt] [[-e] [char] [gap]] + if matches.opt_present("help") { + return print_usage(&mut opts, &matches); + } + + + for f in files { + let header: String = matches.opt_str("h").unwrap_or(f.to_string()); + let options = build_options(&matches, header); + pr(&f, options); + } + + 0 +} + +fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { + println!("{} {} -- print files", NAME, VERSION); + println!(); + println!("Usage: {} [+page] [-column] [-adFfmprt] [[-e] [char] [gap]] [-L locale] [-h header] [[-i] [char] [gap]] [-l lines] [-o offset] [[-s] [char]] [[-n] [char] [width]] [-w width] [-] [file ...].", NAME); - println!(); - let usage: &str = "The pr utility is a printing and pagination filter + println!(); + let usage: &str = "The pr utility is a printing and pagination filter for text files. When multiple input files are spec- ified, each is read, formatted, and written to stan- dard output. By default, the input is separated @@ -122,27 +160,11 @@ pub fn uumain(args: Vec) -> i32 { are separated by at least one . Input lines that do not fit into a text column are truncated. Lines are not truncated under single column output."; - println!("{}", opts.usage(usage)); - if matches.free.is_empty() { - return 1; - } - return 0; + println!("{}", opts.usage(usage)); + if matches.free.is_empty() { + return 1; } - - - let mut files = matches.free.clone(); - if files.is_empty() { - //For stdin - files.push("-".to_owned()); - } - - for f in files { - let header: String = matches.opt_str("h").unwrap_or(f.to_string()); - let options = build_options(&matches, header); - pr(&f, options); - } - - 0 + return 0; } fn build_options(matches: &Matches, header: String) -> OutputOptions { @@ -163,13 +185,40 @@ fn build_options(matches: &Matches, header: String) -> OutputOptions { } } +fn open(path: &str) -> Option> { + // TODO Use Result instead of Option + if path == "-" { + let stdin = stdin(); + return Some(Box::new(stdin) as Box); + } + + match get_input_type(path)? { + InputType::Directory => None, + #[cfg(unix)] + InputType::Socket => { + // TODO Add reading from socket + None + } + _ => { + match File::open(path) { + Ok(file) => Some(Box::new(file) as Box), + _ => None + } + } + } +} + fn pr(path: &str, options: OutputOptions) -> std::io::Result<()> { - let file = File::open(path)?; - let file_last_modified_time = file_last_modified_time(path); - let lines = BufReader::new(file).lines(); let mut i = 0; let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); + let file_last_modified_time = file_last_modified_time(path); + let reader = open(path); + // TODO Handle error here + let lines: Lines>> = reader.map(|i| { + BufReader::new(i).lines() + }).unwrap(); + for line in lines { if i == CONTENT_LINES_PER_PAGE { page = page + 1; @@ -244,7 +293,7 @@ fn header_content(last_modified: &String, header: &String, page: usize) -> Vec String { - let file_metadata = fs::metadata(path); + let file_metadata = metadata(path); return file_metadata.map(|i| { return i.modified().map(|x| { let datetime: DateTime = x.into(); @@ -256,3 +305,38 @@ fn file_last_modified_time(path: &str) -> String { fn trailer_content() -> Vec { vec!["".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string()] } + +fn get_input_type(path: &str) -> Option { + if path == "-" { + return Some(InputType::StdIn); + } + + metadata(path).map(|i| { + match i.file_type() { + #[cfg(unix)] + ft if ft.is_block_device() => + { + Some(InputType::BlockDevice) + } + #[cfg(unix)] + ft if ft.is_char_device() => + { + Some(InputType::CharacterDevice) + } + #[cfg(unix)] + ft if ft.is_fifo() => + { + Some(InputType::Fifo) + } + #[cfg(unix)] + ft if ft.is_socket() => + { + Some(InputType::Socket) + } + ft if ft.is_dir() => Some(InputType::Directory), + ft if ft.is_file() => Some(InputType::File), + ft if ft.is_symlink() => Some(InputType::SymLink), + _ => None + } + }).unwrap_or(None) +} From 2d609b2cd17a88f1fbf8cfb70c9699ac898515ae Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Mon, 10 Dec 2018 22:07:16 +0530 Subject: [PATCH 006/126] pr: add custom errors pr: code refactoring for references --- src/pr/Cargo.toml | 1 + src/pr/pr.rs | 182 +++++++++++++++++++++++++++------------------- 2 files changed, 107 insertions(+), 76 deletions(-) diff --git a/src/pr/Cargo.toml b/src/pr/Cargo.toml index c53915747..08cc5ac30 100644 --- a/src/pr/Cargo.toml +++ b/src/pr/Cargo.toml @@ -12,6 +12,7 @@ path = "pr.rs" getopts = "0.2.18" time = "0.1.40" chrono = "0.4.6" +quick-error = "1.2.2" [dependencies.uucore] path = "../uucore" diff --git a/src/pr/pr.rs b/src/pr/pr.rs index fe9733274..058133422 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -6,24 +6,23 @@ // that was distributed with this source code. // -extern crate getopts; -extern crate chrono; #[cfg(unix)] extern crate unix_socket; - #[macro_use] +extern crate quick_error; +extern crate chrono; +extern crate getopts; extern crate uucore; -use std::io::{BufRead, BufReader, Lines, stdin}; +use std::io::{BufRead, BufReader, stdin, stdout, stderr, Error, Read, Write, Stdout}; use std::vec::Vec; use chrono::offset::Local; use chrono::DateTime; -use getopts::Matches; -use getopts::Options; -use std::io::{self, Read}; +use getopts::{Matches, Options}; use std::fs::{metadata, File}; #[cfg(unix)] use std::os::unix::fs::FileTypeExt; +use quick_error::ResultExt; static NAME: &str = "pr"; @@ -77,6 +76,27 @@ enum InputType { Socket, } +quick_error! { + #[derive(Debug)] + enum PrError { + Input(err: Error, path: String) { + context(path: &'a str, err: Error) -> (err, path.to_owned()) + display("pr: Reading from input {0} gave error", path) + cause(err) + } + + UnknownFiletype(path: String) { + display("pr: {0}: unknown filetype", path) + } + + EncounteredErrors(msg: String) { + display("pr: {0} encountered", msg) + } + IsDirectory(path: String) { + display("pr: {0}: Is a directory", path) + } + } +} pub fn uumain(args: Vec) -> i32 { let mut opts = getopts::Options::new(); @@ -112,7 +132,7 @@ pub fn uumain(args: Vec) -> i32 { return 0; } - let mut files = matches.free.clone(); + let mut files: Vec = matches.free.clone(); if files.is_empty() { //For stdin files.push("-".to_owned()); @@ -122,14 +142,15 @@ pub fn uumain(args: Vec) -> i32 { return print_usage(&mut opts, &matches); } - for f in files { - let header: String = matches.opt_str("h").unwrap_or(f.to_string()); - let options = build_options(&matches, header); - pr(&f, options); + let header: &String = &matches.opt_str("h").unwrap_or(f.to_string()); + let options: &OutputOptions = &build_options(&matches, header); + let status: i32 = pr(&f, options); + if status != 0 { + return status; + } } - - 0 + return 0; } fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { @@ -167,8 +188,8 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { return 0; } -fn build_options(matches: &Matches, header: String) -> OutputOptions { - let numbering_options = matches.opt_str("n").map(|i| { +fn build_options(matches: &Matches, header: &String) -> OutputOptions { + let numbering_options: Option = matches.opt_str("n").map(|i| { NumberingMode { width: i.parse::().unwrap_or(NumberingMode::default().width), separator: NumberingMode::default().separator, @@ -181,68 +202,75 @@ fn build_options(matches: &Matches, header: String) -> OutputOptions { }); OutputOptions { number: numbering_options, - header, + header: header.to_string(), } } -fn open(path: &str) -> Option> { - // TODO Use Result instead of Option - if path == "-" { - let stdin = stdin(); - return Some(Box::new(stdin) as Box); - } - - match get_input_type(path)? { - InputType::Directory => None, +fn open(path: &str) -> Result, PrError> { + match get_input_type(path) { + Some(InputType::Directory) => Err(PrError::IsDirectory(path.to_string())), #[cfg(unix)] - InputType::Socket => { + Some(InputType::Socket) => { // TODO Add reading from socket - None + Err(PrError::EncounteredErrors("Reading from socket not supported yet".to_string())) } - _ => { - match File::open(path) { - Ok(file) => Some(Box::new(file) as Box), - _ => None - } + Some(InputType::StdIn) => { + let stdin = stdin(); + Ok(Box::new(stdin) as Box) } + Some(_) => Ok(Box::new(File::open(path).context(path)?) as Box), + None => Err(PrError::UnknownFiletype(path.to_string())) } } -fn pr(path: &str, options: OutputOptions) -> std::io::Result<()> { +fn pr(path: &str, options: &OutputOptions) -> i32 { let mut i = 0; let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); let file_last_modified_time = file_last_modified_time(path); - let reader = open(path); - // TODO Handle error here - let lines: Lines>> = reader.map(|i| { - BufReader::new(i).lines() - }).unwrap(); + match open(path) { + Ok(reader) => { + // TODO Replace the loop + for line in BufReader::new(reader).lines() { + if i == CONTENT_LINES_PER_PAGE { + page = page + 1; + i = 0; + prepare_page(&file_last_modified_time, &mut buffered_content, options, &page); + } + match line { + Ok(content) => buffered_content.push(content), + Err(error) => { + writeln!(&mut stderr(), "pr: Unable to read from input type {}\n{}", path, error.to_string()); + return -1; + } + } + i = i + 1; + } - for line in lines { - if i == CONTENT_LINES_PER_PAGE { - page = page + 1; - i = 0; - flush_buffered_page(&file_last_modified_time, &mut buffered_content, &options, page); + if i != 0 { + page = page + 1; + prepare_page(&file_last_modified_time, &mut buffered_content, options, &page); + } + } + Err(error) => { + writeln!(&mut stderr(), "{}", error); + return -1; } - i = i + 1; - buffered_content.push(line?); } - if i != 0 { - page = page + 1; - flush_buffered_page(&file_last_modified_time, &mut buffered_content, &options, page); - } - Ok(()) + return 0; } -fn print_page(header_content: &Vec, lines: &Vec, options: &OutputOptions, page: usize) -> String { - let mut page_content: Vec = Vec::new(); - let trailer_content = trailer_content(); - assert_eq!(lines.len() <= CONTENT_LINES_PER_PAGE, true, "Only {} lines of content allowed in a pr output page", CONTENT_LINES_PER_PAGE.to_string()); - assert_eq!(header_content.len(), HEADER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr header", HEADER_LINES_PER_PAGE.to_string()); - assert_eq!(trailer_content.len(), TRAILER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr trailer", TRAILER_LINES_PER_PAGE.to_string()); +fn print_page(header_content: &Vec, lines: &Vec, options: &OutputOptions, page: &usize) { + let trailer_content: Vec = trailer_content(); + assert_eq!(lines.len() <= CONTENT_LINES_PER_PAGE, true, "Only {} lines of content allowed in a pr output page", CONTENT_LINES_PER_PAGE); + assert_eq!(header_content.len(), HEADER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr header", HEADER_LINES_PER_PAGE); + assert_eq!(trailer_content.len(), TRAILER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr trailer", TRAILER_LINES_PER_PAGE); + let out: &mut Stdout = &mut stdout(); + let new_line: &[u8] = "\n".as_bytes(); + out.lock(); for x in header_content { - page_content.push(x.to_string()); + out.write(x.as_bytes()); + out.write(new_line); } let width: usize = options.as_ref() @@ -258,37 +286,39 @@ fn print_page(header_content: &Vec, lines: &Vec, options: &Outpu let mut i = 1; for x in lines { if options.number.is_none() { - page_content.push(x.to_string()); + out.write(x.as_bytes()); } else { - let fmtd_line_number: String = get_fmtd_line_number(width, prev_lines + i, &separator); - page_content.push(format!("{}{}", fmtd_line_number, x.to_string())); + let fmtd_line_number: String = get_fmtd_line_number(&width, prev_lines + i, &separator); + out.write(format!("{}{}", fmtd_line_number, x).as_bytes()); } + out.write(new_line); i = i + 1; } - page_content.extend(trailer_content); - page_content.join("\n") + for x in trailer_content { + out.write(x.as_bytes()); + out.write(new_line); + } + out.flush(); } -fn get_fmtd_line_number(width: usize, line_number: usize, separator: &String) -> String { - format!("{:>width$}{}", take_last_n(&line_number.to_string(), width), separator, width = width) -} - -fn take_last_n(s: &String, n: usize) -> &str { - if s.len() >= n { - &s[s.len() - n..] +fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) -> String { + let line_str = line_number.to_string(); + if line_str.len() >= *width { + format!("{:>width$}{}", &line_str[line_str.len() - *width..], separator, width = width) } else { - s + format!("{:>width$}{}", line_str, separator, width = width) } } -fn flush_buffered_page(file_last_modified_time: &String, buffered_content: &mut Vec, options: &OutputOptions, page: usize) { - let header = header_content(file_last_modified_time, &options.header, page); - print!("{}", print_page(&header, buffered_content, &options, page)); + +fn prepare_page(file_last_modified_time: &String, buffered_content: &mut Vec, options: &OutputOptions, page: &usize) { + let header: Vec = header_content(file_last_modified_time, &options.header, &page); + print_page(&header, buffered_content, &options, &page); buffered_content.clear(); } -fn header_content(last_modified: &String, header: &String, page: usize) -> Vec { - let first_line: String = format!("{} {} Page {}", last_modified, header, page.to_string()); +fn header_content(last_modified: &String, header: &String, page: &usize) -> Vec { + let first_line: String = format!("{} {} Page {}", last_modified, header, page); vec!["".to_string(), "".to_string(), first_line, "".to_string(), "".to_string()] } From 781d77eb3cacb861114a091f3c16c32b8ab29211 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 12 Dec 2018 15:52:22 +0530 Subject: [PATCH 007/126] pr: add support for -d option --- src/pr/pr.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 058133422..264088076 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -38,6 +38,8 @@ struct OutputOptions { /// Line numbering mode number: Option, header: String, + double_spaced: bool, + line_separator: String } impl AsRef for OutputOptions { @@ -109,6 +111,13 @@ pub fn uumain(args: Vec) -> i32 { "STRING", ); + opts.optflag( + "d", + "", + "Produce output that is double spaced. An extra character is output following every + found in the input.", + ); + opts.optflagopt( "n", "", @@ -200,9 +209,18 @@ fn build_options(matches: &Matches, header: &String) -> OutputOptions { } return None; }); + + let line_separator: String = if matches.opt_present("d") { + "\n\n".to_string() + } else { + "\n".to_string() + }; + OutputOptions { number: numbering_options, header: header.to_string(), + double_spaced: matches.opt_present("d"), + line_separator } } @@ -266,11 +284,12 @@ fn print_page(header_content: &Vec, lines: &Vec, options: &Outpu assert_eq!(header_content.len(), HEADER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr header", HEADER_LINES_PER_PAGE); assert_eq!(trailer_content.len(), TRAILER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr trailer", TRAILER_LINES_PER_PAGE); let out: &mut Stdout = &mut stdout(); - let new_line: &[u8] = "\n".as_bytes(); + let line_separator = options.as_ref().line_separator.as_bytes(); + out.lock(); for x in header_content { out.write(x.as_bytes()); - out.write(new_line); + out.write(line_separator); } let width: usize = options.as_ref() @@ -291,12 +310,12 @@ fn print_page(header_content: &Vec, lines: &Vec, options: &Outpu let fmtd_line_number: String = get_fmtd_line_number(&width, prev_lines + i, &separator); out.write(format!("{}{}", fmtd_line_number, x).as_bytes()); } - out.write(new_line); + out.write(line_separator); i = i + 1; } for x in trailer_content { out.write(x.as_bytes()); - out.write(new_line); + out.write(line_separator); } out.flush(); } From 77d3d08f0bc8348e9470e21b80891f7c820ad707 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 12 Dec 2018 16:06:30 +0530 Subject: [PATCH 008/126] pr: show current time for stdin input --- src/pr/pr.rs | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 264088076..512e7308e 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -39,7 +39,8 @@ struct OutputOptions { number: Option, header: String, double_spaced: bool, - line_separator: String + line_separator: String, + last_modified_time: String, } impl AsRef for OutputOptions { @@ -153,7 +154,7 @@ pub fn uumain(args: Vec) -> i32 { for f in files { let header: &String = &matches.opt_str("h").unwrap_or(f.to_string()); - let options: &OutputOptions = &build_options(&matches, header); + let options: &OutputOptions = &build_options(&matches, header, &f); let status: i32 = pr(&f, options); if status != 0 { return status; @@ -197,7 +198,7 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { return 0; } -fn build_options(matches: &Matches, header: &String) -> OutputOptions { +fn build_options(matches: &Matches, header: &String, path: &String) -> OutputOptions { let numbering_options: Option = matches.opt_str("n").map(|i| { NumberingMode { width: i.parse::().unwrap_or(NumberingMode::default().width), @@ -216,11 +217,18 @@ fn build_options(matches: &Matches, header: &String) -> OutputOptions { "\n".to_string() }; + let last_modified_time = if path.eq("-") { + current_time() + } else { + file_last_modified_time(path) + }; + OutputOptions { number: numbering_options, header: header.to_string(), double_spaced: matches.opt_present("d"), - line_separator + line_separator, + last_modified_time, } } @@ -245,7 +253,6 @@ fn pr(path: &str, options: &OutputOptions) -> i32 { let mut i = 0; let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); - let file_last_modified_time = file_last_modified_time(path); match open(path) { Ok(reader) => { // TODO Replace the loop @@ -253,7 +260,7 @@ fn pr(path: &str, options: &OutputOptions) -> i32 { if i == CONTENT_LINES_PER_PAGE { page = page + 1; i = 0; - prepare_page(&file_last_modified_time, &mut buffered_content, options, &page); + prepare_page(&mut buffered_content, options, &page); } match line { Ok(content) => buffered_content.push(content), @@ -267,7 +274,7 @@ fn pr(path: &str, options: &OutputOptions) -> i32 { if i != 0 { page = page + 1; - prepare_page(&file_last_modified_time, &mut buffered_content, options, &page); + prepare_page(&mut buffered_content, options, &page); } } Err(error) => { @@ -330,14 +337,14 @@ fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) - } -fn prepare_page(file_last_modified_time: &String, buffered_content: &mut Vec, options: &OutputOptions, page: &usize) { - let header: Vec = header_content(file_last_modified_time, &options.header, &page); +fn prepare_page(buffered_content: &mut Vec, options: &OutputOptions, page: &usize) { + let header: Vec = header_content(&options, &page); print_page(&header, buffered_content, &options, &page); buffered_content.clear(); } -fn header_content(last_modified: &String, header: &String, page: &usize) -> Vec { - let first_line: String = format!("{} {} Page {}", last_modified, header, page); +fn header_content(options: &OutputOptions, page: &usize) -> Vec { + let first_line: String = format!("{} {} Page {}", options.last_modified_time, options.header, page); vec!["".to_string(), "".to_string(), first_line, "".to_string(), "".to_string()] } @@ -351,6 +358,11 @@ fn file_last_modified_time(path: &str) -> String { }).unwrap_or(String::new()); } +fn current_time() -> String { + let datetime: DateTime = Local::now(); + datetime.format("%b %d %H:%M %Y").to_string() +} + fn trailer_content() -> Vec { vec!["".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string()] } From 1cf84a730529359d0987aa25aae8b87fb63cc32f Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 12 Dec 2018 16:48:29 +0530 Subject: [PATCH 009/126] pr: refactor option flags into constants --- src/pr/pr.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 512e7308e..f86fd5adc 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -33,6 +33,9 @@ static TRAILER_LINES_PER_PAGE: usize = 5; static CONTENT_LINES_PER_PAGE: usize = LINES_PER_PAGE - HEADER_LINES_PER_PAGE - TRAILER_LINES_PER_PAGE; static NUMBERING_MODE_DEFAULT_SEPARATOR: &str = "\t"; static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; +static STRING_HEADER_OPTION: &str = "h"; +static NUMBERING_MODE_OPTION: &str = "n"; +static FILE_STDIN: &str = "-"; struct OutputOptions { /// Line numbering mode @@ -105,7 +108,7 @@ pub fn uumain(args: Vec) -> i32 { let mut opts = getopts::Options::new(); opts.optopt( - "h", + STRING_HEADER_OPTION, "", "Use the string header to replace the file name \ in the header line.", @@ -120,7 +123,7 @@ pub fn uumain(args: Vec) -> i32 { ); opts.optflagopt( - "n", + NUMBERING_MODE_OPTION, "", "Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies the first width column positions of each text column or each line of -m output. If char (any nondigit @@ -145,7 +148,7 @@ pub fn uumain(args: Vec) -> i32 { let mut files: Vec = matches.free.clone(); if files.is_empty() { //For stdin - files.push("-".to_owned()); + files.push(FILE_STDIN.to_owned()); } if matches.opt_present("help") { @@ -153,7 +156,7 @@ pub fn uumain(args: Vec) -> i32 { } for f in files { - let header: &String = &matches.opt_str("h").unwrap_or(f.to_string()); + let header: &String = &matches.opt_str(STRING_HEADER_OPTION).unwrap_or(f.to_string()); let options: &OutputOptions = &build_options(&matches, header, &f); let status: i32 = pr(&f, options); if status != 0 { @@ -199,13 +202,13 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { } fn build_options(matches: &Matches, header: &String, path: &String) -> OutputOptions { - let numbering_options: Option = matches.opt_str("n").map(|i| { + let numbering_options: Option = matches.opt_str(NUMBERING_MODE_OPTION).map(|i| { NumberingMode { width: i.parse::().unwrap_or(NumberingMode::default().width), separator: NumberingMode::default().separator, } }).or_else(|| { - if matches.opt_present("n") { + if matches.opt_present(NUMBERING_MODE_OPTION) { return Some(NumberingMode::default()); } return None; @@ -217,7 +220,7 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> OutputOpt "\n".to_string() }; - let last_modified_time = if path.eq("-") { + let last_modified_time = if path.eq(FILE_STDIN) { current_time() } else { file_last_modified_time(path) @@ -368,7 +371,7 @@ fn trailer_content() -> Vec { } fn get_input_type(path: &str) -> Option { - if path == "-" { + if path == FILE_STDIN { return Some(InputType::StdIn); } From 8c7cbf65a5f3f48a3bbce7026f4266b70c3fa906 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 12 Dec 2018 16:48:43 +0530 Subject: [PATCH 010/126] pr: throw error on reading from socket --- src/pr/pr.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index f86fd5adc..921dada45 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -98,9 +98,14 @@ quick_error! { EncounteredErrors(msg: String) { display("pr: {0} encountered", msg) } + IsDirectory(path: String) { display("pr: {0}: Is a directory", path) } + + IsSocket(path: String) { + display("pr: cannot open {}, Operation not supported on socket", path) + } } } @@ -240,8 +245,7 @@ fn open(path: &str) -> Result, PrError> { Some(InputType::Directory) => Err(PrError::IsDirectory(path.to_string())), #[cfg(unix)] Some(InputType::Socket) => { - // TODO Add reading from socket - Err(PrError::EncounteredErrors("Reading from socket not supported yet".to_string())) + Err(PrError::IsSocket(path.to_string())) } Some(InputType::StdIn) => { let stdin = stdin(); From 420a066312083fe8685dc756c01ebcea9388a7c6 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 12 Dec 2018 21:25:54 +0530 Subject: [PATCH 011/126] pr: add read buffer size and fix unused Result types --- src/pr/pr.rs | 96 +++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 921dada45..02945eb4f 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -23,7 +23,7 @@ use std::fs::{metadata, File}; #[cfg(unix)] use std::os::unix::fs::FileTypeExt; use quick_error::ResultExt; - +use std::convert::From; static NAME: &str = "pr"; static VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -36,12 +36,12 @@ static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; static STRING_HEADER_OPTION: &str = "h"; static NUMBERING_MODE_OPTION: &str = "n"; static FILE_STDIN: &str = "-"; +static READ_BUFFER_SIZE: usize = 1024 * 64; struct OutputOptions { /// Line numbering mode number: Option, header: String, - double_spaced: bool, line_separator: String, last_modified_time: String, } @@ -82,6 +82,12 @@ enum InputType { Socket, } +impl From for PrError { + fn from(err: Error) -> Self { + PrError::EncounteredErrors(err.to_string()) + } +} + quick_error! { #[derive(Debug)] enum PrError { @@ -163,7 +169,13 @@ pub fn uumain(args: Vec) -> i32 { for f in files { let header: &String = &matches.opt_str(STRING_HEADER_OPTION).unwrap_or(f.to_string()); let options: &OutputOptions = &build_options(&matches, header, &f); - let status: i32 = pr(&f, options); + let status: i32 = match pr(&f, options) { + Err(error) => { + writeln!(&mut stderr(), "{}", error); + -1 + }, + _ => 0 + }; if status != 0 { return status; } @@ -234,7 +246,6 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> OutputOpt OutputOptions { number: numbering_options, header: header.to_string(), - double_spaced: matches.opt_present("d"), line_separator, last_modified_time, } @@ -256,54 +267,44 @@ fn open(path: &str) -> Result, PrError> { } } -fn pr(path: &str, options: &OutputOptions) -> i32 { +fn pr(path: &str, options: &OutputOptions) -> Result { let mut i = 0; let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); - match open(path) { - Ok(reader) => { - // TODO Replace the loop - for line in BufReader::new(reader).lines() { - if i == CONTENT_LINES_PER_PAGE { - page = page + 1; - i = 0; - prepare_page(&mut buffered_content, options, &page); - } - match line { - Ok(content) => buffered_content.push(content), - Err(error) => { - writeln!(&mut stderr(), "pr: Unable to read from input type {}\n{}", path, error.to_string()); - return -1; - } - } - i = i + 1; - } - if i != 0 { - page = page + 1; - prepare_page(&mut buffered_content, options, &page); - } - } - Err(error) => { - writeln!(&mut stderr(), "{}", error); - return -1; + for line in BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines() { + if i == CONTENT_LINES_PER_PAGE { + page = page + 1; + i = 0; + print_page(&buffered_content, options, &page)?; + buffered_content = Vec::new(); } + buffered_content.push(line?); + i = i + 1; } - return 0; + + if i != 0 { + page = page + 1; + print_page(&buffered_content, options, &page)?; + } + return Ok(0); } -fn print_page(header_content: &Vec, lines: &Vec, options: &OutputOptions, page: &usize) { +fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Result { + let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(); assert_eq!(lines.len() <= CONTENT_LINES_PER_PAGE, true, "Only {} lines of content allowed in a pr output page", CONTENT_LINES_PER_PAGE); - assert_eq!(header_content.len(), HEADER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr header", HEADER_LINES_PER_PAGE); + assert_eq!(header.len(), HEADER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr header", HEADER_LINES_PER_PAGE); assert_eq!(trailer_content.len(), TRAILER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr trailer", TRAILER_LINES_PER_PAGE); let out: &mut Stdout = &mut stdout(); let line_separator = options.as_ref().line_separator.as_bytes(); + let mut lines_written = 0; out.lock(); - for x in header_content { - out.write(x.as_bytes()); - out.write(line_separator); + for x in header { + out.write(x.as_bytes())?; + out.write(line_separator)?; + lines_written += 1; } let width: usize = options.as_ref() @@ -319,19 +320,22 @@ fn print_page(header_content: &Vec, lines: &Vec, options: &Outpu let mut i = 1; for x in lines { if options.number.is_none() { - out.write(x.as_bytes()); + out.write(x.as_bytes())?; } else { let fmtd_line_number: String = get_fmtd_line_number(&width, prev_lines + i, &separator); - out.write(format!("{}{}", fmtd_line_number, x).as_bytes()); + out.write(format!("{}{}", fmtd_line_number, x).as_bytes())?; } - out.write(line_separator); + out.write(line_separator)?; i = i + 1; } + lines_written += i - 1; for x in trailer_content { - out.write(x.as_bytes()); - out.write(line_separator); + out.write(x.as_bytes())?; + out.write(line_separator)?; + lines_written += 1; } - out.flush(); + out.flush()?; + Ok(lines_written) } fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) -> String { @@ -344,12 +348,6 @@ fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) - } -fn prepare_page(buffered_content: &mut Vec, options: &OutputOptions, page: &usize) { - let header: Vec = header_content(&options, &page); - print_page(&header, buffered_content, &options, &page); - buffered_content.clear(); -} - fn header_content(options: &OutputOptions, page: &usize) -> Vec { let first_line: String = format!("{} {} Page {}", options.last_modified_time, options.header, page); vec!["".to_string(), "".to_string(), first_line, "".to_string(), "".to_string()] From c58ee96abf38c7e1fca8eefdb106b72565ed5fa1 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 12 Dec 2018 22:45:48 +0530 Subject: [PATCH 012/126] pr: add long names for -d and -h --- src/pr/pr.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 02945eb4f..2a0ced6ff 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -34,6 +34,7 @@ static CONTENT_LINES_PER_PAGE: usize = LINES_PER_PAGE - HEADER_LINES_PER_PAGE - static NUMBERING_MODE_DEFAULT_SEPARATOR: &str = "\t"; static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; static STRING_HEADER_OPTION: &str = "h"; +static DOUBLE_SPACE_OPTION: &str = "d"; static NUMBERING_MODE_OPTION: &str = "n"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; @@ -120,15 +121,15 @@ pub fn uumain(args: Vec) -> i32 { opts.optopt( STRING_HEADER_OPTION, - "", + "header", "Use the string header to replace the file name \ in the header line.", "STRING", ); opts.optflag( - "d", - "", + DOUBLE_SPACE_OPTION, + "double-space", "Produce output that is double spaced. An extra character is output following every found in the input.", ); From 9a3c572de8ab2f3856b921a1585ebeeb69b090ce Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 12 Dec 2018 23:31:44 +0530 Subject: [PATCH 013/126] pr: add --page option --- src/pr/pr.rs | 66 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 2a0ced6ff..e54a3b11f 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -36,6 +36,7 @@ static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; static STRING_HEADER_OPTION: &str = "h"; static DOUBLE_SPACE_OPTION: &str = "d"; static NUMBERING_MODE_OPTION: &str = "n"; +static PAGE_RANGE_OPTION: &str = "page"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; @@ -45,6 +46,8 @@ struct OutputOptions { header: String, line_separator: String, last_modified_time: String, + start_page: Option, + end_page: Option, } impl AsRef for OutputOptions { @@ -89,6 +92,12 @@ impl From for PrError { } } +impl From for PrError { + fn from(err: std::num::ParseIntError) -> Self { + PrError::EncounteredErrors(err.to_string()) + } +} + quick_error! { #[derive(Debug)] enum PrError { @@ -103,7 +112,7 @@ quick_error! { } EncounteredErrors(msg: String) { - display("pr: {0} encountered", msg) + display("pr: {0}", msg) } IsDirectory(path: String) { @@ -119,6 +128,13 @@ quick_error! { pub fn uumain(args: Vec) -> i32 { let mut opts = getopts::Options::new(); + opts.optflagopt( + "", + PAGE_RANGE_OPTION, + "Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]", + "FIRST_PAGE[:LAST_PAGE]", + ); + opts.optopt( STRING_HEADER_OPTION, "header", @@ -169,12 +185,17 @@ pub fn uumain(args: Vec) -> i32 { for f in files { let header: &String = &matches.opt_str(STRING_HEADER_OPTION).unwrap_or(f.to_string()); - let options: &OutputOptions = &build_options(&matches, header, &f); + let result_options = build_options(&matches, header, &f); + if result_options.is_err() { + writeln!(&mut stderr(), "{}", result_options.err().unwrap()); + return 1; + } + let options = &result_options.unwrap(); let status: i32 = match pr(&f, options) { Err(error) => { writeln!(&mut stderr(), "{}", error); - -1 - }, + 1 + } _ => 0 }; if status != 0 { @@ -219,7 +240,7 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { return 0; } -fn build_options(matches: &Matches, header: &String, path: &String) -> OutputOptions { +fn build_options(matches: &Matches, header: &String, path: &String) -> Result { let numbering_options: Option = matches.opt_str(NUMBERING_MODE_OPTION).map(|i| { NumberingMode { width: i.parse::().unwrap_or(NumberingMode::default().width), @@ -244,12 +265,36 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> OutputOpt file_last_modified_time(path) }; - OutputOptions { + let start_page = match matches.opt_str(PAGE_RANGE_OPTION).map(|i| { + let x: Vec<&str> = i.split(":").collect(); + x[0].parse::() + }) { + Some(res) => Some(res?), + _ => None + }; + + let end_page = match matches.opt_str(PAGE_RANGE_OPTION) + .filter(|i| i.contains(":")) + .map(|i| { + let x: Vec<&str> = i.split(":").collect(); + x[1].parse::() + }) { + Some(res) => Some(res?), + _ => None + }; + + if start_page.is_some() && end_page.is_some() && start_page.unwrap() > end_page.unwrap() { + return Err(PrError::EncounteredErrors(format!("invalid page range ‘{}:{}’", start_page.unwrap(), end_page.unwrap()))); + } + + Ok(OutputOptions { number: numbering_options, header: header.to_string(), line_separator, last_modified_time, - } + start_page, + end_page, + }) } fn open(path: &str) -> Result, PrError> { @@ -292,6 +337,13 @@ fn pr(path: &str, options: &OutputOptions) -> Result { } fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Result { + let start_page = options.as_ref().start_page.as_ref(); + let last_page = options.as_ref().end_page.as_ref(); + let is_within_print_range = (start_page.is_none() || page >= start_page.unwrap()) && + (last_page.is_none() || page <= last_page.unwrap()); + if !is_within_print_range { + return Ok(0); + } let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(); assert_eq!(lines.len() <= CONTENT_LINES_PER_PAGE, true, "Only {} lines of content allowed in a pr output page", CONTENT_LINES_PER_PAGE); From 55043d7a15a2fcc3b7328448101b68ed3ad43827 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 12 Dec 2018 23:38:59 +0530 Subject: [PATCH 014/126] pr: print only 28 lines if double spaced option is used --- src/pr/pr.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index e54a3b11f..a9bb0ce60 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -44,6 +44,7 @@ struct OutputOptions { /// Line numbering mode number: Option, header: String, + double_space: bool, line_separator: String, last_modified_time: String, start_page: Option, @@ -253,12 +254,16 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result Result Result { let mut i = 0; let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); - + let lines_per_page = if options.as_ref().double_space { + CONTENT_LINES_PER_PAGE / 2 + } else { + CONTENT_LINES_PER_PAGE + }; for line in BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines() { - if i == CONTENT_LINES_PER_PAGE { + if i == lines_per_page { page = page + 1; i = 0; print_page(&buffered_content, options, &page)?; From 9e023b8a91ee1f0e50e7ec969a2160320309251d Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Thu, 13 Dec 2018 09:59:25 +0530 Subject: [PATCH 015/126] pr: add -t option to not print header, trailer and -l to print line numbers pr: Add -l option set number of lines pr: Refactor opts --- src/pr/pr.rs | 89 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 15 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index a9bb0ce60..8f9551de6 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -24,19 +24,22 @@ use std::fs::{metadata, File}; use std::os::unix::fs::FileTypeExt; use quick_error::ResultExt; use std::convert::From; +use getopts::HasArg; +use getopts::Occur; static NAME: &str = "pr"; static VERSION: &str = env!("CARGO_PKG_VERSION"); static LINES_PER_PAGE: usize = 66; static HEADER_LINES_PER_PAGE: usize = 5; static TRAILER_LINES_PER_PAGE: usize = 5; -static CONTENT_LINES_PER_PAGE: usize = LINES_PER_PAGE - HEADER_LINES_PER_PAGE - TRAILER_LINES_PER_PAGE; static NUMBERING_MODE_DEFAULT_SEPARATOR: &str = "\t"; static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; static STRING_HEADER_OPTION: &str = "h"; static DOUBLE_SPACE_OPTION: &str = "d"; static NUMBERING_MODE_OPTION: &str = "n"; static PAGE_RANGE_OPTION: &str = "page"; +static NO_HEADER_TRAILER_OPTION: &str = "t"; +static PAGE_LENGTH_OPTION: &str = "l"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; @@ -49,6 +52,9 @@ struct OutputOptions { last_modified_time: String, start_page: Option, end_page: Option, + display_header: bool, + display_trailer: bool, + content_lines_per_page: usize, } impl AsRef for OutputOptions { @@ -129,29 +135,36 @@ quick_error! { pub fn uumain(args: Vec) -> i32 { let mut opts = getopts::Options::new(); - opts.optflagopt( + opts.opt( "", PAGE_RANGE_OPTION, "Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]", "FIRST_PAGE[:LAST_PAGE]", + HasArg::Yes, + Occur::Optional, ); - opts.optopt( + opts.opt( STRING_HEADER_OPTION, "header", "Use the string header to replace the file name \ in the header line.", "STRING", + HasArg::Yes, + Occur::Optional, ); - opts.optflag( + opts.opt( DOUBLE_SPACE_OPTION, "double-space", "Produce output that is double spaced. An extra character is output following every found in the input.", + "", + HasArg::No, + Occur::Optional, ); - opts.optflagopt( + opts.opt( NUMBERING_MODE_OPTION, "", "Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies @@ -159,6 +172,29 @@ pub fn uumain(args: Vec) -> i32 { character) is given, it is appended to the line number to separate it from whatever follows. The default for char is a . Line numbers longer than width columns are truncated.", "[char][width]", + HasArg::Yes, + Occur::Optional, + ); + + opts.opt( + NO_HEADER_TRAILER_OPTION, + "omit-header", + "Write neither the five-line identifying header nor the five-line trailer usually supplied for each page. Quit + writing after the last line of each file without spacing to the end of the page.", + "", + HasArg::No, + Occur::Optional, + ); + + opts.opt( + PAGE_LENGTH_OPTION, + "length", + "Override the 66-line default and reset the page length to lines. If lines is not greater than the sum of both + the header and trailer depths (in lines), the pr utility shall suppress both the header and trailer, as if the + -t option were in effect.", + "lines", + HasArg::Yes, + Occur::Optional, ); opts.optflag("", "help", "display this help and exit"); @@ -262,8 +298,6 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result Result() + }) { + Some(res) => res?, + _ => LINES_PER_PAGE + }; + + let content_lines_per_page = page_length - (HEADER_LINES_PER_PAGE - TRAILER_LINES_PER_PAGE); + + let display_header_and_trailer = !(page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE)) + && !matches.opt_present(NO_HEADER_TRAILER_OPTION); + + Ok(OutputOptions { number: numbering_options, header: header.to_string(), @@ -300,6 +347,9 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result Result { let mut i = 0; let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); + let content_lines_per_page = options.as_ref().content_lines_per_page; let lines_per_page = if options.as_ref().double_space { - CONTENT_LINES_PER_PAGE / 2 + content_lines_per_page / 2 } else { - CONTENT_LINES_PER_PAGE + content_lines_per_page }; for line in BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines() { if i == lines_per_page { @@ -349,16 +400,24 @@ fn pr(path: &str, options: &OutputOptions) -> Result { fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Result { let start_page = options.as_ref().start_page.as_ref(); let last_page = options.as_ref().end_page.as_ref(); + let content_lines_per_page = options.as_ref().content_lines_per_page; let is_within_print_range = (start_page.is_none() || page >= start_page.unwrap()) && (last_page.is_none() || page <= last_page.unwrap()); if !is_within_print_range { return Ok(0); } - let header: Vec = header_content(options, page); - let trailer_content: Vec = trailer_content(); - assert_eq!(lines.len() <= CONTENT_LINES_PER_PAGE, true, "Only {} lines of content allowed in a pr output page", CONTENT_LINES_PER_PAGE); - assert_eq!(header.len(), HEADER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr header", HEADER_LINES_PER_PAGE); - assert_eq!(trailer_content.len(), TRAILER_LINES_PER_PAGE, "Only {} lines of content allowed in a pr trailer", TRAILER_LINES_PER_PAGE); + let header: Vec = if options.as_ref().display_header { + header_content(options, page) + } else { + Vec::new() + }; + + let trailer_content: Vec = if options.as_ref().display_trailer { + trailer_content() + } else { + Vec::new() + }; + let out: &mut Stdout = &mut stdout(); let line_separator = options.as_ref().line_separator.as_bytes(); let mut lines_written = 0; @@ -379,7 +438,7 @@ fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Res .map(|i| i.separator.to_string()) .unwrap_or(NumberingMode::default().separator); - let prev_lines = CONTENT_LINES_PER_PAGE * (page - 1); + let prev_lines = content_lines_per_page * (page - 1); let mut i = 1; for x in lines { if options.number.is_none() { From fd4447785b12ad1691ec5c885adb006f95209b10 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Thu, 13 Dec 2018 12:16:14 +0530 Subject: [PATCH 016/126] pr: add -r option to suppress errors and -F to use form feed separator pr: Add -F to print line feed character for page separator --- src/pr/pr.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 8f9551de6..c95ffa45a 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -40,6 +40,8 @@ static NUMBERING_MODE_OPTION: &str = "n"; static PAGE_RANGE_OPTION: &str = "page"; static NO_HEADER_TRAILER_OPTION: &str = "t"; static PAGE_LENGTH_OPTION: &str = "l"; +static SUPPRESS_PRINTING_ERROR: &str = "r"; +static FORM_FEED_OPTION: &str = "F"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; @@ -55,6 +57,8 @@ struct OutputOptions { display_header: bool, display_trailer: bool, content_lines_per_page: usize, + suppress_errors: bool, + page_separator_char: String, } impl AsRef for OutputOptions { @@ -197,6 +201,24 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + SUPPRESS_PRINTING_ERROR, + "no-file-warnings", + "omit warning when a file cannot be opened", + "", + HasArg::No, + Occur::Optional, + ); + + opts.opt( + FORM_FEED_OPTION, + "form-feed", + "Use a for new pages, instead of the default behavior that uses a sequence of s.", + "", + HasArg::No, + Occur::Optional, + ); + opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); @@ -230,7 +252,9 @@ pub fn uumain(args: Vec) -> i32 { let options = &result_options.unwrap(); let status: i32 = match pr(&f, options) { Err(error) => { - writeln!(&mut stderr(), "{}", error); + if !options.suppress_errors { + writeln!(&mut stderr(), "{}", error); + } 1 } _ => 0 @@ -338,6 +362,11 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result Result, options: &OutputOptions, page: &usize) -> Res let content_lines_per_page = options.as_ref().content_lines_per_page; let is_within_print_range = (start_page.is_none() || page >= start_page.unwrap()) && (last_page.is_none() || page <= last_page.unwrap()); + let page_separator = options.as_ref().page_separator_char.as_bytes(); if !is_within_print_range { return Ok(0); } @@ -447,13 +479,24 @@ fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Res let fmtd_line_number: String = get_fmtd_line_number(&width, prev_lines + i, &separator); out.write(format!("{}{}", fmtd_line_number, x).as_bytes())?; } - out.write(line_separator)?; + + if i == trailer_content.len() { + out.write(page_separator)?; + } else { + out.write(line_separator)?; + } + i = i + 1; } lines_written += i - 1; - for x in trailer_content { + for index in 0..trailer_content.len() { + let x: &String = trailer_content.get(index).unwrap(); out.write(x.as_bytes())?; - out.write(line_separator)?; + if index + 1 == trailer_content.len() { + out.write(page_separator)?; + } else { + out.write(line_separator)?; + } lines_written += 1; } out.flush()?; From 0098cfe5b7cc4b244b42b690632c418cc220f526 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Fri, 14 Dec 2018 09:09:19 +0530 Subject: [PATCH 017/126] pr: add ColumnModeOptions and fix reading of input after page range is finished --- src/pr/pr.rs | 184 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 121 insertions(+), 63 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index c95ffa45a..4b4632355 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -37,13 +37,17 @@ static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; static STRING_HEADER_OPTION: &str = "h"; static DOUBLE_SPACE_OPTION: &str = "d"; static NUMBERING_MODE_OPTION: &str = "n"; -static PAGE_RANGE_OPTION: &str = "page"; +static PAGE_RANGE_OPTION: &str = "pages"; static NO_HEADER_TRAILER_OPTION: &str = "t"; static PAGE_LENGTH_OPTION: &str = "l"; static SUPPRESS_PRINTING_ERROR: &str = "r"; static FORM_FEED_OPTION: &str = "F"; +static COLUMN_WIDTH_OPTION: &str = "w"; +static COLUMN_OPTION: &str = "column"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; +static DEFAULT_COLUMN_WIDTH: usize = 72; +static DEFAULT_COLUMN_SEPARATOR: &str = "\t"; struct OutputOptions { /// Line numbering mode @@ -59,6 +63,13 @@ struct OutputOptions { content_lines_per_page: usize, suppress_errors: bool, page_separator_char: String, + column_mode_options: Option, +} + +struct ColumnModeOptions { + width: usize, + columns: usize, + column_separator: String, } impl AsRef for OutputOptions { @@ -139,23 +150,19 @@ quick_error! { pub fn uumain(args: Vec) -> i32 { let mut opts = getopts::Options::new(); - opts.opt( + opts.optflagopt( "", PAGE_RANGE_OPTION, "Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]", "FIRST_PAGE[:LAST_PAGE]", - HasArg::Yes, - Occur::Optional, ); - opts.opt( + opts.optopt( STRING_HEADER_OPTION, "header", "Use the string header to replace the file name \ in the header line.", - "STRING", - HasArg::Yes, - Occur::Optional, + "STRING" ); opts.opt( @@ -168,16 +175,14 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); - opts.opt( + opts.optflagopt( NUMBERING_MODE_OPTION, "", "Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies the first width column positions of each text column or each line of -m output. If char (any nondigit character) is given, it is appended to the line number to separate it from whatever follows. The default for char is a . Line numbers longer than width columns are truncated.", - "[char][width]", - HasArg::Yes, - Occur::Optional, + "[char][width]" ); opts.opt( @@ -219,6 +224,30 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + "", + COLUMN_OPTION, + "Produce multi-column output that is arranged in column columns (the default shall be 1) and is written down each + column in the order in which the text is received from the input file. This option should not be used with -m. + The options -e and -i shall be assumed for multiple text-column output. Whether or not text columns are pro‐ + duced with identical vertical lengths is unspecified, but a text column shall never exceed the length of the + page (see the -l option). When used with -t, use the minimum number of lines to write the output.", + "[column]", + HasArg::Yes, + Occur::Optional, + ); + + opts.opt( + COLUMN_WIDTH_OPTION, + "width", + "Set the width of the line to width column positions for multiple text-column output only. If the -w option is + not specified and the -s option is not specified, the default width shall be 72. If the -w option is not speci‐ + fied and the -s option is specified, the default width shall be 512.", + "[width]", + HasArg::Yes, + Occur::Optional, + ); + opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); @@ -368,6 +397,24 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result()) { + Some(res) => res?, + _ => DEFAULT_COLUMN_WIDTH + }; + + let column_mode_options = match matches.opt_str(COLUMN_OPTION).map(|i| { + i.parse::() + }) { + Some(res) => { + Some(ColumnModeOptions { + columns: res?, + width: column_width, + column_separator: DEFAULT_COLUMN_SEPARATOR.to_string(), + }) + } + _ => None + }; + Ok(OutputOptions { number: numbering_options, header: header.to_string(), @@ -381,6 +428,7 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result Result { let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); let content_lines_per_page = options.as_ref().content_lines_per_page; + let columns = options.as_ref().column_mode_options.as_ref().map(|i| i.columns).unwrap_or(1); let lines_per_page = if options.as_ref().double_space { - content_lines_per_page / 2 + (content_lines_per_page / 2) * columns } else { - content_lines_per_page + content_lines_per_page * columns }; for line in BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines() { if i == lines_per_page { page = page + 1; i = 0; + if !_is_within_page_range(options, &page) { + return Ok(0) + } print_page(&buffered_content, options, &page)?; buffered_content = Vec::new(); } @@ -422,33 +474,26 @@ fn pr(path: &str, options: &OutputOptions) -> Result { } if i != 0 { + if !_is_within_page_range(options, &page) { + return Ok(0) + } page = page + 1; print_page(&buffered_content, options, &page)?; } + return Ok(0); } -fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Result { +fn _is_within_page_range(options: &OutputOptions, page: &usize) -> bool { let start_page = options.as_ref().start_page.as_ref(); let last_page = options.as_ref().end_page.as_ref(); - let content_lines_per_page = options.as_ref().content_lines_per_page; - let is_within_print_range = (start_page.is_none() || page >= start_page.unwrap()) && - (last_page.is_none() || page <= last_page.unwrap()); - let page_separator = options.as_ref().page_separator_char.as_bytes(); - if !is_within_print_range { - return Ok(0); - } - let header: Vec = if options.as_ref().display_header { - header_content(options, page) - } else { - Vec::new() - }; + (start_page.is_none() || page >= start_page.unwrap()) && (last_page.is_none() || page <= last_page.unwrap()) +} - let trailer_content: Vec = if options.as_ref().display_trailer { - trailer_content() - } else { - Vec::new() - }; +fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Result { + let page_separator = options.as_ref().page_separator_char.as_bytes(); + let header: Vec = header_content(options, page); + let trailer_content: Vec = trailer_content(options); let out: &mut Stdout = &mut stdout(); let line_separator = options.as_ref().line_separator.as_bytes(); @@ -461,34 +506,8 @@ fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Res lines_written += 1; } - let width: usize = options.as_ref() - .number.as_ref() - .map(|i| i.width) - .unwrap_or(0); - let separator: String = options.as_ref() - .number.as_ref() - .map(|i| i.separator.to_string()) - .unwrap_or(NumberingMode::default().separator); + lines_written += write_columns(lines, options, page_separator, out, line_separator, page)?; - let prev_lines = content_lines_per_page * (page - 1); - let mut i = 1; - for x in lines { - if options.number.is_none() { - out.write(x.as_bytes())?; - } else { - let fmtd_line_number: String = get_fmtd_line_number(&width, prev_lines + i, &separator); - out.write(format!("{}{}", fmtd_line_number, x).as_bytes())?; - } - - if i == trailer_content.len() { - out.write(page_separator)?; - } else { - out.write(line_separator)?; - } - - i = i + 1; - } - lines_written += i - 1; for index in 0..trailer_content.len() { let x: &String = trailer_content.get(index).unwrap(); out.write(x.as_bytes())?; @@ -503,6 +522,37 @@ fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Res Ok(lines_written) } +fn write_columns(lines: &Vec, options: &OutputOptions, page_separator: &[u8], out: &mut Stdout, line_separator: &[u8], page: &usize) -> Result { + let content_lines_per_page = options.as_ref().content_lines_per_page; + let prev_lines = content_lines_per_page * (page - 1); + let width: usize = options.as_ref() + .number.as_ref() + .map(|i| i.width) + .unwrap_or(0); + let separator: String = options.as_ref() + .number.as_ref() + .map(|i| i.separator.to_string()) + .unwrap_or(NumberingMode::default().separator); + + let mut i = 0; + for x in lines { + if options.number.is_none() { + out.write(x.as_bytes())?; + } else { + let fmtd_line_number: String = get_fmtd_line_number(&width, prev_lines + i, &separator); + out.write(format!("{}{}", fmtd_line_number, x).as_bytes())?; + } + + if i == lines.len() { + out.write(page_separator)?; + } else { + out.write(line_separator)?; + } + i += 1; + } + Ok(i) +} + fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) -> String { let line_str = line_number.to_string(); if line_str.len() >= *width { @@ -514,8 +564,12 @@ fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) - fn header_content(options: &OutputOptions, page: &usize) -> Vec { - let first_line: String = format!("{} {} Page {}", options.last_modified_time, options.header, page); - vec!["".to_string(), "".to_string(), first_line, "".to_string(), "".to_string()] + if options.as_ref().display_header { + let first_line: String = format!("{} {} Page {}", options.last_modified_time, options.header, page); + vec!["".to_string(), "".to_string(), first_line, "".to_string(), "".to_string()] + } else { + Vec::new() + } } fn file_last_modified_time(path: &str) -> String { @@ -533,8 +587,12 @@ fn current_time() -> String { datetime.format("%b %d %H:%M %Y").to_string() } -fn trailer_content() -> Vec { - vec!["".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string()] +fn trailer_content(options: &OutputOptions) -> Vec { + if options.as_ref().display_trailer { + vec!["".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string()] + } else { + Vec::new() + } } fn get_input_type(path: &str) -> Option { From 2897039000f46cfb92a2aac19a85c7023629220c Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Fri, 14 Dec 2018 09:13:55 +0530 Subject: [PATCH 018/126] pr: fix number of lines printed per page and short pages getting skipped pr: Fix number of lines printed per page pr: Fix first short page getting skipped due to page range --- src/pr/pr.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 4b4632355..403fbc3bb 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -162,7 +162,7 @@ pub fn uumain(args: Vec) -> i32 { "header", "Use the string header to replace the file name \ in the header line.", - "STRING" + "STRING", ); opts.opt( @@ -182,7 +182,7 @@ pub fn uumain(args: Vec) -> i32 { the first width column positions of each text column or each line of -m output. If char (any nondigit character) is given, it is appended to the line number to separate it from whatever follows. The default for char is a . Line numbers longer than width columns are truncated.", - "[char][width]" + "[char][width]", ); opts.opt( @@ -386,7 +386,7 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result LINES_PER_PAGE }; - let content_lines_per_page = page_length - (HEADER_LINES_PER_PAGE - TRAILER_LINES_PER_PAGE); + let content_lines_per_page = page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); let display_header_and_trailer = !(page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE)) && !matches.opt_present(NO_HEADER_TRAILER_OPTION); @@ -453,7 +453,7 @@ fn pr(path: &str, options: &OutputOptions) -> Result { let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); let content_lines_per_page = options.as_ref().content_lines_per_page; - let columns = options.as_ref().column_mode_options.as_ref().map(|i| i.columns).unwrap_or(1); + let columns = _get_columns(options); let lines_per_page = if options.as_ref().double_space { (content_lines_per_page / 2) * columns } else { @@ -464,7 +464,7 @@ fn pr(path: &str, options: &OutputOptions) -> Result { page = page + 1; i = 0; if !_is_within_page_range(options, &page) { - return Ok(0) + return Ok(0); } print_page(&buffered_content, options, &page)?; buffered_content = Vec::new(); @@ -474,16 +474,20 @@ fn pr(path: &str, options: &OutputOptions) -> Result { } if i != 0 { - if !_is_within_page_range(options, &page) { - return Ok(0) - } page = page + 1; + if !_is_within_page_range(options, &page) { + return Ok(0); + } print_page(&buffered_content, options, &page)?; } return Ok(0); } +fn _get_columns(options: &OutputOptions) -> usize { + options.as_ref().column_mode_options.as_ref().map(|i| i.columns).unwrap_or(1) +} + fn _is_within_page_range(options: &OutputOptions, page: &usize) -> bool { let start_page = options.as_ref().start_page.as_ref(); let last_page = options.as_ref().end_page.as_ref(); From f799d22b7d7f83fd5f0608d12bb7eb7e6ec7d4c6 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sat, 15 Dec 2018 09:18:41 +0530 Subject: [PATCH 019/126] pr: add multi column printing --- src/pr/pr.rs | 128 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 92 insertions(+), 36 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 403fbc3bb..c7a833402 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -67,7 +67,7 @@ struct OutputOptions { } struct ColumnModeOptions { - width: usize, + width: Option, columns: usize, column_separator: String, } @@ -78,6 +78,25 @@ impl AsRef for OutputOptions { } } +impl OutputOptions { + fn get_columns(&self) -> usize { + self.as_ref() + .column_mode_options.as_ref() + .map(|i| i.columns) + .unwrap_or(1) + } + + fn lines_to_read_for_page(&self) -> usize { + let content_lines_per_page = &self.as_ref().content_lines_per_page; + let columns = self.get_columns(); + if self.as_ref().double_space { + (content_lines_per_page / 2) * columns + } else { + content_lines_per_page * columns + } + } +} + struct NumberingMode { /// Line numbering mode width: usize, @@ -393,13 +412,13 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result()) { - Some(res) => res?, - _ => DEFAULT_COLUMN_WIDTH + Some(res) => Some(res?), + _ => None }; let column_mode_options = match matches.opt_str(COLUMN_OPTION).map(|i| { @@ -408,7 +427,10 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result { Some(ColumnModeOptions { columns: res?, - width: column_width, + width: match column_width { + Some(x) => Some(x), + None => Some(DEFAULT_COLUMN_WIDTH) + }, column_separator: DEFAULT_COLUMN_SEPARATOR.to_string(), }) } @@ -452,21 +474,16 @@ fn pr(path: &str, options: &OutputOptions) -> Result { let mut i = 0; let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); - let content_lines_per_page = options.as_ref().content_lines_per_page; - let columns = _get_columns(options); - let lines_per_page = if options.as_ref().double_space { - (content_lines_per_page / 2) * columns - } else { - content_lines_per_page * columns - }; + let read_lines_per_page = options.lines_to_read_for_page(); + let mut line_number = 0; for line in BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines() { - if i == lines_per_page { + if i == read_lines_per_page { page = page + 1; i = 0; if !_is_within_page_range(options, &page) { return Ok(0); } - print_page(&buffered_content, options, &page)?; + line_number += print_page(&buffered_content, options, &page, &line_number)?; buffered_content = Vec::new(); } buffered_content.push(line?); @@ -478,39 +495,33 @@ fn pr(path: &str, options: &OutputOptions) -> Result { if !_is_within_page_range(options, &page) { return Ok(0); } - print_page(&buffered_content, options, &page)?; + print_page(&buffered_content, options, &page, &line_number)?; } return Ok(0); } -fn _get_columns(options: &OutputOptions) -> usize { - options.as_ref().column_mode_options.as_ref().map(|i| i.columns).unwrap_or(1) -} - fn _is_within_page_range(options: &OutputOptions, page: &usize) -> bool { let start_page = options.as_ref().start_page.as_ref(); let last_page = options.as_ref().end_page.as_ref(); (start_page.is_none() || page >= start_page.unwrap()) && (last_page.is_none() || page <= last_page.unwrap()) } -fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Result { +fn print_page(lines: &Vec, options: &OutputOptions, page: &usize, line_number: &usize) -> Result { let page_separator = options.as_ref().page_separator_char.as_bytes(); let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(options); let out: &mut Stdout = &mut stdout(); let line_separator = options.as_ref().line_separator.as_bytes(); - let mut lines_written = 0; out.lock(); for x in header { out.write(x.as_bytes())?; out.write(line_separator)?; - lines_written += 1; } - lines_written += write_columns(lines, options, page_separator, out, line_separator, page)?; + let lines_written = write_columns(lines, options, out, line_number)?; for index in 0..trailer_content.len() { let x: &String = trailer_content.get(index).unwrap(); @@ -520,43 +531,88 @@ fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Res } else { out.write(line_separator)?; } - lines_written += 1; } out.flush()?; Ok(lines_written) } -fn write_columns(lines: &Vec, options: &OutputOptions, page_separator: &[u8], out: &mut Stdout, line_separator: &[u8], page: &usize) -> Result { +fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout, line_number: &usize) -> Result { + let line_separator = options.as_ref().line_separator.as_bytes(); + let page_separator = options.as_ref().page_separator_char.as_bytes(); let content_lines_per_page = options.as_ref().content_lines_per_page; - let prev_lines = content_lines_per_page * (page - 1); let width: usize = options.as_ref() .number.as_ref() .map(|i| i.width) .unwrap_or(0); - let separator: String = options.as_ref() + let number_separator: String = options.as_ref() .number.as_ref() .map(|i| i.separator.to_string()) .unwrap_or(NumberingMode::default().separator); - let mut i = 0; - for x in lines { - if options.number.is_none() { - out.write(x.as_bytes())?; - } else { - let fmtd_line_number: String = get_fmtd_line_number(&width, prev_lines + i, &separator); - out.write(format!("{}{}", fmtd_line_number, x).as_bytes())?; - } + let blank_line = "".to_string(); + let columns = options.get_columns(); + let col_sep: &String = options.as_ref() + .column_mode_options.as_ref() + .map(|i| &i.column_separator) + .unwrap_or(&blank_line); + + let col_width: Option = options.as_ref() + .column_mode_options.as_ref() + .map(|i| i.width) + .unwrap_or(None); + + let mut i = 0; + let is_number_mode = options.number.is_some(); + for start in 0..content_lines_per_page { + let indexes: Vec = get_indexes(start, content_lines_per_page, columns); + let mut line = String::new(); + for index in indexes { + let read_line: &String = lines.get(index).unwrap_or(&blank_line); + let next_line_number = line_number + index + 1; + let trimmed_line = get_line_for_printing( + next_line_number, &width, + &number_separator, columns, + col_sep, col_width, + read_line, is_number_mode); + line.push_str(&trimmed_line); + i += 1; + } + out.write(line.as_bytes())?; if i == lines.len() { out.write(page_separator)?; } else { out.write(line_separator)?; } - i += 1; } Ok(i) } +fn get_line_for_printing(line_number: usize, width: &usize, + separator: &String, columns: usize, col_sep: &String, col_width: Option, + read_line: &String, is_number_mode: bool) -> String { + let fmtd_line_number: String = if is_number_mode { + get_fmtd_line_number(&width, line_number, &separator) + } else { + "".to_string() + }; + let complete_line = format!("{}{}{}", fmtd_line_number, read_line, col_sep); + // TODO Adjust the width according to -n option + // TODO Line has less content than the column width + col_width.map(|i| complete_line.chars().take(i / columns).collect()).unwrap_or(complete_line) +} + +fn get_indexes(start: usize, content_lines_per_page: usize, columns: usize) -> Vec { + let mut indexes: Vec = Vec::new(); + let mut offset = start; + indexes.push(offset); + for _col in 1..columns { + offset += content_lines_per_page; + indexes.push(offset); + } + indexes +} + fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) -> String { let line_str = line_number.to_string(); if line_str.len() >= *width { From 629236bd39e75c5470448f69d60cee91489c7fe7 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sat, 15 Dec 2018 11:27:40 +0530 Subject: [PATCH 020/126] pr: add first test --- tests/common/util.rs | 14 +++++ tests/fixtures/pr/test_one_page.log | 56 +++++++++++++++++ tests/fixtures/pr/test_one_page.log.expected | 66 ++++++++++++++++++++ tests/test_pr.rs | 29 +++++++++ 4 files changed, 165 insertions(+) create mode 100644 tests/fixtures/pr/test_one_page.log create mode 100644 tests/fixtures/pr/test_one_page.log.expected create mode 100644 tests/test_pr.rs diff --git a/tests/common/util.rs b/tests/common/util.rs index a2fab66c6..90b518619 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -127,6 +127,15 @@ impl CmdResult { let contents = read_scenario_fixture(&self.tmpd, file_rel_path); self.stdout_is(contents) } + /// like stdout_is_fixture(...), but replaces the data in fixture file based on values provided in template_vars + /// command output + pub fn stdout_is_templated_fixture>(&self, file_rel_path: T, template_vars: Vec<(String, String)>) -> Box<&CmdResult> { + let mut contents = read_scenario_fixture(&self.tmpd, file_rel_path); + for kv in template_vars { + contents = contents.replace(&kv.0, &kv.1); + } + self.stdout_is(contents) + } /// asserts that the command resulted in stderr stream output that equals the /// passed in value, when both are trimmed of trailing whitespace @@ -615,6 +624,11 @@ impl UCommand { cmd_result.failure(); cmd_result } + + pub fn get_full_fixture_path(&self, file_rel_path: &str) -> String{ + let tmpdir_path = self.tmpd.as_ref().unwrap().path(); + format!("{}/{}", tmpdir_path.to_str().unwrap(), file_rel_path) + } } pub fn read_size(child: &mut Child, size: usize) -> String { diff --git a/tests/fixtures/pr/test_one_page.log b/tests/fixtures/pr/test_one_page.log new file mode 100644 index 000000000..4de6f5bf3 --- /dev/null +++ b/tests/fixtures/pr/test_one_page.log @@ -0,0 +1,56 @@ +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed diff --git a/tests/fixtures/pr/test_one_page.log.expected b/tests/fixtures/pr/test_one_page.log.expected new file mode 100644 index 000000000..54f772392 --- /dev/null +++ b/tests/fixtures/pr/test_one_page.log.expected @@ -0,0 +1,66 @@ + + +{last_modified_time} test_one_page.log Page 1 + + +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs new file mode 100644 index 000000000..8ec8ebc0d --- /dev/null +++ b/tests/test_pr.rs @@ -0,0 +1,29 @@ +extern crate chrono; + +use common::util::*; +use std::fs::metadata; +use test_pr::chrono::DateTime; +use test_pr::chrono::offset::Local; + +fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { + let tmp_dir_path = ucmd.get_full_fixture_path(path); + let file_metadata = metadata(tmp_dir_path); + return file_metadata.map(|i| { + return i.modified().map(|x| { + let datetime: DateTime = x.into(); + datetime.format("%b %d %H:%M %Y").to_string() + }).unwrap_or(String::new()); + }).unwrap_or(String::new()); +} + + +#[test] +fn test_output_multi_files_print_all_chars() { + let test_file_path = "test_one_page.log"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["test_one_page.log"]) + .succeeds() + .stdout_is_templated_fixture("test_one_page.log.expected", vec![("{last_modified_time}".to_string(), value)]); +} \ No newline at end of file From 64e2e1dbac31faf427401197ec8392bb02973a22 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sat, 15 Dec 2018 11:34:05 +0530 Subject: [PATCH 021/126] pr: remove parameter header and get_input_type pr: Remove parameter header from build_options pr: Remove unnecessary get_input_type --- src/pr/pr.rs | 106 ++++++++++++++++++----------------------------- tests/test_pr.rs | 2 +- 2 files changed, 41 insertions(+), 67 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index c7a833402..a6636eaa7 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -112,21 +112,6 @@ impl Default for NumberingMode { } } -enum InputType { - Directory, - File, - StdIn, - SymLink, - #[cfg(unix)] - BlockDevice, - #[cfg(unix)] - CharacterDevice, - #[cfg(unix)] - Fifo, - #[cfg(unix)] - Socket, -} - impl From for PrError { fn from(err: Error) -> Self { PrError::EncounteredErrors(err.to_string()) @@ -163,6 +148,10 @@ quick_error! { IsSocket(path: String) { display("pr: cannot open {}, Operation not supported on socket", path) } + + NotExists(path: String) { + display("pr: cannot open {}, No such file or directory", path) + } } } @@ -291,8 +280,7 @@ pub fn uumain(args: Vec) -> i32 { } for f in files { - let header: &String = &matches.opt_str(STRING_HEADER_OPTION).unwrap_or(f.to_string()); - let result_options = build_options(&matches, header, &f); + let result_options = build_options(&matches, &f); if result_options.is_err() { writeln!(&mut stderr(), "{}", result_options.err().unwrap()); return 1; @@ -349,7 +337,8 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { return 0; } -fn build_options(matches: &Matches, header: &String, path: &String) -> Result { +fn build_options(matches: &Matches, path: &String) -> Result { + let header: String = matches.opt_str(STRING_HEADER_OPTION).unwrap_or(path.to_string()); let numbering_options: Option = matches.opt_str(NUMBERING_MODE_OPTION).map(|i| { NumberingMode { width: i.parse::().unwrap_or(NumberingMode::default().width), @@ -439,7 +428,7 @@ fn build_options(matches: &Matches, header: &String, path: &String) -> Result Result Result, PrError> { - match get_input_type(path) { - Some(InputType::Directory) => Err(PrError::IsDirectory(path.to_string())), - #[cfg(unix)] - Some(InputType::Socket) => { - Err(PrError::IsSocket(path.to_string())) - } - Some(InputType::StdIn) => { - let stdin = stdin(); - Ok(Box::new(stdin) as Box) - } - Some(_) => Ok(Box::new(File::open(path).context(path)?) as Box), - None => Err(PrError::UnknownFiletype(path.to_string())) + if path == FILE_STDIN { + let stdin = stdin(); + return Ok(Box::new(stdin) as Box); } + + metadata(path).map(|i| { + let path_string = path.to_string(); + match i.file_type() { + #[cfg(unix)] + ft if ft.is_block_device() => + { + Err(PrError::UnknownFiletype(path_string)) + } + #[cfg(unix)] + ft if ft.is_char_device() => + { + Err(PrError::UnknownFiletype(path_string)) + } + #[cfg(unix)] + ft if ft.is_fifo() => + { + Err(PrError::UnknownFiletype(path_string)) + } + #[cfg(unix)] + ft if ft.is_socket() => + { + Err(PrError::IsSocket(path_string)) + } + ft if ft.is_dir() => Err(PrError::IsDirectory(path_string)), + ft if ft.is_file() || ft.is_symlink() => Ok(Box::new(File::open(path).context(path)?) as Box), + _ => Err(PrError::UnknownFiletype(path_string)) + } + }).unwrap_or(Err(PrError::NotExists(path.to_string()))) } fn pr(path: &str, options: &OutputOptions) -> Result { @@ -654,38 +663,3 @@ fn trailer_content(options: &OutputOptions) -> Vec { Vec::new() } } - -fn get_input_type(path: &str) -> Option { - if path == FILE_STDIN { - return Some(InputType::StdIn); - } - - metadata(path).map(|i| { - match i.file_type() { - #[cfg(unix)] - ft if ft.is_block_device() => - { - Some(InputType::BlockDevice) - } - #[cfg(unix)] - ft if ft.is_char_device() => - { - Some(InputType::CharacterDevice) - } - #[cfg(unix)] - ft if ft.is_fifo() => - { - Some(InputType::Fifo) - } - #[cfg(unix)] - ft if ft.is_socket() => - { - Some(InputType::Socket) - } - ft if ft.is_dir() => Some(InputType::Directory), - ft if ft.is_file() => Some(InputType::File), - ft if ft.is_symlink() => Some(InputType::SymLink), - _ => None - } - }).unwrap_or(None) -} diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 8ec8ebc0d..5e839bc3a 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -18,7 +18,7 @@ fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { #[test] -fn test_output_multi_files_print_all_chars() { +fn test_without_any_options() { let test_file_path = "test_one_page.log"; let mut scenario = new_ucmd!(); let value = file_last_modified_time(&scenario, test_file_path); From afc58eb6ea7adf451f5cf518fdef6922e957ebc8 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sat, 15 Dec 2018 22:54:01 +0530 Subject: [PATCH 022/126] pr: add tests for -n -h -d option pr: Add test for -h option pr: Add test for -d option --- src/pr/pr.rs | 44 +++- tests/fixtures/pr/test_num_page.log | 112 ++++++++++ tests/fixtures/pr/test_num_page.log.expected | 132 ++++++++++++ .../fixtures/pr/test_num_page_2.log.expected | 132 ++++++++++++ .../pr/test_num_page_less_content.log | 7 + .../test_num_page_less_content.log.expected | 19 ++ .../pr/test_one_page_double_line.log.expected | 204 ++++++++++++++++++ .../pr/test_one_page_header.log.expected | 66 ++++++ tests/test_pr.rs | 101 ++++++++- 9 files changed, 808 insertions(+), 9 deletions(-) create mode 100644 tests/fixtures/pr/test_num_page.log create mode 100644 tests/fixtures/pr/test_num_page.log.expected create mode 100644 tests/fixtures/pr/test_num_page_2.log.expected create mode 100644 tests/fixtures/pr/test_num_page_less_content.log create mode 100644 tests/fixtures/pr/test_num_page_less_content.log.expected create mode 100644 tests/fixtures/pr/test_one_page_double_line.log.expected create mode 100644 tests/fixtures/pr/test_one_page_header.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index a6636eaa7..20db63d1b 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -158,19 +158,23 @@ quick_error! { pub fn uumain(args: Vec) -> i32 { let mut opts = getopts::Options::new(); - opts.optflagopt( + opts.opt( "", PAGE_RANGE_OPTION, "Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]", "FIRST_PAGE[:LAST_PAGE]", + HasArg::Yes, + Occur::Optional, ); - opts.optopt( + opts.opt( STRING_HEADER_OPTION, "header", "Use the string header to replace the file name \ in the header line.", "STRING", + HasArg::Yes, + Occur::Optional, ); opts.opt( @@ -183,14 +187,16 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); - opts.optflagopt( + opts.opt( NUMBERING_MODE_OPTION, - "", + "--number-lines", "Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies the first width column positions of each text column or each line of -m output. If char (any nondigit character) is given, it is appended to the line number to separate it from whatever follows. The default for char is a . Line numbers longer than width columns are truncated.", "[char][width]", + HasArg::Maybe, + Occur::Optional, ); opts.opt( @@ -271,10 +277,22 @@ pub fn uumain(args: Vec) -> i32 { let mut files: Vec = matches.free.clone(); if files.is_empty() { - //For stdin - files.push(FILE_STDIN.to_owned()); + // -n value is optional if -n is given the opts gets confused + if matches.opt_present(NUMBERING_MODE_OPTION) { + let is_afile = is_a_file(&matches, &mut files); + if is_afile.is_err() { + writeln!(&mut stderr(), "{}", is_afile.err().unwrap()); + return 1; + } else { + files.push(is_afile.unwrap()); + } + } else { + //For stdin + files.push(FILE_STDIN.to_owned()); + } } + if matches.opt_present("help") { return print_usage(&mut opts, &matches); } @@ -302,6 +320,14 @@ pub fn uumain(args: Vec) -> i32 { return 0; } +fn is_a_file(matches: &Matches, files: &mut Vec) -> Result { + let could_be_file = matches.opt_str(NUMBERING_MODE_OPTION).unwrap(); + match File::open(&could_be_file) { + Ok(f) => Ok(could_be_file), + Err(e) => Err(PrError::NotExists(could_be_file)) + } +} + fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { println!("{} {} -- print files", NAME, VERSION); println!(); @@ -573,11 +599,15 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout, let mut i = 0; let is_number_mode = options.number.is_some(); + for start in 0..content_lines_per_page { let indexes: Vec = get_indexes(start, content_lines_per_page, columns); let mut line = String::new(); for index in indexes { - let read_line: &String = lines.get(index).unwrap_or(&blank_line); + if lines.get(index).is_none() { + break; + } + let read_line = lines.get(index).unwrap(); let next_line_number = line_number + index + 1; let trimmed_line = get_line_for_printing( next_line_number, &width, diff --git a/tests/fixtures/pr/test_num_page.log b/tests/fixtures/pr/test_num_page.log new file mode 100644 index 000000000..da467dce2 --- /dev/null +++ b/tests/fixtures/pr/test_num_page.log @@ -0,0 +1,112 @@ +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed diff --git a/tests/fixtures/pr/test_num_page.log.expected b/tests/fixtures/pr/test_num_page.log.expected new file mode 100644 index 000000000..076d3f212 --- /dev/null +++ b/tests/fixtures/pr/test_num_page.log.expected @@ -0,0 +1,132 @@ + + +{last_modified_time} test_num_page.log Page 1 + + + 1 ntation processAirPortStateChanges]: pppConnectionState 0 + 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 8 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 9 Mon Dec 10 11:42:57.002 Info: 802.1X changed + 10 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 11 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 12 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 13 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 14 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 15 Mon Dec 10 11:42:57.302 Info: 802.1X changed + 16 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 17 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 18 Mon Dec 10 11:42:57.449 Info: 802.1X changed + 19 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 20 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 21 Mon Dec 10 11:42:57.600 Info: 802.1X changed + 22 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 23 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 24 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 25 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 26 Mon Dec 10 11:42:57.749 Info: 802.1X changed + 27 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 28 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 29 Mon Dec 10 11:42:57.896 Info: 802.1X changed + 30 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 31 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 32 Mon Dec 10 11:42:58.045 Info: 802.1X changed + 33 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 34 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 35 Mon Dec 10 11:42:58.193 Info: 802.1X changed + 36 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 37 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 38 Mon Dec 10 11:42:58.342 Info: 802.1X changed + 39 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 40 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 41 Mon Dec 10 11:42:58.491 Info: 802.1X changed + 42 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 43 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 44 Mon Dec 10 11:42:58.640 Info: 802.1X changed + 45 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 46 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 47 Mon Dec 10 11:42:58.805 Info: 802.1X changed + 48 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 49 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 50 Mon Dec 10 11:42:58.958 Info: 802.1X changed + 51 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 52 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 53 Mon Dec 10 11:42:59.155 Info: 802.1X changed + 54 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 55 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 56 Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + +{last_modified_time} test_num_page.log Page 2 + + + 57 ntation processAirPortStateChanges]: pppConnectionState 0 + 58 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 59 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 60 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 61 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 62 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 63 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 64 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 65 Mon Dec 10 11:42:57.002 Info: 802.1X changed + 66 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 67 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 68 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 69 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 70 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 71 Mon Dec 10 11:42:57.302 Info: 802.1X changed + 72 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 73 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 74 Mon Dec 10 11:42:57.449 Info: 802.1X changed + 75 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 76 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 77 Mon Dec 10 11:42:57.600 Info: 802.1X changed + 78 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 79 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 80 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 81 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 82 Mon Dec 10 11:42:57.749 Info: 802.1X changed + 83 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 84 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 85 Mon Dec 10 11:42:57.896 Info: 802.1X changed + 86 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 87 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 88 Mon Dec 10 11:42:58.045 Info: 802.1X changed + 89 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 90 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 91 Mon Dec 10 11:42:58.193 Info: 802.1X changed + 92 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 93 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 94 Mon Dec 10 11:42:58.342 Info: 802.1X changed + 95 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 96 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 97 Mon Dec 10 11:42:58.491 Info: 802.1X changed + 98 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 99 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 100 Mon Dec 10 11:42:58.640 Info: 802.1X changed + 101 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 102 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 103 Mon Dec 10 11:42:58.805 Info: 802.1X changed + 104 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 105 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 106 Mon Dec 10 11:42:58.958 Info: 802.1X changed + 107 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 108 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 109 Mon Dec 10 11:42:59.155 Info: 802.1X changed + 110 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 111 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 112 Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + diff --git a/tests/fixtures/pr/test_num_page_2.log.expected b/tests/fixtures/pr/test_num_page_2.log.expected new file mode 100644 index 000000000..dae437ef8 --- /dev/null +++ b/tests/fixtures/pr/test_num_page_2.log.expected @@ -0,0 +1,132 @@ + + +{last_modified_time} test_num_page.log Page 1 + + + 1 ntation processAirPortStateChanges]: pppConnectionState 0 + 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 8 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 9 Mon Dec 10 11:42:57.002 Info: 802.1X changed +10 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +11 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +12 Mon Dec 10 11:42:57.152 Info: 802.1X changed +13 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +14 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +15 Mon Dec 10 11:42:57.302 Info: 802.1X changed +16 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +17 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +18 Mon Dec 10 11:42:57.449 Info: 802.1X changed +19 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +20 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +21 Mon Dec 10 11:42:57.600 Info: 802.1X changed +22 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +23 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +24 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +25 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +26 Mon Dec 10 11:42:57.749 Info: 802.1X changed +27 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +28 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +29 Mon Dec 10 11:42:57.896 Info: 802.1X changed +30 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +31 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +32 Mon Dec 10 11:42:58.045 Info: 802.1X changed +33 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +34 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +35 Mon Dec 10 11:42:58.193 Info: 802.1X changed +36 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +37 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +38 Mon Dec 10 11:42:58.342 Info: 802.1X changed +39 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +40 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +41 Mon Dec 10 11:42:58.491 Info: 802.1X changed +42 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +43 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +44 Mon Dec 10 11:42:58.640 Info: 802.1X changed +45 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +46 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +47 Mon Dec 10 11:42:58.805 Info: 802.1X changed +48 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +49 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +50 Mon Dec 10 11:42:58.958 Info: 802.1X changed +51 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +52 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +53 Mon Dec 10 11:42:59.155 Info: 802.1X changed +54 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +55 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +56 Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + +{last_modified_time} test_num_page.log Page 2 + + +57 ntation processAirPortStateChanges]: pppConnectionState 0 +58 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +59 Mon Dec 10 11:42:56.705 Info: 802.1X changed +60 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +61 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +62 Mon Dec 10 11:42:56.854 Info: 802.1X changed +63 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +64 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +65 Mon Dec 10 11:42:57.002 Info: 802.1X changed +66 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +67 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +68 Mon Dec 10 11:42:57.152 Info: 802.1X changed +69 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +70 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +71 Mon Dec 10 11:42:57.302 Info: 802.1X changed +72 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +73 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +74 Mon Dec 10 11:42:57.449 Info: 802.1X changed +75 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +76 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +77 Mon Dec 10 11:42:57.600 Info: 802.1X changed +78 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +79 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +80 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +81 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +82 Mon Dec 10 11:42:57.749 Info: 802.1X changed +83 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +84 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +85 Mon Dec 10 11:42:57.896 Info: 802.1X changed +86 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +87 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +88 Mon Dec 10 11:42:58.045 Info: 802.1X changed +89 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +90 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +91 Mon Dec 10 11:42:58.193 Info: 802.1X changed +92 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +93 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +94 Mon Dec 10 11:42:58.342 Info: 802.1X changed +95 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +96 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +97 Mon Dec 10 11:42:58.491 Info: 802.1X changed +98 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +99 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +00 Mon Dec 10 11:42:58.640 Info: 802.1X changed +01 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +02 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +03 Mon Dec 10 11:42:58.805 Info: 802.1X changed +04 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +05 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +06 Mon Dec 10 11:42:58.958 Info: 802.1X changed +07 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +08 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +09 Mon Dec 10 11:42:59.155 Info: 802.1X changed +10 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +11 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +12 Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + diff --git a/tests/fixtures/pr/test_num_page_less_content.log b/tests/fixtures/pr/test_num_page_less_content.log new file mode 100644 index 000000000..cf13a6862 --- /dev/null +++ b/tests/fixtures/pr/test_num_page_less_content.log @@ -0,0 +1,7 @@ +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 \ No newline at end of file diff --git a/tests/fixtures/pr/test_num_page_less_content.log.expected b/tests/fixtures/pr/test_num_page_less_content.log.expected new file mode 100644 index 000000000..a3c733e01 --- /dev/null +++ b/tests/fixtures/pr/test_num_page_less_content.log.expected @@ -0,0 +1,19 @@ + + +{last_modified_time} test_num_page_less_content.log Page 1 + + + 1 ntation processAirPortStateChanges]: pppConnectionState 0 + 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + + + + + + + diff --git a/tests/fixtures/pr/test_one_page_double_line.log.expected b/tests/fixtures/pr/test_one_page_double_line.log.expected new file mode 100644 index 000000000..831570103 --- /dev/null +++ b/tests/fixtures/pr/test_one_page_double_line.log.expected @@ -0,0 +1,204 @@ + + + + +{last_modified_time} test_one_page.log Page 1 + + + + + +ntation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:56.705 Info: 802.1X changed + +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:56.854 Info: 802.1X changed + +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:57.002 Info: 802.1X changed + +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:57.152 Info: 802.1X changed + +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:57.302 Info: 802.1X changed + +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:57.449 Info: 802.1X changed + +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:57.600 Info: 802.1X changed + +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:57.749 Info: 802.1X changed + +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} test_one_page.log Page 2 + + + + + +Mon Dec 10 11:42:57.896 Info: 802.1X changed + +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:58.045 Info: 802.1X changed + +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:58.193 Info: 802.1X changed + +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:58.342 Info: 802.1X changed + +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:58.491 Info: 802.1X changed + +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:58.640 Info: 802.1X changed + +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:58.805 Info: 802.1X changed + +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:58.958 Info: 802.1X changed + +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:59.155 Info: 802.1X changed + +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + +Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/fixtures/pr/test_one_page_header.log.expected b/tests/fixtures/pr/test_one_page_header.log.expected new file mode 100644 index 000000000..a00d5f855 --- /dev/null +++ b/tests/fixtures/pr/test_one_page_header.log.expected @@ -0,0 +1,66 @@ + + +{last_modified_time} {header} Page 1 + + +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 5e839bc3a..bb068181d 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -20,10 +20,107 @@ fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { #[test] fn test_without_any_options() { let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page.log.expected"; let mut scenario = new_ucmd!(); let value = file_last_modified_time(&scenario, test_file_path); scenario - .args(&["test_one_page.log"]) + .args(&[test_file_path]) .succeeds() - .stdout_is_templated_fixture("test_one_page.log.expected", vec![("{last_modified_time}".to_string(), value)]); + .stdout_is_templated_fixture(expected_test_file_path, vec![("{last_modified_time}".to_string(), value)]); +} + +#[test] +fn test_with_numbering_option() { + let test_file_path = "test_num_page.log"; + let expected_test_file_path = "test_num_page.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![("{last_modified_time}".to_string(), value)]); +} + +#[test] +fn test_with_numbering_option_when_content_is_less_than_page() { + let test_file_path = "test_num_page_less_content.log"; + let expected_test_file_path = "test_num_page_less_content.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![("{last_modified_time}".to_string(), value)]); +} + +#[test] +fn test_with_numbering_option_with_number_width() { + let test_file_path = "test_num_page.log"; + let expected_test_file_path = "test_num_page_2.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["-n", "2", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![("{last_modified_time}".to_string(), value)]); +} + +#[test] +fn test_with_header_option() { + let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page_header.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + let header = "new file"; + scenario + .args(&["-h", header, test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + ("{last_modified_time}".to_string(), value), + ("{header}".to_string(), header.to_string()) + ]); +} + +#[test] +fn test_with_long_header_option() { + let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page_header.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + let header = "new file"; + scenario + .args(&["--header=new file", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + ("{last_modified_time}".to_string(), value), + ("{header}".to_string(), header.to_string()) + ]); +} + +#[test] +fn test_with_double_space_option() { + let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page_double_line.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["-d", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + ("{last_modified_time}".to_string(), value), + ]); +} + +#[test] +fn test_with_long_double_space_option() { + let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page_double_line.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["--double-space", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + ("{last_modified_time}".to_string(), value), + ]); } \ No newline at end of file From 88ec02a61c6db2eb8423f89999dc91c89a8ea5d2 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sun, 16 Dec 2018 11:53:30 +0530 Subject: [PATCH 023/126] pr: add suport for -n [char][width] and -N pr: Fix long name for -n pr: Add -N first line number option pr: Add -n[char][width] support --- src/pr/pr.rs | 70 ++++++++-- .../pr/test_num_page_char.log.expected | 132 ++++++++++++++++++ .../pr/test_num_page_char_one.log.expected | 132 ++++++++++++++++++ .../pr/test_one_page_first_line.log.expected | 66 +++++++++ tests/test_pr.rs | 56 ++++++++ 5 files changed, 442 insertions(+), 14 deletions(-) create mode 100644 tests/fixtures/pr/test_num_page_char.log.expected create mode 100644 tests/fixtures/pr/test_num_page_char_one.log.expected create mode 100644 tests/fixtures/pr/test_one_page_first_line.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 20db63d1b..afcc54164 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -37,6 +37,7 @@ static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; static STRING_HEADER_OPTION: &str = "h"; static DOUBLE_SPACE_OPTION: &str = "d"; static NUMBERING_MODE_OPTION: &str = "n"; +static FIRST_LINE_NUMBER_OPTION: &str = "N"; static PAGE_RANGE_OPTION: &str = "pages"; static NO_HEADER_TRAILER_OPTION: &str = "t"; static PAGE_LENGTH_OPTION: &str = "l"; @@ -101,6 +102,7 @@ struct NumberingMode { /// Line numbering mode width: usize, separator: String, + first_number: usize, } impl Default for NumberingMode { @@ -108,6 +110,7 @@ impl Default for NumberingMode { NumberingMode { width: NUMBERING_MODE_DEFAULT_WIDTH, separator: NUMBERING_MODE_DEFAULT_SEPARATOR.to_string(), + first_number: 1, } } } @@ -189,7 +192,7 @@ pub fn uumain(args: Vec) -> i32 { opts.opt( NUMBERING_MODE_OPTION, - "--number-lines", + "number-lines", "Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies the first width column positions of each text column or each line of -m output. If char (any nondigit character) is given, it is appended to the line number to separate it from whatever follows. The default @@ -199,6 +202,15 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + FIRST_LINE_NUMBER_OPTION, + "first-line-number", + "start counting with NUMBER at 1st line of first page printed", + "NUMBER", + HasArg::Yes, + Occur::Optional, + ); + opts.opt( NO_HEADER_TRAILER_OPTION, "omit-header", @@ -279,12 +291,13 @@ pub fn uumain(args: Vec) -> i32 { if files.is_empty() { // -n value is optional if -n is given the opts gets confused if matches.opt_present(NUMBERING_MODE_OPTION) { - let is_afile = is_a_file(&matches, &mut files); - if is_afile.is_err() { - writeln!(&mut stderr(), "{}", is_afile.err().unwrap()); + let maybe_file = matches.opt_str(NUMBERING_MODE_OPTION).unwrap(); + let is_afile = is_a_file(&maybe_file); + if !is_afile { + writeln!(&mut stderr(), "{}", PrError::NotExists(maybe_file)); return 1; } else { - files.push(is_afile.unwrap()); + files.push(maybe_file); } } else { //For stdin @@ -320,12 +333,8 @@ pub fn uumain(args: Vec) -> i32 { return 0; } -fn is_a_file(matches: &Matches, files: &mut Vec) -> Result { - let could_be_file = matches.opt_str(NUMBERING_MODE_OPTION).unwrap(); - match File::open(&could_be_file) { - Ok(f) => Ok(could_be_file), - Err(e) => Err(PrError::NotExists(could_be_file)) - } +fn is_a_file(could_be_file: &String) -> bool { + File::open(could_be_file).is_ok() } fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { @@ -365,10 +374,39 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { fn build_options(matches: &Matches, path: &String) -> Result { let header: String = matches.opt_str(STRING_HEADER_OPTION).unwrap_or(path.to_string()); + + let default_first_number = NumberingMode::default().first_number; + let first_number = matches.opt_str(FIRST_LINE_NUMBER_OPTION).map(|n| { + n.parse::().unwrap_or(default_first_number) + }).unwrap_or(default_first_number); + let numbering_options: Option = matches.opt_str(NUMBERING_MODE_OPTION).map(|i| { + let parse_result = i.parse::(); + + let separator = if parse_result.is_err() { + if is_a_file(&i) { + NumberingMode::default().separator + } else { + i[0..1].to_string() + } + } else { + NumberingMode::default().separator + }; + + let width = if parse_result.is_err() { + if is_a_file(&i) { + NumberingMode::default().width + } else { + i[1..].parse::().unwrap_or(NumberingMode::default().width) + } + } else { + parse_result.unwrap() + }; + NumberingMode { - width: i.parse::().unwrap_or(NumberingMode::default().width), - separator: NumberingMode::default().separator, + width, + separator, + first_number, } }).or_else(|| { if matches.opt_present(NUMBERING_MODE_OPTION) { @@ -510,7 +548,11 @@ fn pr(path: &str, options: &OutputOptions) -> Result { let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); let read_lines_per_page = options.lines_to_read_for_page(); - let mut line_number = 0; + let mut line_number = options.as_ref() + .number + .as_ref() + .map(|i| i.first_number) + .unwrap_or(1) - 1; for line in BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines() { if i == read_lines_per_page { page = page + 1; diff --git a/tests/fixtures/pr/test_num_page_char.log.expected b/tests/fixtures/pr/test_num_page_char.log.expected new file mode 100644 index 000000000..169dbd844 --- /dev/null +++ b/tests/fixtures/pr/test_num_page_char.log.expected @@ -0,0 +1,132 @@ + + +{last_modified_time} test_num_page.log Page 1 + + + 1cntation processAirPortStateChanges]: pppConnectionState 0 + 2cMon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3cMon Dec 10 11:42:56.705 Info: 802.1X changed + 4cMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5cMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6cMon Dec 10 11:42:56.854 Info: 802.1X changed + 7cMon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 8cMon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 9cMon Dec 10 11:42:57.002 Info: 802.1X changed + 10cMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 11cMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 12cMon Dec 10 11:42:57.152 Info: 802.1X changed + 13cMon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 14cMon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 15cMon Dec 10 11:42:57.302 Info: 802.1X changed + 16cMon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 17cMon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 18cMon Dec 10 11:42:57.449 Info: 802.1X changed + 19cMon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 20cMon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 21cMon Dec 10 11:42:57.600 Info: 802.1X changed + 22cMon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 23cMon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 24cMon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 25cMon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 26cMon Dec 10 11:42:57.749 Info: 802.1X changed + 27cMon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 28cMon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 29cMon Dec 10 11:42:57.896 Info: 802.1X changed + 30cMon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 31cMon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 32cMon Dec 10 11:42:58.045 Info: 802.1X changed + 33cMon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 34cMon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 35cMon Dec 10 11:42:58.193 Info: 802.1X changed + 36cMon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 37cMon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 38cMon Dec 10 11:42:58.342 Info: 802.1X changed + 39cMon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 40cMon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 41cMon Dec 10 11:42:58.491 Info: 802.1X changed + 42cMon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 43cMon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 44cMon Dec 10 11:42:58.640 Info: 802.1X changed + 45cMon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 46cMon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 47cMon Dec 10 11:42:58.805 Info: 802.1X changed + 48cMon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 49cMon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 50cMon Dec 10 11:42:58.958 Info: 802.1X changed + 51cMon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 52cMon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 53cMon Dec 10 11:42:59.155 Info: 802.1X changed + 54cMon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 55cMon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 56cMon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + +{last_modified_time} test_num_page.log Page 2 + + + 57cntation processAirPortStateChanges]: pppConnectionState 0 + 58cMon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 59cMon Dec 10 11:42:56.705 Info: 802.1X changed + 60cMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 61cMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 62cMon Dec 10 11:42:56.854 Info: 802.1X changed + 63cMon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 64cMon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 65cMon Dec 10 11:42:57.002 Info: 802.1X changed + 66cMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 67cMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 68cMon Dec 10 11:42:57.152 Info: 802.1X changed + 69cMon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 70cMon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 71cMon Dec 10 11:42:57.302 Info: 802.1X changed + 72cMon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 73cMon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 74cMon Dec 10 11:42:57.449 Info: 802.1X changed + 75cMon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 76cMon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 77cMon Dec 10 11:42:57.600 Info: 802.1X changed + 78cMon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 79cMon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 80cMon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 81cMon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 82cMon Dec 10 11:42:57.749 Info: 802.1X changed + 83cMon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 84cMon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 85cMon Dec 10 11:42:57.896 Info: 802.1X changed + 86cMon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 87cMon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 88cMon Dec 10 11:42:58.045 Info: 802.1X changed + 89cMon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 90cMon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 91cMon Dec 10 11:42:58.193 Info: 802.1X changed + 92cMon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 93cMon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 94cMon Dec 10 11:42:58.342 Info: 802.1X changed + 95cMon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 96cMon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 97cMon Dec 10 11:42:58.491 Info: 802.1X changed + 98cMon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 99cMon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 100cMon Dec 10 11:42:58.640 Info: 802.1X changed + 101cMon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 102cMon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 103cMon Dec 10 11:42:58.805 Info: 802.1X changed + 104cMon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 105cMon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 106cMon Dec 10 11:42:58.958 Info: 802.1X changed + 107cMon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 108cMon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 109cMon Dec 10 11:42:59.155 Info: 802.1X changed + 110cMon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 111cMon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 112cMon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + diff --git a/tests/fixtures/pr/test_num_page_char_one.log.expected b/tests/fixtures/pr/test_num_page_char_one.log.expected new file mode 100644 index 000000000..dd7813192 --- /dev/null +++ b/tests/fixtures/pr/test_num_page_char_one.log.expected @@ -0,0 +1,132 @@ + + +{last_modified_time} test_num_page.log Page 1 + + +1cntation processAirPortStateChanges]: pppConnectionState 0 +2cMon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +3cMon Dec 10 11:42:56.705 Info: 802.1X changed +4cMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +5cMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +6cMon Dec 10 11:42:56.854 Info: 802.1X changed +7cMon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +8cMon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +9cMon Dec 10 11:42:57.002 Info: 802.1X changed +0cMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +1cMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +2cMon Dec 10 11:42:57.152 Info: 802.1X changed +3cMon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +4cMon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +5cMon Dec 10 11:42:57.302 Info: 802.1X changed +6cMon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +7cMon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +8cMon Dec 10 11:42:57.449 Info: 802.1X changed +9cMon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +0cMon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +1cMon Dec 10 11:42:57.600 Info: 802.1X changed +2cMon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +3cMon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +4cMon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +5cMon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +6cMon Dec 10 11:42:57.749 Info: 802.1X changed +7cMon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +8cMon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +9cMon Dec 10 11:42:57.896 Info: 802.1X changed +0cMon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +1cMon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +2cMon Dec 10 11:42:58.045 Info: 802.1X changed +3cMon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +4cMon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +5cMon Dec 10 11:42:58.193 Info: 802.1X changed +6cMon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +7cMon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +8cMon Dec 10 11:42:58.342 Info: 802.1X changed +9cMon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +0cMon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +1cMon Dec 10 11:42:58.491 Info: 802.1X changed +2cMon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +3cMon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +4cMon Dec 10 11:42:58.640 Info: 802.1X changed +5cMon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +6cMon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +7cMon Dec 10 11:42:58.805 Info: 802.1X changed +8cMon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +9cMon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +0cMon Dec 10 11:42:58.958 Info: 802.1X changed +1cMon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +2cMon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +3cMon Dec 10 11:42:59.155 Info: 802.1X changed +4cMon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +5cMon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +6cMon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + +{last_modified_time} test_num_page.log Page 2 + + +7cntation processAirPortStateChanges]: pppConnectionState 0 +8cMon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +9cMon Dec 10 11:42:56.705 Info: 802.1X changed +0cMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +1cMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +2cMon Dec 10 11:42:56.854 Info: 802.1X changed +3cMon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +4cMon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +5cMon Dec 10 11:42:57.002 Info: 802.1X changed +6cMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +7cMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +8cMon Dec 10 11:42:57.152 Info: 802.1X changed +9cMon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +0cMon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +1cMon Dec 10 11:42:57.302 Info: 802.1X changed +2cMon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +3cMon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +4cMon Dec 10 11:42:57.449 Info: 802.1X changed +5cMon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +6cMon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +7cMon Dec 10 11:42:57.600 Info: 802.1X changed +8cMon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +9cMon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +0cMon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +1cMon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +2cMon Dec 10 11:42:57.749 Info: 802.1X changed +3cMon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +4cMon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +5cMon Dec 10 11:42:57.896 Info: 802.1X changed +6cMon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +7cMon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +8cMon Dec 10 11:42:58.045 Info: 802.1X changed +9cMon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +0cMon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +1cMon Dec 10 11:42:58.193 Info: 802.1X changed +2cMon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +3cMon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +4cMon Dec 10 11:42:58.342 Info: 802.1X changed +5cMon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +6cMon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +7cMon Dec 10 11:42:58.491 Info: 802.1X changed +8cMon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +9cMon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +0cMon Dec 10 11:42:58.640 Info: 802.1X changed +1cMon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +2cMon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +3cMon Dec 10 11:42:58.805 Info: 802.1X changed +4cMon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +5cMon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +6cMon Dec 10 11:42:58.958 Info: 802.1X changed +7cMon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +8cMon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +9cMon Dec 10 11:42:59.155 Info: 802.1X changed +0cMon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +1cMon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +2cMon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + diff --git a/tests/fixtures/pr/test_one_page_first_line.log.expected b/tests/fixtures/pr/test_one_page_first_line.log.expected new file mode 100644 index 000000000..303f01c73 --- /dev/null +++ b/tests/fixtures/pr/test_one_page_first_line.log.expected @@ -0,0 +1,66 @@ + + +{last_modified_time} test_one_page.log Page 1 + + + 5 ntation processAirPortStateChanges]: pppConnectionState 0 + 6 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 7 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 8 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 9 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 10 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 11 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 12 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 13 Mon Dec 10 11:42:57.002 Info: 802.1X changed + 14 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 15 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 16 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 17 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 18 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 19 Mon Dec 10 11:42:57.302 Info: 802.1X changed + 20 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 21 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 22 Mon Dec 10 11:42:57.449 Info: 802.1X changed + 23 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 24 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 25 Mon Dec 10 11:42:57.600 Info: 802.1X changed + 26 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 27 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 28 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 29 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 30 Mon Dec 10 11:42:57.749 Info: 802.1X changed + 31 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 32 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 33 Mon Dec 10 11:42:57.896 Info: 802.1X changed + 34 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 35 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 36 Mon Dec 10 11:42:58.045 Info: 802.1X changed + 37 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 38 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 39 Mon Dec 10 11:42:58.193 Info: 802.1X changed + 40 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 41 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 42 Mon Dec 10 11:42:58.342 Info: 802.1X changed + 43 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 44 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 45 Mon Dec 10 11:42:58.491 Info: 802.1X changed + 46 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 47 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 48 Mon Dec 10 11:42:58.640 Info: 802.1X changed + 49 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 50 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 51 Mon Dec 10 11:42:58.805 Info: 802.1X changed + 52 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 53 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 54 Mon Dec 10 11:42:58.958 Info: 802.1X changed + 55 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 56 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 57 Mon Dec 10 11:42:59.155 Info: 802.1X changed + 58 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 59 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 60 Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index bb068181d..fb4523c0c 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -123,4 +123,60 @@ fn test_with_long_double_space_option() { .stdout_is_templated_fixture(expected_test_file_path, vec![ ("{last_modified_time}".to_string(), value), ]); +} + +#[test] +fn test_with_first_line_number_option() { + let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page_first_line.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["-N", "5", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + ("{last_modified_time}".to_string(), value), + ]); +} + +#[test] +fn test_with_first_line_number_long_option() { + let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page_first_line.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["--first-line-number=5", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + ("{last_modified_time}".to_string(), value), + ]); +} + +#[test] +fn test_with_number_option_with_custom_separator_char() { + let test_file_path = "test_num_page.log"; + let expected_test_file_path = "test_num_page_char.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["-nc", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + ("{last_modified_time}".to_string(), value), + ]); +} + +#[test] +fn test_with_number_option_with_custom_separator_char_and_width() { + let test_file_path = "test_num_page.log"; + let expected_test_file_path = "test_num_page_char_one.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["-nc1", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + ("{last_modified_time}".to_string(), value), + ]); } \ No newline at end of file From b742230dbbd32115c4f3aabf753f41383b56f6e3 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sun, 16 Dec 2018 21:36:42 +0530 Subject: [PATCH 024/126] pr: fix page ranges pr: Fix page ranges --- src/pr/pr.rs | 68 +- tests/common/util.rs | 4 +- tests/fixtures/pr/test.log | 1000 +++++++++++++++++ .../pr/test_page_range_1.log.expected | 264 +++++ .../pr/test_page_range_2.log.expected | 200 ++++ tests/test_pr.rs | 82 +- 6 files changed, 1584 insertions(+), 34 deletions(-) create mode 100644 tests/fixtures/pr/test.log create mode 100644 tests/fixtures/pr/test_page_range_1.log.expected create mode 100644 tests/fixtures/pr/test_page_range_2.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index afcc54164..08681c0de 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -26,6 +26,7 @@ use quick_error::ResultExt; use std::convert::From; use getopts::HasArg; use getopts::Occur; +use std::num::ParseIntError; static NAME: &str = "pr"; static VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -73,6 +74,13 @@ struct ColumnModeOptions { column_separator: String, } +#[derive(PartialEq, Eq)] +enum PrintPageCommand { + Skip, + Abort, + Print, +} + impl AsRef for OutputOptions { fn as_ref(&self) -> &OutputOptions { self @@ -429,26 +437,37 @@ fn build_options(matches: &Matches, path: &String) -> Result| { + let unparsed_value = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); + match i { + Ok(val) => Ok(val), + Err(_e) => Err(PrError::EncounteredErrors(format!("invalid --pages argument '{}'", unparsed_value))) + } + }; + let start_page = match matches.opt_str(PAGE_RANGE_OPTION).map(|i| { let x: Vec<&str> = i.split(":").collect(); x[0].parse::() - }) { - Some(res) => Some(res?), - _ => None - }; + }).map(invalid_pages_map) + { + Some(res) => Some(res?), + _ => None + }; let end_page = match matches.opt_str(PAGE_RANGE_OPTION) .filter(|i| i.contains(":")) .map(|i| { let x: Vec<&str> = i.split(":").collect(); x[1].parse::() - }) { - Some(res) => Some(res?), - _ => None - }; + }) + .map(invalid_pages_map) + { + Some(res) => Some(res?), + _ => None + }; if start_page.is_some() && end_page.is_some() && start_page.unwrap() > end_page.unwrap() { - return Err(PrError::EncounteredErrors(format!("invalid page range ‘{}:{}’", start_page.unwrap(), end_page.unwrap()))); + return Err(PrError::EncounteredErrors(format!("invalid --pages argument '{}:{}'", start_page.unwrap(), end_page.unwrap()))); } let page_length = match matches.opt_str(PAGE_LENGTH_OPTION).map(|i| { @@ -548,6 +567,8 @@ fn pr(path: &str, options: &OutputOptions) -> Result { let mut page: usize = 0; let mut buffered_content: Vec = Vec::new(); let read_lines_per_page = options.lines_to_read_for_page(); + let start_page = options.as_ref().start_page.as_ref(); + let last_page = options.as_ref().end_page.as_ref(); let mut line_number = options.as_ref() .number .as_ref() @@ -557,11 +578,14 @@ fn pr(path: &str, options: &OutputOptions) -> Result { if i == read_lines_per_page { page = page + 1; i = 0; - if !_is_within_page_range(options, &page) { + + let cmd = _get_print_command(start_page, last_page, &page); + if cmd == PrintPageCommand::Print { + line_number += print_page(&buffered_content, options, &page, &line_number)?; + buffered_content = Vec::new(); + } else if cmd == PrintPageCommand::Abort { return Ok(0); } - line_number += print_page(&buffered_content, options, &page, &line_number)?; - buffered_content = Vec::new(); } buffered_content.push(line?); i = i + 1; @@ -569,19 +593,27 @@ fn pr(path: &str, options: &OutputOptions) -> Result { if i != 0 { page = page + 1; - if !_is_within_page_range(options, &page) { + let cmd = _get_print_command(start_page, last_page, &page); + if cmd == PrintPageCommand::Print { + print_page(&buffered_content, options, &page, &line_number)?; + } else if cmd == PrintPageCommand::Abort { return Ok(0); } - print_page(&buffered_content, options, &page, &line_number)?; } return Ok(0); } -fn _is_within_page_range(options: &OutputOptions, page: &usize) -> bool { - let start_page = options.as_ref().start_page.as_ref(); - let last_page = options.as_ref().end_page.as_ref(); - (start_page.is_none() || page >= start_page.unwrap()) && (last_page.is_none() || page <= last_page.unwrap()) +fn _get_print_command(start_page: Option<&usize>, last_page: Option<&usize>, page: &usize) -> PrintPageCommand { + let below_page_range = start_page.is_some() && page < start_page.unwrap(); + let is_within_page_range = (start_page.is_none() || page >= start_page.unwrap()) + && (last_page.is_none() || page <= last_page.unwrap()); + if below_page_range { + return PrintPageCommand::Skip; + } else if is_within_page_range { + return PrintPageCommand::Print; + } + return PrintPageCommand::Abort; } fn print_page(lines: &Vec, options: &OutputOptions, page: &usize, line_number: &usize) -> Result { diff --git a/tests/common/util.rs b/tests/common/util.rs index 90b518619..4f0178a39 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -129,10 +129,10 @@ impl CmdResult { } /// like stdout_is_fixture(...), but replaces the data in fixture file based on values provided in template_vars /// command output - pub fn stdout_is_templated_fixture>(&self, file_rel_path: T, template_vars: Vec<(String, String)>) -> Box<&CmdResult> { + pub fn stdout_is_templated_fixture>(&self, file_rel_path: T, template_vars: Vec<(&String, &String)>) -> Box<&CmdResult> { let mut contents = read_scenario_fixture(&self.tmpd, file_rel_path); for kv in template_vars { - contents = contents.replace(&kv.0, &kv.1); + contents = contents.replace(kv.0, kv.1); } self.stdout_is(contents) } diff --git a/tests/fixtures/pr/test.log b/tests/fixtures/pr/test.log new file mode 100644 index 000000000..53aaa0151 --- /dev/null +++ b/tests/fixtures/pr/test.log @@ -0,0 +1,1000 @@ +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed +Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_END (en0) +Mon Dec 10 11:42:59.372 Info: Roaming ended on interface en0 +Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: RSN_HANDSHAKE_DONE (en0) +Mon Dec 10 11:42:59.373 Info: -[CWXPCInterfaceContext setRoamInProgress:reason:]_block_invoke: roam status metric data: CWAWDMetricRoamStatus: status:0 security: 4 profile:5 origin:<34fcb9>(-69) target:<6cf37f>(-56) latency:6.083439s +Mon Dec 10 11:42:59.373 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90046 +Mon Dec 10 11:42:59.373 Info: RESUME AWDL for interface en0, reason=Roam token=2685 +Mon Dec 10 11:42:59.373 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=5] +Mon Dec 10 11:42:59.374 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 0 +Mon Dec 10 11:43:01.072 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP' +Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP +Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: DHCP airport_changed = 1 +Mon Dec 10 11:43:01.073 Info: -[CWXPCSubsystem internal_submitIPConfigLatencyMetric:leaseDuration:]: IPConfig Latency metric data: CWAWDMetricIPConfigLatencyData: DHCP latency: 29010 msecs, duration: 480 mins, security: 4 +Mon Dec 10 11:43:01.073 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90007 +Mon Dec 10 11:43:01.073 SC: _setDHCPMessage: dhcpInfoKey "State:/Network/Interface/en0/AirPort/DHCP Message" = (null) +Mon Dec 10 11:43:10.369 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:10.369 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=162 Mbps +Mon Dec 10 11:43:10.369 Info: link quality changed +Mon Dec 10 11:43:23.376 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:23.377 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps +Mon Dec 10 11:43:23.377 Info: link quality changed +Mon Dec 10 11:43:28.380 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:28.380 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 11:43:28.380 Info: link quality changed +Mon Dec 10 11:43:31.744 AutoJoin: BACKGROUND SCAN request on interface en0 with SSID list (null) +Mon Dec 10 11:43:31.747 Scan: Cache-assisted scan request on channel 1 does not require a live scan +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 2 does not require a live scan +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 3 does not require a live scan +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.748 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.748 [channelNumber=1(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.748 [channelNumber=2(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.748 [channelNumber=3(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:43:31.748 )} took 0.0025 seconds, returned 10 results +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 4 does not require a live scan +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 5 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 6 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.749 [channelNumber=4(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.749 [channelNumber=5(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.749 [channelNumber=6(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:43:31.749 )} took 0.0008 seconds, returned 7 results +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 7 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 8 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 9 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.749 [channelNumber=7(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.749 [channelNumber=8(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.749 [channelNumber=9(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:43:31.749 )} took 0.0002 seconds, returned 1 results +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 10 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 11 does not require a live scan +Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 12 does not require a live scan +Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.750 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.750 [channelNumber=10(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.750 [channelNumber=11(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.750 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:43:31.750 )} took 0.0004 seconds, returned 4 results +Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 13 does not require a live scan +Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 36 does not require a live scan +Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 40 does not require a live scan +Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.751 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.751 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.751 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 11:43:31.751 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 11:43:31.751 )} took 0.0009 seconds, returned 9 results +Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 44 does not require a live scan +Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 48 does not require a live scan +Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 149 does not require a live scan +Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.752 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.752 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 11:43:31.752 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 11:43:31.752 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:43:31.752 )} took 0.0010 seconds, returned 9 results +Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 153 does not require a live scan +Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 157 does not require a live scan +Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 161 does not require a live scan +Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.753 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 11:43:31.753 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.753 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 11:43:31.753 )} took 0.0007 seconds, returned 9 results +Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 165 does not require a live scan +Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 52 does not require a live scan +Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 56 does not require a live scan +Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.753 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.753 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 11:43:31.753 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 11:43:31.753 )} took 0.0005 seconds, returned 6 results +Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 60 does not require a live scan +Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 64 does not require a live scan +Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.754 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 11:43:31.754 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 11:43:31.754 )} took 0.0003 seconds, returned 4 results +Mon Dec 10 11:43:42.382 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:42.382 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=270 Mbps +Mon Dec 10 11:43:42.383 Info: link quality changed +Mon Dec 10 11:49:12.347 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 11:49:12.350 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 11:52:32.194 Info: SCAN request received from pid 92 (locationd) with priority 2 +Mon Dec 10 11:52:32.448 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 11:52:32.450 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 11:52:32.451 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 11:52:32.451 [channelNumber=1(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.451 [channelNumber=2(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.451 [channelNumber=3(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.451 [channelNumber=4(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.451 [channelNumber=5(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.451 [channelNumber=6(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:52:32.451 )} took 0.2566 seconds, returned 10 results +Mon Dec 10 11:52:32.451 Info: scan cache updated +Mon Dec 10 11:52:32.712 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 11:52:32.715 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 11:52:32.715 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 11:52:32.715 [channelNumber=7(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.715 [channelNumber=8(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.715 [channelNumber=9(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.715 [channelNumber=10(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.715 [channelNumber=11(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.715 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:52:32.715 )} took 0.2636 seconds, returned 10 results +Mon Dec 10 11:52:32.994 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 11:52:32.997 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 11:52:32.998 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 11:52:32.998 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:32.998 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 11:52:32.998 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 11:52:32.998 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 11:52:32.998 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 11:52:32.998 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:52:32.998 )} took 0.2822 seconds, returned 14 results +Mon Dec 10 11:52:33.405 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 11:52:33.408 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 11:52:33.409 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 11:52:33.409 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 11:52:33.409 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:33.409 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 11:52:33.409 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:52:33.409 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 11:52:33.409 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 11:52:33.409 )} took 0.4099 seconds, returned 11 results +Mon Dec 10 11:52:33.669 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 11:52:33.672 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 11:52:33.672 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 11:52:33.672 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 11:52:33.672 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 11:52:33.672 )} took 0.2625 seconds, returned 8 results +Mon Dec 10 11:52:33.673 Info: scan cache updated +Mon Dec 10 11:52:33.693 Info: SCAN request received from pid 92 (locationd) with priority 2 +Mon Dec 10 11:52:33.693 Scan: locationd requested a live scan less than 10 seconds after previous request (1.4991s) returning cached scan results +Mon Dec 10 11:52:33.728 Info: SCAN request received from pid 92 (locationd) with priority 2 +Mon Dec 10 11:52:33.728 Scan: locationd requested a live scan less than 10 seconds after previous request (1.5339s) returning cached scan results +Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: caps = CPU Net Disk +Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: Being put into maintenance wake mode while fully awake. +Mon Dec 10 11:55:47.610 Info: psCallback: powerSource = AC Power +Mon Dec 10 11:55:47.610 Info: psCallback: set powersave disabled on en0 +Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) +Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) +Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 +Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 +Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds +Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds +Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests +Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests +Mon Dec 10 11:55:48.093 IPC: ADDED XPC CLIENT CONNECTION [loginwindow (pid=101, euid=1651299376, egid=604256670)] +Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:55:48.105 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) +Mon Dec 10 11:56:07.629 Driver Discovery: _PMConnectionHandler: caps = +Mon Dec 10 11:56:07.629 AutoJoin: BEST CONNECTED SCAN CANCELLED on interface en0 +Mon Dec 10 11:56:07.629 AutoJoin: BACKGROUND SCAN CANCELLED on interface en0 +Mon Dec 10 11:56:07.629 AutoJoin: Auto-join retry cancelled on interface en0 +Mon Dec 10 11:56:07.629 Offload: _tcpKeepAliveActive: TCP keep-alive is active. +Mon Dec 10 11:56:07.637 P2P: _changeInterfaceFlags: Marking p2p0 down +Mon Dec 10 11:56:07.637 Info: SleepAcknowledgementCheckForHostAP: Checking sleep readiness for HostAP +Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Checking sleep readiness +Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Delaying sleep acknowledgement because of VifUp +Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: KEV_DL_SIFFLAGS received for p2p0 [flags=0xffff8802 (down)]. +Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: Flags changed for p2p0 (0xffff8843 -> 0xffff8802) (down). +Mon Dec 10 11:56:07.638 P2P: _deviceInterfaceMarkedDown: p2p0 marked down +Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Stop GO' action (param = 0x0) +Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Scan' action (param = 0x0) +Mon Dec 10 11:56:07.638 P2P: _p2pSupervisorEventRunLoopCallback: Mark down complete for p2p0 +Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness +Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementCheck: Checking if auto-join is in progress before sleep acknowledgement +Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementDelayForAutoJoinAttempt_block_invoke: AUTO-JOIN attempt complete for en0, re-checking sleep readiness +Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness +Mon Dec 10 11:56:07.639 WoW: _wowEnabled: WoW is active on en0 +Mon Dec 10 11:56:07.639 WoW: wowExchangeRequiredForNode: WoW exchange not required for en0 +Mon Dec 10 11:56:07.639 _acknowledgeSleepEvent: Acknowledging sleep event +Mon Dec 10 11:56:07.639 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=(null), priority=7] +Mon Dec 10 11:56:07.640 AutoJoin: Auto-join retry cancelled on interface en0 +Mon Dec 10 11:56:07.640 Info: -[CWXPCSubsystem resetAutoJoinDisableState]_block_invoke: Auto-join disabled state reset +Mon Dec 10 11:56:17.640 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=(null), priority=7] +Mon Dec 10 12:04:46.023 Driver Discovery: _PMConnectionHandler: caps = CPU Net Disk Early +Mon Dec 10 12:04:46.023 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:46.023 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on awdl0 +Mon Dec 10 12:04:46.023 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:46.023 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on p2p0 +Mon Dec 10 12:04:46.023 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:46.023 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on en0 +Mon Dec 10 12:04:46.023 Driver Discovery: _PMConnectionHandler: DARK WAKE with maintenance SSID, performing maintenance wake auto-join for interface en0 +Mon Dec 10 12:04:46.023 AutoJoin: AUTO-JOIN trigger requested (Maintenance Wake) +Mon Dec 10 12:04:46.026 Info: psCallback: powerSource = AC Power +Mon Dec 10 12:04:46.026 Info: psCallback: set powersave disabled on en0 +Mon Dec 10 12:04:46.331 BTC: BluetoothCoexStatusMonitoringCallback: Bluetooth Status Notification +Mon Dec 10 12:04:46.331 BTC: BluetoothCoexStatusNotificationProcess: BT: ON, Num HID Devices is <0>, Num SCO Devices is <0>, Num A2DP Devices is <0>, Bluetooth Bandwidth Utilization is <3>, LWM <5>, HWM <26> +Mon Dec 10 12:04:46.332 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:04:46.332 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:04:46.332 Info: AWDL real time mode ended +Mon Dec 10 12:04:46.332 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:04:46.332 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:04:46.332 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:04:46.332 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:04:46.332 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:04:46.332 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:04:46.332 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:04:46.332 {type = mutable dict, count = 2, +Mon Dec 10 12:04:46.332 entries => +Mon Dec 10 12:04:46.332 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.332 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.332 } +Mon Dec 10 12:04:46.332 +Mon Dec 10 12:04:46.332 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:04:46.332 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:04:46.333 AutoJoin: user: patidar +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:04:46.333 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:04:46.333 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:04:46.333 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:04:46.333 Info: AWDL real time mode ended +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:04:46.333 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:04:46.333 {type = mutable dict, count = 2, +Mon Dec 10 12:04:46.333 entries => +Mon Dec 10 12:04:46.333 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.333 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.333 } +Mon Dec 10 12:04:46.333 +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:04:46.333 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:04:46.334 Info: SCAN request received from pid 92 (locationd) with priority 2 +Mon Dec 10 12:04:46.334 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:04:46.334 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:04:46.334 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:04:46.334 Driver Event: _bsd_80211_event_callback: AWDL_SYNC_STATE_CHANGED (awdl0) +Mon Dec 10 12:04:46.334 Info: -[CWXPCSubsystem clearScanCacheWithInterfaceName:connection:error:]: Clearing scan cache for interface en0 +Mon Dec 10 12:04:46.334 Info: -[CWXPCSubsystem clearScanCacheWithInterfaceName:connection:error:]: Clearing family+driver scan cache for interface en0 +Mon Dec 10 12:04:46.334 AutoJoin: AUTO-JOIN STARTED for interface en0 (Maintenance Wake) +Mon Dec 10 12:04:46.334 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=en0, priority=7] +Mon Dec 10 12:04:46.334 AutoJoin: NOT RECOVERY MODE => continuing +Mon Dec 10 12:04:46.334 Info: scan cache updated +Mon Dec 10 12:04:46.335 AutoJoin: NOT LOGINWINDOW MODE 802.1X => continuing +Mon Dec 10 12:04:46.335 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:04:46.335 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:04:46.335 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:04:46.335 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:04:46.335 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:04:46.336 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:04:46.336 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:04:46.336 {type = mutable dict, count = 2, +Mon Dec 10 12:04:46.336 entries => +Mon Dec 10 12:04:46.336 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.336 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.336 } +Mon Dec 10 12:04:46.336 +Mon Dec 10 12:04:46.336 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:04:46.336 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:04:46.336 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:04:46.336 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:04:46.336 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:04:46.336 Info: REQUEST DEFERRED minimum=7 [client=locationd, type=4, interface=en0, priority=5] +Mon Dec 10 12:04:46.336 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:04:46.336 P2P: _interfaceLinkChanged: Stopping IPv6 link local on awdl0 +Mon Dec 10 12:04:46.336 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:04:46.337 Info: AWDL real time mode ended +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:04:46.337 AutoJoin: Reviewing the preferred networks list +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:04:46.337 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:04:46.337 AutoJoin: Adding network ['XT1635-02 9086' (wifi.ssid.5854313633352d30322039303836) - WPA2 Personal] +Mon Dec 10 12:04:46.337 AutoJoin: Adding network ['Prawin' (wifi.ssid.50726177696e) - WPA/WPA2 Personal] +Mon Dec 10 12:04:46.337 AutoJoin: Adding network ['Tilak' (wifi.ssid.54696c616b) - WPA Personal] +Mon Dec 10 12:04:46.337 AutoJoin: Ignoring disabled network ['Redmi' (wifi.ssid.5265646d69) - Open] +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:04:46.337 {type = mutable dict, count = 2, +Mon Dec 10 12:04:46.337 entries => +Mon Dec 10 12:04:46.337 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.337 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.337 } +Mon Dec 10 12:04:46.337 +Mon Dec 10 12:04:46.337 AutoJoin: Adding network ['twdata' (wifi.ssid.747764617461) - WPA2 Enterprise] +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:04:46.337 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:04:46.337 AutoJoin: Adding network ['401UnauthorizedAccess' (wifi.ssid.343031556e617574686f72697a6564416363657373) - WPA2 Personal] +Mon Dec 10 12:04:46.338 AutoJoin: Adding network ['Ayush' (wifi.ssid.4179757368) - WPA/WPA2 Personal] +Mon Dec 10 12:04:46.338 AutoJoin: Adding network ['twguest' (wifi.ssid.74776775657374) - WPA2 Personal] +Mon Dec 10 12:04:46.338 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:04:46.338 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:04:46.338 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:04:46.338 AutoJoin: Ignoring disabled network ['Illiad' (wifi.ssid.496c6c696164) - WPA2 Personal] +Mon Dec 10 12:04:46.338 AutoJoin: Adding network ['NOSI' (wifi.ssid.4e4f5349) - WPA2 Enterprise] +Mon Dec 10 12:04:46.338 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:04:46.338 AutoJoin: Adding network ['Network Not Found' (wifi.ssid.4e6574776f726b204e6f7420466f756e64) - WPA2 Personal] +Mon Dec 10 12:04:46.338 Driver Event: _bsd_80211_event_callback: AWDL_SYNC_STATE_CHANGED (awdl0) +Mon Dec 10 12:04:46.338 AutoJoin: Adding network ['403Forbidden' (wifi.ssid.343033466f7262696464656e) - WPA2 Personal] +Mon Dec 10 12:04:46.338 AutoJoin: Adding network ['NETGEAR' (wifi.ssid.4e455447454152) - WPA2 Personal] +Mon Dec 10 12:04:46.338 AutoJoin: Adding network ['No' (wifi.ssid.4e6f) - WPA2 Personal] +Mon Dec 10 12:04:46.338 Info: AWDL real time mode ended +Mon Dec 10 12:04:46.338 AutoJoin: Adding network ['gruppopam' (wifi.ssid.67727570706f70616d) - WPA2 Personal] +Mon Dec 10 12:04:46.338 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:04:46.339 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:04:46.340 AutoJoin: NOT LINK DOWN RECOVERY => continuing +Mon Dec 10 12:04:46.340 AutoJoin: MAINTENANCE WAKE => will attempt to restore maintenance wake association +Mon Dec 10 12:04:46.340 AutoJoin: Already associated to 'NOSI' (<4e4f5349>), will not continue auto-join +Mon Dec 10 12:04:46.340 AutoJoin: AUTO-JOIN COMPLETED for interface en0, took 0.0056 seconds, returned result 'success', error [NO ERROR] +Mon Dec 10 12:04:46.340 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=7] +Mon Dec 10 12:04:46.340 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:04:46.340 Info: REQUEST UN-DEFERRED minimum=-9223372036854775808 [client=locationd, type=4, interface=en0, priority=5] +Mon Dec 10 12:04:46.340 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:04:46.340 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:04:46.340 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:04:46.341 {type = mutable dict, count = 2, +Mon Dec 10 12:04:46.341 entries => +Mon Dec 10 12:04:46.341 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.341 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:46.341 } +Mon Dec 10 12:04:46.341 +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:04:46.341 Driver Event: _bsd_80211_event_callback: POWER_CHANGED (en0) +Mon Dec 10 12:04:46.341 BTC: BluetoothCoexistenceTickle: Triggering BTC status notification +Mon Dec 10 12:04:46.341 P2P: _bsd_80211_event_callback: Marking p2p0 up because en0 was powered on +Mon Dec 10 12:04:46.341 P2P: _changeInterfaceFlags: Marking p2p0 up +Mon Dec 10 12:04:46.342 Info: -[CWXPCSubsystem performScanWithChannelList:ssidList:legacyScanSSID:dwellTimeOverride:includeHiddenNetworks:mergeScanResults:interfaceName:connection:error:]: Failed to perform Wi-Fi scan, returned error code 16, will try again in 200 ms +Mon Dec 10 12:04:46.342 P2P: AwdlNodeShouldBeMarkedUp: awdl0 should be marked up +Mon Dec 10 12:04:46.342 P2P: _bsd_80211_event_callback: Marking awdl0 up because en0 was powered on +Mon Dec 10 12:04:46.342 P2P: _interfaceLinkChanged: Starting IPv6 link local on awdl0 +Mon Dec 10 12:04:46.342 Info: power changed +Mon Dec 10 12:04:46.342 _interfaceFlagsChanged: KEV_DL_SIFFLAGS received for p2p0 [flags=0xffff8843 (up)]. +Mon Dec 10 12:04:46.342 _interfaceFlagsChanged: Flags changed for p2p0 (0xffff8802 -> 0xffff8843) (up). +Mon Dec 10 12:04:46.342 Driver Discovery: _interfaceFlagsChanged: p2p0 transitioning from down to up. +Mon Dec 10 12:04:46.342 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:04:46.342 P2P: _deviceInterfaceMarkedUp: p2p0 marked up +Mon Dec 10 12:04:46.342 P2P: _deviceInterfaceMarkedUp: on p2p0 Num Advertised[0] +Mon Dec 10 12:04:46.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:04:46.343 BTC: BluetoothCoexStatusMonitoringCallback: Bluetooth Status Notification +Mon Dec 10 12:04:46.343 BTC: BluetoothCoexStatusNotificationProcess: BT: ON, Num HID Devices is <0>, Num SCO Devices is <0>, Num A2DP Devices is <0>, Bluetooth Bandwidth Utilization is <3>, LWM <5>, HWM <26> +Mon Dec 10 12:04:46.344 AutoJoin: BACKGROUND SCAN SCHEDULED on interface en0 in 60.0s with SSID list (null), remaining SSID list (null) +Mon Dec 10 12:04:46.501 P2P: _interfaceLinkChanged: Starting IPv6 link local on awdl0 +Mon Dec 10 12:04:46.501 Driver Event: _bsd_80211_event_callback: CHANNEL_SWITCH (en0) +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/ProfileID' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/WEP40' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/SSID_STR' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/AirPlay' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/AutoJoinTimestamp' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/BSSID' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/SSID' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/CHANNEL' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/Busy' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/Power Status' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/WEPOPENSYSTEM' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/CachedScanRecord' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/UserMode8021X' +Mon Dec 10 12:04:46.509 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/BusyUI' +Mon Dec 10 12:04:47.037 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:04:47.041 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:04:47.041 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:04:47.041 [channelNumber=1(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.041 [channelNumber=2(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.041 [channelNumber=3(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.041 [channelNumber=4(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.041 [channelNumber=5(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.041 [channelNumber=6(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:04:47.041 )} took 0.7073 seconds, returned 11 results +Mon Dec 10 12:04:47.041 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:04:47.041 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:04:47.041 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:04:47.041 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:04:47.042 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:04:47.042 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:04:47.042 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:04:47.042 {type = mutable dict, count = 2, +Mon Dec 10 12:04:47.042 entries => +Mon Dec 10 12:04:47.042 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:47.042 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:04:47.042 } +Mon Dec 10 12:04:47.042 +Mon Dec 10 12:04:47.042 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:04:47.042 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:04:47.042 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:04:47.042 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:04:47.042 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:04:47.288 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:04:47.290 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:04:47.290 [channelNumber=7(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.290 [channelNumber=8(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.290 [channelNumber=9(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.290 [channelNumber=10(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.290 [channelNumber=11(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.290 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:04:47.290 )} took 0.2476 seconds, returned 3 results +Mon Dec 10 12:04:47.291 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:04:47.559 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:04:47.562 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:04:47.562 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:04:47.562 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:47.562 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:04:47.562 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:04:47.562 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:04:47.562 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:04:47.562 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:04:47.562 )} took 0.2715 seconds, returned 11 results +Mon Dec 10 12:04:47.563 Info: scan cache updated +Mon Dec 10 12:04:47.807 Driver Discovery: _PMConnectionHandler: caps = CPU Net Disk +Mon Dec 10 12:04:47.808 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:47.808 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on awdl0 +Mon Dec 10 12:04:47.808 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:47.808 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on p2p0 +Mon Dec 10 12:04:47.809 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:47.809 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on en0 +Mon Dec 10 12:04:47.809 Driver Discovery: _PMConnectionHandler: DARK WAKE with maintenance SSID, performing maintenance wake auto-join for interface en0 +Mon Dec 10 12:04:47.811 AutoJoin: AUTO-JOIN trigger requested (Maintenance Wake) +Mon Dec 10 12:04:47.811 Info: psCallback: powerSource = AC Power +Mon Dec 10 12:04:47.811 Info: psCallback: set powersave disabled on en0 +Mon Dec 10 12:04:47.815 IPC: INVALIDATED XPC CLIENT CONNECTION [loginwindow (pid=101, euid=1651299376, egid=604256670)] +Mon Dec 10 12:04:47.815 WoW: WoW not supported on awdl0, skipping +Mon Dec 10 12:04:47.815 WoW: WoW not supported on p2p0, skipping +Mon Dec 10 12:04:47.815 AutoJoin: user: patidar +Mon Dec 10 12:04:47.816 Info: -[CWXPCSubsystem clearScanCacheWithInterfaceName:connection:error:]: Clearing scan cache for interface en0 +Mon Dec 10 12:04:47.816 Info: -[CWXPCSubsystem clearScanCacheWithInterfaceName:connection:error:]: Clearing family+driver scan cache for interface en0 +Mon Dec 10 12:04:47.816 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=en0, priority=7] +Mon Dec 10 12:04:47.816 AutoJoin: AUTO-JOIN STARTED for interface en0 (Maintenance Wake) +Mon Dec 10 12:04:47.816 AutoJoin: NOT RECOVERY MODE => continuing +Mon Dec 10 12:04:47.818 AutoJoin: NOT LOGINWINDOW MODE 802.1X => continuing +Mon Dec 10 12:04:47.821 AutoJoin: Reviewing the preferred networks list +Mon Dec 10 12:04:47.821 AutoJoin: Adding network ['XT1635-02 9086' (wifi.ssid.5854313633352d30322039303836) - WPA2 Personal] +Mon Dec 10 12:04:47.821 AutoJoin: Adding network ['Prawin' (wifi.ssid.50726177696e) - WPA/WPA2 Personal] +Mon Dec 10 12:04:47.821 AutoJoin: Adding network ['Tilak' (wifi.ssid.54696c616b) - WPA Personal] +Mon Dec 10 12:04:47.821 AutoJoin: Ignoring disabled network ['Redmi' (wifi.ssid.5265646d69) - Open] +Mon Dec 10 12:04:47.821 AutoJoin: Adding network ['twdata' (wifi.ssid.747764617461) - WPA2 Enterprise] +Mon Dec 10 12:04:47.821 AutoJoin: Adding network ['401UnauthorizedAccess' (wifi.ssid.343031556e617574686f72697a6564416363657373) - WPA2 Personal] +Mon Dec 10 12:04:47.821 AutoJoin: Adding network ['Ayush' (wifi.ssid.4179757368) - WPA/WPA2 Personal] +Mon Dec 10 12:04:47.821 AutoJoin: Adding network ['twguest' (wifi.ssid.74776775657374) - WPA2 Personal] +Mon Dec 10 12:04:47.821 AutoJoin: Ignoring disabled network ['Illiad' (wifi.ssid.496c6c696164) - WPA2 Personal] +Mon Dec 10 12:04:47.821 AutoJoin: Adding network ['NOSI' (wifi.ssid.4e4f5349) - WPA2 Enterprise] +Mon Dec 10 12:04:47.822 AutoJoin: Adding network ['Network Not Found' (wifi.ssid.4e6574776f726b204e6f7420466f756e64) - WPA2 Personal] +Mon Dec 10 12:04:47.822 AutoJoin: Adding network ['403Forbidden' (wifi.ssid.343033466f7262696464656e) - WPA2 Personal] +Mon Dec 10 12:04:47.822 AutoJoin: Adding network ['NETGEAR' (wifi.ssid.4e455447454152) - WPA2 Personal] +Mon Dec 10 12:04:47.822 AutoJoin: Adding network ['No' (wifi.ssid.4e6f) - WPA2 Personal] +Mon Dec 10 12:04:47.822 AutoJoin: Adding network ['gruppopam' (wifi.ssid.67727570706f70616d) - WPA2 Personal] +Mon Dec 10 12:04:47.823 AutoJoin: NOT LINK DOWN RECOVERY => continuing +Mon Dec 10 12:04:47.823 AutoJoin: MAINTENANCE WAKE => will attempt to restore maintenance wake association +Mon Dec 10 12:04:47.823 AutoJoin: Already associated to 'NOSI' (<4e4f5349>), will not continue auto-join +Mon Dec 10 12:04:47.823 AutoJoin: AUTO-JOIN COMPLETED for interface en0, took 0.0074 seconds, returned result 'success', error [NO ERROR] +Mon Dec 10 12:04:47.823 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=7] +Mon Dec 10 12:04:48.030 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:04:48.031 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:04:48.032 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:04:48.032 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:04:48.032 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:48.032 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:04:48.032 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:04:48.032 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:04:48.032 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:04:48.032 )} took 0.4685 seconds, returned 8 results +Mon Dec 10 12:04:48.177 Driver Discovery: _PMConnectionHandler: caps = CPU Video Audio Net Disk +Mon Dec 10 12:04:48.177 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:48.177 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on awdl0 +Mon Dec 10 12:04:48.178 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:48.178 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on p2p0 +Mon Dec 10 12:04:48.178 Info: _systemWokenByWiFi: System wake reason: , was not woken by WiFi +Mon Dec 10 12:04:48.178 Info: _updateWakeLimitCounters: TCP keep alive timed out 0 times on en0 +Mon Dec 10 12:04:48.178 AutoJoin: -[CWXPCInterfaceContext clearAllProblematicNetworks]_block_invoke: Unblacklisting all networks. +Mon Dec 10 12:04:48.178 AutoJoin: -[CWXPCInterfaceContext clearAllNetworksBlacklistedForScanOffload]_block_invoke: Clearing all networks blacklisted for scan offload. +Mon Dec 10 12:04:48.178 Offload: _tcpKeepAliveActive: TCP keep-alive is active. +Mon Dec 10 12:04:48.178 AutoJoin: airportdProcessFullWake: Received full wake event for en0 +Mon Dec 10 12:04:48.178 AutoJoin: airportdProcessFullWake: Invoking auto-join for full wake event for en0 +Mon Dec 10 12:04:48.178 Info: __enableTemporarilyDisabledNetworks: Attempting to re-enable any temporarily-disabled network profiles +Mon Dec 10 12:04:48.178 Info: psCallback: powerSource = AC Power +Mon Dec 10 12:04:48.178 Info: psCallback: set powersave disabled on en0 +Mon Dec 10 12:04:48.180 AutoJoin: AUTO-JOIN trigger requested (Full Wake) +Mon Dec 10 12:04:48.180 AutoJoin: BEST CONNECTED SCAN SCHEDULED on interface en0 in 20.0s for network 'NOSI' +Mon Dec 10 12:04:48.181 AutoJoin: user: patidar +Mon Dec 10 12:04:48.182 AutoJoin: BACKGROUND SCAN SCHEDULED on interface en0 in 60.0s with SSID list (null), remaining SSID list (null) +Mon Dec 10 12:04:48.182 Info: -[CWXPCSubsystem clearScanCacheWithInterfaceName:connection:error:]: Clearing scan cache for interface en0 +Mon Dec 10 12:04:48.182 Info: -[CWXPCSubsystem clearScanCacheWithInterfaceName:connection:error:]: Clearing family+driver scan cache for interface en0 +Mon Dec 10 12:04:48.182 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=en0, priority=7] +Mon Dec 10 12:04:48.182 AutoJoin: AUTO-JOIN STARTED for interface en0 (Full Wake) +Mon Dec 10 12:04:48.182 AutoJoin: NOT RECOVERY MODE => continuing +Mon Dec 10 12:04:48.183 AutoJoin: NOT LOGINWINDOW MODE 802.1X => continuing +Mon Dec 10 12:04:48.185 AutoJoin: Reviewing the preferred networks list +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['XT1635-02 9086' (wifi.ssid.5854313633352d30322039303836) - WPA2 Personal] +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['Prawin' (wifi.ssid.50726177696e) - WPA/WPA2 Personal] +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['Tilak' (wifi.ssid.54696c616b) - WPA Personal] +Mon Dec 10 12:04:48.185 AutoJoin: Ignoring disabled network ['Redmi' (wifi.ssid.5265646d69) - Open] +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['twdata' (wifi.ssid.747764617461) - WPA2 Enterprise] +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['401UnauthorizedAccess' (wifi.ssid.343031556e617574686f72697a6564416363657373) - WPA2 Personal] +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['Ayush' (wifi.ssid.4179757368) - WPA/WPA2 Personal] +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['twguest' (wifi.ssid.74776775657374) - WPA2 Personal] +Mon Dec 10 12:04:48.185 AutoJoin: Ignoring disabled network ['Illiad' (wifi.ssid.496c6c696164) - WPA2 Personal] +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['NOSI' (wifi.ssid.4e4f5349) - WPA2 Enterprise] +Mon Dec 10 12:04:48.185 AutoJoin: Adding network ['Network Not Found' (wifi.ssid.4e6574776f726b204e6f7420466f756e64) - WPA2 Personal] +Mon Dec 10 12:04:48.186 AutoJoin: Adding network ['403Forbidden' (wifi.ssid.343033466f7262696464656e) - WPA2 Personal] +Mon Dec 10 12:04:48.186 AutoJoin: Adding network ['NETGEAR' (wifi.ssid.4e455447454152) - WPA2 Personal] +Mon Dec 10 12:04:48.186 AutoJoin: Adding network ['No' (wifi.ssid.4e6f) - WPA2 Personal] +Mon Dec 10 12:04:48.186 AutoJoin: Adding network ['gruppopam' (wifi.ssid.67727570706f70616d) - WPA2 Personal] +Mon Dec 10 12:04:48.187 AutoJoin: NOT LINK DOWN RECOVERY => continuing +Mon Dec 10 12:04:48.187 AutoJoin: NOT MAINTENANCE WAKE => continuing +Mon Dec 10 12:04:48.189 AutoJoin: No known colocated network for preferred network wifi.ssid.4e4f5349 +Mon Dec 10 12:04:48.189 AutoJoin: NOT MORE-PREFERRED USER MODE 802.1X NETWORKS => continuing +Mon Dec 10 12:04:48.189 AutoJoin: NOT SYSTEM MODE 802.1X => continuing +Mon Dec 10 12:04:48.189 AutoJoin: NOT WOW => continuing +Mon Dec 10 12:04:48.189 AutoJoin: NOT Power On / Reinit => continuing +Mon Dec 10 12:04:48.189 AutoJoin: NOT PNL Changed => continuing +Mon Dec 10 12:04:48.189 AutoJoin: AUTOJOIN => auto-join using the entire preferred networks list +Mon Dec 10 12:04:48.189 AutoJoin: Already associated to 'NOSI' (<4e4f5349>), will not continue auto-join +Mon Dec 10 12:04:48.189 AutoJoin: AUTO-JOIN COMPLETED for interface en0, took 0.0069 seconds, returned result 'success', error [NO ERROR] +Mon Dec 10 12:04:48.189 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=7] +Mon Dec 10 12:04:48.216 Info: machine wake +Mon Dec 10 12:04:48.216 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.216 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.216 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.216 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.216 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.216 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.216 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.216 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.217 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.217 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.217 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.217 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.218 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.218 Info: START MONITORING EVENT request received from pid 383 (WiFiProxy) +Mon Dec 10 12:04:48.225 Info: -[AirPortExtraImplementation initBackend]_block_invoke: _isBusy 0 +Mon Dec 10 12:04:48.226 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:04:48.227 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:04:48.344 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:04:48.344 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:04:48.344 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:04:48.344 )} took 0.3106 seconds, returned 8 results +Mon Dec 10 12:04:48.344 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:04:48.345 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:04:48.957 Info: SCAN request received from pid 92 (locationd) with priority 2 +Mon Dec 10 12:04:48.957 Scan: locationd requested a live scan less than 10 seconds after previous request (2.6229s) returning cached scan results +Mon Dec 10 12:04:48.969 Info: SCAN request received from pid 92 (locationd) with priority 2 +Mon Dec 10 12:04:48.969 Scan: locationd requested a live scan less than 10 seconds after previous request (2.6358s) returning cached scan results +Mon Dec 10 12:04:49.319 Info: ACQUIRE BT PAGING LOCK request received from pid 106 (bluetoothd) +Mon Dec 10 12:04:49.320 Info: BT PAGING LOCK GRANTED immediately, auto-join has had a chance to run since wake +Mon Dec 10 12:04:49.320 Info: BT PAGING LOCK GRANTED after 0.0 seconds +Mon Dec 10 12:04:49.321 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) +Mon Dec 10 12:04:49.321 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds +Mon Dec 10 12:04:49.321 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests +Mon Dec 10 12:05:06.345 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:06.345 Info: _bsd_80211_event_callback: link quality: RSSI=-56 dBm TxRate=162 Mbps +Mon Dec 10 12:05:06.345 Info: link quality changed +Mon Dec 10 12:05:08.180 AutoJoin: BEST CONNECTED SCAN request on interface en0 for network 'XT1635-02 9086' +Mon Dec 10 12:05:08.281 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:08.284 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:08.284 [channelNumber=1(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.284 [channelNumber=2(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.284 [channelNumber=3(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:08.284 )} took 0.1034 seconds, returned 7 results +Mon Dec 10 12:05:08.284 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:08.284 Info: scan cache updated +Mon Dec 10 12:05:08.383 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:08.386 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:08.386 [channelNumber=4(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.386 [channelNumber=5(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.386 [channelNumber=6(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:08.386 )} took 0.1023 seconds, returned 7 results +Mon Dec 10 12:05:08.386 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:08.486 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:08.488 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:08.488 [channelNumber=7(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.488 [channelNumber=8(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.488 [channelNumber=9(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:08.488 )} took 0.1016 seconds, returned 1 results +Mon Dec 10 12:05:08.488 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:08.589 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:08.592 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:08.592 [channelNumber=10(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.592 [channelNumber=11(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.592 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:08.592 )} took 0.1036 seconds, returned 4 results +Mon Dec 10 12:05:08.592 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:08.719 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:08.722 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:08.722 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.722 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:05:08.722 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 12:05:08.722 )} took 0.1298 seconds, returned 5 results +Mon Dec 10 12:05:08.722 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:08.826 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:08.828 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:08.828 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:05:08.828 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:05:08.828 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:08.828 )} took 0.1067 seconds, returned 4 results +Mon Dec 10 12:05:08.829 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:08.929 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:08.932 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:08.932 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:08.932 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:05:08.932 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:08.932 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 12:05:08.932 )} took 0.1035 seconds, returned 7 results +Mon Dec 10 12:05:09.215 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:09.217 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:09.217 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:09.217 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:05:09.217 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:05:09.217 )} took 0.2851 seconds, returned 5 results +Mon Dec 10 12:05:09.217 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:09.482 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:09.485 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:09.485 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:09.485 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:05:09.485 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:05:09.485 )} took 0.2679 seconds, returned 8 results +Mon Dec 10 12:05:09.486 Info: scan cache updated +Mon Dec 10 12:05:09.487 Roam: ROAMING PROFILES already set to AC POWER for 2.4GHz on en0 +Mon Dec 10 12:05:09.487 Roam: ROAMING PROFILES already set to AC POWER for 5GHz on en0 +Mon Dec 10 12:05:09.487 AutoJoin: BEST CONNECTED ROAM triggered +Mon Dec 10 12:05:09.488 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_START (en0) +Mon Dec 10 12:05:09.488 Info: Roaming started on interface en0 +Mon Dec 10 12:05:09.488 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=en0, priority=5] +Mon Dec 10 12:05:09.490 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 2 +Mon Dec 10 12:05:09.490 Info: SUSPEND AWDL for interface en0, timeout=10.0s, reason=Roam, token=2686 +Mon Dec 10 12:05:10.934 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_END (en0) +Mon Dec 10 12:05:10.934 Info: Roaming ended on interface en0 +Mon Dec 10 12:05:10.935 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:05:10.935 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:05:10.935 Info: -[CWXPCInterfaceContext setRoamInProgress:reason:]_block_invoke: roam status metric data: CWAWDMetricRoamStatus: status:3 security: 4 profile:5 origin:<6cf37f>(-56) target:<6cf37f>(-57) latency:1.445767s +Mon Dec 10 12:05:10.935 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90046 +Mon Dec 10 12:05:10.935 Info: RESUME AWDL for interface en0, reason=Roam token=2686 +Mon Dec 10 12:05:10.935 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=5] +Mon Dec 10 12:05:10.936 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 0 +Mon Dec 10 12:05:11.354 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:11.354 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=243 Mbps +Mon Dec 10 12:05:11.354 Info: link quality changed +Mon Dec 10 12:05:16.355 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:16.355 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 12:05:16.356 Info: link quality changed +Mon Dec 10 12:05:21.359 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:21.359 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=300 Mbps +Mon Dec 10 12:05:21.360 Info: link quality changed +Mon Dec 10 12:05:29.363 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:29.363 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=216 Mbps +Mon Dec 10 12:05:29.364 Info: link quality changed +Mon Dec 10 12:05:38.367 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:38.367 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=243 Mbps +Mon Dec 10 12:05:38.368 Info: link quality changed +Mon Dec 10 12:05:48.180 AutoJoin: BACKGROUND SCAN request on interface en0 with SSID list (null) +Mon Dec 10 12:05:48.181 Scan: Cache-assisted scan request on channel 1 does not require a live scan +Mon Dec 10 12:05:48.181 Scan: Cache-assisted scan request on channel 2 does not require a live scan +Mon Dec 10 12:05:48.181 Scan: Cache-assisted scan request on channel 3 does not require a live scan +Mon Dec 10 12:05:48.181 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.181 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.181 [channelNumber=1(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.181 [channelNumber=2(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.181 [channelNumber=3(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.181 )} took 0.0006 seconds, returned 7 results +Mon Dec 10 12:05:48.181 Scan: Cache-assisted scan request on channel 4 does not require a live scan +Mon Dec 10 12:05:48.181 Scan: Cache-assisted scan request on channel 5 does not require a live scan +Mon Dec 10 12:05:48.182 Scan: Cache-assisted scan request on channel 6 does not require a live scan +Mon Dec 10 12:05:48.182 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.182 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.182 [channelNumber=4(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.182 [channelNumber=5(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.182 [channelNumber=6(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.182 )} took 0.0006 seconds, returned 7 results +Mon Dec 10 12:05:48.182 Scan: Cache-assisted scan request on channel 7 does not require a live scan +Mon Dec 10 12:05:48.182 Scan: Cache-assisted scan request on channel 8 does not require a live scan +Mon Dec 10 12:05:48.182 Scan: Cache-assisted scan request on channel 9 does not require a live scan +Mon Dec 10 12:05:48.182 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.182 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.182 [channelNumber=7(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.182 [channelNumber=8(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.182 [channelNumber=9(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.182 )} took 0.0003 seconds, returned 1 results +Mon Dec 10 12:05:48.182 Scan: Cache-assisted scan request on channel 10 does not require a live scan +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request on channel 11 does not require a live scan +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request on channel 12 does not require a live scan +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.183 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.183 [channelNumber=10(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.183 [channelNumber=11(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.183 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.183 )} took 0.0007 seconds, returned 4 results +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request on channel 13 does not require a live scan +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request on channel 36 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 40 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.184 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.184 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.184 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:05:48.184 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 12:05:48.184 )} took 0.0007 seconds, returned 5 results +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 44 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 48 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 149 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.185 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.185 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:05:48.185 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:05:48.185 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.185 )} took 0.0006 seconds, returned 4 results +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 153 does not require a live scan +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 157 does not require a live scan +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 161 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.186 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.186 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:05:48.186 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.186 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 12:05:48.186 )} took 0.0010 seconds, returned 7 results +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 165 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 52 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 56 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.187 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.187 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.187 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:05:48.187 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:05:48.187 )} took 0.0008 seconds, returned 5 results +Mon Dec 10 12:05:48.187 Scan: Cache-assisted scan request on channel 60 does not require a live scan +Mon Dec 10 12:05:48.187 Scan: Cache-assisted scan request on channel 64 does not require a live scan +Mon Dec 10 12:05:48.188 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.188 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.188 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:05:48.188 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:05:48.188 )} took 0.0013 seconds, returned 8 results +Mon Dec 10 12:05:50.375 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:50.375 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=216 Mbps +Mon Dec 10 12:05:50.376 Info: link quality changed +Mon Dec 10 12:05:55.378 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:55.378 Info: _bsd_80211_event_callback: link quality: RSSI=-56 dBm TxRate=243 Mbps +Mon Dec 10 12:05:55.379 Info: link quality changed +Mon Dec 10 12:06:28.759 Driver Event: _bsd_80211_event_callback: AWDL_SYNC_STATE_CHANGED (awdl0) +Mon Dec 10 12:06:28.763 Info: AWDL started +Mon Dec 10 12:06:28.763 Driver Event: _bsd_80211_event_callback: CHANNEL_SWITCH (en0) +Mon Dec 10 12:06:28.765 Roam: ROAMING PROFILES updated to SINGLE-BAND, SINGLE-AP for 2.4GHz on en0 +Mon Dec 10 12:06:28.765 Roam: ROAMING PROFILES updated to SINGLE-BAND, SINGLE-AP for 5GHz on en0 +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/ProfileID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/WEP40' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/SSID_STR' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/AirPlay' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/AutoJoinTimestamp' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/BSSID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/SSID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/CHANNEL' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/Busy' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/Power Status' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/WEPOPENSYSTEM' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/CachedScanRecord' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/UserMode8021X' +Mon Dec 10 12:06:28.771 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/BusyUI' +Mon Dec 10 12:06:28.945 Info: INTERFACE STATE INFO request received from pid 362 (sharingd) +Mon Dec 10 12:06:28.946 Info: -[CWXPCInterfaceContext __copyMACAddressForInterface:]: MAC address: <82cd0ac3 bf73> +Mon Dec 10 12:06:30.064 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:30.151 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:30.151 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.137 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.138 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.832 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.832 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:48.742 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:48.742 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.121 P2P: _terminateGroupOwnerTimer: Terminate group owner timer notification received. +Mon Dec 10 12:06:49.267 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.267 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.793 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.793 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.931 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:06:50.931 Driver Event: _bsd_80211_event_callback: AWDL_STATISTICS (awdl0) +Mon Dec 10 12:06:50.932 Info: AWDL real time mode ended +Mon Dec 10 12:06:50.945 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:06:50.945 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:06:50.945 {type = mutable dict, count = 2, +Mon Dec 10 12:06:50.945 entries => +Mon Dec 10 12:06:50.945 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.945 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.945 } +Mon Dec 10 12:06:50.945 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:06:50.945 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:06:50.945 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:06:50.945 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.945 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:06:50.945 Info: AWDL real time mode ended +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:06:50.946 {type = mutable dict, count = 2, +Mon Dec 10 12:06:50.946 entries => +Mon Dec 10 12:06:50.946 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.946 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.946 } +Mon Dec 10 12:06:50.946 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:06:50.946 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_SYNC_STATE_CHANGED (awdl0) +Mon Dec 10 12:06:50.947 Info: AWDL ended +Mon Dec 10 12:06:50.951 Info: -[CWXPCInterfaceContext __submitAWDLUsageMetric:duration:]: AWDL usage metric data: CWAWDMetricAwdlUsageData: selfInfraChannel 40, peerInfraChannel 0, numOfPeers 6. Keys: Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90013 +Mon Dec 10 12:06:50.952 Info: INTERFACE STATE INFO request received from pid 362 (sharingd) +Mon Dec 10 12:06:50.952 Info: -[CWXPCInterfaceContext __copyMACAddressForInterface:]: MAC address: <82cd0ac3 bf73> +Mon Dec 10 12:06:50.953 Roam: ROAMING PROFILES updated to AC POWER for 2.4GHz on en0 +Mon Dec 10 12:06:50.953 Roam: ROAMING PROFILES updated to AC POWER for 5GHz on en0 +Mon Dec 10 12:06:53.680 Info: -[CWXPCSubsystem handleDeviceCountMetricQuery:]_block_invoke: DeviceCount metric data: CWAWDMetricDeviceCountData: timeSinceBoot: 1515466.360642, deviceCount: 1 +Mon Dec 10 12:06:53.684 Info: -[CWXPCSubsystem handleNetworkPrefsMetricQuery:]: NetworkPrefs metric data: CWAWDMetricNetworkPrefsData: preferred 15 hidden 0 open 1 wep 0 wpa 12 eap 2 +Mon Dec 10 12:06:53.684 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90004 +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90001 +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x9000d +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x9000b +Mon Dec 10 12:12:03.594 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:03.594 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=216 Mbps +Mon Dec 10 12:12:03.595 Info: link quality changed +Mon Dec 10 12:12:09.598 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:09.598 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=270 Mbps +Mon Dec 10 12:12:09.599 Info: link quality changed +Mon Dec 10 12:12:56.625 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:56.625 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 12:12:56.625 Info: link quality changed +Mon Dec 10 12:13:01.625 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:01.625 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps +Mon Dec 10 12:13:01.626 Info: link quality changed +Mon Dec 10 12:13:06.628 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:06.628 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 12:13:06.628 Info: link quality changed +Mon Dec 10 12:13:27.639 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:27.639 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=243 Mbps +Mon Dec 10 12:13:27.640 Info: link quality changed +Mon Dec 10 12:14:46.658 Info: SCAN request received from pid 92 (locationd) with priority 2 +Mon Dec 10 12:14:46.902 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:46.905 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:14:46.906 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:46.906 [channelNumber=1(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=2(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=3(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=4(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=5(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=6(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:14:46.906 )} took 0.2478 seconds, returned 13 results +Mon Dec 10 12:14:46.906 Info: scan cache updated +Mon Dec 10 12:14:47.158 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:47.160 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:47.160 [channelNumber=7(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=8(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=9(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=10(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=11(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:14:47.160 )} took 0.2532 seconds, returned 4 results +Mon Dec 10 12:14:47.161 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:14:47.433 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:47.436 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:14:47.437 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:47.437 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.437 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:14:47.437 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:14:47.437 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:14:47.437 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:14:47.437 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:14:47.437 )} took 0.2763 seconds, returned 11 results +Mon Dec 10 12:14:47.778 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:47.781 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:14:47.782 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:47.782 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:14:47.782 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.782 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:14:47.782 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.782 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:14:47.782 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:14:47.782 )} took 0.3436 seconds, returned 9 results +Mon Dec 10 12:14:48.052 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:48.055 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:48.055 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:14:48.055 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:14:48.055 )} took 0.2714 seconds, returned 6 results +Mon Dec 10 12:14:48.055 Info: QUERY SCAN CACHE request received from pid 92 (locationd) diff --git a/tests/fixtures/pr/test_page_range_1.log.expected b/tests/fixtures/pr/test_page_range_1.log.expected new file mode 100644 index 000000000..67fbf88a5 --- /dev/null +++ b/tests/fixtures/pr/test_page_range_1.log.expected @@ -0,0 +1,264 @@ + + +{last_modified_time} test.log Page 15 + + +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + +{last_modified_time} test.log Page 16 + + +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/ProfileID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/WEP40' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/SSID_STR' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/AirPlay' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/AutoJoinTimestamp' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/BSSID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/SSID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/CHANNEL' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/Busy' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/Power Status' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/WEPOPENSYSTEM' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/CachedScanRecord' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/UserMode8021X' +Mon Dec 10 12:06:28.771 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/BusyUI' +Mon Dec 10 12:06:28.945 Info: INTERFACE STATE INFO request received from pid 362 (sharingd) +Mon Dec 10 12:06:28.946 Info: -[CWXPCInterfaceContext __copyMACAddressForInterface:]: MAC address: <82cd0ac3 bf73> +Mon Dec 10 12:06:30.064 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:30.151 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:30.151 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.137 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.138 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.832 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.832 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:48.742 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:48.742 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.121 P2P: _terminateGroupOwnerTimer: Terminate group owner timer notification received. +Mon Dec 10 12:06:49.267 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.267 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.793 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.793 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.931 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:06:50.931 Driver Event: _bsd_80211_event_callback: AWDL_STATISTICS (awdl0) +Mon Dec 10 12:06:50.932 Info: AWDL real time mode ended +Mon Dec 10 12:06:50.945 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:06:50.945 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:06:50.945 {type = mutable dict, count = 2, +Mon Dec 10 12:06:50.945 entries => +Mon Dec 10 12:06:50.945 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.945 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.945 } +Mon Dec 10 12:06:50.945 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:06:50.945 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:06:50.945 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:06:50.945 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.945 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> + + + + + + + +{last_modified_time} test.log Page 17 + + +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:06:50.945 Info: AWDL real time mode ended +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:06:50.946 {type = mutable dict, count = 2, +Mon Dec 10 12:06:50.946 entries => +Mon Dec 10 12:06:50.946 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.946 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.946 } +Mon Dec 10 12:06:50.946 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:06:50.946 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_SYNC_STATE_CHANGED (awdl0) +Mon Dec 10 12:06:50.947 Info: AWDL ended +Mon Dec 10 12:06:50.951 Info: -[CWXPCInterfaceContext __submitAWDLUsageMetric:duration:]: AWDL usage metric data: CWAWDMetricAwdlUsageData: selfInfraChannel 40, peerInfraChannel 0, numOfPeers 6. Keys: Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90013 +Mon Dec 10 12:06:50.952 Info: INTERFACE STATE INFO request received from pid 362 (sharingd) +Mon Dec 10 12:06:50.952 Info: -[CWXPCInterfaceContext __copyMACAddressForInterface:]: MAC address: <82cd0ac3 bf73> +Mon Dec 10 12:06:50.953 Roam: ROAMING PROFILES updated to AC POWER for 2.4GHz on en0 +Mon Dec 10 12:06:50.953 Roam: ROAMING PROFILES updated to AC POWER for 5GHz on en0 +Mon Dec 10 12:06:53.680 Info: -[CWXPCSubsystem handleDeviceCountMetricQuery:]_block_invoke: DeviceCount metric data: CWAWDMetricDeviceCountData: timeSinceBoot: 1515466.360642, deviceCount: 1 +Mon Dec 10 12:06:53.684 Info: -[CWXPCSubsystem handleNetworkPrefsMetricQuery:]: NetworkPrefs metric data: CWAWDMetricNetworkPrefsData: preferred 15 hidden 0 open 1 wep 0 wpa 12 eap 2 +Mon Dec 10 12:06:53.684 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90004 +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90001 +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x9000d +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x9000b +Mon Dec 10 12:12:03.594 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:03.594 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=216 Mbps +Mon Dec 10 12:12:03.595 Info: link quality changed +Mon Dec 10 12:12:09.598 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:09.598 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=270 Mbps +Mon Dec 10 12:12:09.599 Info: link quality changed +Mon Dec 10 12:12:56.625 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:56.625 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 12:12:56.625 Info: link quality changed +Mon Dec 10 12:13:01.625 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:01.625 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps +Mon Dec 10 12:13:01.626 Info: link quality changed +Mon Dec 10 12:13:06.628 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:06.628 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 12:13:06.628 Info: link quality changed +Mon Dec 10 12:13:27.639 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:27.639 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=243 Mbps +Mon Dec 10 12:13:27.640 Info: link quality changed + + + + + + + +{last_modified_time} test.log Page 18 + + +Mon Dec 10 12:14:46.658 Info: SCAN request received from pid 92 (locationd) with priority 2 +Mon Dec 10 12:14:46.902 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:46.905 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:14:46.906 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:46.906 [channelNumber=1(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=2(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=3(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=4(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=5(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:46.906 [channelNumber=6(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:14:46.906 )} took 0.2478 seconds, returned 13 results +Mon Dec 10 12:14:46.906 Info: scan cache updated +Mon Dec 10 12:14:47.158 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:47.160 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:47.160 [channelNumber=7(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=8(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=9(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=10(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=11(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.160 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:14:47.160 )} took 0.2532 seconds, returned 4 results +Mon Dec 10 12:14:47.161 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:14:47.433 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:47.436 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:14:47.437 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:47.437 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.437 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:14:47.437 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:14:47.437 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:14:47.437 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:14:47.437 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:14:47.437 )} took 0.2763 seconds, returned 11 results +Mon Dec 10 12:14:47.778 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:47.781 Info: QUERY SCAN CACHE request received from pid 92 (locationd) +Mon Dec 10 12:14:47.782 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:47.782 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:14:47.782 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.782 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:14:47.782 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:14:47.782 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:14:47.782 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:14:47.782 )} took 0.3436 seconds, returned 9 results +Mon Dec 10 12:14:48.052 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) +Mon Dec 10 12:14:48.055 AutoJoin: Successful cache-assisted scan request for locationd with channels {( +Mon Dec 10 12:14:48.055 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:14:48.055 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:14:48.055 )} took 0.2714 seconds, returned 6 results +Mon Dec 10 12:14:48.055 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + + + + + + + + + + + + + diff --git a/tests/fixtures/pr/test_page_range_2.log.expected b/tests/fixtures/pr/test_page_range_2.log.expected new file mode 100644 index 000000000..d90166b19 --- /dev/null +++ b/tests/fixtures/pr/test_page_range_2.log.expected @@ -0,0 +1,200 @@ + + +{last_modified_time} test.log Page 15 + + +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + +{last_modified_time} test.log Page 16 + + +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/ProfileID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/WEP40' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/SSID_STR' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/AirPlay' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/AutoJoinTimestamp' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/BSSID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/SSID' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/CHANNEL' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/Busy' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/Power Status' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/WEPOPENSYSTEM' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/CachedScanRecord' +Mon Dec 10 12:06:28.770 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/UserMode8021X' +Mon Dec 10 12:06:28.771 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Interface/en0/AirPort/BusyUI' +Mon Dec 10 12:06:28.945 Info: INTERFACE STATE INFO request received from pid 362 (sharingd) +Mon Dec 10 12:06:28.946 Info: -[CWXPCInterfaceContext __copyMACAddressForInterface:]: MAC address: <82cd0ac3 bf73> +Mon Dec 10 12:06:30.064 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:30.151 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:30.151 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.137 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.138 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.832 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:31.832 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:48.742 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:48.742 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.121 P2P: _terminateGroupOwnerTimer: Terminate group owner timer notification received. +Mon Dec 10 12:06:49.267 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.267 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.793 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:49.793 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.931 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:06:50.931 Driver Event: _bsd_80211_event_callback: AWDL_STATISTICS (awdl0) +Mon Dec 10 12:06:50.932 Info: AWDL real time mode ended +Mon Dec 10 12:06:50.945 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:06:50.945 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:06:50.945 {type = mutable dict, count = 2, +Mon Dec 10 12:06:50.945 entries => +Mon Dec 10 12:06:50.945 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.945 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.945 } +Mon Dec 10 12:06:50.945 +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:06:50.945 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:06:50.945 Driver Event: _bsd_80211_event_callback: AWDL_REALTIME_MODE_END (awdl0) +Mon Dec 10 12:06:50.945 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.945 BTC: __BluetoothCoexHandleUpdateForNode: Handle Bluetooth Coex: FrequencyBand <2>, Bluetooth Bandwidth Utilization <3>, Clamshell Mode <0> + + + + + + + +{last_modified_time} test.log Page 17 + + +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 2.4GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexSetProfile: profile for band 5GHz didn't change +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: band = 0x2 +Mon Dec 10 12:06:50.945 Info: AWDL real time mode ended +Mon Dec 10 12:06:50.945 BTC: BluetoothCoexHandle_ApplyPolicy: Bluetooth Coex: hosting AP = NO, assoc as STA = YES, assoced in 2.4GHz = NO +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: band = 2 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexGetCurrentBssidPhyMode: Bluetooth Coex: Active PHY Mode 16. PHY Mode +Mon Dec 10 12:06:50.946 {type = mutable dict, count = 2, +Mon Dec 10 12:06:50.946 entries => +Mon Dec 10 12:06:50.946 0 : {contents = "PHYMODE_ACTIVE"} = {value = +16, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.946 1 : {contents = "PHYMODE_SUPPORTED"} = {value = +159, type = kCFNumberSInt32Type} +Mon Dec 10 12:06:50.946 } +Mon Dec 10 12:06:50.946 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: PHY mode: <10> 5GHz: YES +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: MCS index set size = 16, NSS = 2SS, need to re-assoc = YES +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Bluetooth Coex: 11bg only = NO, BT on = YES, # HIDs = 0, # A2DP = 0, # SCO = 0, fallback = normal -> Middle Chain is ON +Mon Dec 10 12:06:50.946 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexSettingPerChainPower: Chain Power Setting does not need to be updated +Mon Dec 10 12:06:50.946 BTC: BluetoothCoexHandle_ReconfigureAntennas: Skipping REASSOC - The # of chains did not change. +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_PEER_PRESENCE (awdl0) +Mon Dec 10 12:06:50.946 Driver Event: _bsd_80211_event_callback: AWDL_SYNC_STATE_CHANGED (awdl0) +Mon Dec 10 12:06:50.947 Info: AWDL ended +Mon Dec 10 12:06:50.951 Info: -[CWXPCInterfaceContext __submitAWDLUsageMetric:duration:]: AWDL usage metric data: CWAWDMetricAwdlUsageData: selfInfraChannel 40, peerInfraChannel 0, numOfPeers 6. Keys: Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90013 +Mon Dec 10 12:06:50.952 Info: INTERFACE STATE INFO request received from pid 362 (sharingd) +Mon Dec 10 12:06:50.952 Info: -[CWXPCInterfaceContext __copyMACAddressForInterface:]: MAC address: <82cd0ac3 bf73> +Mon Dec 10 12:06:50.953 Roam: ROAMING PROFILES updated to AC POWER for 2.4GHz on en0 +Mon Dec 10 12:06:50.953 Roam: ROAMING PROFILES updated to AC POWER for 5GHz on en0 +Mon Dec 10 12:06:53.680 Info: -[CWXPCSubsystem handleDeviceCountMetricQuery:]_block_invoke: DeviceCount metric data: CWAWDMetricDeviceCountData: timeSinceBoot: 1515466.360642, deviceCount: 1 +Mon Dec 10 12:06:53.684 Info: -[CWXPCSubsystem handleNetworkPrefsMetricQuery:]: NetworkPrefs metric data: CWAWDMetricNetworkPrefsData: preferred 15 hidden 0 open 1 wep 0 wpa 12 eap 2 +Mon Dec 10 12:06:53.684 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90004 +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90001 +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x9000d +Mon Dec 10 12:06:53.852 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x9000b +Mon Dec 10 12:12:03.594 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:03.594 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=216 Mbps +Mon Dec 10 12:12:03.595 Info: link quality changed +Mon Dec 10 12:12:09.598 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:09.598 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=270 Mbps +Mon Dec 10 12:12:09.599 Info: link quality changed +Mon Dec 10 12:12:56.625 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:12:56.625 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 12:12:56.625 Info: link quality changed +Mon Dec 10 12:13:01.625 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:01.625 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps +Mon Dec 10 12:13:01.626 Info: link quality changed +Mon Dec 10 12:13:06.628 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:06.628 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 12:13:06.628 Info: link quality changed +Mon Dec 10 12:13:27.639 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:13:27.639 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=243 Mbps +Mon Dec 10 12:13:27.640 Info: link quality changed + + + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index fb4523c0c..da0785839 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -26,7 +26,7 @@ fn test_without_any_options() { scenario .args(&[test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![("{last_modified_time}".to_string(), value)]); + .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); } #[test] @@ -38,7 +38,7 @@ fn test_with_numbering_option() { scenario .args(&["-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![("{last_modified_time}".to_string(), value)]); + .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); } #[test] @@ -50,7 +50,7 @@ fn test_with_numbering_option_when_content_is_less_than_page() { scenario .args(&["-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![("{last_modified_time}".to_string(), value)]); + .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); } #[test] @@ -62,7 +62,7 @@ fn test_with_numbering_option_with_number_width() { scenario .args(&["-n", "2", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![("{last_modified_time}".to_string(), value)]); + .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); } #[test] @@ -76,8 +76,8 @@ fn test_with_header_option() { .args(&["-h", header, test_file_path]) .succeeds() .stdout_is_templated_fixture(expected_test_file_path, vec![ - ("{last_modified_time}".to_string(), value), - ("{header}".to_string(), header.to_string()) + (&"{last_modified_time}".to_string(), &value), + (&"{header}".to_string(), &header.to_string()) ]); } @@ -92,8 +92,8 @@ fn test_with_long_header_option() { .args(&["--header=new file", test_file_path]) .succeeds() .stdout_is_templated_fixture(expected_test_file_path, vec![ - ("{last_modified_time}".to_string(), value), - ("{header}".to_string(), header.to_string()) + (&"{last_modified_time}".to_string(), &value), + (&"{header}".to_string(), &header.to_string()) ]); } @@ -107,7 +107,7 @@ fn test_with_double_space_option() { .args(&["-d", test_file_path]) .succeeds() .stdout_is_templated_fixture(expected_test_file_path, vec![ - ("{last_modified_time}".to_string(), value), + (&"{last_modified_time}".to_string(), &value), ]); } @@ -121,7 +121,7 @@ fn test_with_long_double_space_option() { .args(&["--double-space", test_file_path]) .succeeds() .stdout_is_templated_fixture(expected_test_file_path, vec![ - ("{last_modified_time}".to_string(), value), + (&"{last_modified_time}".to_string(), &value), ]); } @@ -135,7 +135,7 @@ fn test_with_first_line_number_option() { .args(&["-N", "5", "-n", test_file_path]) .succeeds() .stdout_is_templated_fixture(expected_test_file_path, vec![ - ("{last_modified_time}".to_string(), value), + (&"{last_modified_time}".to_string(), &value), ]); } @@ -149,7 +149,7 @@ fn test_with_first_line_number_long_option() { .args(&["--first-line-number=5", "-n", test_file_path]) .succeeds() .stdout_is_templated_fixture(expected_test_file_path, vec![ - ("{last_modified_time}".to_string(), value), + (&"{last_modified_time}".to_string(), &value), ]); } @@ -163,7 +163,7 @@ fn test_with_number_option_with_custom_separator_char() { .args(&["-nc", test_file_path]) .succeeds() .stdout_is_templated_fixture(expected_test_file_path, vec![ - ("{last_modified_time}".to_string(), value), + (&"{last_modified_time}".to_string(), &value), ]); } @@ -177,6 +177,60 @@ fn test_with_number_option_with_custom_separator_char_and_width() { .args(&["-nc1", test_file_path]) .succeeds() .stdout_is_templated_fixture(expected_test_file_path, vec![ - ("{last_modified_time}".to_string(), value), + (&"{last_modified_time}".to_string(), &value), + ]); +} + +#[test] +fn test_valid_page_ranges() { + let test_file_path = "test_num_page.log"; + let mut scenario = new_ucmd!(); + scenario + .args(&["--pages=20:5", test_file_path]) + .fails() + .stderr_is("pr: invalid --pages argument '20:5'") + .stdout_is(""); + new_ucmd!() + .args(&["--pages=1:5", test_file_path]) + .succeeds(); + new_ucmd!() + .args(&["--pages=1", test_file_path]) + .succeeds(); + new_ucmd!() + .args(&["--pages=-1:5", test_file_path]) + .fails() + .stderr_is("pr: invalid --pages argument '-1:5'") + .stdout_is(""); + new_ucmd!() + .args(&["--pages=1:-5", test_file_path]) + .fails() + .stderr_is("pr: invalid --pages argument '1:-5'") + .stdout_is(""); + new_ucmd!() + .args(&["--pages=5:1", test_file_path]) + .fails() + .stderr_is("pr: invalid --pages argument '5:1'") + .stdout_is(""); + +} + +#[test] +fn test_page_range() { + let test_file_path = "test.log"; + let expected_test_file_path = "test_page_range_1.log.expected"; + let expected_test_file_path1 = "test_page_range_2.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["--pages=15", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + (&"{last_modified_time}".to_string(), &value), + ]); + new_ucmd!() + .args(&["--pages=15:17", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path1, vec![ + (&"{last_modified_time}".to_string(), &value), ]); } \ No newline at end of file From b578bb6563e01da21c97f7987d51dda1b3f74840 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sun, 16 Dec 2018 22:54:09 +0530 Subject: [PATCH 025/126] pr: add test for -t -l -r option pr: Add test for -l option pr: Add test for -r suppress error option --- src/pr/pr.rs | 24 ++- .../pr/test_one_page_no_ht.log.expected | 56 +++++ .../fixtures/pr/test_page_length.log.expected | 200 ++++++++++++++++++ .../pr/test_page_length1.log.expected | 10 + tests/test_pr.rs | 49 ++++- 5 files changed, 327 insertions(+), 12 deletions(-) create mode 100644 tests/fixtures/pr/test_one_page_no_ht.log.expected create mode 100644 tests/fixtures/pr/test_page_length.log.expected create mode 100644 tests/fixtures/pr/test_page_length1.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 08681c0de..1cc81bfe2 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -302,7 +302,7 @@ pub fn uumain(args: Vec) -> i32 { let maybe_file = matches.opt_str(NUMBERING_MODE_OPTION).unwrap(); let is_afile = is_a_file(&maybe_file); if !is_afile { - writeln!(&mut stderr(), "{}", PrError::NotExists(maybe_file)); + print_error(&matches, PrError::NotExists(maybe_file)); return 1; } else { files.push(maybe_file); @@ -321,15 +321,13 @@ pub fn uumain(args: Vec) -> i32 { for f in files { let result_options = build_options(&matches, &f); if result_options.is_err() { - writeln!(&mut stderr(), "{}", result_options.err().unwrap()); + print_error(&matches, result_options.err().unwrap()); return 1; } let options = &result_options.unwrap(); let status: i32 = match pr(&f, options) { Err(error) => { - if !options.suppress_errors { - writeln!(&mut stderr(), "{}", error); - } + print_error(&matches, error); 1 } _ => 0 @@ -345,6 +343,12 @@ fn is_a_file(could_be_file: &String) -> bool { File::open(could_be_file).is_ok() } +fn print_error(matches: &Matches, err: PrError) { + if !matches.opt_present(SUPPRESS_PRINTING_ERROR) { + writeln!(&mut stderr(), "{}", err); + } +} + fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { println!("{} {} -- print files", NAME, VERSION); println!(); @@ -476,11 +480,15 @@ fn build_options(matches: &Matches, path: &String) -> Result res?, _ => LINES_PER_PAGE }; + let page_length_le_ht = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); - let content_lines_per_page = page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); + let display_header_and_trailer = !(page_length_le_ht) && !matches.opt_present(NO_HEADER_TRAILER_OPTION); - let display_header_and_trailer = !(page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE)) - && !matches.opt_present(NO_HEADER_TRAILER_OPTION); + let content_lines_per_page = if page_length_le_ht { + page_length + } else { + page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE) + }; let suppress_errors = matches.opt_present(SUPPRESS_PRINTING_ERROR); diff --git a/tests/fixtures/pr/test_one_page_no_ht.log.expected b/tests/fixtures/pr/test_one_page_no_ht.log.expected new file mode 100644 index 000000000..3d5131358 --- /dev/null +++ b/tests/fixtures/pr/test_one_page_no_ht.log.expected @@ -0,0 +1,56 @@ +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed \ No newline at end of file diff --git a/tests/fixtures/pr/test_page_length.log.expected b/tests/fixtures/pr/test_page_length.log.expected new file mode 100644 index 000000000..02425a8e6 --- /dev/null +++ b/tests/fixtures/pr/test_page_length.log.expected @@ -0,0 +1,200 @@ + + +{last_modified_time} test.log Page 2 + + + 1 ntation processAirPortStateChanges]: pppConnectionState 0 + 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 8 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 9 Mon Dec 10 11:42:57.002 Info: 802.1X changed + 10 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 11 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 12 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 13 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 14 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 15 Mon Dec 10 11:42:57.302 Info: 802.1X changed + 16 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 17 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 18 Mon Dec 10 11:42:57.449 Info: 802.1X changed + 19 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 20 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 21 Mon Dec 10 11:42:57.600 Info: 802.1X changed + 22 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 23 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 24 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 25 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 26 Mon Dec 10 11:42:57.749 Info: 802.1X changed + 27 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 28 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 29 Mon Dec 10 11:42:57.896 Info: 802.1X changed + 30 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 31 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 32 Mon Dec 10 11:42:58.045 Info: 802.1X changed + 33 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 34 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 35 Mon Dec 10 11:42:58.193 Info: 802.1X changed + 36 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 37 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 38 Mon Dec 10 11:42:58.342 Info: 802.1X changed + 39 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 40 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 41 Mon Dec 10 11:42:58.491 Info: 802.1X changed + 42 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 43 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 44 Mon Dec 10 11:42:58.640 Info: 802.1X changed + 45 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 46 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 47 Mon Dec 10 11:42:58.805 Info: 802.1X changed + 48 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 49 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 50 Mon Dec 10 11:42:58.958 Info: 802.1X changed + 51 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 52 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 53 Mon Dec 10 11:42:59.155 Info: 802.1X changed + 54 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 55 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 56 Mon Dec 10 11:42:59.352 Info: 802.1X changed + 57 Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 58 Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 59 Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_END (en0) + 60 Mon Dec 10 11:42:59.372 Info: Roaming ended on interface en0 + 61 Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: RSN_HANDSHAKE_DONE (en0) + 62 Mon Dec 10 11:42:59.373 Info: -[CWXPCInterfaceContext setRoamInProgress:reason:]_block_invoke: roam status metric data: CWAWDMetricRoamStatus: status:0 security: 4 profile:5 origin:<34fcb9>(-69) target:<6cf37f>(-56) latency:6.083439s + 63 Mon Dec 10 11:42:59.373 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90046 + 64 Mon Dec 10 11:42:59.373 Info: RESUME AWDL for interface en0, reason=Roam token=2685 + 65 Mon Dec 10 11:42:59.373 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=5] + 66 Mon Dec 10 11:42:59.374 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 0 + 67 Mon Dec 10 11:43:01.072 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP' + 68 Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP + 69 Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: DHCP airport_changed = 1 + 70 Mon Dec 10 11:43:01.073 Info: -[CWXPCSubsystem internal_submitIPConfigLatencyMetric:leaseDuration:]: IPConfig Latency metric data: CWAWDMetricIPConfigLatencyData: DHCP latency: 29010 msecs, duration: 480 mins, security: 4 + 71 Mon Dec 10 11:43:01.073 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90007 + 72 Mon Dec 10 11:43:01.073 SC: _setDHCPMessage: dhcpInfoKey "State:/Network/Interface/en0/AirPort/DHCP Message" = (null) + 73 Mon Dec 10 11:43:10.369 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 74 Mon Dec 10 11:43:10.369 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=162 Mbps + 75 Mon Dec 10 11:43:10.369 Info: link quality changed + 76 Mon Dec 10 11:43:23.376 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 77 Mon Dec 10 11:43:23.377 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps + 78 Mon Dec 10 11:43:23.377 Info: link quality changed + 79 Mon Dec 10 11:43:28.380 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 80 Mon Dec 10 11:43:28.380 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps + 81 Mon Dec 10 11:43:28.380 Info: link quality changed + 82 Mon Dec 10 11:43:31.744 AutoJoin: BACKGROUND SCAN request on interface en0 with SSID list (null) + 83 Mon Dec 10 11:43:31.747 Scan: Cache-assisted scan request on channel 1 does not require a live scan + 84 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 2 does not require a live scan + 85 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 3 does not require a live scan + 86 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request does not require a live scan + 87 Mon Dec 10 11:43:31.748 AutoJoin: Successful cache-assisted background scan request with channels {( + 88 Mon Dec 10 11:43:31.748 [channelNumber=1(2GHz), channelWidth={20MHz}, active], + 89 Mon Dec 10 11:43:31.748 [channelNumber=2(2GHz), channelWidth={20MHz}, active], + 90 Mon Dec 10 11:43:31.748 [channelNumber=3(2GHz), channelWidth={20MHz}, active] + + + + + + + +{last_modified_time} test.log Page 3 + + + 91 Mon Dec 10 11:52:32.715 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 92 Mon Dec 10 11:52:32.715 [channelNumber=7(2GHz), channelWidth={20MHz}, active], + 93 Mon Dec 10 11:52:32.715 [channelNumber=8(2GHz), channelWidth={20MHz}, active], + 94 Mon Dec 10 11:52:32.715 [channelNumber=9(2GHz), channelWidth={20MHz}, active], + 95 Mon Dec 10 11:52:32.715 [channelNumber=10(2GHz), channelWidth={20MHz}, active], + 96 Mon Dec 10 11:52:32.715 [channelNumber=11(2GHz), channelWidth={20MHz}, active], + 97 Mon Dec 10 11:52:32.715 [channelNumber=12(2GHz), channelWidth={20MHz}, active] + 98 Mon Dec 10 11:52:32.715 )} took 0.2636 seconds, returned 10 results + 99 Mon Dec 10 11:52:32.994 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 100 Mon Dec 10 11:52:32.997 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 101 Mon Dec 10 11:52:32.998 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 102 Mon Dec 10 11:52:32.998 [channelNumber=13(2GHz), channelWidth={20MHz}, active], + 103 Mon Dec 10 11:52:32.998 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], + 104 Mon Dec 10 11:52:32.998 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active], + 105 Mon Dec 10 11:52:32.998 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], + 106 Mon Dec 10 11:52:32.998 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], + 107 Mon Dec 10 11:52:32.998 [channelNumber=149(5GHz), channelWidth={20MHz}, active] + 108 Mon Dec 10 11:52:32.998 )} took 0.2822 seconds, returned 14 results + 109 Mon Dec 10 11:52:33.405 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 110 Mon Dec 10 11:52:33.408 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 111 Mon Dec 10 11:52:33.409 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 112 Mon Dec 10 11:52:33.409 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], + 113 Mon Dec 10 11:52:33.409 [channelNumber=157(5GHz), channelWidth={20MHz}, active], + 114 Mon Dec 10 11:52:33.409 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active], + 115 Mon Dec 10 11:52:33.409 [channelNumber=165(5GHz), channelWidth={20MHz}, active], + 116 Mon Dec 10 11:52:33.409 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], + 117 Mon Dec 10 11:52:33.409 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] + 118 Mon Dec 10 11:52:33.409 )} took 0.4099 seconds, returned 11 results + 119 Mon Dec 10 11:52:33.669 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 120 Mon Dec 10 11:52:33.672 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 121 Mon Dec 10 11:52:33.672 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 122 Mon Dec 10 11:52:33.672 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], + 123 Mon Dec 10 11:52:33.672 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] + 124 Mon Dec 10 11:52:33.672 )} took 0.2625 seconds, returned 8 results + 125 Mon Dec 10 11:52:33.673 Info: scan cache updated + 126 Mon Dec 10 11:52:33.693 Info: SCAN request received from pid 92 (locationd) with priority 2 + 127 Mon Dec 10 11:52:33.693 Scan: locationd requested a live scan less than 10 seconds after previous request (1.4991s) returning cached scan results + 128 Mon Dec 10 11:52:33.728 Info: SCAN request received from pid 92 (locationd) with priority 2 + 129 Mon Dec 10 11:52:33.728 Scan: locationd requested a live scan less than 10 seconds after previous request (1.5339s) returning cached scan results + 130 Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: caps = CPU Net Disk + 131 Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: Being put into maintenance wake mode while fully awake. + 132 Mon Dec 10 11:55:47.610 Info: psCallback: powerSource = AC Power + 133 Mon Dec 10 11:55:47.610 Info: psCallback: set powersave disabled on en0 + 134 Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) + 135 Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) + 136 Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 + 137 Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 + 138 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds + 139 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds + 140 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests + 141 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests + 142 Mon Dec 10 11:55:48.093 IPC: ADDED XPC CLIENT CONNECTION [loginwindow (pid=101, euid=1651299376, egid=604256670)] + 143 Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 144 Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 145 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 146 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 147 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 148 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 149 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 150 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 151 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 152 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 153 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 154 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 155 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 156 Mon Dec 10 11:55:48.105 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 157 Mon Dec 10 11:56:07.629 Driver Discovery: _PMConnectionHandler: caps = + 158 Mon Dec 10 11:56:07.629 AutoJoin: BEST CONNECTED SCAN CANCELLED on interface en0 + 159 Mon Dec 10 11:56:07.629 AutoJoin: BACKGROUND SCAN CANCELLED on interface en0 + 160 Mon Dec 10 11:56:07.629 AutoJoin: Auto-join retry cancelled on interface en0 + 161 Mon Dec 10 11:56:07.629 Offload: _tcpKeepAliveActive: TCP keep-alive is active. + 162 Mon Dec 10 11:56:07.637 P2P: _changeInterfaceFlags: Marking p2p0 down + 163 Mon Dec 10 11:56:07.637 Info: SleepAcknowledgementCheckForHostAP: Checking sleep readiness for HostAP + 164 Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Checking sleep readiness + 165 Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Delaying sleep acknowledgement because of VifUp + 166 Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: KEV_DL_SIFFLAGS received for p2p0 [flags=0xffff8802 (down)]. + 167 Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: Flags changed for p2p0 (0xffff8843 -> 0xffff8802) (down). + 168 Mon Dec 10 11:56:07.638 P2P: _deviceInterfaceMarkedDown: p2p0 marked down + 169 Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Stop GO' action (param = 0x0) + 170 Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Scan' action (param = 0x0) + 171 Mon Dec 10 11:56:07.638 P2P: _p2pSupervisorEventRunLoopCallback: Mark down complete for p2p0 + 172 Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness + 173 Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementCheck: Checking if auto-join is in progress before sleep acknowledgement + 174 Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementDelayForAutoJoinAttempt_block_invoke: AUTO-JOIN attempt complete for en0, re-checking sleep readiness + 175 Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness + 176 Mon Dec 10 11:56:07.639 WoW: _wowEnabled: WoW is active on en0 + 177 Mon Dec 10 11:56:07.639 WoW: wowExchangeRequiredForNode: WoW exchange not required for en0 + 178 Mon Dec 10 11:56:07.639 _acknowledgeSleepEvent: Acknowledging sleep event + 179 Mon Dec 10 11:56:07.639 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=(null), priority=7] + 180 Mon Dec 10 11:56:07.640 AutoJoin: Auto-join retry cancelled on interface en0 + + + + + diff --git a/tests/fixtures/pr/test_page_length1.log.expected b/tests/fixtures/pr/test_page_length1.log.expected new file mode 100644 index 000000000..7162fe499 --- /dev/null +++ b/tests/fixtures/pr/test_page_length1.log.expected @@ -0,0 +1,10 @@ + 1 ntation processAirPortStateChanges]: pppConnectionState 0 + 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 7 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 8 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 9 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 10 Mon Dec 10 11:42:57.302 Info: 802.1X changed \ No newline at end of file diff --git a/tests/test_pr.rs b/tests/test_pr.rs index da0785839..6063e569b 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -182,7 +182,7 @@ fn test_with_number_option_with_custom_separator_char_and_width() { } #[test] -fn test_valid_page_ranges() { +fn test_with_valid_page_ranges() { let test_file_path = "test_num_page.log"; let mut scenario = new_ucmd!(); scenario @@ -211,11 +211,10 @@ fn test_valid_page_ranges() { .fails() .stderr_is("pr: invalid --pages argument '5:1'") .stdout_is(""); - } #[test] -fn test_page_range() { +fn test_with_page_range() { let test_file_path = "test.log"; let expected_test_file_path = "test_page_range_1.log.expected"; let expected_test_file_path1 = "test_page_range_2.log.expected"; @@ -233,4 +232,46 @@ fn test_page_range() { .stdout_is_templated_fixture(expected_test_file_path1, vec![ (&"{last_modified_time}".to_string(), &value), ]); -} \ No newline at end of file +} + +#[test] +fn test_with_no_header_trailer_option() { + let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page_no_ht.log.expected"; + let mut scenario = new_ucmd!(); + scenario + .args(&["-t", test_file_path]) + .succeeds() + .stdout_is_fixture(expected_test_file_path); +} + +#[test] +fn test_with_page_length_option() { + let test_file_path = "test.log"; + let expected_test_file_path = "test_page_length.log.expected"; + let expected_test_file_path1 = "test_page_length1.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["--pages=2:3", "-l", "100", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + (&"{last_modified_time}".to_string(), &value), + ]); + + new_ucmd!() + .args(&["--pages=2:3", "-l", "5", "-n", test_file_path]) + .succeeds() + .stdout_is_fixture(expected_test_file_path1); +} + +#[test] +fn test_with_suppress_error_option() { + let test_file_path = "test_num_page.log"; + let mut scenario = new_ucmd!(); + scenario + .args(&["--pages=20:5", "-r", test_file_path]) + .fails() + .stderr_is("") + .stdout_is(""); +} From f3676573b5ee21162aad3b359517b228198ffb50 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Mon, 17 Dec 2018 12:40:35 +0530 Subject: [PATCH 026/126] pr: print padded string for each column and handle tab issues pr: Print fixed padded string for each column pr: Fix display length vs str length due to tabs --- src/pr/pr.rs | 40 +++- .../fixtures/pr/test_page_length.log.expected | 180 +++++++++--------- .../pr/test_page_length1.log.expected | 12 +- .../pr/test_page_range_1.log.expected | 112 +++++------ .../pr/test_page_range_2.log.expected | 114 ++++++----- 5 files changed, 239 insertions(+), 219 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 1cc81bfe2..ef5358255 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -27,9 +27,11 @@ use std::convert::From; use getopts::HasArg; use getopts::Occur; use std::num::ParseIntError; +use std::str::Chars; static NAME: &str = "pr"; static VERSION: &str = env!("CARGO_PKG_VERSION"); +static TAB: char = '\t'; static LINES_PER_PAGE: usize = 66; static HEADER_LINES_PER_PAGE: usize = 5; static TRAILER_LINES_PER_PAGE: usize = 5; @@ -684,7 +686,7 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout, for start in 0..content_lines_per_page { let indexes: Vec = get_indexes(start, content_lines_per_page, columns); - let mut line = String::new(); + let mut line: Vec = Vec::new(); for index in indexes { if lines.get(index).is_none() { break; @@ -693,13 +695,13 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout, let next_line_number = line_number + index + 1; let trimmed_line = get_line_for_printing( next_line_number, &width, - &number_separator, columns, - col_sep, col_width, + &number_separator, columns, col_width, read_line, is_number_mode); - line.push_str(&trimmed_line); + line.push(trimmed_line); i += 1; } - out.write(line.as_bytes())?; + + out.write(line.join(col_sep).as_bytes())?; if i == lines.len() { out.write(page_separator)?; } else { @@ -710,17 +712,37 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout, } fn get_line_for_printing(line_number: usize, width: &usize, - separator: &String, columns: usize, col_sep: &String, col_width: Option, + separator: &String, columns: usize, + col_width: Option, read_line: &String, is_number_mode: bool) -> String { let fmtd_line_number: String = if is_number_mode { get_fmtd_line_number(&width, line_number, &separator) } else { "".to_string() }; - let complete_line = format!("{}{}{}", fmtd_line_number, read_line, col_sep); + let mut complete_line = format!("{}{}", fmtd_line_number, read_line); + + let tab_count: usize = complete_line + .chars() + .filter(|i| i == &TAB) + .count(); + + let display_length = complete_line.len() + (tab_count * 7); // TODO Adjust the width according to -n option - // TODO Line has less content than the column width - col_width.map(|i| complete_line.chars().take(i / columns).collect()).unwrap_or(complete_line) + // TODO actual len of the string vs display len of string because of tabs + col_width.map(|i| { + let min_width = (i - (columns - 1)) / columns; + if display_length < min_width { + for _i in 0..(min_width - display_length) { + complete_line.push(' '); + } + } + + complete_line + .chars() + .take(min_width) + .collect() + }).unwrap_or(complete_line) } fn get_indexes(start: usize, content_lines_per_page: usize, columns: usize) -> Vec { diff --git a/tests/fixtures/pr/test_page_length.log.expected b/tests/fixtures/pr/test_page_length.log.expected index 02425a8e6..412f53a77 100644 --- a/tests/fixtures/pr/test_page_length.log.expected +++ b/tests/fixtures/pr/test_page_length.log.expected @@ -3,96 +3,96 @@ {last_modified_time} test.log Page 2 - 1 ntation processAirPortStateChanges]: pppConnectionState 0 - 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed - 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed - 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 8 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 9 Mon Dec 10 11:42:57.002 Info: 802.1X changed - 10 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 11 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 12 Mon Dec 10 11:42:57.152 Info: 802.1X changed - 13 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 14 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 15 Mon Dec 10 11:42:57.302 Info: 802.1X changed - 16 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 17 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 18 Mon Dec 10 11:42:57.449 Info: 802.1X changed - 19 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 20 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 21 Mon Dec 10 11:42:57.600 Info: 802.1X changed - 22 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 23 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 24 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 25 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 26 Mon Dec 10 11:42:57.749 Info: 802.1X changed - 27 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 28 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 29 Mon Dec 10 11:42:57.896 Info: 802.1X changed - 30 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 31 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 32 Mon Dec 10 11:42:58.045 Info: 802.1X changed - 33 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 34 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 35 Mon Dec 10 11:42:58.193 Info: 802.1X changed - 36 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 37 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 38 Mon Dec 10 11:42:58.342 Info: 802.1X changed - 39 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 40 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 41 Mon Dec 10 11:42:58.491 Info: 802.1X changed - 42 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 43 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 44 Mon Dec 10 11:42:58.640 Info: 802.1X changed - 45 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 46 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 47 Mon Dec 10 11:42:58.805 Info: 802.1X changed - 48 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 49 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 50 Mon Dec 10 11:42:58.958 Info: 802.1X changed - 51 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 52 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 53 Mon Dec 10 11:42:59.155 Info: 802.1X changed - 54 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 55 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 56 Mon Dec 10 11:42:59.352 Info: 802.1X changed - 57 Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 58 Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 59 Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_END (en0) - 60 Mon Dec 10 11:42:59.372 Info: Roaming ended on interface en0 - 61 Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: RSN_HANDSHAKE_DONE (en0) - 62 Mon Dec 10 11:42:59.373 Info: -[CWXPCInterfaceContext setRoamInProgress:reason:]_block_invoke: roam status metric data: CWAWDMetricRoamStatus: status:0 security: 4 profile:5 origin:<34fcb9>(-69) target:<6cf37f>(-56) latency:6.083439s - 63 Mon Dec 10 11:42:59.373 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90046 - 64 Mon Dec 10 11:42:59.373 Info: RESUME AWDL for interface en0, reason=Roam token=2685 - 65 Mon Dec 10 11:42:59.373 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=5] - 66 Mon Dec 10 11:42:59.374 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 0 - 67 Mon Dec 10 11:43:01.072 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP' - 68 Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP - 69 Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: DHCP airport_changed = 1 - 70 Mon Dec 10 11:43:01.073 Info: -[CWXPCSubsystem internal_submitIPConfigLatencyMetric:leaseDuration:]: IPConfig Latency metric data: CWAWDMetricIPConfigLatencyData: DHCP latency: 29010 msecs, duration: 480 mins, security: 4 - 71 Mon Dec 10 11:43:01.073 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90007 - 72 Mon Dec 10 11:43:01.073 SC: _setDHCPMessage: dhcpInfoKey "State:/Network/Interface/en0/AirPort/DHCP Message" = (null) - 73 Mon Dec 10 11:43:10.369 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) - 74 Mon Dec 10 11:43:10.369 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=162 Mbps - 75 Mon Dec 10 11:43:10.369 Info: link quality changed - 76 Mon Dec 10 11:43:23.376 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) - 77 Mon Dec 10 11:43:23.377 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps - 78 Mon Dec 10 11:43:23.377 Info: link quality changed - 79 Mon Dec 10 11:43:28.380 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) - 80 Mon Dec 10 11:43:28.380 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps - 81 Mon Dec 10 11:43:28.380 Info: link quality changed - 82 Mon Dec 10 11:43:31.744 AutoJoin: BACKGROUND SCAN request on interface en0 with SSID list (null) - 83 Mon Dec 10 11:43:31.747 Scan: Cache-assisted scan request on channel 1 does not require a live scan - 84 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 2 does not require a live scan - 85 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 3 does not require a live scan - 86 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request does not require a live scan - 87 Mon Dec 10 11:43:31.748 AutoJoin: Successful cache-assisted background scan request with channels {( - 88 Mon Dec 10 11:43:31.748 [channelNumber=1(2GHz), channelWidth={20MHz}, active], - 89 Mon Dec 10 11:43:31.748 [channelNumber=2(2GHz), channelWidth={20MHz}, active], - 90 Mon Dec 10 11:43:31.748 [channelNumber=3(2GHz), channelWidth={20MHz}, active] + 1 Mon Dec 10 11:43:31.748 )} took 0.0025 seconds, returned 10 results + 2 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 4 does not require a live scan + 3 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 5 does not require a live scan + 4 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 6 does not require a live scan + 5 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan + 6 Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( + 7 Mon Dec 10 11:43:31.749 [channelNumber=4(2GHz), channelWidth={20MHz}, active], + 8 Mon Dec 10 11:43:31.749 [channelNumber=5(2GHz), channelWidth={20MHz}, active], + 9 Mon Dec 10 11:43:31.749 [channelNumber=6(2GHz), channelWidth={20MHz}, active] + 10 Mon Dec 10 11:43:31.749 )} took 0.0008 seconds, returned 7 results + 11 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 7 does not require a live scan + 12 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 8 does not require a live scan + 13 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 9 does not require a live scan + 14 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan + 15 Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( + 16 Mon Dec 10 11:43:31.749 [channelNumber=7(2GHz), channelWidth={20MHz}, active], + 17 Mon Dec 10 11:43:31.749 [channelNumber=8(2GHz), channelWidth={20MHz}, active], + 18 Mon Dec 10 11:43:31.749 [channelNumber=9(2GHz), channelWidth={20MHz}, active] + 19 Mon Dec 10 11:43:31.749 )} took 0.0002 seconds, returned 1 results + 20 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 10 does not require a live scan + 21 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 11 does not require a live scan + 22 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 12 does not require a live scan + 23 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request does not require a live scan + 24 Mon Dec 10 11:43:31.750 AutoJoin: Successful cache-assisted background scan request with channels {( + 25 Mon Dec 10 11:43:31.750 [channelNumber=10(2GHz), channelWidth={20MHz}, active], + 26 Mon Dec 10 11:43:31.750 [channelNumber=11(2GHz), channelWidth={20MHz}, active], + 27 Mon Dec 10 11:43:31.750 [channelNumber=12(2GHz), channelWidth={20MHz}, active] + 28 Mon Dec 10 11:43:31.750 )} took 0.0004 seconds, returned 4 results + 29 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 13 does not require a live scan + 30 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 36 does not require a live scan + 31 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 40 does not require a live scan + 32 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request does not require a live scan + 33 Mon Dec 10 11:43:31.751 AutoJoin: Successful cache-assisted background scan request with channels {( + 34 Mon Dec 10 11:43:31.751 [channelNumber=13(2GHz), channelWidth={20MHz}, active], + 35 Mon Dec 10 11:43:31.751 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], + 36 Mon Dec 10 11:43:31.751 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active] + 37 Mon Dec 10 11:43:31.751 )} took 0.0009 seconds, returned 9 results + 38 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 44 does not require a live scan + 39 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 48 does not require a live scan + 40 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 149 does not require a live scan + 41 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request does not require a live scan + 42 Mon Dec 10 11:43:31.752 AutoJoin: Successful cache-assisted background scan request with channels {( + 43 Mon Dec 10 11:43:31.752 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], + 44 Mon Dec 10 11:43:31.752 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], + 45 Mon Dec 10 11:43:31.752 [channelNumber=149(5GHz), channelWidth={20MHz}, active] + 46 Mon Dec 10 11:43:31.752 )} took 0.0010 seconds, returned 9 results + 47 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 153 does not require a live scan + 48 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 157 does not require a live scan + 49 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 161 does not require a live scan + 50 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request does not require a live scan + 51 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( + 52 Mon Dec 10 11:43:31.753 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], + 53 Mon Dec 10 11:43:31.753 [channelNumber=157(5GHz), channelWidth={20MHz}, active], + 54 Mon Dec 10 11:43:31.753 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active] + 55 Mon Dec 10 11:43:31.753 )} took 0.0007 seconds, returned 9 results + 56 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 165 does not require a live scan + 57 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 52 does not require a live scan + 58 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 56 does not require a live scan + 59 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request does not require a live scan + 60 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( + 61 Mon Dec 10 11:43:31.753 [channelNumber=165(5GHz), channelWidth={20MHz}, active], + 62 Mon Dec 10 11:43:31.753 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], + 63 Mon Dec 10 11:43:31.753 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] + 64 Mon Dec 10 11:43:31.753 )} took 0.0005 seconds, returned 6 results + 65 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 60 does not require a live scan + 66 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 64 does not require a live scan + 67 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request does not require a live scan + 68 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( + 69 Mon Dec 10 11:43:31.754 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], + 70 Mon Dec 10 11:43:31.754 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] + 71 Mon Dec 10 11:43:31.754 )} took 0.0003 seconds, returned 4 results + 72 Mon Dec 10 11:43:42.382 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 73 Mon Dec 10 11:43:42.382 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=270 Mbps + 74 Mon Dec 10 11:43:42.383 Info: link quality changed + 75 Mon Dec 10 11:49:12.347 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 76 Mon Dec 10 11:49:12.350 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 77 Mon Dec 10 11:52:32.194 Info: SCAN request received from pid 92 (locationd) with priority 2 + 78 Mon Dec 10 11:52:32.448 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 79 Mon Dec 10 11:52:32.450 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 80 Mon Dec 10 11:52:32.451 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 81 Mon Dec 10 11:52:32.451 [channelNumber=1(2GHz), channelWidth={20MHz}, active], + 82 Mon Dec 10 11:52:32.451 [channelNumber=2(2GHz), channelWidth={20MHz}, active], + 83 Mon Dec 10 11:52:32.451 [channelNumber=3(2GHz), channelWidth={20MHz}, active], + 84 Mon Dec 10 11:52:32.451 [channelNumber=4(2GHz), channelWidth={20MHz}, active], + 85 Mon Dec 10 11:52:32.451 [channelNumber=5(2GHz), channelWidth={20MHz}, active], + 86 Mon Dec 10 11:52:32.451 [channelNumber=6(2GHz), channelWidth={20MHz}, active] + 87 Mon Dec 10 11:52:32.451 )} took 0.2566 seconds, returned 10 results + 88 Mon Dec 10 11:52:32.451 Info: scan cache updated + 89 Mon Dec 10 11:52:32.712 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 90 Mon Dec 10 11:52:32.715 Info: QUERY SCAN CACHE request received from pid 92 (locationd) diff --git a/tests/fixtures/pr/test_page_length1.log.expected b/tests/fixtures/pr/test_page_length1.log.expected index 7162fe499..09d8e3ce6 100644 --- a/tests/fixtures/pr/test_page_length1.log.expected +++ b/tests/fixtures/pr/test_page_length1.log.expected @@ -1,10 +1,10 @@ - 1 ntation processAirPortStateChanges]: pppConnectionState 0 - 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed - 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 1 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 2 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 3 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 4 Mon Dec 10 11:42:57.002 Info: 802.1X changed + 5 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 6 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars 7 Mon Dec 10 11:42:57.152 Info: 802.1X changed 8 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 9 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 10 Mon Dec 10 11:42:57.302 Info: 802.1X changed \ No newline at end of file + 10 Mon Dec 10 11:42:57.302 Info: 802.1X changed diff --git a/tests/fixtures/pr/test_page_range_1.log.expected b/tests/fixtures/pr/test_page_range_1.log.expected index 67fbf88a5..f254261d4 100644 --- a/tests/fixtures/pr/test_page_range_1.log.expected +++ b/tests/fixtures/pr/test_page_range_1.log.expected @@ -3,62 +3,62 @@ {last_modified_time} test.log Page 15 -ntation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:56.705 Info: 802.1X changed -Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:56.854 Info: 802.1X changed -Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.002 Info: 802.1X changed -Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.152 Info: 802.1X changed -Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.302 Info: 802.1X changed -Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.449 Info: 802.1X changed -Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.600 Info: 802.1X changed -Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.749 Info: 802.1X changed -Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.896 Info: 802.1X changed -Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.045 Info: 802.1X changed -Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.193 Info: 802.1X changed -Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.342 Info: 802.1X changed -Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.491 Info: 802.1X changed -Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.640 Info: 802.1X changed -Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.805 Info: 802.1X changed -Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.958 Info: 802.1X changed -Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:59.155 Info: 802.1X changed -Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:59.352 Info: 802.1X changed +Mon Dec 10 12:05:48.183 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.183 )} took 0.0007 seconds, returned 4 results +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request on channel 13 does not require a live scan +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request on channel 36 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 40 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.184 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.184 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.184 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:05:48.184 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 12:05:48.184 )} took 0.0007 seconds, returned 5 results +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 44 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 48 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 149 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.185 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.185 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:05:48.185 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:05:48.185 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.185 )} took 0.0006 seconds, returned 4 results +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 153 does not require a live scan +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 157 does not require a live scan +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 161 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.186 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.186 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:05:48.186 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.186 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 12:05:48.186 )} took 0.0010 seconds, returned 7 results +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 165 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 52 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 56 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.187 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.187 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.187 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:05:48.187 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:05:48.187 )} took 0.0008 seconds, returned 5 results +Mon Dec 10 12:05:48.187 Scan: Cache-assisted scan request on channel 60 does not require a live scan +Mon Dec 10 12:05:48.187 Scan: Cache-assisted scan request on channel 64 does not require a live scan +Mon Dec 10 12:05:48.188 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.188 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.188 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:05:48.188 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:05:48.188 )} took 0.0013 seconds, returned 8 results +Mon Dec 10 12:05:50.375 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:50.375 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=216 Mbps +Mon Dec 10 12:05:50.376 Info: link quality changed +Mon Dec 10 12:05:55.378 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:55.378 Info: _bsd_80211_event_callback: link quality: RSSI=-56 dBm TxRate=243 Mbps +Mon Dec 10 12:05:55.379 Info: link quality changed +Mon Dec 10 12:06:28.759 Driver Event: _bsd_80211_event_callback: AWDL_SYNC_STATE_CHANGED (awdl0) +Mon Dec 10 12:06:28.763 Info: AWDL started +Mon Dec 10 12:06:28.763 Driver Event: _bsd_80211_event_callback: CHANNEL_SWITCH (en0) +Mon Dec 10 12:06:28.765 Roam: ROAMING PROFILES updated to SINGLE-BAND, SINGLE-AP for 2.4GHz on en0 +Mon Dec 10 12:06:28.765 Roam: ROAMING PROFILES updated to SINGLE-BAND, SINGLE-AP for 5GHz on en0 diff --git a/tests/fixtures/pr/test_page_range_2.log.expected b/tests/fixtures/pr/test_page_range_2.log.expected index d90166b19..4f260eb65 100644 --- a/tests/fixtures/pr/test_page_range_2.log.expected +++ b/tests/fixtures/pr/test_page_range_2.log.expected @@ -3,62 +3,62 @@ {last_modified_time} test.log Page 15 -ntation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:56.705 Info: 802.1X changed -Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:56.854 Info: 802.1X changed -Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.002 Info: 802.1X changed -Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.152 Info: 802.1X changed -Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.302 Info: 802.1X changed -Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.449 Info: 802.1X changed -Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.600 Info: 802.1X changed -Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.749 Info: 802.1X changed -Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:57.896 Info: 802.1X changed -Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.045 Info: 802.1X changed -Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.193 Info: 802.1X changed -Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.342 Info: 802.1X changed -Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.491 Info: 802.1X changed -Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.640 Info: 802.1X changed -Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.805 Info: 802.1X changed -Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:58.958 Info: 802.1X changed -Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:59.155 Info: 802.1X changed -Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:59.352 Info: 802.1X changed +Mon Dec 10 12:05:48.183 [channelNumber=12(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.183 )} took 0.0007 seconds, returned 4 results +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request on channel 13 does not require a live scan +Mon Dec 10 12:05:48.183 Scan: Cache-assisted scan request on channel 36 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 40 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.184 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.184 [channelNumber=13(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.184 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:05:48.184 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 12:05:48.184 )} took 0.0007 seconds, returned 5 results +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 44 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 48 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request on channel 149 does not require a live scan +Mon Dec 10 12:05:48.184 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.185 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.185 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], +Mon Dec 10 12:05:48.185 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:05:48.185 [channelNumber=149(5GHz), channelWidth={20MHz}, active] +Mon Dec 10 12:05:48.185 )} took 0.0006 seconds, returned 4 results +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 153 does not require a live scan +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 157 does not require a live scan +Mon Dec 10 12:05:48.185 Scan: Cache-assisted scan request on channel 161 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.186 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.186 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], +Mon Dec 10 12:05:48.186 [channelNumber=157(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.186 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active] +Mon Dec 10 12:05:48.186 )} took 0.0010 seconds, returned 7 results +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 165 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 52 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request on channel 56 does not require a live scan +Mon Dec 10 12:05:48.186 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.187 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.187 [channelNumber=165(5GHz), channelWidth={20MHz}, active], +Mon Dec 10 12:05:48.187 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:05:48.187 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:05:48.187 )} took 0.0008 seconds, returned 5 results +Mon Dec 10 12:05:48.187 Scan: Cache-assisted scan request on channel 60 does not require a live scan +Mon Dec 10 12:05:48.187 Scan: Cache-assisted scan request on channel 64 does not require a live scan +Mon Dec 10 12:05:48.188 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 12:05:48.188 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 12:05:48.188 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], +Mon Dec 10 12:05:48.188 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] +Mon Dec 10 12:05:48.188 )} took 0.0013 seconds, returned 8 results +Mon Dec 10 12:05:50.375 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:50.375 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=216 Mbps +Mon Dec 10 12:05:50.376 Info: link quality changed +Mon Dec 10 12:05:55.378 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 12:05:55.378 Info: _bsd_80211_event_callback: link quality: RSSI=-56 dBm TxRate=243 Mbps +Mon Dec 10 12:05:55.379 Info: link quality changed +Mon Dec 10 12:06:28.759 Driver Event: _bsd_80211_event_callback: AWDL_SYNC_STATE_CHANGED (awdl0) +Mon Dec 10 12:06:28.763 Info: AWDL started +Mon Dec 10 12:06:28.763 Driver Event: _bsd_80211_event_callback: CHANNEL_SWITCH (en0) +Mon Dec 10 12:06:28.765 Roam: ROAMING PROFILES updated to SINGLE-BAND, SINGLE-AP for 2.4GHz on en0 +Mon Dec 10 12:06:28.765 Roam: ROAMING PROFILES updated to SINGLE-BAND, SINGLE-AP for 5GHz on en0 @@ -196,5 +196,3 @@ Mon Dec 10 12:13:27.640 Info: link quality changed - - From 5705ed142ff20ad8e2eae7c7f0c3f2d2f5016a7a Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Wed, 19 Dec 2018 22:06:36 +0530 Subject: [PATCH 027/126] pr: write pagination logic of reading file using iterators --- src/pr/Cargo.toml | 1 + src/pr/pr.rs | 173 +++++++++++++++++++++++----------------------- 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/pr/Cargo.toml b/src/pr/Cargo.toml index 08cc5ac30..d33681b5f 100644 --- a/src/pr/Cargo.toml +++ b/src/pr/Cargo.toml @@ -13,6 +13,7 @@ getopts = "0.2.18" time = "0.1.40" chrono = "0.4.6" quick-error = "1.2.2" +itertools = "0.7.8" [dependencies.uucore] path = "../uucore" diff --git a/src/pr/pr.rs b/src/pr/pr.rs index ef5358255..7460bc674 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -10,11 +10,12 @@ extern crate unix_socket; #[macro_use] extern crate quick_error; +extern crate itertools; extern crate chrono; extern crate getopts; extern crate uucore; -use std::io::{BufRead, BufReader, stdin, stdout, stderr, Error, Read, Write, Stdout}; +use std::io::{BufRead, BufReader, stdin, stdout, stderr, Error, Read, Write, Stdout, Lines}; use std::vec::Vec; use chrono::offset::Local; use chrono::DateTime; @@ -24,10 +25,10 @@ use std::fs::{metadata, File}; use std::os::unix::fs::FileTypeExt; use quick_error::ResultExt; use std::convert::From; -use getopts::HasArg; -use getopts::Occur; +use getopts::{HasArg, Occur}; use std::num::ParseIntError; -use std::str::Chars; +use itertools::{Itertools, GroupBy}; +use std::iter::{Enumerate, Map, TakeWhile, SkipWhile}; static NAME: &str = "pr"; static VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -65,7 +66,6 @@ struct OutputOptions { display_header: bool, display_trailer: bool, content_lines_per_page: usize, - suppress_errors: bool, page_separator_char: String, column_mode_options: Option, } @@ -76,38 +76,12 @@ struct ColumnModeOptions { column_separator: String, } -#[derive(PartialEq, Eq)] -enum PrintPageCommand { - Skip, - Abort, - Print, -} - impl AsRef for OutputOptions { fn as_ref(&self) -> &OutputOptions { self } } -impl OutputOptions { - fn get_columns(&self) -> usize { - self.as_ref() - .column_mode_options.as_ref() - .map(|i| i.columns) - .unwrap_or(1) - } - - fn lines_to_read_for_page(&self) -> usize { - let content_lines_per_page = &self.as_ref().content_lines_per_page; - let columns = self.get_columns(); - if self.as_ref().double_space { - (content_lines_per_page / 2) * columns - } else { - content_lines_per_page * columns - } - } -} - struct NumberingMode { /// Line numbering mode width: usize, @@ -492,8 +466,6 @@ fn build_options(matches: &Matches, path: &String) -> Result Result Result, PrError> { } fn pr(path: &str, options: &OutputOptions) -> Result { - let mut i = 0; - let mut page: usize = 0; - let mut buffered_content: Vec = Vec::new(); - let read_lines_per_page = options.lines_to_read_for_page(); - let start_page = options.as_ref().start_page.as_ref(); - let last_page = options.as_ref().end_page.as_ref(); - let mut line_number = options.as_ref() - .number - .as_ref() - .map(|i| i.first_number) - .unwrap_or(1) - 1; - for line in BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines() { - if i == read_lines_per_page { - page = page + 1; - i = 0; + let start_page: &usize = options.start_page.as_ref().unwrap_or(&1); + let last_page: Option<&usize> = options.end_page.as_ref(); + let lines_needed_per_page: usize = lines_to_read_for_page(options); + let start_line_number: usize = get_start_line_number(options); - let cmd = _get_print_command(start_page, last_page, &page); - if cmd == PrintPageCommand::Print { - line_number += print_page(&buffered_content, options, &page, &line_number)?; - buffered_content = Vec::new(); - } else if cmd == PrintPageCommand::Abort { - return Ok(0); - } + let pages: GroupBy>>>, _>, _>, _>>, _>, _> = + BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) + .lines() + .enumerate() + .skip_while(|line_index: &(usize, Result)| { + // Skip the initial lines if not in page range + let start_line_index_of_start_page = (*start_page - 1) * lines_needed_per_page; + line_index.0 < (start_line_index_of_start_page) + }) + .take_while(|i: &(usize, Result)| { + // Only read the file until provided last page reached + last_page + .map(|lp| i.0 < ((*lp) * lines_needed_per_page)) + .unwrap_or(true) + }) + .map(|i: (usize, Result)| i.1) // just get lines remove real line number + .enumerate() + .map(|i: (usize, Result)| (i.0 + start_line_number, i.1)) // get display line number with line content + .group_by(|i: &(usize, Result)| { + ((i.0 - start_line_number + 1) as f64 / lines_needed_per_page as f64).ceil() as usize + (start_page - 1) + }); // group them by page number + + + for (page_number, content_with_line_number) in pages.into_iter() { + let mut lines: Vec<(usize, String)> = Vec::new(); + for line_number_and_line in content_with_line_number { + let line_number: usize = line_number_and_line.0; + let line: Result = line_number_and_line.1; + let x = line?; + lines.push((line_number, x)); } - buffered_content.push(line?); - i = i + 1; + + print_page(&lines, options, &page_number); } - if i != 0 { - page = page + 1; - let cmd = _get_print_command(start_page, last_page, &page); - if cmd == PrintPageCommand::Print { - print_page(&buffered_content, options, &page, &line_number)?; - } else if cmd == PrintPageCommand::Abort { - return Ok(0); - } - } return Ok(0); } -fn _get_print_command(start_page: Option<&usize>, last_page: Option<&usize>, page: &usize) -> PrintPageCommand { - let below_page_range = start_page.is_some() && page < start_page.unwrap(); - let is_within_page_range = (start_page.is_none() || page >= start_page.unwrap()) - && (last_page.is_none() || page <= last_page.unwrap()); - if below_page_range { - return PrintPageCommand::Skip; - } else if is_within_page_range { - return PrintPageCommand::Print; - } - return PrintPageCommand::Abort; -} - -fn print_page(lines: &Vec, options: &OutputOptions, page: &usize, line_number: &usize) -> Result { +fn print_page(lines: &Vec<(usize, String)>, options: &OutputOptions, page: &usize) -> Result { let page_separator = options.as_ref().page_separator_char.as_bytes(); let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(options); @@ -640,7 +602,7 @@ fn print_page(lines: &Vec, options: &OutputOptions, page: &usize, line_n out.write(line_separator)?; } - let lines_written = write_columns(lines, options, out, line_number)?; + let lines_written = write_columns(lines, options, out)?; for index in 0..trailer_content.len() { let x: &String = trailer_content.get(index).unwrap(); @@ -655,7 +617,7 @@ fn print_page(lines: &Vec, options: &OutputOptions, page: &usize, line_n Ok(lines_written) } -fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout, line_number: &usize) -> Result { +fn write_columns(lines: &Vec<(usize, String)>, options: &OutputOptions, out: &mut Stdout) -> Result { let line_separator = options.as_ref().line_separator.as_bytes(); let page_separator = options.as_ref().page_separator_char.as_bytes(); let content_lines_per_page = options.as_ref().content_lines_per_page; @@ -669,7 +631,7 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout, .unwrap_or(NumberingMode::default().separator); let blank_line = "".to_string(); - let columns = options.get_columns(); + let columns = get_columns(options); let col_sep: &String = options.as_ref() .column_mode_options.as_ref() @@ -691,8 +653,8 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout, if lines.get(index).is_none() { break; } - let read_line = lines.get(index).unwrap(); - let next_line_number = line_number + index + 1; + let read_line: &String = &lines.get(index).unwrap().1; + let next_line_number: usize = lines.get(index).unwrap().0; let trimmed_line = get_line_for_printing( next_line_number, &width, &number_separator, columns, col_width, @@ -728,8 +690,8 @@ fn get_line_for_printing(line_number: usize, width: &usize, .count(); let display_length = complete_line.len() + (tab_count * 7); - // TODO Adjust the width according to -n option - // TODO actual len of the string vs display len of string because of tabs +// TODO Adjust the width according to -n option +// TODO actual len of the string vs display len of string because of tabs col_width.map(|i| { let min_width = (i - (columns - 1)) / columns; if display_length < min_width { @@ -797,3 +759,40 @@ fn trailer_content(options: &OutputOptions) -> Vec { Vec::new() } } + +/// Returns starting line number for the file to be printed. +/// If -N is specified the first line number changes otherwise +/// default is 1. +/// # Arguments +/// * `opts` - A reference to OutputOptions +fn get_start_line_number(opts: &OutputOptions) -> usize { + opts.number + .as_ref() + .map(|i| i.first_number) + .unwrap_or(1) +} + +/// Returns number of lines to read from input for constructing one page of pr output. +/// If double space -d is used lines are halved. +/// If columns --columns is used the lines are multiplied by the value. +/// # Arguments +/// * `opts` - A reference to OutputOptions +fn lines_to_read_for_page(opts: &OutputOptions) -> usize { + let content_lines_per_page = opts.content_lines_per_page; + let columns = get_columns(opts); + if opts.double_space { + (content_lines_per_page / 2) * columns + } else { + content_lines_per_page * columns + } +} + +/// Returns number of columns to output +/// # Arguments +/// * `opts` - A reference to OutputOptions +fn get_columns(opts: &OutputOptions) -> usize { + opts.column_mode_options + .as_ref() + .map(|i| i.columns) + .unwrap_or(1) +} From d9084a7399fc6c37703acab4896d7b4a4a69d406 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Thu, 20 Dec 2018 21:19:42 +0530 Subject: [PATCH 028/126] pr: implement across option and fix tests --- src/pr/pr.rs | 116 +++--- .../pr/test_one_page_double_line.log.expected | 72 ---- .../fixtures/pr/test_page_length.log.expected | 360 +++++++++--------- .../pr/test_page_length1.log.expected | 22 +- 4 files changed, 264 insertions(+), 306 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 7460bc674..0f1fffcd8 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -48,6 +48,7 @@ static PAGE_LENGTH_OPTION: &str = "l"; static SUPPRESS_PRINTING_ERROR: &str = "r"; static FORM_FEED_OPTION: &str = "F"; static COLUMN_WIDTH_OPTION: &str = "w"; +static ACROSS_OPTION: &str = "a"; static COLUMN_OPTION: &str = "column"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; @@ -60,6 +61,7 @@ struct OutputOptions { header: String, double_space: bool, line_separator: String, + content_line_separator: String, last_modified_time: String, start_page: Option, end_page: Option, @@ -74,6 +76,7 @@ struct ColumnModeOptions { width: Option, columns: usize, column_separator: String, + across_mode: bool, } impl AsRef for OutputOptions { @@ -258,6 +261,17 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + ACROSS_OPTION, + "across", + "Modify the effect of the - column option so that the columns are filled across the page in a round-robin order + (for example, when column is 2, the first input line heads column 1, the second heads column 2, the third is the + second line in column 1, and so on).", + "", + HasArg::No, + Occur::Optional, + ); + opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); @@ -405,12 +419,14 @@ fn build_options(matches: &Matches, path: &String) -> Result Result None }; + let across_mode = matches.opt_present(ACROSS_OPTION); + let column_mode_options = match matches.opt_str(COLUMN_OPTION).map(|i| { i.parse::() }) { @@ -486,6 +504,7 @@ fn build_options(matches: &Matches, path: &String) -> Result Some(DEFAULT_COLUMN_WIDTH) }, column_separator: DEFAULT_COLUMN_SEPARATOR.to_string(), + across_mode, }) } _ => None @@ -496,6 +515,7 @@ fn build_options(matches: &Matches, path: &String) -> Result Result { let lines_needed_per_page: usize = lines_to_read_for_page(options); let start_line_number: usize = get_start_line_number(options); - let pages: GroupBy>>>, _>, _>, _>>, _>, _> = + let pages: GroupBy>>>, _>, _>, _>, _> = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) .lines() .enumerate() @@ -564,11 +584,9 @@ fn pr(path: &str, options: &OutputOptions) -> Result { .map(|lp| i.0 < ((*lp) * lines_needed_per_page)) .unwrap_or(true) }) - .map(|i: (usize, Result)| i.1) // just get lines remove real line number - .enumerate() .map(|i: (usize, Result)| (i.0 + start_line_number, i.1)) // get display line number with line content .group_by(|i: &(usize, Result)| { - ((i.0 - start_line_number + 1) as f64 / lines_needed_per_page as f64).ceil() as usize + (start_page - 1) + ((i.0 - start_line_number + 1) as f64 / lines_needed_per_page as f64).ceil() as usize }); // group them by page number @@ -589,12 +607,12 @@ fn pr(path: &str, options: &OutputOptions) -> Result { } fn print_page(lines: &Vec<(usize, String)>, options: &OutputOptions, page: &usize) -> Result { - let page_separator = options.as_ref().page_separator_char.as_bytes(); + let page_separator = options.page_separator_char.as_bytes(); let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(options); let out: &mut Stdout = &mut stdout(); - let line_separator = options.as_ref().line_separator.as_bytes(); + let line_separator = options.line_separator.as_bytes(); out.lock(); for x in header { @@ -607,25 +625,28 @@ fn print_page(lines: &Vec<(usize, String)>, options: &OutputOptions, page: &usiz for index in 0..trailer_content.len() { let x: &String = trailer_content.get(index).unwrap(); out.write(x.as_bytes())?; - if index + 1 == trailer_content.len() { - out.write(page_separator)?; - } else { + if index + 1 != trailer_content.len() { out.write(line_separator)?; } } + out.write(page_separator)?; out.flush()?; Ok(lines_written) } fn write_columns(lines: &Vec<(usize, String)>, options: &OutputOptions, out: &mut Stdout) -> Result { - let line_separator = options.as_ref().line_separator.as_bytes(); - let page_separator = options.as_ref().page_separator_char.as_bytes(); - let content_lines_per_page = options.as_ref().content_lines_per_page; - let width: usize = options.as_ref() + let line_separator = options.content_line_separator.as_bytes(); + let content_lines_per_page = if options.double_space { + options.content_lines_per_page / 2 + } else { + options.content_lines_per_page + }; + + let width: usize = options .number.as_ref() .map(|i| i.width) .unwrap_or(0); - let number_separator: String = options.as_ref() + let number_separator: String = options .number.as_ref() .map(|i| i.separator.to_string()) .unwrap_or(NumberingMode::default().separator); @@ -633,23 +654,44 @@ fn write_columns(lines: &Vec<(usize, String)>, options: &OutputOptions, out: &mu let blank_line = "".to_string(); let columns = get_columns(options); - let col_sep: &String = options.as_ref() + let col_sep: &String = options .column_mode_options.as_ref() .map(|i| &i.column_separator) .unwrap_or(&blank_line); - let col_width: Option = options.as_ref() + let col_width: Option = options .column_mode_options.as_ref() .map(|i| i.width) .unwrap_or(None); - let mut i = 0; + let across_mode = options + .column_mode_options.as_ref() + .map(|i| i.across_mode) + .unwrap_or(false); + + let mut lines_printed = 0; let is_number_mode = options.number.is_some(); - for start in 0..content_lines_per_page { - let indexes: Vec = get_indexes(start, content_lines_per_page, columns); - let mut line: Vec = Vec::new(); - for index in indexes { + let fetch_indexes: Vec> = if across_mode { + (0..content_lines_per_page) + .map(|a| + (0..columns) + .map(|i| a * columns + i) + .collect() + ).collect() + } else { + (0..content_lines_per_page) + .map(|start| + (0..columns) + .map(|i| start + content_lines_per_page * i) + .collect() + ).collect() + }; + + for fetch_index in fetch_indexes { + let indexes = fetch_index.len(); + for i in 0..indexes { + let index = fetch_index[i]; if lines.get(index).is_none() { break; } @@ -659,18 +701,15 @@ fn write_columns(lines: &Vec<(usize, String)>, options: &OutputOptions, out: &mu next_line_number, &width, &number_separator, columns, col_width, read_line, is_number_mode); - line.push(trimmed_line); - i += 1; - } - - out.write(line.join(col_sep).as_bytes())?; - if i == lines.len() { - out.write(page_separator)?; - } else { - out.write(line_separator)?; + out.write(trimmed_line.as_bytes())?; + if (i + 1) != indexes { + out.write(col_sep.as_bytes())?; + } + lines_printed += 1; } + out.write(line_separator)?; } - Ok(i) + Ok(lines_printed) } fn get_line_for_printing(line_number: usize, width: &usize, @@ -707,17 +746,6 @@ fn get_line_for_printing(line_number: usize, width: &usize, }).unwrap_or(complete_line) } -fn get_indexes(start: usize, content_lines_per_page: usize, columns: usize) -> Vec { - let mut indexes: Vec = Vec::new(); - let mut offset = start; - indexes.push(offset); - for _col in 1..columns { - offset += content_lines_per_page; - indexes.push(offset); - } - indexes -} - fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) -> String { let line_str = line_number.to_string(); if line_str.len() >= *width { @@ -729,7 +757,7 @@ fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) - fn header_content(options: &OutputOptions, page: &usize) -> Vec { - if options.as_ref().display_header { + if options.display_header { let first_line: String = format!("{} {} Page {}", options.last_modified_time, options.header, page); vec!["".to_string(), "".to_string(), first_line, "".to_string(), "".to_string()] } else { diff --git a/tests/fixtures/pr/test_one_page_double_line.log.expected b/tests/fixtures/pr/test_one_page_double_line.log.expected index 831570103..e32101fcf 100644 --- a/tests/fixtures/pr/test_one_page_double_line.log.expected +++ b/tests/fixtures/pr/test_one_page_double_line.log.expected @@ -1,13 +1,8 @@ - - {last_modified_time} test_one_page.log Page 1 - - - ntation processAirPortStateChanges]: pppConnectionState 0 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars @@ -71,45 +66,9 @@ Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementati - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {last_modified_time} test_one_page.log Page 2 - - - Mon Dec 10 11:42:57.896 Info: 802.1X changed Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 @@ -171,34 +130,3 @@ Mon Dec 10 11:42:59.352 Info: 802.1X changed - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/fixtures/pr/test_page_length.log.expected b/tests/fixtures/pr/test_page_length.log.expected index 412f53a77..8f4ab82d1 100644 --- a/tests/fixtures/pr/test_page_length.log.expected +++ b/tests/fixtures/pr/test_page_length.log.expected @@ -3,96 +3,96 @@ {last_modified_time} test.log Page 2 - 1 Mon Dec 10 11:43:31.748 )} took 0.0025 seconds, returned 10 results - 2 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 4 does not require a live scan - 3 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 5 does not require a live scan - 4 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 6 does not require a live scan - 5 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan - 6 Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( - 7 Mon Dec 10 11:43:31.749 [channelNumber=4(2GHz), channelWidth={20MHz}, active], - 8 Mon Dec 10 11:43:31.749 [channelNumber=5(2GHz), channelWidth={20MHz}, active], - 9 Mon Dec 10 11:43:31.749 [channelNumber=6(2GHz), channelWidth={20MHz}, active] - 10 Mon Dec 10 11:43:31.749 )} took 0.0008 seconds, returned 7 results - 11 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 7 does not require a live scan - 12 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 8 does not require a live scan - 13 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 9 does not require a live scan - 14 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan - 15 Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( - 16 Mon Dec 10 11:43:31.749 [channelNumber=7(2GHz), channelWidth={20MHz}, active], - 17 Mon Dec 10 11:43:31.749 [channelNumber=8(2GHz), channelWidth={20MHz}, active], - 18 Mon Dec 10 11:43:31.749 [channelNumber=9(2GHz), channelWidth={20MHz}, active] - 19 Mon Dec 10 11:43:31.749 )} took 0.0002 seconds, returned 1 results - 20 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 10 does not require a live scan - 21 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 11 does not require a live scan - 22 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 12 does not require a live scan - 23 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request does not require a live scan - 24 Mon Dec 10 11:43:31.750 AutoJoin: Successful cache-assisted background scan request with channels {( - 25 Mon Dec 10 11:43:31.750 [channelNumber=10(2GHz), channelWidth={20MHz}, active], - 26 Mon Dec 10 11:43:31.750 [channelNumber=11(2GHz), channelWidth={20MHz}, active], - 27 Mon Dec 10 11:43:31.750 [channelNumber=12(2GHz), channelWidth={20MHz}, active] - 28 Mon Dec 10 11:43:31.750 )} took 0.0004 seconds, returned 4 results - 29 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 13 does not require a live scan - 30 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 36 does not require a live scan - 31 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 40 does not require a live scan - 32 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request does not require a live scan - 33 Mon Dec 10 11:43:31.751 AutoJoin: Successful cache-assisted background scan request with channels {( - 34 Mon Dec 10 11:43:31.751 [channelNumber=13(2GHz), channelWidth={20MHz}, active], - 35 Mon Dec 10 11:43:31.751 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], - 36 Mon Dec 10 11:43:31.751 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active] - 37 Mon Dec 10 11:43:31.751 )} took 0.0009 seconds, returned 9 results - 38 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 44 does not require a live scan - 39 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 48 does not require a live scan - 40 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 149 does not require a live scan - 41 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request does not require a live scan - 42 Mon Dec 10 11:43:31.752 AutoJoin: Successful cache-assisted background scan request with channels {( - 43 Mon Dec 10 11:43:31.752 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], - 44 Mon Dec 10 11:43:31.752 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], - 45 Mon Dec 10 11:43:31.752 [channelNumber=149(5GHz), channelWidth={20MHz}, active] - 46 Mon Dec 10 11:43:31.752 )} took 0.0010 seconds, returned 9 results - 47 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 153 does not require a live scan - 48 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 157 does not require a live scan - 49 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 161 does not require a live scan - 50 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request does not require a live scan - 51 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( - 52 Mon Dec 10 11:43:31.753 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], - 53 Mon Dec 10 11:43:31.753 [channelNumber=157(5GHz), channelWidth={20MHz}, active], - 54 Mon Dec 10 11:43:31.753 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active] - 55 Mon Dec 10 11:43:31.753 )} took 0.0007 seconds, returned 9 results - 56 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 165 does not require a live scan - 57 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 52 does not require a live scan - 58 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 56 does not require a live scan - 59 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request does not require a live scan - 60 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( - 61 Mon Dec 10 11:43:31.753 [channelNumber=165(5GHz), channelWidth={20MHz}, active], - 62 Mon Dec 10 11:43:31.753 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], - 63 Mon Dec 10 11:43:31.753 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] - 64 Mon Dec 10 11:43:31.753 )} took 0.0005 seconds, returned 6 results - 65 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 60 does not require a live scan - 66 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 64 does not require a live scan - 67 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request does not require a live scan - 68 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( - 69 Mon Dec 10 11:43:31.754 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], - 70 Mon Dec 10 11:43:31.754 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] - 71 Mon Dec 10 11:43:31.754 )} took 0.0003 seconds, returned 4 results - 72 Mon Dec 10 11:43:42.382 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) - 73 Mon Dec 10 11:43:42.382 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=270 Mbps - 74 Mon Dec 10 11:43:42.383 Info: link quality changed - 75 Mon Dec 10 11:49:12.347 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) - 76 Mon Dec 10 11:49:12.350 Info: QUERY SCAN CACHE request received from pid 92 (locationd) - 77 Mon Dec 10 11:52:32.194 Info: SCAN request received from pid 92 (locationd) with priority 2 - 78 Mon Dec 10 11:52:32.448 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) - 79 Mon Dec 10 11:52:32.450 Info: QUERY SCAN CACHE request received from pid 92 (locationd) - 80 Mon Dec 10 11:52:32.451 AutoJoin: Successful cache-assisted scan request for locationd with channels {( - 81 Mon Dec 10 11:52:32.451 [channelNumber=1(2GHz), channelWidth={20MHz}, active], - 82 Mon Dec 10 11:52:32.451 [channelNumber=2(2GHz), channelWidth={20MHz}, active], - 83 Mon Dec 10 11:52:32.451 [channelNumber=3(2GHz), channelWidth={20MHz}, active], - 84 Mon Dec 10 11:52:32.451 [channelNumber=4(2GHz), channelWidth={20MHz}, active], - 85 Mon Dec 10 11:52:32.451 [channelNumber=5(2GHz), channelWidth={20MHz}, active], - 86 Mon Dec 10 11:52:32.451 [channelNumber=6(2GHz), channelWidth={20MHz}, active] - 87 Mon Dec 10 11:52:32.451 )} took 0.2566 seconds, returned 10 results - 88 Mon Dec 10 11:52:32.451 Info: scan cache updated - 89 Mon Dec 10 11:52:32.712 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) - 90 Mon Dec 10 11:52:32.715 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 91 Mon Dec 10 11:43:31.748 )} took 0.0025 seconds, returned 10 results + 92 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 4 does not require a live scan + 93 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 5 does not require a live scan + 94 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 6 does not require a live scan + 95 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan + 96 Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( + 97 Mon Dec 10 11:43:31.749 [channelNumber=4(2GHz), channelWidth={20MHz}, active], + 98 Mon Dec 10 11:43:31.749 [channelNumber=5(2GHz), channelWidth={20MHz}, active], + 99 Mon Dec 10 11:43:31.749 [channelNumber=6(2GHz), channelWidth={20MHz}, active] + 100 Mon Dec 10 11:43:31.749 )} took 0.0008 seconds, returned 7 results + 101 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 7 does not require a live scan + 102 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 8 does not require a live scan + 103 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 9 does not require a live scan + 104 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan + 105 Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( + 106 Mon Dec 10 11:43:31.749 [channelNumber=7(2GHz), channelWidth={20MHz}, active], + 107 Mon Dec 10 11:43:31.749 [channelNumber=8(2GHz), channelWidth={20MHz}, active], + 108 Mon Dec 10 11:43:31.749 [channelNumber=9(2GHz), channelWidth={20MHz}, active] + 109 Mon Dec 10 11:43:31.749 )} took 0.0002 seconds, returned 1 results + 110 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 10 does not require a live scan + 111 Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 11 does not require a live scan + 112 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 12 does not require a live scan + 113 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request does not require a live scan + 114 Mon Dec 10 11:43:31.750 AutoJoin: Successful cache-assisted background scan request with channels {( + 115 Mon Dec 10 11:43:31.750 [channelNumber=10(2GHz), channelWidth={20MHz}, active], + 116 Mon Dec 10 11:43:31.750 [channelNumber=11(2GHz), channelWidth={20MHz}, active], + 117 Mon Dec 10 11:43:31.750 [channelNumber=12(2GHz), channelWidth={20MHz}, active] + 118 Mon Dec 10 11:43:31.750 )} took 0.0004 seconds, returned 4 results + 119 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 13 does not require a live scan + 120 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 36 does not require a live scan + 121 Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 40 does not require a live scan + 122 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request does not require a live scan + 123 Mon Dec 10 11:43:31.751 AutoJoin: Successful cache-assisted background scan request with channels {( + 124 Mon Dec 10 11:43:31.751 [channelNumber=13(2GHz), channelWidth={20MHz}, active], + 125 Mon Dec 10 11:43:31.751 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], + 126 Mon Dec 10 11:43:31.751 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active] + 127 Mon Dec 10 11:43:31.751 )} took 0.0009 seconds, returned 9 results + 128 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 44 does not require a live scan + 129 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 48 does not require a live scan + 130 Mon Dec 10 11:43:31.751 Scan: Cache-assisted scan request on channel 149 does not require a live scan + 131 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request does not require a live scan + 132 Mon Dec 10 11:43:31.752 AutoJoin: Successful cache-assisted background scan request with channels {( + 133 Mon Dec 10 11:43:31.752 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], + 134 Mon Dec 10 11:43:31.752 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], + 135 Mon Dec 10 11:43:31.752 [channelNumber=149(5GHz), channelWidth={20MHz}, active] + 136 Mon Dec 10 11:43:31.752 )} took 0.0010 seconds, returned 9 results + 137 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 153 does not require a live scan + 138 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 157 does not require a live scan + 139 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request on channel 161 does not require a live scan + 140 Mon Dec 10 11:43:31.752 Scan: Cache-assisted scan request does not require a live scan + 141 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( + 142 Mon Dec 10 11:43:31.753 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], + 143 Mon Dec 10 11:43:31.753 [channelNumber=157(5GHz), channelWidth={20MHz}, active], + 144 Mon Dec 10 11:43:31.753 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active] + 145 Mon Dec 10 11:43:31.753 )} took 0.0007 seconds, returned 9 results + 146 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 165 does not require a live scan + 147 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 52 does not require a live scan + 148 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 56 does not require a live scan + 149 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request does not require a live scan + 150 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( + 151 Mon Dec 10 11:43:31.753 [channelNumber=165(5GHz), channelWidth={20MHz}, active], + 152 Mon Dec 10 11:43:31.753 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], + 153 Mon Dec 10 11:43:31.753 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] + 154 Mon Dec 10 11:43:31.753 )} took 0.0005 seconds, returned 6 results + 155 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 60 does not require a live scan + 156 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request on channel 64 does not require a live scan + 157 Mon Dec 10 11:43:31.753 Scan: Cache-assisted scan request does not require a live scan + 158 Mon Dec 10 11:43:31.753 AutoJoin: Successful cache-assisted background scan request with channels {( + 159 Mon Dec 10 11:43:31.754 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], + 160 Mon Dec 10 11:43:31.754 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] + 161 Mon Dec 10 11:43:31.754 )} took 0.0003 seconds, returned 4 results + 162 Mon Dec 10 11:43:42.382 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 163 Mon Dec 10 11:43:42.382 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=270 Mbps + 164 Mon Dec 10 11:43:42.383 Info: link quality changed + 165 Mon Dec 10 11:49:12.347 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 166 Mon Dec 10 11:49:12.350 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 167 Mon Dec 10 11:52:32.194 Info: SCAN request received from pid 92 (locationd) with priority 2 + 168 Mon Dec 10 11:52:32.448 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 169 Mon Dec 10 11:52:32.450 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 170 Mon Dec 10 11:52:32.451 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 171 Mon Dec 10 11:52:32.451 [channelNumber=1(2GHz), channelWidth={20MHz}, active], + 172 Mon Dec 10 11:52:32.451 [channelNumber=2(2GHz), channelWidth={20MHz}, active], + 173 Mon Dec 10 11:52:32.451 [channelNumber=3(2GHz), channelWidth={20MHz}, active], + 174 Mon Dec 10 11:52:32.451 [channelNumber=4(2GHz), channelWidth={20MHz}, active], + 175 Mon Dec 10 11:52:32.451 [channelNumber=5(2GHz), channelWidth={20MHz}, active], + 176 Mon Dec 10 11:52:32.451 [channelNumber=6(2GHz), channelWidth={20MHz}, active] + 177 Mon Dec 10 11:52:32.451 )} took 0.2566 seconds, returned 10 results + 178 Mon Dec 10 11:52:32.451 Info: scan cache updated + 179 Mon Dec 10 11:52:32.712 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 180 Mon Dec 10 11:52:32.715 Info: QUERY SCAN CACHE request received from pid 92 (locationd) @@ -103,96 +103,96 @@ {last_modified_time} test.log Page 3 - 91 Mon Dec 10 11:52:32.715 AutoJoin: Successful cache-assisted scan request for locationd with channels {( - 92 Mon Dec 10 11:52:32.715 [channelNumber=7(2GHz), channelWidth={20MHz}, active], - 93 Mon Dec 10 11:52:32.715 [channelNumber=8(2GHz), channelWidth={20MHz}, active], - 94 Mon Dec 10 11:52:32.715 [channelNumber=9(2GHz), channelWidth={20MHz}, active], - 95 Mon Dec 10 11:52:32.715 [channelNumber=10(2GHz), channelWidth={20MHz}, active], - 96 Mon Dec 10 11:52:32.715 [channelNumber=11(2GHz), channelWidth={20MHz}, active], - 97 Mon Dec 10 11:52:32.715 [channelNumber=12(2GHz), channelWidth={20MHz}, active] - 98 Mon Dec 10 11:52:32.715 )} took 0.2636 seconds, returned 10 results - 99 Mon Dec 10 11:52:32.994 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) - 100 Mon Dec 10 11:52:32.997 Info: QUERY SCAN CACHE request received from pid 92 (locationd) - 101 Mon Dec 10 11:52:32.998 AutoJoin: Successful cache-assisted scan request for locationd with channels {( - 102 Mon Dec 10 11:52:32.998 [channelNumber=13(2GHz), channelWidth={20MHz}, active], - 103 Mon Dec 10 11:52:32.998 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], - 104 Mon Dec 10 11:52:32.998 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active], - 105 Mon Dec 10 11:52:32.998 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], - 106 Mon Dec 10 11:52:32.998 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], - 107 Mon Dec 10 11:52:32.998 [channelNumber=149(5GHz), channelWidth={20MHz}, active] - 108 Mon Dec 10 11:52:32.998 )} took 0.2822 seconds, returned 14 results - 109 Mon Dec 10 11:52:33.405 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) - 110 Mon Dec 10 11:52:33.408 Info: QUERY SCAN CACHE request received from pid 92 (locationd) - 111 Mon Dec 10 11:52:33.409 AutoJoin: Successful cache-assisted scan request for locationd with channels {( - 112 Mon Dec 10 11:52:33.409 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], - 113 Mon Dec 10 11:52:33.409 [channelNumber=157(5GHz), channelWidth={20MHz}, active], - 114 Mon Dec 10 11:52:33.409 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active], - 115 Mon Dec 10 11:52:33.409 [channelNumber=165(5GHz), channelWidth={20MHz}, active], - 116 Mon Dec 10 11:52:33.409 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], - 117 Mon Dec 10 11:52:33.409 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] - 118 Mon Dec 10 11:52:33.409 )} took 0.4099 seconds, returned 11 results - 119 Mon Dec 10 11:52:33.669 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) - 120 Mon Dec 10 11:52:33.672 Info: QUERY SCAN CACHE request received from pid 92 (locationd) - 121 Mon Dec 10 11:52:33.672 AutoJoin: Successful cache-assisted scan request for locationd with channels {( - 122 Mon Dec 10 11:52:33.672 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], - 123 Mon Dec 10 11:52:33.672 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] - 124 Mon Dec 10 11:52:33.672 )} took 0.2625 seconds, returned 8 results - 125 Mon Dec 10 11:52:33.673 Info: scan cache updated - 126 Mon Dec 10 11:52:33.693 Info: SCAN request received from pid 92 (locationd) with priority 2 - 127 Mon Dec 10 11:52:33.693 Scan: locationd requested a live scan less than 10 seconds after previous request (1.4991s) returning cached scan results - 128 Mon Dec 10 11:52:33.728 Info: SCAN request received from pid 92 (locationd) with priority 2 - 129 Mon Dec 10 11:52:33.728 Scan: locationd requested a live scan less than 10 seconds after previous request (1.5339s) returning cached scan results - 130 Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: caps = CPU Net Disk - 131 Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: Being put into maintenance wake mode while fully awake. - 132 Mon Dec 10 11:55:47.610 Info: psCallback: powerSource = AC Power - 133 Mon Dec 10 11:55:47.610 Info: psCallback: set powersave disabled on en0 - 134 Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) - 135 Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) - 136 Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 - 137 Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 - 138 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds - 139 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds - 140 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests - 141 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests - 142 Mon Dec 10 11:55:48.093 IPC: ADDED XPC CLIENT CONNECTION [loginwindow (pid=101, euid=1651299376, egid=604256670)] - 143 Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) - 144 Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) - 145 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) - 146 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) - 147 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) - 148 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) - 149 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) - 150 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) - 151 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) - 152 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) - 153 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) - 154 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) - 155 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) - 156 Mon Dec 10 11:55:48.105 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) - 157 Mon Dec 10 11:56:07.629 Driver Discovery: _PMConnectionHandler: caps = - 158 Mon Dec 10 11:56:07.629 AutoJoin: BEST CONNECTED SCAN CANCELLED on interface en0 - 159 Mon Dec 10 11:56:07.629 AutoJoin: BACKGROUND SCAN CANCELLED on interface en0 - 160 Mon Dec 10 11:56:07.629 AutoJoin: Auto-join retry cancelled on interface en0 - 161 Mon Dec 10 11:56:07.629 Offload: _tcpKeepAliveActive: TCP keep-alive is active. - 162 Mon Dec 10 11:56:07.637 P2P: _changeInterfaceFlags: Marking p2p0 down - 163 Mon Dec 10 11:56:07.637 Info: SleepAcknowledgementCheckForHostAP: Checking sleep readiness for HostAP - 164 Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Checking sleep readiness - 165 Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Delaying sleep acknowledgement because of VifUp - 166 Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: KEV_DL_SIFFLAGS received for p2p0 [flags=0xffff8802 (down)]. - 167 Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: Flags changed for p2p0 (0xffff8843 -> 0xffff8802) (down). - 168 Mon Dec 10 11:56:07.638 P2P: _deviceInterfaceMarkedDown: p2p0 marked down - 169 Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Stop GO' action (param = 0x0) - 170 Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Scan' action (param = 0x0) - 171 Mon Dec 10 11:56:07.638 P2P: _p2pSupervisorEventRunLoopCallback: Mark down complete for p2p0 - 172 Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness - 173 Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementCheck: Checking if auto-join is in progress before sleep acknowledgement - 174 Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementDelayForAutoJoinAttempt_block_invoke: AUTO-JOIN attempt complete for en0, re-checking sleep readiness - 175 Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness - 176 Mon Dec 10 11:56:07.639 WoW: _wowEnabled: WoW is active on en0 - 177 Mon Dec 10 11:56:07.639 WoW: wowExchangeRequiredForNode: WoW exchange not required for en0 - 178 Mon Dec 10 11:56:07.639 _acknowledgeSleepEvent: Acknowledging sleep event - 179 Mon Dec 10 11:56:07.639 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=(null), priority=7] - 180 Mon Dec 10 11:56:07.640 AutoJoin: Auto-join retry cancelled on interface en0 + 181 Mon Dec 10 11:52:32.715 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 182 Mon Dec 10 11:52:32.715 [channelNumber=7(2GHz), channelWidth={20MHz}, active], + 183 Mon Dec 10 11:52:32.715 [channelNumber=8(2GHz), channelWidth={20MHz}, active], + 184 Mon Dec 10 11:52:32.715 [channelNumber=9(2GHz), channelWidth={20MHz}, active], + 185 Mon Dec 10 11:52:32.715 [channelNumber=10(2GHz), channelWidth={20MHz}, active], + 186 Mon Dec 10 11:52:32.715 [channelNumber=11(2GHz), channelWidth={20MHz}, active], + 187 Mon Dec 10 11:52:32.715 [channelNumber=12(2GHz), channelWidth={20MHz}, active] + 188 Mon Dec 10 11:52:32.715 )} took 0.2636 seconds, returned 10 results + 189 Mon Dec 10 11:52:32.994 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 190 Mon Dec 10 11:52:32.997 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 191 Mon Dec 10 11:52:32.998 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 192 Mon Dec 10 11:52:32.998 [channelNumber=13(2GHz), channelWidth={20MHz}, active], + 193 Mon Dec 10 11:52:32.998 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], + 194 Mon Dec 10 11:52:32.998 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active], + 195 Mon Dec 10 11:52:32.998 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], + 196 Mon Dec 10 11:52:32.998 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], + 197 Mon Dec 10 11:52:32.998 [channelNumber=149(5GHz), channelWidth={20MHz}, active] + 198 Mon Dec 10 11:52:32.998 )} took 0.2822 seconds, returned 14 results + 199 Mon Dec 10 11:52:33.405 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 200 Mon Dec 10 11:52:33.408 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 201 Mon Dec 10 11:52:33.409 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 202 Mon Dec 10 11:52:33.409 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], + 203 Mon Dec 10 11:52:33.409 [channelNumber=157(5GHz), channelWidth={20MHz}, active], + 204 Mon Dec 10 11:52:33.409 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active], + 205 Mon Dec 10 11:52:33.409 [channelNumber=165(5GHz), channelWidth={20MHz}, active], + 206 Mon Dec 10 11:52:33.409 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], + 207 Mon Dec 10 11:52:33.409 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] + 208 Mon Dec 10 11:52:33.409 )} took 0.4099 seconds, returned 11 results + 209 Mon Dec 10 11:52:33.669 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 210 Mon Dec 10 11:52:33.672 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 211 Mon Dec 10 11:52:33.672 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 212 Mon Dec 10 11:52:33.672 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], + 213 Mon Dec 10 11:52:33.672 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] + 214 Mon Dec 10 11:52:33.672 )} took 0.2625 seconds, returned 8 results + 215 Mon Dec 10 11:52:33.673 Info: scan cache updated + 216 Mon Dec 10 11:52:33.693 Info: SCAN request received from pid 92 (locationd) with priority 2 + 217 Mon Dec 10 11:52:33.693 Scan: locationd requested a live scan less than 10 seconds after previous request (1.4991s) returning cached scan results + 218 Mon Dec 10 11:52:33.728 Info: SCAN request received from pid 92 (locationd) with priority 2 + 219 Mon Dec 10 11:52:33.728 Scan: locationd requested a live scan less than 10 seconds after previous request (1.5339s) returning cached scan results + 220 Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: caps = CPU Net Disk + 221 Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: Being put into maintenance wake mode while fully awake. + 222 Mon Dec 10 11:55:47.610 Info: psCallback: powerSource = AC Power + 223 Mon Dec 10 11:55:47.610 Info: psCallback: set powersave disabled on en0 + 224 Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) + 225 Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) + 226 Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 + 227 Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 + 228 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds + 229 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds + 230 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests + 231 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests + 232 Mon Dec 10 11:55:48.093 IPC: ADDED XPC CLIENT CONNECTION [loginwindow (pid=101, euid=1651299376, egid=604256670)] + 233 Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 234 Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 235 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 236 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 237 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 238 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 239 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 240 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 241 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 242 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 243 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 244 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 245 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 246 Mon Dec 10 11:55:48.105 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 247 Mon Dec 10 11:56:07.629 Driver Discovery: _PMConnectionHandler: caps = + 248 Mon Dec 10 11:56:07.629 AutoJoin: BEST CONNECTED SCAN CANCELLED on interface en0 + 249 Mon Dec 10 11:56:07.629 AutoJoin: BACKGROUND SCAN CANCELLED on interface en0 + 250 Mon Dec 10 11:56:07.629 AutoJoin: Auto-join retry cancelled on interface en0 + 251 Mon Dec 10 11:56:07.629 Offload: _tcpKeepAliveActive: TCP keep-alive is active. + 252 Mon Dec 10 11:56:07.637 P2P: _changeInterfaceFlags: Marking p2p0 down + 253 Mon Dec 10 11:56:07.637 Info: SleepAcknowledgementCheckForHostAP: Checking sleep readiness for HostAP + 254 Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Checking sleep readiness + 255 Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Delaying sleep acknowledgement because of VifUp + 256 Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: KEV_DL_SIFFLAGS received for p2p0 [flags=0xffff8802 (down)]. + 257 Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: Flags changed for p2p0 (0xffff8843 -> 0xffff8802) (down). + 258 Mon Dec 10 11:56:07.638 P2P: _deviceInterfaceMarkedDown: p2p0 marked down + 259 Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Stop GO' action (param = 0x0) + 260 Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Scan' action (param = 0x0) + 261 Mon Dec 10 11:56:07.638 P2P: _p2pSupervisorEventRunLoopCallback: Mark down complete for p2p0 + 262 Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness + 263 Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementCheck: Checking if auto-join is in progress before sleep acknowledgement + 264 Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementDelayForAutoJoinAttempt_block_invoke: AUTO-JOIN attempt complete for en0, re-checking sleep readiness + 265 Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness + 266 Mon Dec 10 11:56:07.639 WoW: _wowEnabled: WoW is active on en0 + 267 Mon Dec 10 11:56:07.639 WoW: wowExchangeRequiredForNode: WoW exchange not required for en0 + 268 Mon Dec 10 11:56:07.639 _acknowledgeSleepEvent: Acknowledging sleep event + 269 Mon Dec 10 11:56:07.639 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=(null), priority=7] + 270 Mon Dec 10 11:56:07.640 AutoJoin: Auto-join retry cancelled on interface en0 diff --git a/tests/fixtures/pr/test_page_length1.log.expected b/tests/fixtures/pr/test_page_length1.log.expected index 09d8e3ce6..a09a2a986 100644 --- a/tests/fixtures/pr/test_page_length1.log.expected +++ b/tests/fixtures/pr/test_page_length1.log.expected @@ -1,10 +1,12 @@ - 1 Mon Dec 10 11:42:56.854 Info: 802.1X changed - 2 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 3 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 4 Mon Dec 10 11:42:57.002 Info: 802.1X changed - 5 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 6 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 7 Mon Dec 10 11:42:57.152 Info: 802.1X changed - 8 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 9 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 10 Mon Dec 10 11:42:57.302 Info: 802.1X changed + 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 8 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 9 Mon Dec 10 11:42:57.002 Info: 802.1X changed + 10 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + + 11 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 12 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 13 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 14 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 15 Mon Dec 10 11:42:57.302 Info: 802.1X changed + From f497fb9d8896a9fc659e99cd7c7b783249fdebee Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sat, 22 Dec 2018 12:30:10 +0530 Subject: [PATCH 029/126] pr: read from stdin --- src/pr/pr.rs | 8 +- tests/fixtures/pr/stdin.log | 82 +++++++++++++++++ tests/fixtures/pr/stdin.log.expected | 132 +++++++++++++++++++++++++++ tests/test_pr.rs | 18 ++++ 4 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/pr/stdin.log create mode 100644 tests/fixtures/pr/stdin.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 0f1fffcd8..87ef46120 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -330,7 +330,7 @@ pub fn uumain(args: Vec) -> i32 { } fn is_a_file(could_be_file: &String) -> bool { - File::open(could_be_file).is_ok() + could_be_file == FILE_STDIN || File::open(could_be_file).is_ok() } fn print_error(matches: &Matches, err: PrError) { @@ -375,7 +375,11 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { } fn build_options(matches: &Matches, path: &String) -> Result { - let header: String = matches.opt_str(STRING_HEADER_OPTION).unwrap_or(path.to_string()); + let header: String = matches.opt_str(STRING_HEADER_OPTION).unwrap_or(if path == FILE_STDIN { + "".to_string() + } else { + path.to_string() + }); let default_first_number = NumberingMode::default().first_number; let first_number = matches.opt_str(FIRST_LINE_NUMBER_OPTION).map(|n| { diff --git a/tests/fixtures/pr/stdin.log b/tests/fixtures/pr/stdin.log new file mode 100644 index 000000000..72c7f4604 --- /dev/null +++ b/tests/fixtures/pr/stdin.log @@ -0,0 +1,82 @@ +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed +Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_END (en0) +Mon Dec 10 11:42:59.372 Info: Roaming ended on interface en0 +Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: RSN_HANDSHAKE_DONE (en0) +Mon Dec 10 11:42:59.373 Info: -[CWXPCInterfaceContext setRoamInProgress:reason:]_block_invoke: roam status metric data: CWAWDMetricRoamStatus: status:0 security: 4 profile:5 origin:<34fcb9>(-69) target:<6cf37f>(-56) latency:6.083439s +Mon Dec 10 11:42:59.373 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90046 +Mon Dec 10 11:42:59.373 Info: RESUME AWDL for interface en0, reason=Roam token=2685 +Mon Dec 10 11:42:59.373 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=5] +Mon Dec 10 11:42:59.374 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 0 +Mon Dec 10 11:43:01.072 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP' +Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP +Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: DHCP airport_changed = 1 +Mon Dec 10 11:43:01.073 Info: -[CWXPCSubsystem internal_submitIPConfigLatencyMetric:leaseDuration:]: IPConfig Latency metric data: CWAWDMetricIPConfigLatencyData: DHCP latency: 29010 msecs, duration: 480 mins, security: 4 +Mon Dec 10 11:43:01.073 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90007 +Mon Dec 10 11:43:01.073 SC: _setDHCPMessage: dhcpInfoKey "State:/Network/Interface/en0/AirPort/DHCP Message" = (null) +Mon Dec 10 11:43:10.369 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:10.369 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=162 Mbps +Mon Dec 10 11:43:10.369 Info: link quality changed +Mon Dec 10 11:43:23.376 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:23.377 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps +Mon Dec 10 11:43:23.377 Info: link quality changed +Mon Dec 10 11:43:28.380 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:28.380 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 11:43:28.380 Info: link quality changed +Mon Dec 10 11:43:31.744 AutoJoin: BACKGROUND SCAN request on interface en0 with SSID list (null) diff --git a/tests/fixtures/pr/stdin.log.expected b/tests/fixtures/pr/stdin.log.expected new file mode 100644 index 000000000..6922ee594 --- /dev/null +++ b/tests/fixtures/pr/stdin.log.expected @@ -0,0 +1,132 @@ + + +{last_modified_time} Page 1 + + + 1 ntation processAirPortStateChanges]: pppConnectionState 0 + 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 8 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 9 Mon Dec 10 11:42:57.002 Info: 802.1X changed + 10 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 11 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 12 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 13 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 14 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 15 Mon Dec 10 11:42:57.302 Info: 802.1X changed + 16 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 17 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 18 Mon Dec 10 11:42:57.449 Info: 802.1X changed + 19 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 20 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 21 Mon Dec 10 11:42:57.600 Info: 802.1X changed + 22 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 23 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 24 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 25 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 26 Mon Dec 10 11:42:57.749 Info: 802.1X changed + 27 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 28 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 29 Mon Dec 10 11:42:57.896 Info: 802.1X changed + 30 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 31 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 32 Mon Dec 10 11:42:58.045 Info: 802.1X changed + 33 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 34 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 35 Mon Dec 10 11:42:58.193 Info: 802.1X changed + 36 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 37 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 38 Mon Dec 10 11:42:58.342 Info: 802.1X changed + 39 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 40 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 41 Mon Dec 10 11:42:58.491 Info: 802.1X changed + 42 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 43 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 44 Mon Dec 10 11:42:58.640 Info: 802.1X changed + 45 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 46 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 47 Mon Dec 10 11:42:58.805 Info: 802.1X changed + 48 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 49 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 50 Mon Dec 10 11:42:58.958 Info: 802.1X changed + 51 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 52 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 53 Mon Dec 10 11:42:59.155 Info: 802.1X changed + 54 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 55 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 56 Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + +{last_modified_time} Page 2 + + + 57 Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 58 Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 59 Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_END (en0) + 60 Mon Dec 10 11:42:59.372 Info: Roaming ended on interface en0 + 61 Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: RSN_HANDSHAKE_DONE (en0) + 62 Mon Dec 10 11:42:59.373 Info: -[CWXPCInterfaceContext setRoamInProgress:reason:]_block_invoke: roam status metric data: CWAWDMetricRoamStatus: status:0 security: 4 profile:5 origin:<34fcb9>(-69) target:<6cf37f>(-56) latency:6.083439s + 63 Mon Dec 10 11:42:59.373 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90046 + 64 Mon Dec 10 11:42:59.373 Info: RESUME AWDL for interface en0, reason=Roam token=2685 + 65 Mon Dec 10 11:42:59.373 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=5] + 66 Mon Dec 10 11:42:59.374 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 0 + 67 Mon Dec 10 11:43:01.072 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP' + 68 Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP + 69 Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: DHCP airport_changed = 1 + 70 Mon Dec 10 11:43:01.073 Info: -[CWXPCSubsystem internal_submitIPConfigLatencyMetric:leaseDuration:]: IPConfig Latency metric data: CWAWDMetricIPConfigLatencyData: DHCP latency: 29010 msecs, duration: 480 mins, security: 4 + 71 Mon Dec 10 11:43:01.073 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90007 + 72 Mon Dec 10 11:43:01.073 SC: _setDHCPMessage: dhcpInfoKey "State:/Network/Interface/en0/AirPort/DHCP Message" = (null) + 73 Mon Dec 10 11:43:10.369 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 74 Mon Dec 10 11:43:10.369 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=162 Mbps + 75 Mon Dec 10 11:43:10.369 Info: link quality changed + 76 Mon Dec 10 11:43:23.376 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 77 Mon Dec 10 11:43:23.377 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps + 78 Mon Dec 10 11:43:23.377 Info: link quality changed + 79 Mon Dec 10 11:43:28.380 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 80 Mon Dec 10 11:43:28.380 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps + 81 Mon Dec 10 11:43:28.380 Info: link quality changed + 82 Mon Dec 10 11:43:31.744 AutoJoin: BACKGROUND SCAN request on interface en0 with SSID list (null) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 6063e569b..1594a98d0 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -16,6 +16,10 @@ fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { }).unwrap_or(String::new()); } +fn now_time() -> String { + Local::now().format("%b %d %H:%M %Y").to_string() +} + #[test] fn test_without_any_options() { @@ -275,3 +279,17 @@ fn test_with_suppress_error_option() { .stderr_is("") .stdout_is(""); } + +#[test] +fn test_with_stdin() { + let test_file_path = "stdin.log"; + let expected_file_path = "stdin.log.expected"; + let mut scenario = new_ucmd!(); + scenario + .pipe_in_fixture("stdin.log") + .args(&["--pages=1:2", "-n", "-"]) + .run() + .stdout_is_templated_fixture(expected_file_path, vec![ + (&"{last_modified_time}".to_string(), &now_time()), + ]); +} From 69371ce3ceeceacde449b561cd599d0594231d43 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sat, 22 Dec 2018 13:00:16 +0530 Subject: [PATCH 030/126] pr: add tests for --column with across option --- tests/fixtures/pr/column.log | 2000 ++++++++++++++++++ tests/fixtures/pr/column.log.expected | 198 ++ tests/fixtures/pr/column_across.log.expected | 198 ++ tests/test_pr.rs | 31 + 4 files changed, 2427 insertions(+) create mode 100644 tests/fixtures/pr/column.log create mode 100644 tests/fixtures/pr/column.log.expected create mode 100644 tests/fixtures/pr/column_across.log.expected diff --git a/tests/fixtures/pr/column.log b/tests/fixtures/pr/column.log new file mode 100644 index 000000000..7972c09aa --- /dev/null +++ b/tests/fixtures/pr/column.log @@ -0,0 +1,2000 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 +930 +931 +932 +933 +934 +935 +936 +937 +938 +939 +940 +941 +942 +943 +944 +945 +946 +947 +948 +949 +950 +951 +952 +953 +954 +955 +956 +957 +958 +959 +960 +961 +962 +963 +964 +965 +966 +967 +968 +969 +970 +971 +972 +973 +974 +975 +976 +977 +978 +979 +980 +981 +982 +983 +984 +985 +986 +987 +988 +989 +990 +991 +992 +993 +994 +995 +996 +997 +998 +999 +1000 +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +1030 +1031 +1032 +1033 +1034 +1035 +1036 +1037 +1038 +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 +1071 +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +1080 +1081 +1082 +1083 +1084 +1085 +1086 +1087 +1088 +1089 +1090 +1091 +1092 +1093 +1094 +1095 +1096 +1097 +1098 +1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121 +1122 +1123 +1124 +1125 +1126 +1127 +1128 +1129 +1130 +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +1140 +1141 +1142 +1143 +1144 +1145 +1146 +1147 +1148 +1149 +1150 +1151 +1152 +1153 +1154 +1155 +1156 +1157 +1158 +1159 +1160 +1161 +1162 +1163 +1164 +1165 +1166 +1167 +1168 +1169 +1170 +1171 +1172 +1173 +1174 +1175 +1176 +1177 +1178 +1179 +1180 +1181 +1182 +1183 +1184 +1185 +1186 +1187 +1188 +1189 +1190 +1191 +1192 +1193 +1194 +1195 +1196 +1197 +1198 +1199 +1200 +1201 +1202 +1203 +1204 +1205 +1206 +1207 +1208 +1209 +1210 +1211 +1212 +1213 +1214 +1215 +1216 +1217 +1218 +1219 +1220 +1221 +1222 +1223 +1224 +1225 +1226 +1227 +1228 +1229 +1230 +1231 +1232 +1233 +1234 +1235 +1236 +1237 +1238 +1239 +1240 +1241 +1242 +1243 +1244 +1245 +1246 +1247 +1248 +1249 +1250 +1251 +1252 +1253 +1254 +1255 +1256 +1257 +1258 +1259 +1260 +1261 +1262 +1263 +1264 +1265 +1266 +1267 +1268 +1269 +1270 +1271 +1272 +1273 +1274 +1275 +1276 +1277 +1278 +1279 +1280 +1281 +1282 +1283 +1284 +1285 +1286 +1287 +1288 +1289 +1290 +1291 +1292 +1293 +1294 +1295 +1296 +1297 +1298 +1299 +1300 +1301 +1302 +1303 +1304 +1305 +1306 +1307 +1308 +1309 +1310 +1311 +1312 +1313 +1314 +1315 +1316 +1317 +1318 +1319 +1320 +1321 +1322 +1323 +1324 +1325 +1326 +1327 +1328 +1329 +1330 +1331 +1332 +1333 +1334 +1335 +1336 +1337 +1338 +1339 +1340 +1341 +1342 +1343 +1344 +1345 +1346 +1347 +1348 +1349 +1350 +1351 +1352 +1353 +1354 +1355 +1356 +1357 +1358 +1359 +1360 +1361 +1362 +1363 +1364 +1365 +1366 +1367 +1368 +1369 +1370 +1371 +1372 +1373 +1374 +1375 +1376 +1377 +1378 +1379 +1380 +1381 +1382 +1383 +1384 +1385 +1386 +1387 +1388 +1389 +1390 +1391 +1392 +1393 +1394 +1395 +1396 +1397 +1398 +1399 +1400 +1401 +1402 +1403 +1404 +1405 +1406 +1407 +1408 +1409 +1410 +1411 +1412 +1413 +1414 +1415 +1416 +1417 +1418 +1419 +1420 +1421 +1422 +1423 +1424 +1425 +1426 +1427 +1428 +1429 +1430 +1431 +1432 +1433 +1434 +1435 +1436 +1437 +1438 +1439 +1440 +1441 +1442 +1443 +1444 +1445 +1446 +1447 +1448 +1449 +1450 +1451 +1452 +1453 +1454 +1455 +1456 +1457 +1458 +1459 +1460 +1461 +1462 +1463 +1464 +1465 +1466 +1467 +1468 +1469 +1470 +1471 +1472 +1473 +1474 +1475 +1476 +1477 +1478 +1479 +1480 +1481 +1482 +1483 +1484 +1485 +1486 +1487 +1488 +1489 +1490 +1491 +1492 +1493 +1494 +1495 +1496 +1497 +1498 +1499 +1500 +1501 +1502 +1503 +1504 +1505 +1506 +1507 +1508 +1509 +1510 +1511 +1512 +1513 +1514 +1515 +1516 +1517 +1518 +1519 +1520 +1521 +1522 +1523 +1524 +1525 +1526 +1527 +1528 +1529 +1530 +1531 +1532 +1533 +1534 +1535 +1536 +1537 +1538 +1539 +1540 +1541 +1542 +1543 +1544 +1545 +1546 +1547 +1548 +1549 +1550 +1551 +1552 +1553 +1554 +1555 +1556 +1557 +1558 +1559 +1560 +1561 +1562 +1563 +1564 +1565 +1566 +1567 +1568 +1569 +1570 +1571 +1572 +1573 +1574 +1575 +1576 +1577 +1578 +1579 +1580 +1581 +1582 +1583 +1584 +1585 +1586 +1587 +1588 +1589 +1590 +1591 +1592 +1593 +1594 +1595 +1596 +1597 +1598 +1599 +1600 +1601 +1602 +1603 +1604 +1605 +1606 +1607 +1608 +1609 +1610 +1611 +1612 +1613 +1614 +1615 +1616 +1617 +1618 +1619 +1620 +1621 +1622 +1623 +1624 +1625 +1626 +1627 +1628 +1629 +1630 +1631 +1632 +1633 +1634 +1635 +1636 +1637 +1638 +1639 +1640 +1641 +1642 +1643 +1644 +1645 +1646 +1647 +1648 +1649 +1650 +1651 +1652 +1653 +1654 +1655 +1656 +1657 +1658 +1659 +1660 +1661 +1662 +1663 +1664 +1665 +1666 +1667 +1668 +1669 +1670 +1671 +1672 +1673 +1674 +1675 +1676 +1677 +1678 +1679 +1680 +1681 +1682 +1683 +1684 +1685 +1686 +1687 +1688 +1689 +1690 +1691 +1692 +1693 +1694 +1695 +1696 +1697 +1698 +1699 +1700 +1701 +1702 +1703 +1704 +1705 +1706 +1707 +1708 +1709 +1710 +1711 +1712 +1713 +1714 +1715 +1716 +1717 +1718 +1719 +1720 +1721 +1722 +1723 +1724 +1725 +1726 +1727 +1728 +1729 +1730 +1731 +1732 +1733 +1734 +1735 +1736 +1737 +1738 +1739 +1740 +1741 +1742 +1743 +1744 +1745 +1746 +1747 +1748 +1749 +1750 +1751 +1752 +1753 +1754 +1755 +1756 +1757 +1758 +1759 +1760 +1761 +1762 +1763 +1764 +1765 +1766 +1767 +1768 +1769 +1770 +1771 +1772 +1773 +1774 +1775 +1776 +1777 +1778 +1779 +1780 +1781 +1782 +1783 +1784 +1785 +1786 +1787 +1788 +1789 +1790 +1791 +1792 +1793 +1794 +1795 +1796 +1797 +1798 +1799 +1800 +1801 +1802 +1803 +1804 +1805 +1806 +1807 +1808 +1809 +1810 +1811 +1812 +1813 +1814 +1815 +1816 +1817 +1818 +1819 +1820 +1821 +1822 +1823 +1824 +1825 +1826 +1827 +1828 +1829 +1830 +1831 +1832 +1833 +1834 +1835 +1836 +1837 +1838 +1839 +1840 +1841 +1842 +1843 +1844 +1845 +1846 +1847 +1848 +1849 +1850 +1851 +1852 +1853 +1854 +1855 +1856 +1857 +1858 +1859 +1860 +1861 +1862 +1863 +1864 +1865 +1866 +1867 +1868 +1869 +1870 +1871 +1872 +1873 +1874 +1875 +1876 +1877 +1878 +1879 +1880 +1881 +1882 +1883 +1884 +1885 +1886 +1887 +1888 +1889 +1890 +1891 +1892 +1893 +1894 +1895 +1896 +1897 +1898 +1899 +1900 +1901 +1902 +1903 +1904 +1905 +1906 +1907 +1908 +1909 +1910 +1911 +1912 +1913 +1914 +1915 +1916 +1917 +1918 +1919 +1920 +1921 +1922 +1923 +1924 +1925 +1926 +1927 +1928 +1929 +1930 +1931 +1932 +1933 +1934 +1935 +1936 +1937 +1938 +1939 +1940 +1941 +1942 +1943 +1944 +1945 +1946 +1947 +1948 +1949 +1950 +1951 +1952 +1953 +1954 +1955 +1956 +1957 +1958 +1959 +1960 +1961 +1962 +1963 +1964 +1965 +1966 +1967 +1968 +1969 +1970 +1971 +1972 +1973 +1974 +1975 +1976 +1977 +1978 +1979 +1980 +1981 +1982 +1983 +1984 +1985 +1986 +1987 +1988 +1989 +1990 +1991 +1992 +1993 +1994 +1995 +1996 +1997 +1998 +1999 +2000 diff --git a/tests/fixtures/pr/column.log.expected b/tests/fixtures/pr/column.log.expected new file mode 100644 index 000000000..e548d4128 --- /dev/null +++ b/tests/fixtures/pr/column.log.expected @@ -0,0 +1,198 @@ + + +{last_modified_time} column.log Page 3 + + + 337 337 393 393 449 449 + 338 338 394 394 450 450 + 339 339 395 395 451 451 + 340 340 396 396 452 452 + 341 341 397 397 453 453 + 342 342 398 398 454 454 + 343 343 399 399 455 455 + 344 344 400 400 456 456 + 345 345 401 401 457 457 + 346 346 402 402 458 458 + 347 347 403 403 459 459 + 348 348 404 404 460 460 + 349 349 405 405 461 461 + 350 350 406 406 462 462 + 351 351 407 407 463 463 + 352 352 408 408 464 464 + 353 353 409 409 465 465 + 354 354 410 410 466 466 + 355 355 411 411 467 467 + 356 356 412 412 468 468 + 357 357 413 413 469 469 + 358 358 414 414 470 470 + 359 359 415 415 471 471 + 360 360 416 416 472 472 + 361 361 417 417 473 473 + 362 362 418 418 474 474 + 363 363 419 419 475 475 + 364 364 420 420 476 476 + 365 365 421 421 477 477 + 366 366 422 422 478 478 + 367 367 423 423 479 479 + 368 368 424 424 480 480 + 369 369 425 425 481 481 + 370 370 426 426 482 482 + 371 371 427 427 483 483 + 372 372 428 428 484 484 + 373 373 429 429 485 485 + 374 374 430 430 486 486 + 375 375 431 431 487 487 + 376 376 432 432 488 488 + 377 377 433 433 489 489 + 378 378 434 434 490 490 + 379 379 435 435 491 491 + 380 380 436 436 492 492 + 381 381 437 437 493 493 + 382 382 438 438 494 494 + 383 383 439 439 495 495 + 384 384 440 440 496 496 + 385 385 441 441 497 497 + 386 386 442 442 498 498 + 387 387 443 443 499 499 + 388 388 444 444 500 500 + 389 389 445 445 501 501 + 390 390 446 446 502 502 + 391 391 447 447 503 503 + 392 392 448 448 504 504 + + + + + + + +{last_modified_time} column.log Page 4 + + + 505 505 561 561 617 617 + 506 506 562 562 618 618 + 507 507 563 563 619 619 + 508 508 564 564 620 620 + 509 509 565 565 621 621 + 510 510 566 566 622 622 + 511 511 567 567 623 623 + 512 512 568 568 624 624 + 513 513 569 569 625 625 + 514 514 570 570 626 626 + 515 515 571 571 627 627 + 516 516 572 572 628 628 + 517 517 573 573 629 629 + 518 518 574 574 630 630 + 519 519 575 575 631 631 + 520 520 576 576 632 632 + 521 521 577 577 633 633 + 522 522 578 578 634 634 + 523 523 579 579 635 635 + 524 524 580 580 636 636 + 525 525 581 581 637 637 + 526 526 582 582 638 638 + 527 527 583 583 639 639 + 528 528 584 584 640 640 + 529 529 585 585 641 641 + 530 530 586 586 642 642 + 531 531 587 587 643 643 + 532 532 588 588 644 644 + 533 533 589 589 645 645 + 534 534 590 590 646 646 + 535 535 591 591 647 647 + 536 536 592 592 648 648 + 537 537 593 593 649 649 + 538 538 594 594 650 650 + 539 539 595 595 651 651 + 540 540 596 596 652 652 + 541 541 597 597 653 653 + 542 542 598 598 654 654 + 543 543 599 599 655 655 + 544 544 600 600 656 656 + 545 545 601 601 657 657 + 546 546 602 602 658 658 + 547 547 603 603 659 659 + 548 548 604 604 660 660 + 549 549 605 605 661 661 + 550 550 606 606 662 662 + 551 551 607 607 663 663 + 552 552 608 608 664 664 + 553 553 609 609 665 665 + 554 554 610 610 666 666 + 555 555 611 611 667 667 + 556 556 612 612 668 668 + 557 557 613 613 669 669 + 558 558 614 614 670 670 + 559 559 615 615 671 671 + 560 560 616 616 672 672 + + + + + + + +{last_modified_time} column.log Page 5 + + + 673 673 729 729 785 785 + 674 674 730 730 786 786 + 675 675 731 731 787 787 + 676 676 732 732 788 788 + 677 677 733 733 789 789 + 678 678 734 734 790 790 + 679 679 735 735 791 791 + 680 680 736 736 792 792 + 681 681 737 737 793 793 + 682 682 738 738 794 794 + 683 683 739 739 795 795 + 684 684 740 740 796 796 + 685 685 741 741 797 797 + 686 686 742 742 798 798 + 687 687 743 743 799 799 + 688 688 744 744 800 800 + 689 689 745 745 801 801 + 690 690 746 746 802 802 + 691 691 747 747 803 803 + 692 692 748 748 804 804 + 693 693 749 749 805 805 + 694 694 750 750 806 806 + 695 695 751 751 807 807 + 696 696 752 752 808 808 + 697 697 753 753 809 809 + 698 698 754 754 810 810 + 699 699 755 755 811 811 + 700 700 756 756 812 812 + 701 701 757 757 813 813 + 702 702 758 758 814 814 + 703 703 759 759 815 815 + 704 704 760 760 816 816 + 705 705 761 761 817 817 + 706 706 762 762 818 818 + 707 707 763 763 819 819 + 708 708 764 764 820 820 + 709 709 765 765 821 821 + 710 710 766 766 822 822 + 711 711 767 767 823 823 + 712 712 768 768 824 824 + 713 713 769 769 825 825 + 714 714 770 770 826 826 + 715 715 771 771 827 827 + 716 716 772 772 828 828 + 717 717 773 773 829 829 + 718 718 774 774 830 830 + 719 719 775 775 831 831 + 720 720 776 776 832 832 + 721 721 777 777 833 833 + 722 722 778 778 834 834 + 723 723 779 779 835 835 + 724 724 780 780 836 836 + 725 725 781 781 837 837 + 726 726 782 782 838 838 + 727 727 783 783 839 839 + 728 728 784 784 840 840 + + + + + diff --git a/tests/fixtures/pr/column_across.log.expected b/tests/fixtures/pr/column_across.log.expected new file mode 100644 index 000000000..9d5a1dc1c --- /dev/null +++ b/tests/fixtures/pr/column_across.log.expected @@ -0,0 +1,198 @@ + + +{last_modified_time} column.log Page 3 + + + 337 337 338 338 339 339 + 340 340 341 341 342 342 + 343 343 344 344 345 345 + 346 346 347 347 348 348 + 349 349 350 350 351 351 + 352 352 353 353 354 354 + 355 355 356 356 357 357 + 358 358 359 359 360 360 + 361 361 362 362 363 363 + 364 364 365 365 366 366 + 367 367 368 368 369 369 + 370 370 371 371 372 372 + 373 373 374 374 375 375 + 376 376 377 377 378 378 + 379 379 380 380 381 381 + 382 382 383 383 384 384 + 385 385 386 386 387 387 + 388 388 389 389 390 390 + 391 391 392 392 393 393 + 394 394 395 395 396 396 + 397 397 398 398 399 399 + 400 400 401 401 402 402 + 403 403 404 404 405 405 + 406 406 407 407 408 408 + 409 409 410 410 411 411 + 412 412 413 413 414 414 + 415 415 416 416 417 417 + 418 418 419 419 420 420 + 421 421 422 422 423 423 + 424 424 425 425 426 426 + 427 427 428 428 429 429 + 430 430 431 431 432 432 + 433 433 434 434 435 435 + 436 436 437 437 438 438 + 439 439 440 440 441 441 + 442 442 443 443 444 444 + 445 445 446 446 447 447 + 448 448 449 449 450 450 + 451 451 452 452 453 453 + 454 454 455 455 456 456 + 457 457 458 458 459 459 + 460 460 461 461 462 462 + 463 463 464 464 465 465 + 466 466 467 467 468 468 + 469 469 470 470 471 471 + 472 472 473 473 474 474 + 475 475 476 476 477 477 + 478 478 479 479 480 480 + 481 481 482 482 483 483 + 484 484 485 485 486 486 + 487 487 488 488 489 489 + 490 490 491 491 492 492 + 493 493 494 494 495 495 + 496 496 497 497 498 498 + 499 499 500 500 501 501 + 502 502 503 503 504 504 + + + + + + + +{last_modified_time} column.log Page 4 + + + 505 505 506 506 507 507 + 508 508 509 509 510 510 + 511 511 512 512 513 513 + 514 514 515 515 516 516 + 517 517 518 518 519 519 + 520 520 521 521 522 522 + 523 523 524 524 525 525 + 526 526 527 527 528 528 + 529 529 530 530 531 531 + 532 532 533 533 534 534 + 535 535 536 536 537 537 + 538 538 539 539 540 540 + 541 541 542 542 543 543 + 544 544 545 545 546 546 + 547 547 548 548 549 549 + 550 550 551 551 552 552 + 553 553 554 554 555 555 + 556 556 557 557 558 558 + 559 559 560 560 561 561 + 562 562 563 563 564 564 + 565 565 566 566 567 567 + 568 568 569 569 570 570 + 571 571 572 572 573 573 + 574 574 575 575 576 576 + 577 577 578 578 579 579 + 580 580 581 581 582 582 + 583 583 584 584 585 585 + 586 586 587 587 588 588 + 589 589 590 590 591 591 + 592 592 593 593 594 594 + 595 595 596 596 597 597 + 598 598 599 599 600 600 + 601 601 602 602 603 603 + 604 604 605 605 606 606 + 607 607 608 608 609 609 + 610 610 611 611 612 612 + 613 613 614 614 615 615 + 616 616 617 617 618 618 + 619 619 620 620 621 621 + 622 622 623 623 624 624 + 625 625 626 626 627 627 + 628 628 629 629 630 630 + 631 631 632 632 633 633 + 634 634 635 635 636 636 + 637 637 638 638 639 639 + 640 640 641 641 642 642 + 643 643 644 644 645 645 + 646 646 647 647 648 648 + 649 649 650 650 651 651 + 652 652 653 653 654 654 + 655 655 656 656 657 657 + 658 658 659 659 660 660 + 661 661 662 662 663 663 + 664 664 665 665 666 666 + 667 667 668 668 669 669 + 670 670 671 671 672 672 + + + + + + + +{last_modified_time} column.log Page 5 + + + 673 673 674 674 675 675 + 676 676 677 677 678 678 + 679 679 680 680 681 681 + 682 682 683 683 684 684 + 685 685 686 686 687 687 + 688 688 689 689 690 690 + 691 691 692 692 693 693 + 694 694 695 695 696 696 + 697 697 698 698 699 699 + 700 700 701 701 702 702 + 703 703 704 704 705 705 + 706 706 707 707 708 708 + 709 709 710 710 711 711 + 712 712 713 713 714 714 + 715 715 716 716 717 717 + 718 718 719 719 720 720 + 721 721 722 722 723 723 + 724 724 725 725 726 726 + 727 727 728 728 729 729 + 730 730 731 731 732 732 + 733 733 734 734 735 735 + 736 736 737 737 738 738 + 739 739 740 740 741 741 + 742 742 743 743 744 744 + 745 745 746 746 747 747 + 748 748 749 749 750 750 + 751 751 752 752 753 753 + 754 754 755 755 756 756 + 757 757 758 758 759 759 + 760 760 761 761 762 762 + 763 763 764 764 765 765 + 766 766 767 767 768 768 + 769 769 770 770 771 771 + 772 772 773 773 774 774 + 775 775 776 776 777 777 + 778 778 779 779 780 780 + 781 781 782 782 783 783 + 784 784 785 785 786 786 + 787 787 788 788 789 789 + 790 790 791 791 792 792 + 793 793 794 794 795 795 + 796 796 797 797 798 798 + 799 799 800 800 801 801 + 802 802 803 803 804 804 + 805 805 806 806 807 807 + 808 808 809 809 810 810 + 811 811 812 812 813 813 + 814 814 815 815 816 816 + 817 817 818 818 819 819 + 820 820 821 821 822 822 + 823 823 824 824 825 825 + 826 826 827 827 828 828 + 829 829 830 830 831 831 + 832 832 833 833 834 834 + 835 835 836 836 837 837 + 838 838 839 839 840 840 + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 1594a98d0..efe69c29a 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -293,3 +293,34 @@ fn test_with_stdin() { (&"{last_modified_time}".to_string(), &now_time()), ]); } + +#[test] +fn test_with_column() { + let test_file_path = "column.log"; + let expected_test_file_path = "column.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["--pages=3:5", "--column=3", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + (&"{last_modified_time}".to_string(), &value), + ]); + +} + +#[test] +fn test_with_column_across_option() { + let test_file_path = "column.log"; + let expected_test_file_path = "column_across.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["--pages=3:5", "--column=3", "-a", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + (&"{last_modified_time}".to_string(), &value), + ]); + +} + From dd07aed4d173044b57498801e834577898253d31 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sat, 22 Dec 2018 14:15:50 +0530 Subject: [PATCH 031/126] pr: add column separator option --- src/pr/pr.rs | 17 +- .../pr/column_across_sep.log.expected | 198 ++++++++++++++++++ tests/test_pr.rs | 15 ++ 3 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/pr/column_across_sep.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 87ef46120..0fe3be3a7 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -50,6 +50,7 @@ static FORM_FEED_OPTION: &str = "F"; static COLUMN_WIDTH_OPTION: &str = "w"; static ACROSS_OPTION: &str = "a"; static COLUMN_OPTION: &str = "column"; +static COLUMN_SEPARATOR_OPTION: &str = "s"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; @@ -272,6 +273,16 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + COLUMN_SEPARATOR_OPTION, + "", + "Separate text columns by the single character char instead of by the appropriate number of s + (default for char is the character).", + "char", + HasArg::Yes, + Occur::Optional, + ); + opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); @@ -497,6 +508,10 @@ fn build_options(matches: &Matches, path: &String) -> Result() }) { @@ -507,7 +522,7 @@ fn build_options(matches: &Matches, path: &String) -> Result Some(x), None => Some(DEFAULT_COLUMN_WIDTH) }, - column_separator: DEFAULT_COLUMN_SEPARATOR.to_string(), + column_separator, across_mode, }) } diff --git a/tests/fixtures/pr/column_across_sep.log.expected b/tests/fixtures/pr/column_across_sep.log.expected new file mode 100644 index 000000000..65c3e71c8 --- /dev/null +++ b/tests/fixtures/pr/column_across_sep.log.expected @@ -0,0 +1,198 @@ + + +{last_modified_time} column.log Page 3 + + + 337 337 | 338 338 | 339 339 + 340 340 | 341 341 | 342 342 + 343 343 | 344 344 | 345 345 + 346 346 | 347 347 | 348 348 + 349 349 | 350 350 | 351 351 + 352 352 | 353 353 | 354 354 + 355 355 | 356 356 | 357 357 + 358 358 | 359 359 | 360 360 + 361 361 | 362 362 | 363 363 + 364 364 | 365 365 | 366 366 + 367 367 | 368 368 | 369 369 + 370 370 | 371 371 | 372 372 + 373 373 | 374 374 | 375 375 + 376 376 | 377 377 | 378 378 + 379 379 | 380 380 | 381 381 + 382 382 | 383 383 | 384 384 + 385 385 | 386 386 | 387 387 + 388 388 | 389 389 | 390 390 + 391 391 | 392 392 | 393 393 + 394 394 | 395 395 | 396 396 + 397 397 | 398 398 | 399 399 + 400 400 | 401 401 | 402 402 + 403 403 | 404 404 | 405 405 + 406 406 | 407 407 | 408 408 + 409 409 | 410 410 | 411 411 + 412 412 | 413 413 | 414 414 + 415 415 | 416 416 | 417 417 + 418 418 | 419 419 | 420 420 + 421 421 | 422 422 | 423 423 + 424 424 | 425 425 | 426 426 + 427 427 | 428 428 | 429 429 + 430 430 | 431 431 | 432 432 + 433 433 | 434 434 | 435 435 + 436 436 | 437 437 | 438 438 + 439 439 | 440 440 | 441 441 + 442 442 | 443 443 | 444 444 + 445 445 | 446 446 | 447 447 + 448 448 | 449 449 | 450 450 + 451 451 | 452 452 | 453 453 + 454 454 | 455 455 | 456 456 + 457 457 | 458 458 | 459 459 + 460 460 | 461 461 | 462 462 + 463 463 | 464 464 | 465 465 + 466 466 | 467 467 | 468 468 + 469 469 | 470 470 | 471 471 + 472 472 | 473 473 | 474 474 + 475 475 | 476 476 | 477 477 + 478 478 | 479 479 | 480 480 + 481 481 | 482 482 | 483 483 + 484 484 | 485 485 | 486 486 + 487 487 | 488 488 | 489 489 + 490 490 | 491 491 | 492 492 + 493 493 | 494 494 | 495 495 + 496 496 | 497 497 | 498 498 + 499 499 | 500 500 | 501 501 + 502 502 | 503 503 | 504 504 + + + + + + + +{last_modified_time} column.log Page 4 + + + 505 505 | 506 506 | 507 507 + 508 508 | 509 509 | 510 510 + 511 511 | 512 512 | 513 513 + 514 514 | 515 515 | 516 516 + 517 517 | 518 518 | 519 519 + 520 520 | 521 521 | 522 522 + 523 523 | 524 524 | 525 525 + 526 526 | 527 527 | 528 528 + 529 529 | 530 530 | 531 531 + 532 532 | 533 533 | 534 534 + 535 535 | 536 536 | 537 537 + 538 538 | 539 539 | 540 540 + 541 541 | 542 542 | 543 543 + 544 544 | 545 545 | 546 546 + 547 547 | 548 548 | 549 549 + 550 550 | 551 551 | 552 552 + 553 553 | 554 554 | 555 555 + 556 556 | 557 557 | 558 558 + 559 559 | 560 560 | 561 561 + 562 562 | 563 563 | 564 564 + 565 565 | 566 566 | 567 567 + 568 568 | 569 569 | 570 570 + 571 571 | 572 572 | 573 573 + 574 574 | 575 575 | 576 576 + 577 577 | 578 578 | 579 579 + 580 580 | 581 581 | 582 582 + 583 583 | 584 584 | 585 585 + 586 586 | 587 587 | 588 588 + 589 589 | 590 590 | 591 591 + 592 592 | 593 593 | 594 594 + 595 595 | 596 596 | 597 597 + 598 598 | 599 599 | 600 600 + 601 601 | 602 602 | 603 603 + 604 604 | 605 605 | 606 606 + 607 607 | 608 608 | 609 609 + 610 610 | 611 611 | 612 612 + 613 613 | 614 614 | 615 615 + 616 616 | 617 617 | 618 618 + 619 619 | 620 620 | 621 621 + 622 622 | 623 623 | 624 624 + 625 625 | 626 626 | 627 627 + 628 628 | 629 629 | 630 630 + 631 631 | 632 632 | 633 633 + 634 634 | 635 635 | 636 636 + 637 637 | 638 638 | 639 639 + 640 640 | 641 641 | 642 642 + 643 643 | 644 644 | 645 645 + 646 646 | 647 647 | 648 648 + 649 649 | 650 650 | 651 651 + 652 652 | 653 653 | 654 654 + 655 655 | 656 656 | 657 657 + 658 658 | 659 659 | 660 660 + 661 661 | 662 662 | 663 663 + 664 664 | 665 665 | 666 666 + 667 667 | 668 668 | 669 669 + 670 670 | 671 671 | 672 672 + + + + + + + +{last_modified_time} column.log Page 5 + + + 673 673 | 674 674 | 675 675 + 676 676 | 677 677 | 678 678 + 679 679 | 680 680 | 681 681 + 682 682 | 683 683 | 684 684 + 685 685 | 686 686 | 687 687 + 688 688 | 689 689 | 690 690 + 691 691 | 692 692 | 693 693 + 694 694 | 695 695 | 696 696 + 697 697 | 698 698 | 699 699 + 700 700 | 701 701 | 702 702 + 703 703 | 704 704 | 705 705 + 706 706 | 707 707 | 708 708 + 709 709 | 710 710 | 711 711 + 712 712 | 713 713 | 714 714 + 715 715 | 716 716 | 717 717 + 718 718 | 719 719 | 720 720 + 721 721 | 722 722 | 723 723 + 724 724 | 725 725 | 726 726 + 727 727 | 728 728 | 729 729 + 730 730 | 731 731 | 732 732 + 733 733 | 734 734 | 735 735 + 736 736 | 737 737 | 738 738 + 739 739 | 740 740 | 741 741 + 742 742 | 743 743 | 744 744 + 745 745 | 746 746 | 747 747 + 748 748 | 749 749 | 750 750 + 751 751 | 752 752 | 753 753 + 754 754 | 755 755 | 756 756 + 757 757 | 758 758 | 759 759 + 760 760 | 761 761 | 762 762 + 763 763 | 764 764 | 765 765 + 766 766 | 767 767 | 768 768 + 769 769 | 770 770 | 771 771 + 772 772 | 773 773 | 774 774 + 775 775 | 776 776 | 777 777 + 778 778 | 779 779 | 780 780 + 781 781 | 782 782 | 783 783 + 784 784 | 785 785 | 786 786 + 787 787 | 788 788 | 789 789 + 790 790 | 791 791 | 792 792 + 793 793 | 794 794 | 795 795 + 796 796 | 797 797 | 798 798 + 799 799 | 800 800 | 801 801 + 802 802 | 803 803 | 804 804 + 805 805 | 806 806 | 807 807 + 808 808 | 809 809 | 810 810 + 811 811 | 812 812 | 813 813 + 814 814 | 815 815 | 816 816 + 817 817 | 818 818 | 819 819 + 820 820 | 821 821 | 822 822 + 823 823 | 824 824 | 825 825 + 826 826 | 827 827 | 828 828 + 829 829 | 830 830 | 831 831 + 832 832 | 833 833 | 834 834 + 835 835 | 836 836 | 837 837 + 838 838 | 839 839 | 840 840 + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index efe69c29a..6faa48348 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -324,3 +324,18 @@ fn test_with_column_across_option() { } +#[test] +fn test_with_column_across_option_and_column_separator() { + let test_file_path = "column.log"; + let expected_test_file_path = "column_across_sep.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["--pages=3:5", "--column=3", "-s|", "-a", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + (&"{last_modified_time}".to_string(), &value), + ]); + +} + From 5956894d00477a599868f16ca867dfbae6d45cee Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Mon, 24 Dec 2018 11:59:12 +0530 Subject: [PATCH 032/126] pr: add -m and -o option pr: Add -o option --- src/pr/pr.rs | 443 ++++++++++++++---- .../pr/column_spaces_across.log.expected | 198 ++++++++ tests/fixtures/pr/hosts.log | 11 + tests/fixtures/pr/mpr.log.expected | 132 ++++++ tests/fixtures/pr/mpr1.log.expected | 198 ++++++++ tests/fixtures/pr/mpr2.log.expected | 200 ++++++++ tests/test_pr.rs | 63 ++- 7 files changed, 1151 insertions(+), 94 deletions(-) create mode 100644 tests/fixtures/pr/column_spaces_across.log.expected create mode 100644 tests/fixtures/pr/hosts.log create mode 100644 tests/fixtures/pr/mpr.log.expected create mode 100644 tests/fixtures/pr/mpr1.log.expected create mode 100644 tests/fixtures/pr/mpr2.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 0fe3be3a7..06c991c29 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -15,12 +15,12 @@ extern crate chrono; extern crate getopts; extern crate uucore; -use std::io::{BufRead, BufReader, stdin, stdout, stderr, Error, Read, Write, Stdout, Lines}; +use std::io::{BufRead, BufReader, stdin, stdout, stderr, Error, Read, Write, Stdout, Lines, Stdin}; use std::vec::Vec; use chrono::offset::Local; use chrono::DateTime; use getopts::{Matches, Options}; -use std::fs::{metadata, File}; +use std::fs::{metadata, File, Metadata}; #[cfg(unix)] use std::os::unix::fs::FileTypeExt; use quick_error::ResultExt; @@ -29,6 +29,7 @@ use getopts::{HasArg, Occur}; use std::num::ParseIntError; use itertools::{Itertools, GroupBy}; use std::iter::{Enumerate, Map, TakeWhile, SkipWhile}; +use itertools::structs::KMergeBy; static NAME: &str = "pr"; static VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -51,6 +52,8 @@ static COLUMN_WIDTH_OPTION: &str = "w"; static ACROSS_OPTION: &str = "a"; static COLUMN_OPTION: &str = "column"; static COLUMN_SEPARATOR_OPTION: &str = "s"; +static MERGE_FILES_PRINT: &str = "m"; +static OFFSET_SPACES_OPTION: &str = "o"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; @@ -71,6 +74,22 @@ struct OutputOptions { content_lines_per_page: usize, page_separator_char: String, column_mode_options: Option, + merge_files_print: Option, + offset_spaces: usize +} + +struct FileLine { + file_id: usize, + line_number: usize, + page_number: usize, + key: usize, + line_content: Result, +} + +impl AsRef for FileLine { + fn as_ref(&self) -> &FileLine { + self + } } struct ColumnModeOptions { @@ -283,6 +302,27 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + MERGE_FILES_PRINT, + "merge", + "Merge files. Standard output shall be formatted so the pr utility writes one line from each file specified by a + file operand, side by side into text columns of equal fixed widths, in terms of the number of column positions. + Implementations shall support merging of at least nine file operands.", + "", + HasArg::No, + Occur::Optional, + ); + + opts.opt( + OFFSET_SPACES_OPTION, + "indent", + "Each line of output shall be preceded by offset s. If the -o option is not specified, the default offset + shall be zero. The space taken is in addition to the output line width (see the -w option below).", + "offset", + HasArg::Yes, + Occur::Optional, + ); + opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); @@ -297,21 +337,20 @@ pub fn uumain(args: Vec) -> i32 { } let mut files: Vec = matches.free.clone(); - if files.is_empty() { - // -n value is optional if -n is given the opts gets confused - if matches.opt_present(NUMBERING_MODE_OPTION) { - let maybe_file = matches.opt_str(NUMBERING_MODE_OPTION).unwrap(); - let is_afile = is_a_file(&maybe_file); - if !is_afile { - print_error(&matches, PrError::NotExists(maybe_file)); - return 1; - } else { - files.push(maybe_file); - } - } else { - //For stdin - files.push(FILE_STDIN.to_owned()); + // -n value is optional if -n is given the opts gets confused + // if -n is used just before file path it might be captured as value of -n + if matches.opt_str(NUMBERING_MODE_OPTION).is_some() { + let maybe_a_file_path: String = matches.opt_str(NUMBERING_MODE_OPTION).unwrap(); + let is_file: bool = is_a_file(&maybe_a_file_path); + if !is_file && files.is_empty() { + print_error(&matches, PrError::NotExists(maybe_a_file_path)); + return 1; + } else if is_file { + files.insert(0, maybe_a_file_path); } + } else if files.is_empty() { + //For stdin + files.insert(0, FILE_STDIN.to_owned()); } @@ -319,14 +358,25 @@ pub fn uumain(args: Vec) -> i32 { return print_usage(&mut opts, &matches); } - for f in files { - let result_options = build_options(&matches, &f); + let file_groups: Vec> = if matches.opt_present(MERGE_FILES_PRINT) { + vec![files] + } else { + files.into_iter().map(|i| vec![i]).collect() + }; + + for file_group in file_groups { + let result_options: Result = build_options(&matches, &file_group); if result_options.is_err() { print_error(&matches, result_options.err().unwrap()); return 1; } - let options = &result_options.unwrap(); - let status: i32 = match pr(&f, options) { + let options: &OutputOptions = &result_options.unwrap(); + let cmd_result: Result = if file_group.len() == 1 { + pr(&file_group.get(0).unwrap(), options) + } else { + mpr(&file_group, options) + }; + let status: i32 = match cmd_result { Err(error) => { print_error(&matches, error); 1 @@ -385,22 +435,44 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { return 0; } -fn build_options(matches: &Matches, path: &String) -> Result { - let header: String = matches.opt_str(STRING_HEADER_OPTION).unwrap_or(if path == FILE_STDIN { +fn build_options(matches: &Matches, paths: &Vec) -> Result { + let is_merge_mode: bool = matches.opt_present(MERGE_FILES_PRINT); + + if is_merge_mode && matches.opt_present(COLUMN_OPTION) { + let err_msg: String = "cannot specify number of columns when printing in parallel".to_string(); + return Err(PrError::EncounteredErrors(err_msg)); + } + + if is_merge_mode && matches.opt_present(ACROSS_OPTION) { + let err_msg: String = "cannot specify both printing across and printing in parallel".to_string(); + return Err(PrError::EncounteredErrors(err_msg)); + } + + let merge_files_print: Option = if matches.opt_present(MERGE_FILES_PRINT) { + Some(paths.len()) + } else { + None + }; + + let header: String = matches.opt_str(STRING_HEADER_OPTION).unwrap_or(if is_merge_mode { "".to_string() } else { - path.to_string() + if paths[0].to_string() == FILE_STDIN { + "".to_string() + } else { + paths[0].to_string() + } }); - let default_first_number = NumberingMode::default().first_number; - let first_number = matches.opt_str(FIRST_LINE_NUMBER_OPTION).map(|n| { + let default_first_number: usize = NumberingMode::default().first_number; + let first_number: usize = matches.opt_str(FIRST_LINE_NUMBER_OPTION).map(|n| { n.parse::().unwrap_or(default_first_number) }).unwrap_or(default_first_number); let numbering_options: Option = matches.opt_str(NUMBERING_MODE_OPTION).map(|i| { - let parse_result = i.parse::(); + let parse_result: Result = i.parse::(); - let separator = if parse_result.is_err() { + let separator: String = if parse_result.is_err() { if is_a_file(&i) { NumberingMode::default().separator } else { @@ -410,7 +482,7 @@ fn build_options(matches: &Matches, path: &String) -> Result Result Result| { - let unparsed_value = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); + let unparsed_value: String = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); match i { Ok(val) => Ok(val), Err(_e) => Err(PrError::EncounteredErrors(format!("invalid --pages argument '{}'", unparsed_value))) } }; - let start_page = match matches.opt_str(PAGE_RANGE_OPTION).map(|i| { + let start_page: Option = match matches.opt_str(PAGE_RANGE_OPTION).map(|i| { let x: Vec<&str> = i.split(":").collect(); x[0].parse::() }).map(invalid_pages_map) @@ -465,9 +537,9 @@ fn build_options(matches: &Matches, path: &String) -> Result None }; - let end_page = match matches.opt_str(PAGE_RANGE_OPTION) - .filter(|i| i.contains(":")) - .map(|i| { + let end_page: Option = match matches.opt_str(PAGE_RANGE_OPTION) + .filter(|i: &String| i.contains(":")) + .map(|i: String| { let x: Vec<&str> = i.split(":").collect(); x[1].parse::() }) @@ -481,38 +553,38 @@ fn build_options(matches: &Matches, path: &String) -> Result() }) { Some(res) => res?, _ => LINES_PER_PAGE }; - let page_length_le_ht = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); + let page_length_le_ht: bool = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); - let display_header_and_trailer = !(page_length_le_ht) && !matches.opt_present(NO_HEADER_TRAILER_OPTION); + let display_header_and_trailer: bool = !(page_length_le_ht) && !matches.opt_present(NO_HEADER_TRAILER_OPTION); - let content_lines_per_page = if page_length_le_ht { + let content_lines_per_page: usize = if page_length_le_ht { page_length } else { page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE) }; - let page_separator_char = matches.opt_str(FORM_FEED_OPTION).map(|_i| { + let page_separator_char: String = matches.opt_str(FORM_FEED_OPTION).map(|_i| { '\u{000A}'.to_string() }).unwrap_or("\n".to_string()); - let column_width = match matches.opt_str(COLUMN_WIDTH_OPTION).map(|i| i.parse::()) { + let column_width: Option = match matches.opt_str(COLUMN_WIDTH_OPTION).map(|i| i.parse::()) { Some(res) => Some(res?), _ => None }; - let across_mode = matches.opt_present(ACROSS_OPTION); + let across_mode: bool = matches.opt_present(ACROSS_OPTION); - let column_separator = matches.opt_str(COLUMN_SEPARATOR_OPTION) + let column_separator: String = matches.opt_str(COLUMN_SEPARATOR_OPTION) .unwrap_or(DEFAULT_COLUMN_SEPARATOR.to_string()); - let column_mode_options = match matches.opt_str(COLUMN_OPTION).map(|i| { + let column_mode_options: Option = match matches.opt_str(COLUMN_OPTION).map(|i| { i.parse::() }) { Some(res) => { @@ -528,6 +600,14 @@ fn build_options(matches: &Matches, path: &String) -> Result None }; + + let offset_spaces: usize = matches.opt_str(OFFSET_SPACES_OPTION) + .map(|i| { + match i.parse::() { + Ok(val)=> Ok(val), + Err(e)=> Err(PrError::EncounteredErrors("".to_string())) + } + }).unwrap_or(Ok(0))?; Ok(OutputOptions { number: numbering_options, @@ -543,16 +623,18 @@ fn build_options(matches: &Matches, path: &String) -> Result Result, PrError> { if path == FILE_STDIN { - let stdin = stdin(); + let stdin: Stdin = stdin(); return Ok(Box::new(stdin) as Box); } - metadata(path).map(|i| { + metadata(path).map(|i: Metadata| { let path_string = path.to_string(); match i.file_type() { #[cfg(unix)] @@ -582,50 +664,217 @@ fn open(path: &str) -> Result, PrError> { }).unwrap_or(Err(PrError::NotExists(path.to_string()))) } -fn pr(path: &str, options: &OutputOptions) -> Result { +fn pr(path: &String, options: &OutputOptions) -> Result { let start_page: &usize = options.start_page.as_ref().unwrap_or(&1); + let start_line_number: usize = get_start_line_number(options); let last_page: Option<&usize> = options.end_page.as_ref(); let lines_needed_per_page: usize = lines_to_read_for_page(options); - let start_line_number: usize = get_start_line_number(options); - - let pages: GroupBy>>>, _>, _>, _>, _> = - BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) + let file_line_groups: GroupBy>>>, _>, _>, _>, _>, _> = + BufReader::with_capacity(READ_BUFFER_SIZE, open(path).unwrap()) .lines() .enumerate() - .skip_while(|line_index: &(usize, Result)| { - // Skip the initial lines if not in page range - let start_line_index_of_start_page = (*start_page - 1) * lines_needed_per_page; - line_index.0 < (start_line_index_of_start_page) + .map(move |i: (usize, Result)| { + FileLine { + file_id: 0, + line_number: i.0, + line_content: i.1, + page_number: 0, + key: 0, + } }) - .take_while(|i: &(usize, Result)| { + .skip_while(move |file_line: &FileLine| { + // Skip the initial lines if not in page range + let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; + file_line.line_number < (start_line_index_of_start_page) + }) + .take_while(move |file_line: &FileLine| { // Only read the file until provided last page reached last_page - .map(|lp| i.0 < ((*lp) * lines_needed_per_page)) + .map(|lp| file_line.line_number < ((*lp) * lines_needed_per_page)) .unwrap_or(true) }) - .map(|i: (usize, Result)| (i.0 + start_line_number, i.1)) // get display line number with line content - .group_by(|i: &(usize, Result)| { - ((i.0 - start_line_number + 1) as f64 / lines_needed_per_page as f64).ceil() as usize - }); // group them by page number + .map(move |file_line: FileLine| { + let page_number = ((file_line.line_number + 1) as f64 / lines_needed_per_page as f64).ceil() as usize; + FileLine { + line_number: file_line.line_number + start_line_number, + page_number, + key: page_number, + ..file_line + } + }) // get display line number with line content + .group_by(|file_line: &FileLine| { + file_line.page_number + }); - for (page_number, content_with_line_number) in pages.into_iter() { - let mut lines: Vec<(usize, String)> = Vec::new(); - for line_number_and_line in content_with_line_number { - let line_number: usize = line_number_and_line.0; - let line: Result = line_number_and_line.1; - let x = line?; - lines.push((line_number, x)); + for (page_number, file_line_group) in file_line_groups.into_iter() { + let mut lines: Vec = Vec::new(); + for file_line in file_line_group { + if file_line.line_content.is_err() { + return Err(PrError::from(file_line.line_content.unwrap_err())); + } + lines.push(file_line); + } + let print_status: Result = print_page(&lines, options, &page_number); + if print_status.is_err() { + return Err(PrError::from(print_status.unwrap_err())); } - - print_page(&lines, options, &page_number); } return Ok(0); } -fn print_page(lines: &Vec<(usize, String)>, options: &OutputOptions, page: &usize) -> Result { +fn mpr(paths: &Vec, options: &OutputOptions) -> Result { + let nfiles = paths.len(); + + let lines_needed_per_page: usize = lines_to_read_for_page(options); + let lines_needed_per_page_f64: f64 = lines_needed_per_page as f64; + let start_page: &usize = options.start_page.as_ref().unwrap_or(&1); + let last_page: Option<&usize> = options.end_page.as_ref(); + + let file_line_groups: GroupBy>>>, _>, _>, _>, _>, _>, _> = paths + .into_iter() + .enumerate() + .map(|indexed_path: (usize, &String)| { + let start_line_number: usize = get_start_line_number(options); + BufReader::with_capacity(READ_BUFFER_SIZE, open(indexed_path.1).unwrap()) + .lines() + .enumerate() + .map(move |i: (usize, Result)| { + FileLine { + file_id: indexed_path.0, + line_number: i.0, + line_content: i.1, + page_number: 0, + key: 0, + } + }) + .skip_while(move |file_line: &FileLine| { + // Skip the initial lines if not in page range + let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; + file_line.line_number < (start_line_index_of_start_page) + }) + .take_while(move |file_line: &FileLine| { + // Only read the file until provided last page reached + + last_page + .map(|lp| file_line.line_number < ((*lp) * lines_needed_per_page)) + .unwrap_or(true) + }) + .map(move |file_line: FileLine| { + let page_number = ((file_line.line_number + 2 - start_line_number) as f64 / (lines_needed_per_page_f64)).ceil() as usize; + FileLine { + line_number: file_line.line_number + start_line_number, + page_number, + key: page_number * nfiles + file_line.file_id, + ..file_line + } + }) // get display line number with line content + }) + .kmerge_by(|a: &FileLine, b: &FileLine| { + if a.key == b.key { + a.line_number < b.line_number + } else { + a.key < b.key + } + }) + .group_by(|file_line: &FileLine| { + file_line.key + }); + + let mut lines: Vec = Vec::new(); + let start_page: &usize = options.start_page.as_ref().unwrap_or(&1); + let mut page_counter: usize = *start_page; + for (_key, file_line_group) in file_line_groups.into_iter() { + for file_line in file_line_group { + if file_line.line_content.is_err() { + return Err(PrError::from(file_line.line_content.unwrap_err())); + } + let new_page_number = file_line.page_number; + if page_counter != new_page_number { + fill_missing_files(&mut lines, lines_needed_per_page, &nfiles, page_counter); + let print_status: Result = print_page(&lines, options, &page_counter); + if print_status.is_err() { + return Err(PrError::from(print_status.unwrap_err())); + } + lines = Vec::new(); + } + lines.push(file_line); + page_counter = new_page_number; + } + } + + fill_missing_files(&mut lines, lines_needed_per_page, &nfiles, page_counter); + let print_status: Result = print_page(&lines, options, &page_counter); + if print_status.is_err() { + return Err(PrError::from(print_status.unwrap_err())); + } + + + return Ok(0); +} + +fn fill_missing_files(lines: &mut Vec, lines_per_file: usize, nfiles: &usize, page_number: usize) { + let init_line_number = (page_number - 1) * lines_per_file + 1; + let final_line_number = page_number * lines_per_file; + let mut file_id_counter: usize = 0; + let mut line_number_counter: usize = init_line_number; + let mut lines_processed: usize = 0; + let mut file_id_missing: bool = false; + for mut i in 0..lines_per_file * nfiles { + let file_id = lines.get(i).map(|i: &FileLine| i.file_id).unwrap_or(file_id_counter); + let line_number = lines.get(i).map(|i: &FileLine| i.line_number).unwrap_or(1); + if lines_processed == lines_per_file { + line_number_counter = init_line_number; + file_id_counter += 1; + lines_processed = 0; + file_id_missing = false; + } + + if file_id_counter >= *nfiles { + file_id_counter = 0; + file_id_missing = false; + } + + if file_id != file_id_counter { + file_id_missing = true; + } + + if file_id_missing { + // Insert missing file_ids + lines.insert(i, FileLine { + file_id: file_id_counter, + line_number: line_number_counter, + line_content: Ok("".to_string()), + page_number, + key: 0, + }); + line_number_counter += 1; + } else { + // Insert missing lines for a file_id + if line_number < line_number_counter { + line_number_counter += 1; + lines.insert(i, FileLine { + file_id, + line_number: line_number_counter, + line_content: Ok("".to_string()), + page_number, + key: 0, + }); + } else { + line_number_counter = line_number; + if line_number_counter == final_line_number { + line_number_counter = init_line_number; + } + } + } + + lines_processed += 1; + } +} + +fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Result { let page_separator = options.page_separator_char.as_bytes(); let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(options); @@ -653,7 +902,7 @@ fn print_page(lines: &Vec<(usize, String)>, options: &OutputOptions, page: &usiz Ok(lines_written) } -fn write_columns(lines: &Vec<(usize, String)>, options: &OutputOptions, out: &mut Stdout) -> Result { +fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout) -> Result { let line_separator = options.content_line_separator.as_bytes(); let content_lines_per_page = if options.double_space { options.content_lines_per_page / 2 @@ -671,26 +920,35 @@ fn write_columns(lines: &Vec<(usize, String)>, options: &OutputOptions, out: &mu .unwrap_or(NumberingMode::default().separator); let blank_line = "".to_string(); - let columns = get_columns(options); - + let columns = options.merge_files_print.unwrap_or(get_columns(options)); + let def_sep = DEFAULT_COLUMN_SEPARATOR.to_string(); let col_sep: &String = options .column_mode_options.as_ref() .map(|i| &i.column_separator) - .unwrap_or(&blank_line); + .unwrap_or(options + .merge_files_print + .map(|_k| &def_sep) + .unwrap_or(&blank_line) + ); let col_width: Option = options .column_mode_options.as_ref() .map(|i| i.width) - .unwrap_or(None); + .unwrap_or(options + .merge_files_print + .map(|_k| Some(DEFAULT_COLUMN_WIDTH)) + .unwrap_or(None) + ); let across_mode = options .column_mode_options.as_ref() .map(|i| i.across_mode) .unwrap_or(false); + + let offset_spaces: &usize = &options.offset_spaces; let mut lines_printed = 0; let is_number_mode = options.number.is_some(); - let fetch_indexes: Vec> = if across_mode { (0..content_lines_per_page) .map(|a| @@ -707,19 +965,20 @@ fn write_columns(lines: &Vec<(usize, String)>, options: &OutputOptions, out: &mu ).collect() }; + let spaces = " ".repeat(*offset_spaces); + for fetch_index in fetch_indexes { let indexes = fetch_index.len(); for i in 0..indexes { - let index = fetch_index[i]; + let index: usize = fetch_index[i]; if lines.get(index).is_none() { break; } - let read_line: &String = &lines.get(index).unwrap().1; - let next_line_number: usize = lines.get(index).unwrap().0; - let trimmed_line = get_line_for_printing( - next_line_number, &width, - &number_separator, columns, col_width, - read_line, is_number_mode); + let file_line: &FileLine = lines.get(index).unwrap(); + let trimmed_line: String = format!("{}{}", spaces, get_line_for_printing( + file_line, &width, &number_separator, columns, col_width, + is_number_mode, &options.merge_files_print, &i, + )); out.write(trimmed_line.as_bytes())?; if (i + 1) != indexes { out.write(col_sep.as_bytes())?; @@ -731,16 +990,20 @@ fn write_columns(lines: &Vec<(usize, String)>, options: &OutputOptions, out: &mu Ok(lines_printed) } -fn get_line_for_printing(line_number: usize, width: &usize, +fn get_line_for_printing(file_line: &FileLine, width: &usize, separator: &String, columns: usize, col_width: Option, - read_line: &String, is_number_mode: bool) -> String { - let fmtd_line_number: String = if is_number_mode { - get_fmtd_line_number(&width, line_number, &separator) + is_number_mode: bool, merge_files_print: &Option, + index: &usize, +) -> String { + let should_show_line_number_merge_file = merge_files_print.is_none() || index == &usize::min_value(); + let should_show_line_number = is_number_mode && should_show_line_number_merge_file; + let fmtd_line_number: String = if should_show_line_number { + get_fmtd_line_number(&width, file_line.line_number, &separator) } else { "".to_string() }; - let mut complete_line = format!("{}{}", fmtd_line_number, read_line); + let mut complete_line = format!("{}{}", fmtd_line_number, file_line.line_content.as_ref().unwrap()); let tab_count: usize = complete_line .chars() diff --git a/tests/fixtures/pr/column_spaces_across.log.expected b/tests/fixtures/pr/column_spaces_across.log.expected new file mode 100644 index 000000000..037dd814b --- /dev/null +++ b/tests/fixtures/pr/column_spaces_across.log.expected @@ -0,0 +1,198 @@ + + +{last_modified_time} column.log Page 3 + + + 337 337 338 338 339 339 + 340 340 341 341 342 342 + 343 343 344 344 345 345 + 346 346 347 347 348 348 + 349 349 350 350 351 351 + 352 352 353 353 354 354 + 355 355 356 356 357 357 + 358 358 359 359 360 360 + 361 361 362 362 363 363 + 364 364 365 365 366 366 + 367 367 368 368 369 369 + 370 370 371 371 372 372 + 373 373 374 374 375 375 + 376 376 377 377 378 378 + 379 379 380 380 381 381 + 382 382 383 383 384 384 + 385 385 386 386 387 387 + 388 388 389 389 390 390 + 391 391 392 392 393 393 + 394 394 395 395 396 396 + 397 397 398 398 399 399 + 400 400 401 401 402 402 + 403 403 404 404 405 405 + 406 406 407 407 408 408 + 409 409 410 410 411 411 + 412 412 413 413 414 414 + 415 415 416 416 417 417 + 418 418 419 419 420 420 + 421 421 422 422 423 423 + 424 424 425 425 426 426 + 427 427 428 428 429 429 + 430 430 431 431 432 432 + 433 433 434 434 435 435 + 436 436 437 437 438 438 + 439 439 440 440 441 441 + 442 442 443 443 444 444 + 445 445 446 446 447 447 + 448 448 449 449 450 450 + 451 451 452 452 453 453 + 454 454 455 455 456 456 + 457 457 458 458 459 459 + 460 460 461 461 462 462 + 463 463 464 464 465 465 + 466 466 467 467 468 468 + 469 469 470 470 471 471 + 472 472 473 473 474 474 + 475 475 476 476 477 477 + 478 478 479 479 480 480 + 481 481 482 482 483 483 + 484 484 485 485 486 486 + 487 487 488 488 489 489 + 490 490 491 491 492 492 + 493 493 494 494 495 495 + 496 496 497 497 498 498 + 499 499 500 500 501 501 + 502 502 503 503 504 504 + + + + + + + +{last_modified_time} column.log Page 4 + + + 505 505 506 506 507 507 + 508 508 509 509 510 510 + 511 511 512 512 513 513 + 514 514 515 515 516 516 + 517 517 518 518 519 519 + 520 520 521 521 522 522 + 523 523 524 524 525 525 + 526 526 527 527 528 528 + 529 529 530 530 531 531 + 532 532 533 533 534 534 + 535 535 536 536 537 537 + 538 538 539 539 540 540 + 541 541 542 542 543 543 + 544 544 545 545 546 546 + 547 547 548 548 549 549 + 550 550 551 551 552 552 + 553 553 554 554 555 555 + 556 556 557 557 558 558 + 559 559 560 560 561 561 + 562 562 563 563 564 564 + 565 565 566 566 567 567 + 568 568 569 569 570 570 + 571 571 572 572 573 573 + 574 574 575 575 576 576 + 577 577 578 578 579 579 + 580 580 581 581 582 582 + 583 583 584 584 585 585 + 586 586 587 587 588 588 + 589 589 590 590 591 591 + 592 592 593 593 594 594 + 595 595 596 596 597 597 + 598 598 599 599 600 600 + 601 601 602 602 603 603 + 604 604 605 605 606 606 + 607 607 608 608 609 609 + 610 610 611 611 612 612 + 613 613 614 614 615 615 + 616 616 617 617 618 618 + 619 619 620 620 621 621 + 622 622 623 623 624 624 + 625 625 626 626 627 627 + 628 628 629 629 630 630 + 631 631 632 632 633 633 + 634 634 635 635 636 636 + 637 637 638 638 639 639 + 640 640 641 641 642 642 + 643 643 644 644 645 645 + 646 646 647 647 648 648 + 649 649 650 650 651 651 + 652 652 653 653 654 654 + 655 655 656 656 657 657 + 658 658 659 659 660 660 + 661 661 662 662 663 663 + 664 664 665 665 666 666 + 667 667 668 668 669 669 + 670 670 671 671 672 672 + + + + + + + +{last_modified_time} column.log Page 5 + + + 673 673 674 674 675 675 + 676 676 677 677 678 678 + 679 679 680 680 681 681 + 682 682 683 683 684 684 + 685 685 686 686 687 687 + 688 688 689 689 690 690 + 691 691 692 692 693 693 + 694 694 695 695 696 696 + 697 697 698 698 699 699 + 700 700 701 701 702 702 + 703 703 704 704 705 705 + 706 706 707 707 708 708 + 709 709 710 710 711 711 + 712 712 713 713 714 714 + 715 715 716 716 717 717 + 718 718 719 719 720 720 + 721 721 722 722 723 723 + 724 724 725 725 726 726 + 727 727 728 728 729 729 + 730 730 731 731 732 732 + 733 733 734 734 735 735 + 736 736 737 737 738 738 + 739 739 740 740 741 741 + 742 742 743 743 744 744 + 745 745 746 746 747 747 + 748 748 749 749 750 750 + 751 751 752 752 753 753 + 754 754 755 755 756 756 + 757 757 758 758 759 759 + 760 760 761 761 762 762 + 763 763 764 764 765 765 + 766 766 767 767 768 768 + 769 769 770 770 771 771 + 772 772 773 773 774 774 + 775 775 776 776 777 777 + 778 778 779 779 780 780 + 781 781 782 782 783 783 + 784 784 785 785 786 786 + 787 787 788 788 789 789 + 790 790 791 791 792 792 + 793 793 794 794 795 795 + 796 796 797 797 798 798 + 799 799 800 800 801 801 + 802 802 803 803 804 804 + 805 805 806 806 807 807 + 808 808 809 809 810 810 + 811 811 812 812 813 813 + 814 814 815 815 816 816 + 817 817 818 818 819 819 + 820 820 821 821 822 822 + 823 823 824 824 825 825 + 826 826 827 827 828 828 + 829 829 830 830 831 831 + 832 832 833 833 834 834 + 835 835 836 836 837 837 + 838 838 839 839 840 840 + + + + + diff --git a/tests/fixtures/pr/hosts.log b/tests/fixtures/pr/hosts.log new file mode 100644 index 000000000..8d725920c --- /dev/null +++ b/tests/fixtures/pr/hosts.log @@ -0,0 +1,11 @@ +## +# Host Database +# +# localhost is used to configure the loopback interface +# when the system is booting. Do not change this entry. +## +127.0.0.1 localhost +127.0.0.1 Techopss-MacBook-Pro.local +127.0.0.1 tilakpr +255.255.255.255 broadcasthost +::1 localhost \ No newline at end of file diff --git a/tests/fixtures/pr/mpr.log.expected b/tests/fixtures/pr/mpr.log.expected new file mode 100644 index 000000000..f6fffd191 --- /dev/null +++ b/tests/fixtures/pr/mpr.log.expected @@ -0,0 +1,132 @@ + + +{last_modified_time} Page 1 + + + 1 1 ## + 2 2 # Host Database + 3 3 # + 4 4 # localhost is used to configure th + 5 5 # when the system is booting. Do n + 6 6 ## + 7 7 127.0.0.1 localhost + 8 8 127.0.0.1 Techopss-MacBook-Pro.loca + 9 9 127.0.0.1 tilakpr + 10 10 255.255.255.255 broadcasthost + 11 11 ::1 localhost + 12 12 + 13 13 + 14 14 + 15 15 + 16 16 + 17 17 + 18 18 + 19 19 + 20 20 + 21 21 + 22 22 + 23 23 + 24 24 + 25 25 + 26 26 + 27 27 + 28 28 + 29 29 + 30 30 + 31 31 + 32 32 + 33 33 + 34 34 + 35 35 + 36 36 + 37 37 + 38 38 + 39 39 + 40 40 + 41 41 + 42 42 + 43 43 + 44 44 + 45 45 + 46 46 + 47 47 + 48 48 + 49 49 + 50 50 + 51 51 + 52 52 + 53 53 + 54 54 + 55 55 + 56 56 + + + + + + + +{last_modified_time} Page 2 + + + 57 57 + 58 58 + 59 59 + 60 60 + 61 61 + 62 62 + 63 63 + 64 64 + 65 65 + 66 66 + 67 67 + 68 68 + 69 69 + 70 70 + 71 71 + 72 72 + 73 73 + 74 74 + 75 75 + 76 76 + 77 77 + 78 78 + 79 79 + 80 80 + 81 81 + 82 82 + 83 83 + 84 84 + 85 85 + 86 86 + 87 87 + 88 88 + 89 89 + 90 90 + 91 91 + 92 92 + 93 93 + 94 94 + 95 95 + 96 96 + 97 97 + 98 98 + 99 99 + 100 100 + 101 101 + 102 102 + 103 103 + 104 104 + 105 105 + 106 106 + 107 107 + 108 108 + 109 109 + 110 110 + 111 111 + 112 112 + + + + + diff --git a/tests/fixtures/pr/mpr1.log.expected b/tests/fixtures/pr/mpr1.log.expected new file mode 100644 index 000000000..64d786d90 --- /dev/null +++ b/tests/fixtures/pr/mpr1.log.expected @@ -0,0 +1,198 @@ + + +{last_modified_time} Page 2 + + + 57 57 + 58 58 + 59 59 + 60 60 + 61 61 + 62 62 + 63 63 + 64 64 + 65 65 + 66 66 + 67 67 + 68 68 + 69 69 + 70 70 + 71 71 + 72 72 + 73 73 + 74 74 + 75 75 + 76 76 + 77 77 + 78 78 + 79 79 + 80 80 + 81 81 + 82 82 + 83 83 + 84 84 + 85 85 + 86 86 + 87 87 + 88 88 + 89 89 + 90 90 + 91 91 + 92 92 + 93 93 + 94 94 + 95 95 + 96 96 + 97 97 + 98 98 + 99 99 + 100 100 + 101 101 + 102 102 + 103 103 + 104 104 + 105 105 + 106 106 + 107 107 + 108 108 + 109 109 + 110 110 + 111 111 + 112 112 + + + + + + + +{last_modified_time} Page 3 + + + 113 113 + 114 114 + 115 115 + 116 116 + 117 117 + 118 118 + 119 119 + 120 120 + 121 121 + 122 122 + 123 123 + 124 124 + 125 125 + 126 126 + 127 127 + 128 128 + 129 129 + 130 130 + 131 131 + 132 132 + 133 133 + 134 134 + 135 135 + 136 136 + 137 137 + 138 138 + 139 139 + 140 140 + 141 141 + 142 142 + 143 143 + 144 144 + 145 145 + 146 146 + 147 147 + 148 148 + 149 149 + 150 150 + 151 151 + 152 152 + 153 153 + 154 154 + 155 155 + 156 156 + 157 157 + 158 158 + 159 159 + 160 160 + 161 161 + 162 162 + 163 163 + 164 164 + 165 165 + 166 166 + 167 167 + 168 168 + + + + + + + +{last_modified_time} Page 4 + + + 169 169 + 170 170 + 171 171 + 172 172 + 173 173 + 174 174 + 175 175 + 176 176 + 177 177 + 178 178 + 179 179 + 180 180 + 181 181 + 182 182 + 183 183 + 184 184 + 185 185 + 186 186 + 187 187 + 188 188 + 189 189 + 190 190 + 191 191 + 192 192 + 193 193 + 194 194 + 195 195 + 196 196 + 197 197 + 198 198 + 199 199 + 200 200 + 201 201 + 202 202 + 203 203 + 204 204 + 205 205 + 206 206 + 207 207 + 208 208 + 209 209 + 210 210 + 211 211 + 212 212 + 213 213 + 214 214 + 215 215 + 216 216 + 217 217 + 218 218 + 219 219 + 220 220 + 221 221 + 222 222 + 223 223 + 224 224 + + + + + diff --git a/tests/fixtures/pr/mpr2.log.expected b/tests/fixtures/pr/mpr2.log.expected new file mode 100644 index 000000000..091f0f228 --- /dev/null +++ b/tests/fixtures/pr/mpr2.log.expected @@ -0,0 +1,200 @@ + + +{last_modified_time} Page 1 + + + 1 1 ## 1 + 2 2 # Host Database 2 + 3 3 # 3 + 4 4 # localhost is used to 4 + 5 5 # when the system is bo 5 + 6 6 ## 6 + 7 7 127.0.0.1 localhost 7 + 8 8 127.0.0.1 Techopss-MacB 8 + 9 9 127.0.0.1 tilakpr 9 + 10 10 255.255.255.255 broadca 10 + 11 11 ::1 localho 11 + 12 12 12 + 13 13 13 + 14 14 14 + 15 15 15 + 16 16 16 + 17 17 17 + 18 18 18 + 19 19 19 + 20 20 20 + 21 21 21 + 22 22 22 + 23 23 23 + 24 24 24 + 25 25 25 + 26 26 26 + 27 27 27 + 28 28 28 + 29 29 29 + 30 30 30 + 31 31 31 + 32 32 32 + 33 33 33 + 34 34 34 + 35 35 35 + 36 36 36 + 37 37 37 + 38 38 38 + 39 39 39 + 40 40 40 + 41 41 41 + 42 42 42 + 43 43 43 + 44 44 44 + 45 45 45 + 46 46 46 + 47 47 47 + 48 48 48 + 49 49 49 + 50 50 50 + 51 51 51 + 52 52 52 + 53 53 53 + 54 54 54 + 55 55 55 + 56 56 56 + 57 57 57 + 58 58 58 + 59 59 59 + 60 60 60 + 61 61 61 + 62 62 62 + 63 63 63 + 64 64 64 + 65 65 65 + 66 66 66 + 67 67 67 + 68 68 68 + 69 69 69 + 70 70 70 + 71 71 71 + 72 72 72 + 73 73 73 + 74 74 74 + 75 75 75 + 76 76 76 + 77 77 77 + 78 78 78 + 79 79 79 + 80 80 80 + 81 81 81 + 82 82 82 + 83 83 83 + 84 84 84 + 85 85 85 + 86 86 86 + 87 87 87 + 88 88 88 + 89 89 89 + 90 90 90 + + + + + + + +{last_modified_time} Page 2 + + + 91 91 91 + 92 92 92 + 93 93 93 + 94 94 94 + 95 95 95 + 96 96 96 + 97 97 97 + 98 98 98 + 99 99 99 + 100 100 100 + 101 101 101 + 102 102 102 + 103 103 103 + 104 104 104 + 105 105 105 + 106 106 106 + 107 107 107 + 108 108 108 + 109 109 109 + 110 110 110 + 111 111 111 + 112 112 112 + 113 113 113 + 114 114 114 + 115 115 115 + 116 116 116 + 117 117 117 + 118 118 118 + 119 119 119 + 120 120 120 + 121 121 121 + 122 122 122 + 123 123 123 + 124 124 124 + 125 125 125 + 126 126 126 + 127 127 127 + 128 128 128 + 129 129 129 + 130 130 130 + 131 131 131 + 132 132 132 + 133 133 133 + 134 134 134 + 135 135 135 + 136 136 136 + 137 137 137 + 138 138 138 + 139 139 139 + 140 140 140 + 141 141 141 + 142 142 142 + 143 143 143 + 144 144 144 + 145 145 145 + 146 146 146 + 147 147 147 + 148 148 148 + 149 149 149 + 150 150 150 + 151 151 151 + 152 152 152 + 153 153 153 + 154 154 154 + 155 155 155 + 156 156 156 + 157 157 157 + 158 158 158 + 159 159 159 + 160 160 160 + 161 161 161 + 162 162 162 + 163 163 163 + 164 164 164 + 165 165 165 + 166 166 166 + 167 167 167 + 168 168 168 + 169 169 169 + 170 170 170 + 171 171 171 + 172 172 172 + 173 173 173 + 174 174 174 + 175 175 175 + 176 176 176 + 177 177 177 + 178 178 178 + 179 179 179 + 180 180 180 + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 6faa48348..7b8c77d34 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -282,7 +282,6 @@ fn test_with_suppress_error_option() { #[test] fn test_with_stdin() { - let test_file_path = "stdin.log"; let expected_file_path = "stdin.log.expected"; let mut scenario = new_ucmd!(); scenario @@ -306,7 +305,6 @@ fn test_with_column() { .stdout_is_templated_fixture(expected_test_file_path, vec![ (&"{last_modified_time}".to_string(), &value), ]); - } #[test] @@ -321,7 +319,6 @@ fn test_with_column_across_option() { .stdout_is_templated_fixture(expected_test_file_path, vec![ (&"{last_modified_time}".to_string(), &value), ]); - } #[test] @@ -336,6 +333,64 @@ fn test_with_column_across_option_and_column_separator() { .stdout_is_templated_fixture(expected_test_file_path, vec![ (&"{last_modified_time}".to_string(), &value), ]); - } +#[test] +fn test_with_mpr() { + let test_file_path = "column.log"; + let test_file_path1 = "hosts.log"; + let expected_test_file_path = "mpr.log.expected"; + let expected_test_file_path1 = "mpr1.log.expected"; + let expected_test_file_path2 = "mpr2.log.expected"; + new_ucmd!() + .args(&["--pages=1:2", "-m", "-n", test_file_path, test_file_path1]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + (&"{last_modified_time}".to_string(), &now_time()), + ]); + + new_ucmd!() + .args(&["--pages=2:4", "-m", "-n", test_file_path, test_file_path1]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path1, vec![ + (&"{last_modified_time}".to_string(), &now_time()), + ]); + + new_ucmd!() + .args(&["--pages=1:2", "-l", "100", "-n", "-m", test_file_path, test_file_path1, test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path2, vec![ + (&"{last_modified_time}".to_string(), &now_time()), + ]); +} + +#[test] +fn test_with_mpr_and_column_options() { + let test_file_path = "column.log"; + new_ucmd!() + .args(&["--column=2", "-m", "-n", test_file_path]) + .fails() + .stderr_is("pr: cannot specify number of columns when printing in parallel") + .stdout_is(""); + + new_ucmd!() + .args(&["-a", "-m", "-n", test_file_path]) + .fails() + .stderr_is("pr: cannot specify both printing across and printing in parallel") + .stdout_is(""); +} + + +#[test] +fn test_with_offset_space_option() { + let test_file_path = "column.log"; + let expected_test_file_path = "column_spaces_across.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["-o", "5", "--pages=3:5", "--column=3", "-a", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + (&"{last_modified_time}".to_string(), &value), + ]); +} From 5c6c5243349e3544fefcc9c0a0cfc501db8b48e2 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sat, 29 Dec 2018 14:10:43 +0530 Subject: [PATCH 033/126] pr: refactor and fmt fill_missing_lines and error checks pr: Remove unwanted brancing in fill_missing_lines pr: Remove unnecessary error check pr: Rename key to group_key in FileLine pr: Reformat test_pr with rustfmt --- src/pr/pr.rs | 742 +++++++++++++++++++++++++---------------------- tests/test_pr.rs | 216 +++++++++----- 2 files changed, 528 insertions(+), 430 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 06c991c29..87aadf80c 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -10,35 +10,36 @@ extern crate unix_socket; #[macro_use] extern crate quick_error; -extern crate itertools; extern crate chrono; extern crate getopts; +extern crate itertools; extern crate uucore; -use std::io::{BufRead, BufReader, stdin, stdout, stderr, Error, Read, Write, Stdout, Lines, Stdin}; -use std::vec::Vec; use chrono::offset::Local; use chrono::DateTime; +use getopts::{HasArg, Occur}; use getopts::{Matches, Options}; -use std::fs::{metadata, File, Metadata}; -#[cfg(unix)] -use std::os::unix::fs::FileTypeExt; +use itertools::structs::KMergeBy; +use itertools::{GroupBy, Itertools}; use quick_error::ResultExt; use std::convert::From; -use getopts::{HasArg, Occur}; +use std::fs::{metadata, File, Metadata}; +use std::io::{stderr, stdin, stdout, BufRead, BufReader, Lines, Read, Stdin, Stdout, Write}; +use std::iter::{Enumerate, Map, SkipWhile, TakeWhile}; use std::num::ParseIntError; -use itertools::{Itertools, GroupBy}; -use std::iter::{Enumerate, Map, TakeWhile, SkipWhile}; -use itertools::structs::KMergeBy; +#[cfg(unix)] +use std::os::unix::fs::FileTypeExt; +use std::vec::Vec; + +type IOError = std::io::Error; static NAME: &str = "pr"; static VERSION: &str = env!("CARGO_PKG_VERSION"); static TAB: char = '\t'; +static NEW_LINE: &str = "\n"; static LINES_PER_PAGE: usize = 66; static HEADER_LINES_PER_PAGE: usize = 5; static TRAILER_LINES_PER_PAGE: usize = 5; -static NUMBERING_MODE_DEFAULT_SEPARATOR: &str = "\t"; -static NUMBERING_MODE_DEFAULT_WIDTH: usize = 5; static STRING_HEADER_OPTION: &str = "h"; static DOUBLE_SPACE_OPTION: &str = "d"; static NUMBERING_MODE_OPTION: &str = "n"; @@ -57,7 +58,8 @@ static OFFSET_SPACES_OPTION: &str = "o"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; -static DEFAULT_COLUMN_SEPARATOR: &str = "\t"; +static DEFAULT_COLUMN_SEPARATOR: &char = &TAB; +static BLANK_STRING: &str = ""; struct OutputOptions { /// Line numbering mode @@ -67,7 +69,7 @@ struct OutputOptions { line_separator: String, content_line_separator: String, last_modified_time: String, - start_page: Option, + start_page: usize, end_page: Option, display_header: bool, display_trailer: bool, @@ -75,15 +77,15 @@ struct OutputOptions { page_separator_char: String, column_mode_options: Option, merge_files_print: Option, - offset_spaces: usize + offset_spaces: usize, } struct FileLine { file_id: usize, line_number: usize, page_number: usize, - key: usize, - line_content: Result, + group_key: usize, + line_content: Result, } impl AsRef for FileLine { @@ -93,7 +95,7 @@ impl AsRef for FileLine { } struct ColumnModeOptions { - width: Option, + width: usize, columns: usize, column_separator: String, across_mode: bool, @@ -115,21 +117,15 @@ struct NumberingMode { impl Default for NumberingMode { fn default() -> NumberingMode { NumberingMode { - width: NUMBERING_MODE_DEFAULT_WIDTH, - separator: NUMBERING_MODE_DEFAULT_SEPARATOR.to_string(), + width: 5, + separator: TAB.to_string(), first_number: 1, } } } -impl From for PrError { - fn from(err: Error) -> Self { - PrError::EncounteredErrors(err.to_string()) - } -} - -impl From for PrError { - fn from(err: std::num::ParseIntError) -> Self { +impl From for PrError { + fn from(err: IOError) -> Self { PrError::EncounteredErrors(err.to_string()) } } @@ -137,8 +133,8 @@ impl From for PrError { quick_error! { #[derive(Debug)] enum PrError { - Input(err: Error, path: String) { - context(path: &'a str, err: Error) -> (err, path.to_owned()) + Input(err: IOError, path: String) { + context(path: &'a str, err: IOError) -> (err, path.to_owned()) display("pr: Reading from input {0} gave error", path) cause(err) } @@ -181,7 +177,7 @@ pub fn uumain(args: Vec) -> i32 { STRING_HEADER_OPTION, "header", "Use the string header to replace the file name \ - in the header line.", + in the header line.", "STRING", HasArg::Yes, Occur::Optional, @@ -353,7 +349,6 @@ pub fn uumain(args: Vec) -> i32 { files.insert(0, FILE_STDIN.to_owned()); } - if matches.opt_present("help") { return print_usage(&mut opts, &matches); } @@ -381,7 +376,7 @@ pub fn uumain(args: Vec) -> i32 { print_error(&matches, error); 1 } - _ => 0 + _ => 0, }; if status != 0 { return status; @@ -403,10 +398,13 @@ fn print_error(matches: &Matches, err: PrError) { fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { println!("{} {} -- print files", NAME, VERSION); println!(); - println!("Usage: {} [+page] [-column] [-adFfmprt] [[-e] [char] [gap]] + println!( + "Usage: {} [+page] [-column] [-adFfmprt] [[-e] [char] [gap]] [-L locale] [-h header] [[-i] [char] [gap]] [-l lines] [-o offset] [[-s] [char]] [[-n] [char] - [width]] [-w width] [-] [file ...].", NAME); + [width]] [-w width] [-] [file ...].", + NAME + ); println!(); let usage: &str = "The pr utility is a printing and pagination filter for text files. When multiple input files are spec- @@ -435,16 +433,39 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { return 0; } +fn parse_usize(matches: &Matches, opt: &str) -> Option> { + let from_parse_error_to_pr_error = |value_to_parse: (String, String)| { + let i = value_to_parse.0; + let option = value_to_parse.1; + i.parse::().map_err(|_e| { + PrError::EncounteredErrors(format!("invalid {} argument '{}'", option, i)) + }) + }; + matches + .opt_str(opt) + .map(|i| (i, format!("-{}", opt))) + .map(from_parse_error_to_pr_error) +} + fn build_options(matches: &Matches, paths: &Vec) -> Result { + let invalid_pages_map = |i: String| { + let unparsed_value: String = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); + i.parse::().map_err(|_e| { + PrError::EncounteredErrors(format!("invalid --pages argument '{}'", unparsed_value)) + }) + }; + let is_merge_mode: bool = matches.opt_present(MERGE_FILES_PRINT); if is_merge_mode && matches.opt_present(COLUMN_OPTION) { - let err_msg: String = "cannot specify number of columns when printing in parallel".to_string(); + let err_msg: String = + "cannot specify number of columns when printing in parallel".to_string(); return Err(PrError::EncounteredErrors(err_msg)); } if is_merge_mode && matches.opt_present(ACROSS_OPTION) { - let err_msg: String = "cannot specify both printing across and printing in parallel".to_string(); + let err_msg: String = + "cannot specify both printing across and printing in parallel".to_string(); return Err(PrError::EncounteredErrors(err_msg)); } @@ -454,65 +475,71 @@ fn build_options(matches: &Matches, paths: &Vec) -> Result().unwrap_or(default_first_number) - }).unwrap_or(default_first_number); + let first_number: usize = + parse_usize(matches, FIRST_LINE_NUMBER_OPTION).unwrap_or(Ok(default_first_number))?; - let numbering_options: Option = matches.opt_str(NUMBERING_MODE_OPTION).map(|i| { - let parse_result: Result = i.parse::(); + let numbering_options: Option = matches + .opt_str(NUMBERING_MODE_OPTION) + .map(|i| { + let parse_result: Result = i.parse::(); - let separator: String = if parse_result.is_err() { - if is_a_file(&i) { + let separator: String = if parse_result.is_err() { + if is_a_file(&i) { + NumberingMode::default().separator + } else { + i[0..1].to_string() + } + } else { NumberingMode::default().separator - } else { - i[0..1].to_string() - } - } else { - NumberingMode::default().separator - }; + }; - let width: usize = if parse_result.is_err() { - if is_a_file(&i) { - NumberingMode::default().width + let width: usize = if parse_result.is_err() { + if is_a_file(&i) { + NumberingMode::default().width + } else { + i[1..] + .parse::() + .unwrap_or(NumberingMode::default().width) + } } else { - i[1..].parse::().unwrap_or(NumberingMode::default().width) - } - } else { - parse_result.unwrap() - }; + parse_result.unwrap() + }; - NumberingMode { - width, - separator, - first_number, - } - }).or_else(|| { - if matches.opt_present(NUMBERING_MODE_OPTION) { - return Some(NumberingMode::default()); - } - return None; - }); + NumberingMode { + width, + separator, + first_number, + } + }) + .or_else(|| { + if matches.opt_present(NUMBERING_MODE_OPTION) { + return Some(NumberingMode::default()); + } + return None; + }); let double_space: bool = matches.opt_present(DOUBLE_SPACE_OPTION); let content_line_separator: String = if double_space { - "\n\n".to_string() + NEW_LINE.repeat(2) } else { - "\n".to_string() + NEW_LINE.to_string() }; - let line_separator: String = "\n".to_string(); + let line_separator: String = NEW_LINE.to_string(); let last_modified_time: String = if is_merge_mode || paths[0].eq(FILE_STDIN) { current_time() @@ -520,48 +547,46 @@ fn build_options(matches: &Matches, paths: &Vec) -> Result| { - let unparsed_value: String = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); - match i { - Ok(val) => Ok(val), - Err(_e) => Err(PrError::EncounteredErrors(format!("invalid --pages argument '{}'", unparsed_value))) - } + let start_page: usize = match matches + .opt_str(PAGE_RANGE_OPTION) + .map(|i| { + let x: Vec<&str> = i.split(":").collect(); + x[0].to_string() + }) + .map(invalid_pages_map) + { + Some(res) => res?, + _ => 1, }; - let start_page: Option = match matches.opt_str(PAGE_RANGE_OPTION).map(|i| { - let x: Vec<&str> = i.split(":").collect(); - x[0].parse::() - }).map(invalid_pages_map) - { - Some(res) => Some(res?), - _ => None - }; - - let end_page: Option = match matches.opt_str(PAGE_RANGE_OPTION) + let end_page: Option = match matches + .opt_str(PAGE_RANGE_OPTION) .filter(|i: &String| i.contains(":")) .map(|i: String| { let x: Vec<&str> = i.split(":").collect(); - x[1].parse::() + x[1].to_string() }) .map(invalid_pages_map) - { - Some(res) => Some(res?), - _ => None - }; + { + Some(res) => Some(res?), + _ => None, + }; - if start_page.is_some() && end_page.is_some() && start_page.unwrap() > end_page.unwrap() { - return Err(PrError::EncounteredErrors(format!("invalid --pages argument '{}:{}'", start_page.unwrap(), end_page.unwrap()))); + if end_page.is_some() && start_page > end_page.unwrap() { + return Err(PrError::EncounteredErrors(format!( + "invalid --pages argument '{}:{}'", + start_page, + end_page.unwrap() + ))); } - let page_length: usize = match matches.opt_str(PAGE_LENGTH_OPTION).map(|i| { - i.parse::() - }) { - Some(res) => res?, - _ => LINES_PER_PAGE - }; + let page_length: usize = + parse_usize(matches, PAGE_LENGTH_OPTION).unwrap_or(Ok(LINES_PER_PAGE))?; + let page_length_le_ht: bool = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); - let display_header_and_trailer: bool = !(page_length_le_ht) && !matches.opt_present(NO_HEADER_TRAILER_OPTION); + let display_header_and_trailer: bool = + !(page_length_le_ht) && !matches.opt_present(NO_HEADER_TRAILER_OPTION); let content_lines_per_page: usize = if page_length_le_ht { page_length @@ -569,45 +594,31 @@ fn build_options(matches: &Matches, paths: &Vec) -> Result = match matches.opt_str(COLUMN_WIDTH_OPTION).map(|i| i.parse::()) { - Some(res) => Some(res?), - _ => None - }; + let column_width: usize = + parse_usize(matches, COLUMN_WIDTH_OPTION).unwrap_or(Ok(DEFAULT_COLUMN_WIDTH))?; let across_mode: bool = matches.opt_present(ACROSS_OPTION); - let column_separator: String = matches.opt_str(COLUMN_SEPARATOR_OPTION) + let column_separator: String = matches + .opt_str(COLUMN_SEPARATOR_OPTION) .unwrap_or(DEFAULT_COLUMN_SEPARATOR.to_string()); - - let column_mode_options: Option = match matches.opt_str(COLUMN_OPTION).map(|i| { - i.parse::() - }) { - Some(res) => { - Some(ColumnModeOptions { - columns: res?, - width: match column_width { - Some(x) => Some(x), - None => Some(DEFAULT_COLUMN_WIDTH) - }, - column_separator, - across_mode, - }) - } - _ => None + let column_mode_options: Option = match parse_usize(matches, COLUMN_OPTION) { + Some(res) => Some(ColumnModeOptions { + columns: res?, + width: column_width, + column_separator, + across_mode, + }), + _ => None, }; - - let offset_spaces: usize = matches.opt_str(OFFSET_SPACES_OPTION) - .map(|i| { - match i.parse::() { - Ok(val)=> Ok(val), - Err(e)=> Err(PrError::EncounteredErrors("".to_string())) - } - }).unwrap_or(Ok(0))?; + + let offset_spaces: usize = parse_usize(matches, OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?; Ok(OutputOptions { number: numbering_options, @@ -634,94 +645,81 @@ fn open(path: &str) -> Result, PrError> { return Ok(Box::new(stdin) as Box); } - metadata(path).map(|i: Metadata| { - let path_string = path.to_string(); - match i.file_type() { - #[cfg(unix)] - ft if ft.is_block_device() => - { - Err(PrError::UnknownFiletype(path_string)) + metadata(path) + .map(|i: Metadata| { + let path_string = path.to_string(); + match i.file_type() { + #[cfg(unix)] + ft if ft.is_block_device() => Err(PrError::UnknownFiletype(path_string)), + #[cfg(unix)] + ft if ft.is_char_device() => Err(PrError::UnknownFiletype(path_string)), + #[cfg(unix)] + ft if ft.is_fifo() => Err(PrError::UnknownFiletype(path_string)), + #[cfg(unix)] + ft if ft.is_socket() => Err(PrError::IsSocket(path_string)), + ft if ft.is_dir() => Err(PrError::IsDirectory(path_string)), + ft if ft.is_file() || ft.is_symlink() => { + Ok(Box::new(File::open(path).context(path)?) as Box) } - #[cfg(unix)] - ft if ft.is_char_device() => - { - Err(PrError::UnknownFiletype(path_string)) - } - #[cfg(unix)] - ft if ft.is_fifo() => - { - Err(PrError::UnknownFiletype(path_string)) - } - #[cfg(unix)] - ft if ft.is_socket() => - { - Err(PrError::IsSocket(path_string)) - } - ft if ft.is_dir() => Err(PrError::IsDirectory(path_string)), - ft if ft.is_file() || ft.is_symlink() => Ok(Box::new(File::open(path).context(path)?) as Box), - _ => Err(PrError::UnknownFiletype(path_string)) - } - }).unwrap_or(Err(PrError::NotExists(path.to_string()))) + _ => Err(PrError::UnknownFiletype(path_string)), + } + }) + .unwrap_or(Err(PrError::NotExists(path.to_string()))) } fn pr(path: &String, options: &OutputOptions) -> Result { - let start_page: &usize = options.start_page.as_ref().unwrap_or(&1); + let start_page: &usize = &options.start_page; let start_line_number: usize = get_start_line_number(options); let last_page: Option<&usize> = options.end_page.as_ref(); let lines_needed_per_page: usize = lines_to_read_for_page(options); - let file_line_groups: GroupBy>>>, _>, _>, _>, _>, _> = - BufReader::with_capacity(READ_BUFFER_SIZE, open(path).unwrap()) - .lines() - .enumerate() - .map(move |i: (usize, Result)| { - FileLine { - file_id: 0, - line_number: i.0, - line_content: i.1, - page_number: 0, - key: 0, - } - }) - .skip_while(move |file_line: &FileLine| { - // Skip the initial lines if not in page range - let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; - file_line.line_number < (start_line_index_of_start_page) - }) - .take_while(move |file_line: &FileLine| { - // Only read the file until provided last page reached - last_page - .map(|lp| file_line.line_number < ((*lp) * lines_needed_per_page)) - .unwrap_or(true) - }) - .map(move |file_line: FileLine| { - let page_number = ((file_line.line_number + 1) as f64 / lines_needed_per_page as f64).ceil() as usize; - FileLine { - line_number: file_line.line_number + start_line_number, - page_number, - key: page_number, - ..file_line - } - }) // get display line number with line content - .group_by(|file_line: &FileLine| { - file_line.page_number - }); - + let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; + let file_line_groups: GroupBy< + usize, + Map>>>, _>, _>, _>, _>, + _, + > = BufReader::with_capacity(READ_BUFFER_SIZE, open(path).unwrap()) + .lines() + .enumerate() + .map(|i: (usize, Result)| FileLine { + file_id: 0, + line_number: i.0, + line_content: i.1, + page_number: 0, + group_key: 0, + }) + .skip_while(|file_line: &FileLine| { + // Skip the initial lines if not in page range + file_line.line_number < (start_line_index_of_start_page) + }) + .take_while(|file_line: &FileLine| { + // Only read the file until provided last page reached + last_page + .map(|lp| file_line.line_number < ((*lp) * lines_needed_per_page)) + .unwrap_or(true) + }) + .map(|file_line: FileLine| { + let page_number = + ((file_line.line_number + 1) as f64 / lines_needed_per_page as f64).ceil() as usize; + FileLine { + line_number: file_line.line_number + start_line_number, + page_number, + group_key: page_number, + ..file_line + } + }) // get display line number with line content + .group_by(|file_line: &FileLine| file_line.group_key); for (page_number, file_line_group) in file_line_groups.into_iter() { let mut lines: Vec = Vec::new(); for file_line in file_line_group { if file_line.line_content.is_err() { - return Err(PrError::from(file_line.line_content.unwrap_err())); + return Err(file_line.line_content.unwrap_err().into()); } lines.push(file_line); } - let print_status: Result = print_page(&lines, options, &page_number); - if print_status.is_err() { - return Err(PrError::from(print_status.unwrap_err())); - } + print_page(&lines, options, &page_number)?; } - return Ok(0); } @@ -730,10 +728,18 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { let lines_needed_per_page: usize = lines_to_read_for_page(options); let lines_needed_per_page_f64: f64 = lines_needed_per_page as f64; - let start_page: &usize = options.start_page.as_ref().unwrap_or(&1); + let start_page: &usize = &options.start_page; let last_page: Option<&usize> = options.end_page.as_ref(); + let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; - let file_line_groups: GroupBy>>>, _>, _>, _>, _>, _>, _> = paths + let file_line_groups: GroupBy< + usize, + KMergeBy< + Map>>>, _>, _>, _>, _>, + _, + >, + _, + > = paths .into_iter() .enumerate() .map(|indexed_path: (usize, &String)| { @@ -741,63 +747,56 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { BufReader::with_capacity(READ_BUFFER_SIZE, open(indexed_path.1).unwrap()) .lines() .enumerate() - .map(move |i: (usize, Result)| { - FileLine { - file_id: indexed_path.0, - line_number: i.0, - line_content: i.1, - page_number: 0, - key: 0, - } + .map(move |i: (usize, Result)| FileLine { + file_id: indexed_path.0, + line_number: i.0, + line_content: i.1, + page_number: 0, + group_key: 0, }) .skip_while(move |file_line: &FileLine| { // Skip the initial lines if not in page range - let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; file_line.line_number < (start_line_index_of_start_page) }) .take_while(move |file_line: &FileLine| { - // Only read the file until provided last page reached - + // Only read the file until provided last page reached last_page .map(|lp| file_line.line_number < ((*lp) * lines_needed_per_page)) .unwrap_or(true) }) .map(move |file_line: FileLine| { - let page_number = ((file_line.line_number + 2 - start_line_number) as f64 / (lines_needed_per_page_f64)).ceil() as usize; + let page_number = ((file_line.line_number + 2 - start_line_number) as f64 + / (lines_needed_per_page_f64)) + .ceil() as usize; FileLine { line_number: file_line.line_number + start_line_number, page_number, - key: page_number * nfiles + file_line.file_id, + group_key: page_number * nfiles + file_line.file_id, ..file_line } }) // get display line number with line content }) .kmerge_by(|a: &FileLine, b: &FileLine| { - if a.key == b.key { + if a.group_key == b.group_key { a.line_number < b.line_number } else { - a.key < b.key + a.group_key < b.group_key } }) - .group_by(|file_line: &FileLine| { - file_line.key - }); + .group_by(|file_line: &FileLine| file_line.group_key); let mut lines: Vec = Vec::new(); - let start_page: &usize = options.start_page.as_ref().unwrap_or(&1); + let start_page: &usize = &options.start_page; let mut page_counter: usize = *start_page; for (_key, file_line_group) in file_line_groups.into_iter() { for file_line in file_line_group { if file_line.line_content.is_err() { - return Err(PrError::from(file_line.line_content.unwrap_err())); + return Err(file_line.line_content.unwrap_err().into()); } let new_page_number = file_line.page_number; if page_counter != new_page_number { - fill_missing_files(&mut lines, lines_needed_per_page, &nfiles, page_counter); - let print_status: Result = print_page(&lines, options, &page_counter); - if print_status.is_err() { - return Err(PrError::from(print_status.unwrap_err())); - } + fill_missing_lines(&mut lines, lines_needed_per_page, &nfiles, page_counter); + print_page(&lines, options, &page_counter)?; lines = Vec::new(); } lines.push(file_line); @@ -805,76 +804,73 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { } } - fill_missing_files(&mut lines, lines_needed_per_page, &nfiles, page_counter); - let print_status: Result = print_page(&lines, options, &page_counter); - if print_status.is_err() { - return Err(PrError::from(print_status.unwrap_err())); - } - + fill_missing_lines(&mut lines, lines_needed_per_page, &nfiles, page_counter); + print_page(&lines, options, &page_counter)?; return Ok(0); } -fn fill_missing_files(lines: &mut Vec, lines_per_file: usize, nfiles: &usize, page_number: usize) { +fn fill_missing_lines( + lines: &mut Vec, + lines_per_file: usize, + nfiles: &usize, + page_number: usize, +) { let init_line_number = (page_number - 1) * lines_per_file + 1; - let final_line_number = page_number * lines_per_file; let mut file_id_counter: usize = 0; let mut line_number_counter: usize = init_line_number; - let mut lines_processed: usize = 0; - let mut file_id_missing: bool = false; + let mut lines_processed_per_file: usize = 0; for mut i in 0..lines_per_file * nfiles { - let file_id = lines.get(i).map(|i: &FileLine| i.file_id).unwrap_or(file_id_counter); + let file_id = lines + .get(i) + .map(|i: &FileLine| i.file_id) + .unwrap_or(file_id_counter); let line_number = lines.get(i).map(|i: &FileLine| i.line_number).unwrap_or(1); - if lines_processed == lines_per_file { + if lines_processed_per_file == lines_per_file { line_number_counter = init_line_number; file_id_counter += 1; - lines_processed = 0; - file_id_missing = false; - } - - if file_id_counter >= *nfiles { - file_id_counter = 0; - file_id_missing = false; + lines_processed_per_file = 0; } if file_id != file_id_counter { - file_id_missing = true; - } - - if file_id_missing { // Insert missing file_ids - lines.insert(i, FileLine { - file_id: file_id_counter, - line_number: line_number_counter, - line_content: Ok("".to_string()), - page_number, - key: 0, - }); + lines.insert( + i, + FileLine { + file_id: file_id_counter, + line_number: line_number_counter, + line_content: Ok("".to_string()), + page_number, + group_key: 0, + }, + ); line_number_counter += 1; - } else { + } else if line_number < line_number_counter { // Insert missing lines for a file_id - if line_number < line_number_counter { - line_number_counter += 1; - lines.insert(i, FileLine { + line_number_counter += 1; + lines.insert( + i, + FileLine { file_id, line_number: line_number_counter, line_content: Ok("".to_string()), page_number, - key: 0, - }); - } else { - line_number_counter = line_number; - if line_number_counter == final_line_number { - line_number_counter = init_line_number; - } - } + group_key: 0, + }, + ); + } else { + line_number_counter = line_number; } - lines_processed += 1; + lines_processed_per_file += 1; } } -fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> Result { +fn print_page( + lines: &Vec, + options: &OutputOptions, + page: &usize, +) -> Result { let page_separator = options.page_separator_char.as_bytes(); let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(options); @@ -902,7 +898,11 @@ fn print_page(lines: &Vec, options: &OutputOptions, page: &usize) -> R Ok(lines_written) } -fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdout) -> Result { +fn write_columns( + lines: &Vec, + options: &OutputOptions, + out: &mut Stdout, +) -> Result { let line_separator = options.content_line_separator.as_bytes(); let content_lines_per_page = if options.double_space { options.content_lines_per_page / 2 @@ -910,12 +910,10 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdou options.content_lines_per_page }; - let width: usize = options - .number.as_ref() - .map(|i| i.width) - .unwrap_or(0); + let width: usize = options.number.as_ref().map(|i| i.width).unwrap_or(0); let number_separator: String = options - .number.as_ref() + .number + .as_ref() .map(|i| i.separator.to_string()) .unwrap_or(NumberingMode::default().separator); @@ -923,46 +921,50 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdou let columns = options.merge_files_print.unwrap_or(get_columns(options)); let def_sep = DEFAULT_COLUMN_SEPARATOR.to_string(); let col_sep: &String = options - .column_mode_options.as_ref() + .column_mode_options + .as_ref() .map(|i| &i.column_separator) - .unwrap_or(options - .merge_files_print - .map(|_k| &def_sep) - .unwrap_or(&blank_line) + .unwrap_or( + options + .merge_files_print + .map(|_k| &def_sep) + .unwrap_or(&blank_line), ); + // TODO simplify let col_width: Option = options - .column_mode_options.as_ref() - .map(|i| i.width) - .unwrap_or(options - .merge_files_print - .map(|_k| Some(DEFAULT_COLUMN_WIDTH)) - .unwrap_or(None) + .column_mode_options + .as_ref() + .map(|i| Some(i.width)) + .unwrap_or( + options + .merge_files_print + .map(|_k| Some(DEFAULT_COLUMN_WIDTH)) + .unwrap_or(None), ); let across_mode = options - .column_mode_options.as_ref() + .column_mode_options + .as_ref() .map(|i| i.across_mode) .unwrap_or(false); - + let offset_spaces: &usize = &options.offset_spaces; let mut lines_printed = 0; let is_number_mode = options.number.is_some(); let fetch_indexes: Vec> = if across_mode { (0..content_lines_per_page) - .map(|a| - (0..columns) - .map(|i| a * columns + i) - .collect() - ).collect() + .map(|a| (0..columns).map(|i| a * columns + i).collect()) + .collect() } else { (0..content_lines_per_page) - .map(|start| + .map(|start| { (0..columns) .map(|i| start + content_lines_per_page * i) .collect() - ).collect() + }) + .collect() }; let spaces = " ".repeat(*offset_spaces); @@ -975,10 +977,20 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdou break; } let file_line: &FileLine = lines.get(index).unwrap(); - let trimmed_line: String = format!("{}{}", spaces, get_line_for_printing( - file_line, &width, &number_separator, columns, col_width, - is_number_mode, &options.merge_files_print, &i, - )); + let trimmed_line: String = format!( + "{}{}", + spaces, + get_line_for_printing( + file_line, + &width, + &number_separator, + columns, + col_width, + is_number_mode, + &options.merge_files_print, + &i, + ) + ); out.write(trimmed_line.as_bytes())?; if (i + 1) != indexes { out.write(col_sep.as_bytes())?; @@ -990,58 +1002,76 @@ fn write_columns(lines: &Vec, options: &OutputOptions, out: &mut Stdou Ok(lines_printed) } -fn get_line_for_printing(file_line: &FileLine, width: &usize, - separator: &String, columns: usize, - col_width: Option, - is_number_mode: bool, merge_files_print: &Option, - index: &usize, +fn get_line_for_printing( + file_line: &FileLine, + width: &usize, + separator: &String, + columns: usize, + col_width: Option, + is_number_mode: bool, + merge_files_print: &Option, + index: &usize, ) -> String { - let should_show_line_number_merge_file = merge_files_print.is_none() || index == &usize::min_value(); + let should_show_line_number_merge_file = + merge_files_print.is_none() || index == &usize::min_value(); let should_show_line_number = is_number_mode && should_show_line_number_merge_file; let fmtd_line_number: String = if should_show_line_number { get_fmtd_line_number(&width, file_line.line_number, &separator) } else { "".to_string() }; - let mut complete_line = format!("{}{}", fmtd_line_number, file_line.line_content.as_ref().unwrap()); + let mut complete_line = format!( + "{}{}", + fmtd_line_number, + file_line.line_content.as_ref().unwrap() + ); - let tab_count: usize = complete_line - .chars() - .filter(|i| i == &TAB) - .count(); + let tab_count: usize = complete_line.chars().filter(|i| i == &TAB).count(); let display_length = complete_line.len() + (tab_count * 7); -// TODO Adjust the width according to -n option -// TODO actual len of the string vs display len of string because of tabs - col_width.map(|i| { - let min_width = (i - (columns - 1)) / columns; - if display_length < min_width { - for _i in 0..(min_width - display_length) { - complete_line.push(' '); + // TODO Adjust the width according to -n option + // TODO actual len of the string vs display len of string because of tabs + col_width + .map(|i| { + let min_width = (i - (columns - 1)) / columns; + if display_length < min_width { + for _i in 0..(min_width - display_length) { + complete_line.push(' '); + } } - } - complete_line - .chars() - .take(min_width) - .collect() - }).unwrap_or(complete_line) + complete_line.chars().take(min_width).collect() + }) + .unwrap_or(complete_line) } fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) -> String { let line_str = line_number.to_string(); if line_str.len() >= *width { - format!("{:>width$}{}", &line_str[line_str.len() - *width..], separator, width = width) + format!( + "{:>width$}{}", + &line_str[line_str.len() - *width..], + separator, + width = width + ) } else { format!("{:>width$}{}", line_str, separator, width = width) } } - fn header_content(options: &OutputOptions, page: &usize) -> Vec { if options.display_header { - let first_line: String = format!("{} {} Page {}", options.last_modified_time, options.header, page); - vec!["".to_string(), "".to_string(), first_line, "".to_string(), "".to_string()] + let first_line: String = format!( + "{} {} Page {}", + options.last_modified_time, options.header, page + ); + vec![ + BLANK_STRING.to_string(), + BLANK_STRING.to_string(), + first_line, + BLANK_STRING.to_string(), + BLANK_STRING.to_string(), + ] } else { Vec::new() } @@ -1049,12 +1079,17 @@ fn header_content(options: &OutputOptions, page: &usize) -> Vec { fn file_last_modified_time(path: &str) -> String { let file_metadata = metadata(path); - return file_metadata.map(|i| { - return i.modified().map(|x| { - let datetime: DateTime = x.into(); - datetime.format("%b %d %H:%M %Y").to_string() - }).unwrap_or(String::new()); - }).unwrap_or(String::new()); + return file_metadata + .map(|i| { + return i + .modified() + .map(|x| { + let datetime: DateTime = x.into(); + datetime.format("%b %d %H:%M %Y").to_string() + }) + .unwrap_or(String::new()); + }) + .unwrap_or(String::new()); } fn current_time() -> String { @@ -1064,7 +1099,13 @@ fn current_time() -> String { fn trailer_content(options: &OutputOptions) -> Vec { if options.as_ref().display_trailer { - vec!["".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string()] + vec![ + BLANK_STRING.to_string(), + BLANK_STRING.to_string(), + BLANK_STRING.to_string(), + BLANK_STRING.to_string(), + BLANK_STRING.to_string(), + ] } else { Vec::new() } @@ -1076,10 +1117,7 @@ fn trailer_content(options: &OutputOptions) -> Vec { /// # Arguments /// * `opts` - A reference to OutputOptions fn get_start_line_number(opts: &OutputOptions) -> usize { - opts.number - .as_ref() - .map(|i| i.first_number) - .unwrap_or(1) + opts.number.as_ref().map(|i| i.first_number).unwrap_or(1) } /// Returns number of lines to read from input for constructing one page of pr output. diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 7b8c77d34..00d602b55 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -2,25 +2,29 @@ extern crate chrono; use common::util::*; use std::fs::metadata; -use test_pr::chrono::DateTime; use test_pr::chrono::offset::Local; +use test_pr::chrono::DateTime; fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { let tmp_dir_path = ucmd.get_full_fixture_path(path); let file_metadata = metadata(tmp_dir_path); - return file_metadata.map(|i| { - return i.modified().map(|x| { - let datetime: DateTime = x.into(); - datetime.format("%b %d %H:%M %Y").to_string() - }).unwrap_or(String::new()); - }).unwrap_or(String::new()); + return file_metadata + .map(|i| { + return i + .modified() + .map(|x| { + let datetime: DateTime = x.into(); + datetime.format("%b %d %H:%M %Y").to_string() + }) + .unwrap_or(String::new()); + }) + .unwrap_or(String::new()); } fn now_time() -> String { Local::now().format("%b %d %H:%M %Y").to_string() } - #[test] fn test_without_any_options() { let test_file_path = "test_one_page.log"; @@ -30,7 +34,10 @@ fn test_without_any_options() { scenario .args(&[test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -42,7 +49,10 @@ fn test_with_numbering_option() { scenario .args(&["-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -54,7 +64,10 @@ fn test_with_numbering_option_when_content_is_less_than_page() { scenario .args(&["-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -66,7 +79,10 @@ fn test_with_numbering_option_with_number_width() { scenario .args(&["-n", "2", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -79,10 +95,13 @@ fn test_with_header_option() { scenario .args(&["-h", header, test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - (&"{header}".to_string(), &header.to_string()) - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![ + (&"{last_modified_time}".to_string(), &value), + (&"{header}".to_string(), &header.to_string()), + ], + ); } #[test] @@ -95,10 +114,13 @@ fn test_with_long_header_option() { scenario .args(&["--header=new file", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - (&"{header}".to_string(), &header.to_string()) - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![ + (&"{last_modified_time}".to_string(), &value), + (&"{header}".to_string(), &header.to_string()), + ], + ); } #[test] @@ -110,9 +132,10 @@ fn test_with_double_space_option() { scenario .args(&["-d", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -124,9 +147,10 @@ fn test_with_long_double_space_option() { scenario .args(&["--double-space", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -138,9 +162,10 @@ fn test_with_first_line_number_option() { scenario .args(&["-N", "5", "-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -152,9 +177,10 @@ fn test_with_first_line_number_long_option() { scenario .args(&["--first-line-number=5", "-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -166,9 +192,10 @@ fn test_with_number_option_with_custom_separator_char() { scenario .args(&["-nc", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -180,9 +207,10 @@ fn test_with_number_option_with_custom_separator_char_and_width() { scenario .args(&["-nc1", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -197,9 +225,7 @@ fn test_with_valid_page_ranges() { new_ucmd!() .args(&["--pages=1:5", test_file_path]) .succeeds(); - new_ucmd!() - .args(&["--pages=1", test_file_path]) - .succeeds(); + new_ucmd!().args(&["--pages=1", test_file_path]).succeeds(); new_ucmd!() .args(&["--pages=-1:5", test_file_path]) .fails() @@ -227,15 +253,17 @@ fn test_with_page_range() { scenario .args(&["--pages=15", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); new_ucmd!() .args(&["--pages=15:17", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path1, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path1, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -259,9 +287,10 @@ fn test_with_page_length_option() { scenario .args(&["--pages=2:3", "-l", "100", "-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); new_ucmd!() .args(&["--pages=2:3", "-l", "5", "-n", test_file_path]) @@ -288,9 +317,10 @@ fn test_with_stdin() { .pipe_in_fixture("stdin.log") .args(&["--pages=1:2", "-n", "-"]) .run() - .stdout_is_templated_fixture(expected_file_path, vec![ - (&"{last_modified_time}".to_string(), &now_time()), - ]); + .stdout_is_templated_fixture( + expected_file_path, + vec![(&"{last_modified_time}".to_string(), &now_time())], + ); } #[test] @@ -302,9 +332,10 @@ fn test_with_column() { scenario .args(&["--pages=3:5", "--column=3", "-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -316,9 +347,10 @@ fn test_with_column_across_option() { scenario .args(&["--pages=3:5", "--column=3", "-a", "-n", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -328,11 +360,19 @@ fn test_with_column_across_option_and_column_separator() { let mut scenario = new_ucmd!(); let value = file_last_modified_time(&scenario, test_file_path); scenario - .args(&["--pages=3:5", "--column=3", "-s|", "-a", "-n", test_file_path]) + .args(&[ + "--pages=3:5", + "--column=3", + "-s|", + "-a", + "-n", + test_file_path, + ]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -345,23 +385,35 @@ fn test_with_mpr() { new_ucmd!() .args(&["--pages=1:2", "-m", "-n", test_file_path, test_file_path1]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &now_time()), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &now_time())], + ); new_ucmd!() .args(&["--pages=2:4", "-m", "-n", test_file_path, test_file_path1]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path1, vec![ - (&"{last_modified_time}".to_string(), &now_time()), - ]); + .stdout_is_templated_fixture( + expected_test_file_path1, + vec![(&"{last_modified_time}".to_string(), &now_time())], + ); new_ucmd!() - .args(&["--pages=1:2", "-l", "100", "-n", "-m", test_file_path, test_file_path1, test_file_path]) + .args(&[ + "--pages=1:2", + "-l", + "100", + "-n", + "-m", + test_file_path, + test_file_path1, + test_file_path, + ]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path2, vec![ - (&"{last_modified_time}".to_string(), &now_time()), - ]); + .stdout_is_templated_fixture( + expected_test_file_path2, + vec![(&"{last_modified_time}".to_string(), &now_time())], + ); } #[test] @@ -380,7 +432,6 @@ fn test_with_mpr_and_column_options() { .stdout_is(""); } - #[test] fn test_with_offset_space_option() { let test_file_path = "column.log"; @@ -388,9 +439,18 @@ fn test_with_offset_space_option() { let mut scenario = new_ucmd!(); let value = file_last_modified_time(&scenario, test_file_path); scenario - .args(&["-o", "5", "--pages=3:5", "--column=3", "-a", "-n", test_file_path]) + .args(&[ + "-o", + "5", + "--pages=3:5", + "--column=3", + "-a", + "-n", + test_file_path, + ]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![ - (&"{last_modified_time}".to_string(), &value), - ]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } From 847046f3deabe69d0111b531e89f89a2ceca21ba Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sun, 30 Dec 2018 12:08:30 +0530 Subject: [PATCH 034/126] pr: add +page and -column --- src/pr/Cargo.toml | 1 + src/pr/pr.rs | 71 +++++++++++++++++++++++++++++++++++++++++------ tests/test_pr.rs | 17 ++++++++++++ 3 files changed, 81 insertions(+), 8 deletions(-) diff --git a/src/pr/Cargo.toml b/src/pr/Cargo.toml index d33681b5f..481404b3a 100644 --- a/src/pr/Cargo.toml +++ b/src/pr/Cargo.toml @@ -14,6 +14,7 @@ time = "0.1.40" chrono = "0.4.6" quick-error = "1.2.2" itertools = "0.7.8" +regex = "1.0.1" [dependencies.uucore] path = "../uucore" diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 87aadf80c..297d9637d 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -13,6 +13,7 @@ extern crate quick_error; extern crate chrono; extern crate getopts; extern crate itertools; +extern crate regex; extern crate uucore; use chrono::offset::Local; @@ -22,6 +23,7 @@ use getopts::{Matches, Options}; use itertools::structs::KMergeBy; use itertools::{GroupBy, Itertools}; use quick_error::ResultExt; +use regex::Regex; use std::convert::From; use std::fs::{metadata, File, Metadata}; use std::io::{stderr, stdin, stdout, BufRead, BufReader, Lines, Read, Stdin, Stdout, Write}; @@ -322,7 +324,11 @@ pub fn uumain(args: Vec) -> i32 { opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); - let matches = match opts.parse(&args[1..]) { + // Remove -column option as getopts cannot parse things like -3 etc + let re = Regex::new(r"^-\d+").unwrap(); + let opt_args: Vec<&String> = args.iter().filter(|i| !re.is_match(i)).collect(); + + let matches = match opts.parse(&opt_args[1..]) { Ok(m) => m, Err(e) => panic!("Invalid options\n{}", e), }; @@ -332,7 +338,14 @@ pub fn uumain(args: Vec) -> i32 { return 0; } - let mut files: Vec = matches.free.clone(); + let mut files: Vec = matches + .free + .clone() + .iter() + .filter(|i| !i.starts_with('+') && !i.starts_with('-')) + .map(|i| i.to_string()) + .collect(); + // -n value is optional if -n is given the opts gets confused // if -n is used just before file path it might be captured as value of -n if matches.opt_str(NUMBERING_MODE_OPTION).is_some() { @@ -360,7 +373,8 @@ pub fn uumain(args: Vec) -> i32 { }; for file_group in file_groups { - let result_options: Result = build_options(&matches, &file_group); + let result_options: Result = + build_options(&matches, &file_group, args.join(" ")); if result_options.is_err() { print_error(&matches, result_options.err().unwrap()); return 1; @@ -427,6 +441,11 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { that do not fit into a text column are truncated. Lines are not truncated under single column output."; println!("{}", opts.usage(usage)); + println!(" +page \t\tBegin output at page number page of the formatted input."); + println!( + " -column \t\tProduce multi-column output. Refer --{}", + COLUMN_OPTION + ); if matches.free.is_empty() { return 1; } @@ -447,7 +466,11 @@ fn parse_usize(matches: &Matches, opt: &str) -> Option> { .map(from_parse_error_to_pr_error) } -fn build_options(matches: &Matches, paths: &Vec) -> Result { +fn build_options( + matches: &Matches, + paths: &Vec, + free_args: String, +) -> Result { let invalid_pages_map = |i: String| { let unparsed_value: String = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); i.parse::().map_err(|_e| { @@ -547,6 +570,19 @@ fn build_options(matches: &Matches, paths: &Vec) -> Result().map_err(|_e| { + PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) + }) + }) { + Some(res) => res?, + _ => 1, + }; + let start_page: usize = match matches .opt_str(PAGE_RANGE_OPTION) .map(|i| { @@ -556,7 +592,7 @@ fn build_options(matches: &Matches, paths: &Vec) -> Result res?, - _ => 1, + _ => start_page_in_plus_option, }; let end_page: Option = match matches @@ -608,9 +644,28 @@ fn build_options(matches: &Matches, paths: &Vec) -> Result = match parse_usize(matches, COLUMN_OPTION) { - Some(res) => Some(ColumnModeOptions { - columns: res?, + let re_col = Regex::new(r"\s*-(\d+)\s*").unwrap(); + + let start_column_option: Option = match re_col.captures(&free_args).map(|i| { + let unparsed_num = i.get(1).unwrap().as_str().trim(); + unparsed_num.parse::().map_err(|_e| { + PrError::EncounteredErrors(format!("invalid {} argument '{}'", "-", unparsed_num)) + }) + }) { + Some(res) => Some(res?), + _ => None, + }; + + // --column has more priority than -column + + let column_option_value: Option = match parse_usize(matches, COLUMN_OPTION) { + Some(res) => Some(res?), + _ => start_column_option, + }; + + let column_mode_options: Option = match column_option_value { + Some(columns) => Some(ColumnModeOptions { + columns, width: column_width, column_separator, across_mode, diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 00d602b55..d02b42436 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -257,6 +257,15 @@ fn test_with_page_range() { expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)], ); + + new_ucmd!() + .args(&["+15", test_file_path]) + .succeeds() + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); + new_ucmd!() .args(&["--pages=15:17", test_file_path]) .succeeds() @@ -336,6 +345,14 @@ fn test_with_column() { expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)], ); + + new_ucmd!() + .args(&["--pages=3:5", "-3", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] From 87227addc162921b74b001b53d24f27682b3ba7b Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sun, 30 Dec 2018 20:42:48 +0530 Subject: [PATCH 035/126] pr: fix printing form feed --- src/pr/pr.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 297d9637d..799507018 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -62,6 +62,7 @@ static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; static DEFAULT_COLUMN_SEPARATOR: &char = &TAB; static BLANK_STRING: &str = ""; +static FF: u8 = 0x0C as u8; struct OutputOptions { /// Line numbering mode @@ -630,10 +631,12 @@ fn build_options( page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE) }; - let page_separator_char: String = matches - .opt_str(FORM_FEED_OPTION) - .map(|_i| '\u{000A}'.to_string()) - .unwrap_or(NEW_LINE.to_string()); + let page_separator_char: String = if matches.opt_present(FORM_FEED_OPTION) { + let bytes = vec![FF]; + String::from_utf8(bytes).unwrap() + } else { + NEW_LINE.to_string() + }; let column_width: usize = parse_usize(matches, COLUMN_WIDTH_OPTION).unwrap_or(Ok(DEFAULT_COLUMN_WIDTH))?; From 8f9b3228978b73f9963c495edeee1fa10f5865e6 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sun, 30 Dec 2018 21:05:24 +0530 Subject: [PATCH 036/126] pr: fix file not found in pr and mpr --- src/pr/pr.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 799507018..b799f8938 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -735,7 +735,7 @@ fn pr(path: &String, options: &OutputOptions) -> Result { usize, Map>>>, _>, _>, _>, _>, _, - > = BufReader::with_capacity(READ_BUFFER_SIZE, open(path).unwrap()) + > = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) .lines() .enumerate() .map(|i: (usize, Result)| FileLine { @@ -790,6 +790,11 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { let last_page: Option<&usize> = options.end_page.as_ref(); let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; + // Check if files exists + for path in paths { + open(path)?; + } + let file_line_groups: GroupBy< usize, KMergeBy< From 3be5dc69235c58acdd7e8a1e66564d7b58264586 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Fri, 4 Jan 2019 22:34:29 +0530 Subject: [PATCH 037/126] pr: fix form feed pr: fix form feed pr: Rustfmt pr: add test for ff and -l option --- src/pr/pr.rs | 229 +++++++++++++++++++------- tests/fixtures/pr/0F | 330 ++++++++++++++++++++++++++++++++++++++ tests/fixtures/pr/0Fnt | 36 +++++ tests/fixtures/pr/0Ft | 35 ++++ tests/fixtures/pr/3-0F | 198 +++++++++++++++++++++++ tests/fixtures/pr/3a3f-0F | 21 +++ tests/fixtures/pr/3f-0F | 86 ++++++++++ tests/fixtures/pr/FnFn | 68 ++++++++ tests/fixtures/pr/a3-0F | 330 ++++++++++++++++++++++++++++++++++++++ tests/fixtures/pr/a3f-0F | 35 ++++ tests/fixtures/pr/l24-FF | 216 +++++++++++++++++++++++++ tests/test_pr.rs | 46 ++++++ 12 files changed, 1573 insertions(+), 57 deletions(-) create mode 100644 tests/fixtures/pr/0F create mode 100644 tests/fixtures/pr/0Fnt create mode 100644 tests/fixtures/pr/0Ft create mode 100644 tests/fixtures/pr/3-0F create mode 100644 tests/fixtures/pr/3a3f-0F create mode 100644 tests/fixtures/pr/3f-0F create mode 100644 tests/fixtures/pr/FnFn create mode 100644 tests/fixtures/pr/a3-0F create mode 100644 tests/fixtures/pr/a3f-0F create mode 100644 tests/fixtures/pr/l24-FF diff --git a/src/pr/pr.rs b/src/pr/pr.rs index b799f8938..6617f0bb1 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -27,6 +27,7 @@ use regex::Regex; use std::convert::From; use std::fs::{metadata, File, Metadata}; use std::io::{stderr, stdin, stdout, BufRead, BufReader, Lines, Read, Stdin, Stdout, Write}; +use std::iter::FlatMap; use std::iter::{Enumerate, Map, SkipWhile, TakeWhile}; use std::num::ParseIntError; #[cfg(unix)] @@ -51,6 +52,7 @@ static NO_HEADER_TRAILER_OPTION: &str = "t"; static PAGE_LENGTH_OPTION: &str = "l"; static SUPPRESS_PRINTING_ERROR: &str = "r"; static FORM_FEED_OPTION: &str = "F"; +static FORM_FEED_OPTION_SMALL: &str = "f"; static COLUMN_WIDTH_OPTION: &str = "w"; static ACROSS_OPTION: &str = "a"; static COLUMN_OPTION: &str = "column"; @@ -81,6 +83,7 @@ struct OutputOptions { column_mode_options: Option, merge_files_print: Option, offset_spaces: usize, + form_feed_used: bool, } struct FileLine { @@ -89,6 +92,7 @@ struct FileLine { page_number: usize, group_key: usize, line_content: Result, + form_feeds_after: usize, } impl AsRef for FileLine { @@ -127,6 +131,19 @@ impl Default for NumberingMode { } } +impl Default for FileLine { + fn default() -> FileLine { + FileLine { + file_id: 0, + line_number: 0, + page_number: 0, + group_key: 0, + line_content: Ok(BLANK_STRING.to_string()), + form_feeds_after: 0, + } + } +} + impl From for PrError { fn from(err: IOError) -> Self { PrError::EncounteredErrors(err.to_string()) @@ -255,6 +272,15 @@ pub fn uumain(args: Vec) -> i32 { HasArg::No, Occur::Optional, ); + opts.opt( + FORM_FEED_OPTION_SMALL, + "form-feed", + "Same as -F but pause before beginning the first page if standard output is a + terminal.", + "", + HasArg::No, + Occur::Optional, + ); opts.opt( "", @@ -572,7 +598,6 @@ fn build_options( }; // +page option is less priority than --pages - let flags = &matches.free.join(" "); let re = Regex::new(r"\s*\+(\d+)\s*").unwrap(); let start_page_in_plus_option: usize = match re.captures(&free_args).map(|i| { let unparsed_num = i.get(1).unwrap().as_str().trim(); @@ -677,7 +702,8 @@ fn build_options( }; let offset_spaces: usize = parse_usize(matches, OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?; - + let form_feed_used = + matches.opt_present(FORM_FEED_OPTION) || matches.opt_present(FORM_FEED_OPTION_SMALL); Ok(OutputOptions { number: numbering_options, header, @@ -694,6 +720,7 @@ fn build_options( column_mode_options, merge_files_print, offset_spaces, + form_feed_used, }) } @@ -730,53 +757,117 @@ fn pr(path: &String, options: &OutputOptions) -> Result { let start_line_number: usize = get_start_line_number(options); let last_page: Option<&usize> = options.end_page.as_ref(); let lines_needed_per_page: usize = lines_to_read_for_page(options); - let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; - let file_line_groups: GroupBy< - usize, - Map>>>, _>, _>, _>, _>, - _, - > = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) - .lines() - .enumerate() - .map(|i: (usize, Result)| FileLine { - file_id: 0, - line_number: i.0, - line_content: i.1, - page_number: 0, - group_key: 0, - }) - .skip_while(|file_line: &FileLine| { - // Skip the initial lines if not in page range - file_line.line_number < (start_line_index_of_start_page) - }) - .take_while(|file_line: &FileLine| { - // Only read the file until provided last page reached - last_page - .map(|lp| file_line.line_number < ((*lp) * lines_needed_per_page)) - .unwrap_or(true) - }) - .map(|file_line: FileLine| { - let page_number = - ((file_line.line_number + 1) as f64 / lines_needed_per_page as f64).ceil() as usize; - FileLine { - line_number: file_line.line_number + start_line_number, - page_number, - group_key: page_number, - ..file_line - } - }) // get display line number with line content - .group_by(|file_line: &FileLine| file_line.group_key); + let is_form_feed_used = options.form_feed_used; + let lines: Map>>, _>, _, _>>, _>, _> = + BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) + .lines() + .map(|file_content: Result| { + file_content + .map(|content| { + let mut lines: Vec = Vec::new(); + let mut f_occurred: usize = 0; + let mut chunk: Vec = Vec::new(); + for byte in content.as_bytes() { + if byte == &FF { + f_occurred += 1; + } else { + if f_occurred != 0 { + // First time byte occurred in the scan + lines.push(FileLine { + line_content: Ok(String::from_utf8(chunk.clone()).unwrap()), + form_feeds_after: f_occurred, + ..FileLine::default() + }); + chunk.clear(); + } + chunk.push(*byte); + f_occurred = 0; + } + } - for (page_number, file_line_group) in file_line_groups.into_iter() { - let mut lines: Vec = Vec::new(); - for file_line in file_line_group { - if file_line.line_content.is_err() { - return Err(file_line.line_content.unwrap_err().into()); - } - lines.push(file_line); + // First time byte occurred in the scan + lines.push(FileLine { + line_content: Ok(String::from_utf8(chunk.clone()).unwrap()), + form_feeds_after: f_occurred, + ..FileLine::default() + }); + + lines + }) + .unwrap_or_else(|e| { + vec![FileLine { + line_content: Err(e), + ..FileLine::default() + }] + }) + }) + .flat_map(|i| i) + .enumerate() + .map(|i: (usize, FileLine)| FileLine { + line_number: i.0, + ..i.1 + }) + .map(|file_line: FileLine| FileLine { + line_number: file_line.line_number + start_line_number, + ..file_line + }); // get display line number with line content + + let mut page_number = 1; + let mut page_lines: Vec = Vec::new(); + let mut feed_line_present = false; + for file_line in lines { + if file_line.line_content.is_err() { + return Err(file_line.line_content.unwrap_err().into()); + } + + feed_line_present = is_form_feed_used; + + if page_lines.len() == lines_needed_per_page || file_line.form_feeds_after > 0 { + if file_line.form_feeds_after > 1 { + print_page( + &page_lines, + options, + &page_number, + &start_page, + &last_page, + feed_line_present, + )?; + page_lines.clear(); + page_number += 1; + print_page( + &page_lines, + options, + &page_number, + &start_page, + &last_page, + feed_line_present, + )?; + page_number += 1; + } else { + print_page( + &page_lines, + options, + &page_number, + &start_page, + &last_page, + feed_line_present, + )?; + page_number += 1; + } + page_lines.clear(); + } + if file_line.form_feeds_after == 0 { + page_lines.push(file_line); } - print_page(&lines, options, &page_number)?; } + print_page( + &page_lines, + options, + &page_number, + &start_page, + &last_page, + feed_line_present, + )?; return Ok(0); } @@ -814,8 +905,7 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { file_id: indexed_path.0, line_number: i.0, line_content: i.1, - page_number: 0, - group_key: 0, + ..FileLine::default() }) .skip_while(move |file_line: &FileLine| { // Skip the initial lines if not in page range @@ -859,7 +949,14 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { let new_page_number = file_line.page_number; if page_counter != new_page_number { fill_missing_lines(&mut lines, lines_needed_per_page, &nfiles, page_counter); - print_page(&lines, options, &page_counter)?; + print_page( + &lines, + options, + &page_counter, + &start_page, + &last_page, + false, + )?; lines = Vec::new(); } lines.push(file_line); @@ -868,7 +965,14 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { } fill_missing_lines(&mut lines, lines_needed_per_page, &nfiles, page_counter); - print_page(&lines, options, &page_counter)?; + print_page( + &lines, + options, + &page_counter, + &start_page, + &last_page, + false, + )?; return Ok(0); } @@ -904,7 +1008,7 @@ fn fill_missing_lines( line_number: line_number_counter, line_content: Ok("".to_string()), page_number, - group_key: 0, + ..FileLine::default() }, ); line_number_counter += 1; @@ -918,7 +1022,7 @@ fn fill_missing_lines( line_number: line_number_counter, line_content: Ok("".to_string()), page_number, - group_key: 0, + ..FileLine::default() }, ); } else { @@ -933,7 +1037,13 @@ fn print_page( lines: &Vec, options: &OutputOptions, page: &usize, + start_page: &usize, + last_page: &Option<&usize>, + feed_line_present: bool, ) -> Result { + if (last_page.is_some() && page > last_page.unwrap()) || page < start_page { + return Ok(0); + } let page_separator = options.page_separator_char.as_bytes(); let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(options); @@ -946,8 +1056,7 @@ fn print_page( out.write(x.as_bytes())?; out.write(line_separator)?; } - - let lines_written = write_columns(lines, options, out)?; + let lines_written = write_columns(lines, options, out, feed_line_present)?; for index in 0..trailer_content.len() { let x: &String = trailer_content.get(index).unwrap(); @@ -965,6 +1074,7 @@ fn write_columns( lines: &Vec, options: &OutputOptions, out: &mut Stdout, + feed_line_present: bool, ) -> Result { let line_separator = options.content_line_separator.as_bytes(); let content_lines_per_page = if options.double_space { @@ -1031,12 +1141,13 @@ fn write_columns( }; let spaces = " ".repeat(*offset_spaces); - + let mut not_found_break = false; for fetch_index in fetch_indexes { let indexes = fetch_index.len(); for i in 0..indexes { let index: usize = fetch_index[i]; if lines.get(index).is_none() { + not_found_break = true; break; } let file_line: &FileLine = lines.get(index).unwrap(); @@ -1060,7 +1171,11 @@ fn write_columns( } lines_printed += 1; } - out.write(line_separator)?; + if not_found_break && feed_line_present { + break; + } else { + out.write(line_separator)?; + } } Ok(lines_printed) } @@ -1161,7 +1276,7 @@ fn current_time() -> String { } fn trailer_content(options: &OutputOptions) -> Vec { - if options.as_ref().display_trailer { + if options.as_ref().display_trailer && !options.form_feed_used { vec![ BLANK_STRING.to_string(), BLANK_STRING.to_string(), diff --git a/tests/fixtures/pr/0F b/tests/fixtures/pr/0F new file mode 100644 index 000000000..223765391 --- /dev/null +++ b/tests/fixtures/pr/0F @@ -0,0 +1,330 @@ + + +{last_modified_time} {file_name} Page 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 2 + + +1 FF-Test: FF's at Start of File V +2 Options -b -3 / -a -3 / ... +3 -------------------------------------------- +4 3456789 123456789 123456789 123456789 12345678 +5 3 Columns downwards ..., <= 5 lines per page +6 FF-Arangements: Empty Pages at start +7 \ftext; \f\ntext; +8 \f\ftext; \f\f\ntext; \f\n\ftext; \f\n\f\n; +9 3456789 123456789 123456789 +10 zzzzzzzzzzzzzzzzzzzzzzzzzz123456789 +1 12345678 +2 12345678 +3 line truncation before FF; r_r_o_l-test: +14 456789 123456789 123456789 123456789 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 4 + + +15 xyzxyzxyz XYZXYZXYZ abcabcab +16 456789 123456789 xyzxyzxyz XYZXYZXYZ +7 12345678 +8 12345678 +9 3456789 ab +20 DEFGHI 123 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +5 12345678 +6 12345678 +27 no truncation before FF; (r_l-test): +28 no trunc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 5 + + +29 xyzxyzxyz XYZXYZXYZ abcabcab +30 456789 123456789 xyzxyzxyz XYZXYZXYZ +1 12345678 +2 3456789 abcdefghi +3 12345678 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/fixtures/pr/0Fnt b/tests/fixtures/pr/0Fnt new file mode 100644 index 000000000..9ba3a906c --- /dev/null +++ b/tests/fixtures/pr/0Fnt @@ -0,0 +1,36 @@ + +1 FF-Test: FF's at Start of File V +2 Options -b -3 / -a -3 / ... +3 -------------------------------------------- +4 3456789 123456789 123456789 123456789 12345678 +5 3 Columns downwards ..., <= 5 lines per page +6 FF-Arangements: Empty Pages at start +7 \ftext; \f\ntext; +8 \f\ftext; \f\f\ntext; \f\n\ftext; \f\n\f\n; +9 3456789 123456789 123456789 +10 zzzzzzzzzzzzzzzzzzzzzzzzzz123456789 +1 12345678 +2 12345678 +3 line truncation before FF; r_r_o_l-test: +14 456789 123456789 123456789 123456789 + +15 xyzxyzxyz XYZXYZXYZ abcabcab +16 456789 123456789 xyzxyzxyz XYZXYZXYZ +7 12345678 +8 12345678 +9 3456789 ab +20 DEFGHI 123 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +5 12345678 +6 12345678 +27 no truncation before FF; (r_l-test): +28 no trunc + +29 xyzxyzxyz XYZXYZXYZ abcabcab +30 456789 123456789 xyzxyzxyz XYZXYZXYZ +1 12345678 +2 3456789 abcdefghi +3 12345678 diff --git a/tests/fixtures/pr/0Ft b/tests/fixtures/pr/0Ft new file mode 100644 index 000000000..bdd599d47 --- /dev/null +++ b/tests/fixtures/pr/0Ft @@ -0,0 +1,35 @@ + 1 FF-Test: FF's at Start of File V +2 Options -b -3 / -a -3 / ... +3 -------------------------------------------- +4 3456789 123456789 123456789 123456789 12345678 +5 3 Columns downwards ..., <= 5 lines per page +6 FF-Arangements: Empty Pages at start +7 \ftext; \f\ntext; +8 \f\ftext; \f\f\ntext; \f\n\ftext; \f\n\f\n; +9 3456789 123456789 123456789 +10 zzzzzzzzzzzzzzzzzzzzzzzzzz123456789 +1 12345678 +2 12345678 +3 line truncation before FF; r_r_o_l-test: +14 456789 123456789 123456789 123456789 + +15 xyzxyzxyz XYZXYZXYZ abcabcab +16 456789 123456789 xyzxyzxyz XYZXYZXYZ +7 12345678 +8 12345678 +9 3456789 ab +20 DEFGHI 123 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +5 12345678 +6 12345678 +27 no truncation before FF; (r_l-test): +28 no trunc + +29 xyzxyzxyz XYZXYZXYZ abcabcab +30 456789 123456789 xyzxyzxyz XYZXYZXYZ +1 12345678 +2 3456789 abcdefghi +3 12345678 diff --git a/tests/fixtures/pr/3-0F b/tests/fixtures/pr/3-0F new file mode 100644 index 000000000..25a9db171 --- /dev/null +++ b/tests/fixtures/pr/3-0F @@ -0,0 +1,198 @@ + + +{last_modified_time} {file_name} Page 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 4 + + +15 xyzxyzxyz XYZXYZXYZ abcabcab +16 456789 123456789 xyzxyzxyz XYZXYZXYZ +7 12345678 +8 12345678 +9 3456789 ab +20 DEFGHI 123 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +5 12345678 +6 12345678 +27 no truncation before FF; (r_l-test): +28 no trunc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 5 + + +29 xyzxyzxyz XYZXYZXYZ abcabcab +30 456789 123456789 xyzxyzxyz XYZXYZXYZ +1 12345678 +2 3456789 abcdefghi +3 12345678 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/fixtures/pr/3a3f-0F b/tests/fixtures/pr/3a3f-0F new file mode 100644 index 000000000..a2535574f --- /dev/null +++ b/tests/fixtures/pr/3a3f-0F @@ -0,0 +1,21 @@ + + +{last_modified_time} {file_name} Page 3 + + + + +{last_modified_time} {file_name} Page 4 + + +15 xyzxyzxyz XYZXYZXYZ 16 456789 123456789 xyz 7 +8 9 3456789 ab 20 DEFGHI 123 +1 2 3 +4 5 6 +27 no truncation before 28 no trunc + +{last_modified_time} {file_name} Page 5 + + +29 xyzxyzxyz XYZXYZXYZ 30 456789 123456789 xyz 1 +2 3456789 abcdefghi 3 \ No newline at end of file diff --git a/tests/fixtures/pr/3f-0F b/tests/fixtures/pr/3f-0F new file mode 100644 index 000000000..06e47aa66 --- /dev/null +++ b/tests/fixtures/pr/3f-0F @@ -0,0 +1,86 @@ + + +{last_modified_time} {file_name} Page 3 + + + + +{last_modified_time} {file_name} Page 4 + + +15 xyzxyzxyz XYZXYZXYZ abcabcab +16 456789 123456789 xyzxyzxyz XYZXYZXYZ +7 12345678 +8 12345678 +9 3456789 ab +20 DEFGHI 123 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +5 12345678 +6 12345678 +27 no truncation before FF; (r_l-test): +28 no trunc + + +{last_modified_time} {file_name} Page 5 + + +29 xyzxyzxyz XYZXYZXYZ abcabcab +30 456789 123456789 xyzxyzxyz XYZXYZXYZ +1 12345678 +2 3456789 abcdefghi +3 12345678 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/fixtures/pr/FnFn b/tests/fixtures/pr/FnFn new file mode 100644 index 000000000..fa91abafc --- /dev/null +++ b/tests/fixtures/pr/FnFn @@ -0,0 +1,68 @@ +1 FF-Test: FF's in Text V +2 Options -b -3 / -a -3 / ... +3 -------------------------------------------- +4 3456789 123456789 123456789 123456789 12345678 +5 3 Columns downwards ..., <= 5 lines per page +6 FF-Arangements: One Empty Page +7 text\f\f\n; text\f\n\ftext; \f\ftext; +8 \f\f\n; \f\n\f\n; +9 +10 zzzzzzzzzzzzzzzzzzzzzzzzzz123456789 +1 12345678 +2 12345678 +3 line truncation before FF; r_r_o_l-test: +14 456789 123456789 123456789 123456789 + + +15 xyzxyzxyz XYZXYZXYZ abcabcab +16 456789 123456789 xyzxyzxyz XYZXYZXYZ +7 12345678 +8 12345678 +9 3456789 ab +20 DEFGHI 123 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +5 12345678 +6 12345678 +27 no truncation before FF; (r_l-test): +28 no trunc + + +29 xyzxyzxyz XYZXYZXYZ abcabcab +30 456789 123456789 xyzxyzxyz XYZXYZXYZ +1 12345678 +2 3456789 abcdefghi +3 12345678 +4 12345678 +5 12345678 +6 12345678 +7 12345678 +8 12345678 +9 3456789 abcdefghi +40 DEFGHI 123456789 +41 yzxyzxyz XYZXYZXYZ abcabcab +42 456789 123456789 abcdefghi ABCDEDFHI + + + +43 xyzxyzxyz XYZXYZXYZ abcabcab +44 456789 123456789 xyzxyzxyz XYZXYZXYZ +5 12345678 +6 12345678 +7 12345678 +8 12345678 +9 12345678 +50 12345678 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +55 yzxyzxyz XYZXYZXYZ abcabcab +56 456789 123456789 abcdefghi ABCDEDFHI + +57 xyzxyzxyz XYZXYZXYZ abcabcab +58 456789 123456789 xyzxyzxyz XYZXYZXYZ +9 12345678 +60 DEFGHI 123456789 diff --git a/tests/fixtures/pr/a3-0F b/tests/fixtures/pr/a3-0F new file mode 100644 index 000000000..8f0b06290 --- /dev/null +++ b/tests/fixtures/pr/a3-0F @@ -0,0 +1,330 @@ + + +{last_modified_time} {file_name} Page 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 2 + + +1 FF-Test: FF's at St 2 Options -b -3 / -a 3 ------------------- +4 3456789 123456789 123 5 3 Columns downwards 6 FF-Arangements: Emp +7 \ftext; \f\ntext; 8 \f\ftext; \f\f\ntex 9 3456789 123456789 123 +10 zzzzzzzzzzzzzzzzzzz 1 2 +3 line truncation befor 14 456789 123456789 123 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 4 + + +15 xyzxyzxyz XYZXYZXYZ 16 456789 123456789 xyz 7 +8 9 3456789 ab 20 DEFGHI 123 +1 2 3 +4 5 6 +27 no truncation before 28 no trunc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 5 + + +29 xyzxyzxyz XYZXYZXYZ 30 456789 123456789 xyz 1 +2 3456789 abcdefghi 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/fixtures/pr/a3f-0F b/tests/fixtures/pr/a3f-0F new file mode 100644 index 000000000..9da2bb439 --- /dev/null +++ b/tests/fixtures/pr/a3f-0F @@ -0,0 +1,35 @@ + + +{last_modified_time} {file_name} Page 1 + + + + +{last_modified_time} {file_name} Page 2 + + +1 FF-Test: FF's at St 2 Options -b -3 / -a 3 ------------------- +4 3456789 123456789 123 5 3 Columns downwards 6 FF-Arangements: Emp +7 \ftext; \f\ntext; 8 \f\ftext; \f\f\ntex 9 3456789 123456789 123 +10 zzzzzzzzzzzzzzzzzzz 1 2 +3 line truncation befor 14 456789 123456789 123 + +{last_modified_time} {file_name} Page 3 + + + + +{last_modified_time} {file_name} Page 4 + + +15 xyzxyzxyz XYZXYZXYZ 16 456789 123456789 xyz 7 +8 9 3456789 ab 20 DEFGHI 123 +1 2 3 +4 5 6 +27 no truncation before 28 no trunc + +{last_modified_time} {file_name} Page 5 + + +29 xyzxyzxyz XYZXYZXYZ 30 456789 123456789 xyz 1 +2 3456789 abcdefghi 3 \ No newline at end of file diff --git a/tests/fixtures/pr/l24-FF b/tests/fixtures/pr/l24-FF new file mode 100644 index 000000000..497d2f33a --- /dev/null +++ b/tests/fixtures/pr/l24-FF @@ -0,0 +1,216 @@ + + +{last_modified_time} {file_name} Page 1 + + +1 FF-Test: FF's in Text V +2 Options -b -3 / -a -3 / ... +3 -------------------------------------------- +4 3456789 123456789 123456789 123456789 12345678 +5 3 Columns downwards ..., <= 5 lines per page +6 FF-Arangements: One Empty Page +7 text\f\f\n; text\f\n\ftext; \f\ftext; +8 \f\f\n; \f\n\f\n; +9 +10 zzzzzzzzzzzzzzzzzzzzzzzzzz123456789 +1 12345678 +2 12345678 +3 line truncation before FF; r_r_o_l-test: +14 456789 123456789 123456789 123456789 + + + + + + + +{last_modified_time} {file_name} Page 2 + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 3 + + +15 xyzxyzxyz XYZXYZXYZ abcabcab +16 456789 123456789 xyzxyzxyz XYZXYZXYZ +7 12345678 +8 12345678 +9 3456789 ab +20 DEFGHI 123 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +5 12345678 +6 12345678 +27 no truncation before FF; (r_l-test): +28 no trunc + + + + + + + +{last_modified_time} {file_name} Page 4 + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 5 + + +29 xyzxyzxyz XYZXYZXYZ abcabcab +30 456789 123456789 xyzxyzxyz XYZXYZXYZ +1 12345678 +2 3456789 abcdefghi +3 12345678 +4 12345678 +5 12345678 +6 12345678 +7 12345678 +8 12345678 +9 3456789 abcdefghi +40 DEFGHI 123456789 +41 yzxyzxyz XYZXYZXYZ abcabcab +42 456789 123456789 abcdefghi ABCDEDFHI + + + + + + + +{last_modified_time} {file_name} Page 6 + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 7 + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 8 + + +43 xyzxyzxyz XYZXYZXYZ abcabcab +44 456789 123456789 xyzxyzxyz XYZXYZXYZ +5 12345678 +6 12345678 +7 12345678 +8 12345678 +9 12345678 +50 12345678 +1 12345678 +2 12345678 +3 12345678 +4 12345678 +55 yzxyzxyz XYZXYZXYZ abcabcab +56 456789 123456789 abcdefghi ABCDEDFHI + + + + + + + +{last_modified_time} {file_name} Page 9 + + +57 xyzxyzxyz XYZXYZXYZ abcabcab +58 456789 123456789 xyzxyzxyz XYZXYZXYZ +9 12345678 +60 DEFGHI 123456789 + + + + + + + + + + + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index d02b42436..af93d949f 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -471,3 +471,49 @@ fn test_with_offset_space_option() { vec![(&"{last_modified_time}".to_string(), &value)], ); } + +#[test] +fn test_with_pr_core_utils_tests() { + let test_cases = vec![ + ("", vec!["0Ft"], vec!["0F"], 0), + ("", vec!["0Fnt"], vec!["0F"], 0), + ("+3", vec!["0Ft"], vec!["3-0F"], 0), + ("+3 -f", vec!["0Ft"], vec!["3f-0F"], 0), + ("-a -3", vec!["0Ft"], vec!["a3-0F"], 0), + ("-a -3 -f", vec!["0Ft"], vec!["a3f-0F"], 0), + ("-a -3 -f", vec!["0Fnt"], vec!["a3f-0F"], 0), + ("+3 -a -3 -f", vec!["0Ft"], vec!["3a3f-0F"], 0), + ("-l 24", vec!["FnFn"], vec!["l24-FF"], 0), + ]; + + for test_case in test_cases { + let (flags, input_file, expected_file, return_code) = test_case; + let mut scenario = new_ucmd!(); + let input_file_path = input_file.get(0).unwrap(); + let test_file_path = expected_file.get(0).unwrap(); + let value = file_last_modified_time(&scenario, test_file_path); + let mut arguments: Vec<&str> = flags + .split(' ') + .into_iter() + .filter(|i| i.trim() != "") + .collect::>(); + + arguments.extend(input_file.clone()); + + let mut scenario_with_args = scenario.args(&arguments); + + let scenario_with_expected_status = if return_code == 0 { + scenario_with_args.succeeds() + } else { + scenario_with_args.fails() + }; + + scenario_with_expected_status.stdout_is_templated_fixture( + test_file_path, + vec![ + (&"{last_modified_time}".to_string(), &value), + (&"{file_name}".to_string(), &input_file_path.to_string()), + ], + ); + } +} From 4bf5b86cde2b8173b1b11cb82eb4014e8288e2f9 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Fri, 4 Jan 2019 23:14:04 +0530 Subject: [PATCH 038/126] pr: add last page option in +page --- src/pr/pr.rs | 21 ++++++++++++++++++--- tests/test_pr.rs | 8 ++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 6617f0bb1..2de3a663f 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -598,10 +598,11 @@ fn build_options( }; // +page option is less priority than --pages - let re = Regex::new(r"\s*\+(\d+)\s*").unwrap(); + let re = Regex::new(r"\s*\+(\d+:*\d*)\s*").unwrap(); let start_page_in_plus_option: usize = match re.captures(&free_args).map(|i| { let unparsed_num = i.get(1).unwrap().as_str().trim(); - unparsed_num.parse::().map_err(|_e| { + let x: Vec<&str> = unparsed_num.split(":").collect(); + x[0].to_string().parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) }) }) { @@ -609,6 +610,20 @@ fn build_options( _ => 1, }; + let end_page_in_plus_option: Option = match re + .captures(&free_args) + .map(|i| i.get(1).unwrap().as_str().trim()) + .filter(|i| i.contains(":")) + .map(|unparsed_num| { + let x: Vec<&str> = unparsed_num.split(":").collect(); + x[1].to_string().parse::().map_err(|_e| { + PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) + }) + }) { + Some(res) => Some(res?), + _ => None, + }; + let start_page: usize = match matches .opt_str(PAGE_RANGE_OPTION) .map(|i| { @@ -631,7 +646,7 @@ fn build_options( .map(invalid_pages_map) { Some(res) => Some(res?), - _ => None, + _ => end_page_in_plus_option, }; if end_page.is_some() && start_page > end_page.unwrap() { diff --git a/tests/test_pr.rs b/tests/test_pr.rs index af93d949f..863486878 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -273,6 +273,14 @@ fn test_with_page_range() { expected_test_file_path1, vec![(&"{last_modified_time}".to_string(), &value)], ); + + new_ucmd!() + .args(&["+15:17", test_file_path]) + .succeeds() + .stdout_is_templated_fixture( + expected_test_file_path1, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] From a4b723233a26e51220d1c0287f4c31994b02f59b Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sun, 6 Jan 2019 14:49:32 +0530 Subject: [PATCH 039/126] pr: add more tests for form feed and include page_width option W --- src/pr/pr.rs | 109 +++++++++++++------ tests/fixtures/pr/3a3f-0F | 3 +- tests/fixtures/pr/3f-0F | 52 +-------- tests/fixtures/pr/W20l24f-ll | 106 ++++++++++++++++++ tests/fixtures/pr/a3-0F | 6 +- tests/fixtures/pr/a3f-0F | 8 +- tests/fixtures/pr/l24-FF | 202 ++++++++++++++++++++++++++--------- tests/fixtures/pr/tFFt-ll | 56 ++++++++++ tests/test_pr.rs | 1 + 9 files changed, 400 insertions(+), 143 deletions(-) create mode 100644 tests/fixtures/pr/W20l24f-ll create mode 100644 tests/fixtures/pr/tFFt-ll diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 2de3a663f..f463a9890 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -54,6 +54,7 @@ static SUPPRESS_PRINTING_ERROR: &str = "r"; static FORM_FEED_OPTION: &str = "F"; static FORM_FEED_OPTION_SMALL: &str = "f"; static COLUMN_WIDTH_OPTION: &str = "w"; +static PAGE_WIDTH_OPTION: &str = "W"; static ACROSS_OPTION: &str = "a"; static COLUMN_OPTION: &str = "column"; static COLUMN_SEPARATOR_OPTION: &str = "s"; @@ -62,6 +63,7 @@ static OFFSET_SPACES_OPTION: &str = "o"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; +static DEFAULT_COLUMN_WIDTH_WITH_S_OPTION: usize = 512; static DEFAULT_COLUMN_SEPARATOR: &char = &TAB; static BLANK_STRING: &str = ""; static FF: u8 = 0x0C as u8; @@ -84,6 +86,7 @@ struct OutputOptions { merge_files_print: Option, offset_spaces: usize, form_feed_used: bool, + page_width: Option, } struct FileLine { @@ -247,9 +250,9 @@ pub fn uumain(args: Vec) -> i32 { opts.opt( PAGE_LENGTH_OPTION, "length", - "Override the 66-line default and reset the page length to lines. If lines is not greater than the sum of both + "Override the 66-line default (default number of lines of text 56, and with -F 63) and reset the page length to lines. If lines is not greater than the sum of both the header and trailer depths (in lines), the pr utility shall suppress both the header and trailer, as if the - -t option were in effect.", + -t option were in effect. ", "lines", HasArg::Yes, Occur::Optional, @@ -306,6 +309,17 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + PAGE_WIDTH_OPTION, + "page-width", + "set page width to PAGE_WIDTH (72) characters always, + truncate lines, except -J option is set, no interference + with -S or -s", + "[width]", + HasArg::Yes, + Occur::Optional, + ); + opts.opt( ACROSS_OPTION, "across", @@ -498,6 +512,9 @@ fn build_options( paths: &Vec, free_args: String, ) -> Result { + let form_feed_used = + matches.opt_present(FORM_FEED_OPTION) || matches.opt_present(FORM_FEED_OPTION_SMALL); + let invalid_pages_map = |i: String| { let unparsed_value: String = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); i.parse::().map_err(|_e| { @@ -657,8 +674,10 @@ fn build_options( ))); } + let default_lines_per_page = if form_feed_used { 63 } else { LINES_PER_PAGE }; + let page_length: usize = - parse_usize(matches, PAGE_LENGTH_OPTION).unwrap_or(Ok(LINES_PER_PAGE))?; + parse_usize(matches, PAGE_LENGTH_OPTION).unwrap_or(Ok(default_lines_per_page))?; let page_length_le_ht: bool = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); @@ -678,15 +697,27 @@ fn build_options( NEW_LINE.to_string() }; - let column_width: usize = - parse_usize(matches, COLUMN_WIDTH_OPTION).unwrap_or(Ok(DEFAULT_COLUMN_WIDTH))?; - let across_mode: bool = matches.opt_present(ACROSS_OPTION); let column_separator: String = matches .opt_str(COLUMN_SEPARATOR_OPTION) .unwrap_or(DEFAULT_COLUMN_SEPARATOR.to_string()); + let default_column_width = if matches.opt_present(COLUMN_WIDTH_OPTION) + && matches.opt_present(COLUMN_SEPARATOR_OPTION) + { + DEFAULT_COLUMN_WIDTH_WITH_S_OPTION + } else { + DEFAULT_COLUMN_WIDTH + }; + + let column_width: usize = + parse_usize(matches, COLUMN_WIDTH_OPTION).unwrap_or(Ok(default_column_width))?; + let page_width: Option = match parse_usize(matches, PAGE_WIDTH_OPTION) { + Some(res) => Some(res?), + None => None, + }; + let re_col = Regex::new(r"\s*-(\d+)\s*").unwrap(); let start_column_option: Option = match re_col.captures(&free_args).map(|i| { @@ -717,8 +748,6 @@ fn build_options( }; let offset_spaces: usize = parse_usize(matches, OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?; - let form_feed_used = - matches.opt_present(FORM_FEED_OPTION) || matches.opt_present(FORM_FEED_OPTION_SMALL); Ok(OutputOptions { number: numbering_options, header, @@ -736,6 +765,7 @@ fn build_options( merge_files_print, offset_spaces, form_feed_used, + page_width, }) } @@ -834,11 +864,12 @@ fn pr(path: &String, options: &OutputOptions) -> Result { if file_line.line_content.is_err() { return Err(file_line.line_content.unwrap_err().into()); } - feed_line_present = is_form_feed_used; + let form_feeds_after: usize = file_line.form_feeds_after; + page_lines.push(file_line); - if page_lines.len() == lines_needed_per_page || file_line.form_feeds_after > 0 { - if file_line.form_feeds_after > 1 { + if page_lines.len() == lines_needed_per_page || form_feeds_after > 0 { + if form_feeds_after > 1 { print_page( &page_lines, options, @@ -849,15 +880,20 @@ fn pr(path: &String, options: &OutputOptions) -> Result { )?; page_lines.clear(); page_number += 1; - print_page( - &page_lines, - options, - &page_number, - &start_page, - &last_page, - feed_line_present, - )?; - page_number += 1; + + // insert empty pages + let empty_pages_required = form_feeds_after - 1; + for _i in 0..empty_pages_required { + print_page( + &page_lines, + options, + &page_number, + &start_page, + &last_page, + feed_line_present, + )?; + page_number += 1; + } } else { print_page( &page_lines, @@ -871,18 +907,17 @@ fn pr(path: &String, options: &OutputOptions) -> Result { } page_lines.clear(); } - if file_line.form_feeds_after == 0 { - page_lines.push(file_line); - } } - print_page( - &page_lines, - options, - &page_number, - &start_page, - &last_page, - feed_line_present, - )?; + if page_lines.len() != 0 { + print_page( + &page_lines, + options, + &page_number, + &start_page, + &last_page, + feed_line_present, + )?; + } return Ok(0); } @@ -1131,6 +1166,8 @@ fn write_columns( .unwrap_or(None), ); + let page_width: Option = options.page_width; + let across_mode = options .column_mode_options .as_ref() @@ -1178,6 +1215,7 @@ fn write_columns( is_number_mode, &options.merge_files_print, &i, + page_width ) ); out.write(trimmed_line.as_bytes())?; @@ -1204,6 +1242,7 @@ fn get_line_for_printing( is_number_mode: bool, merge_files_print: &Option, index: &usize, + page_width: Option, ) -> String { let should_show_line_number_merge_file = merge_files_print.is_none() || index == &usize::min_value(); @@ -1224,7 +1263,13 @@ fn get_line_for_printing( let display_length = complete_line.len() + (tab_count * 7); // TODO Adjust the width according to -n option // TODO actual len of the string vs display len of string because of tabs - col_width + + let width: Option = match col_width { + Some(x) => Some(x), + None => page_width, + }; + + width .map(|i| { let min_width = (i - (columns - 1)) / columns; if display_length < min_width { diff --git a/tests/fixtures/pr/3a3f-0F b/tests/fixtures/pr/3a3f-0F index a2535574f..6097374c7 100644 --- a/tests/fixtures/pr/3a3f-0F +++ b/tests/fixtures/pr/3a3f-0F @@ -12,7 +12,8 @@ 8 9 3456789 ab 20 DEFGHI 123 1 2 3 4 5 6 -27 no truncation before 28 no trunc +27 no truncation before 28 no trunc + {last_modified_time} {file_name} Page 5 diff --git a/tests/fixtures/pr/3f-0F b/tests/fixtures/pr/3f-0F index 06e47aa66..d32c1f8f6 100644 --- a/tests/fixtures/pr/3f-0F +++ b/tests/fixtures/pr/3f-0F @@ -22,6 +22,7 @@ 6 12345678 27 no truncation before FF; (r_l-test): 28 no trunc + {last_modified_time} {file_name} Page 5 @@ -32,55 +33,4 @@ 1 12345678 2 3456789 abcdefghi 3 12345678 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/fixtures/pr/W20l24f-ll b/tests/fixtures/pr/W20l24f-ll new file mode 100644 index 000000000..d95c04c37 --- /dev/null +++ b/tests/fixtures/pr/W20l24f-ll @@ -0,0 +1,106 @@ + + +{last_modified_time} {file_name} Page 1 + + +1<<< -Test: FF's in +2<<< -b -3 / -a -3 +3<<< >>> +4<<< 123456789 1234 + +6<<< -Arangements: +7<<< \f\f\n; text\f +8<<< f\f\n; \f\n\f\ +9<<< >>> +10<<< >>> +1<<< >>> +2<<< >>> +3<<< truncation bef +14<<< 123456789 123 + + +{last_modified_time} {file_name} Page 2 + + + + +{last_modified_time} {file_name} Page 3 + + +15<<< xyzxyzxyz XYZ +16<<< 123456789 xyz +7<<< >>> +8<<< >>> +9<<< >>> +20<<< >>> +1<<< >>> + + +4<<< >>> +5<<< >>> +6<<< >>> +27<<< truncation be +28<<< trunc + + +{last_modified_time} {file_name} Page 4 + + + + +{last_modified_time} {file_name} Page 5 + + +29<<>> +2<<< abcdefghi >>> +3<<< >>> +4<<< >>> +5<<< >>> +6<<< >>> +7<<< >>> +8<<< >>> +9<<< abcdefghi >>> +40<<< 123456789 >> +41<<< XYZXYZXYZ abc +42<<< 123456789 abc + + +{last_modified_time} {file_name} Page 6 + + + + +{last_modified_time} {file_name} Page 7 + + + + +{last_modified_time} {file_name} Page 8 + + +43<<< xyzxyzxyz XYZ +44<<< 123456789 xyz +5<<< >>> +6<<< >>> +7<<< >>> +8<<< >>> +9<<< >>> +50<<< >>> +1<<< >>> +2<<< >>> +3<<< >>> +4<<< >>> +55<<< XYZXYZXYZ abc +56<<< 123456789 abc + + +{last_modified_time} {file_name} Page 9 + + +57<<< xyzxyzxyz XYZ +58<<< 123456789 xyz +9<<< >>> +60<<< 123456789 >> + \ No newline at end of file diff --git a/tests/fixtures/pr/a3-0F b/tests/fixtures/pr/a3-0F index 8f0b06290..58aeb07c2 100644 --- a/tests/fixtures/pr/a3-0F +++ b/tests/fixtures/pr/a3-0F @@ -3,7 +3,7 @@ {last_modified_time} {file_name} Page 1 - + @@ -73,7 +73,7 @@ 4 3456789 123456789 123 5 3 Columns downwards 6 FF-Arangements: Emp 7 \ftext; \f\ntext; 8 \f\ftext; \f\f\ntex 9 3456789 123456789 123 10 zzzzzzzzzzzzzzzzzzz 1 2 -3 line truncation befor 14 456789 123456789 123 +3 line truncation befor 14 456789 123456789 123 @@ -205,7 +205,7 @@ 8 9 3456789 ab 20 DEFGHI 123 1 2 3 4 5 6 -27 no truncation before 28 no trunc +27 no truncation before 28 no trunc diff --git a/tests/fixtures/pr/a3f-0F b/tests/fixtures/pr/a3f-0F index 9da2bb439..24939c004 100644 --- a/tests/fixtures/pr/a3f-0F +++ b/tests/fixtures/pr/a3f-0F @@ -3,7 +3,7 @@ {last_modified_time} {file_name} Page 1 - + {last_modified_time} {file_name} Page 2 @@ -12,7 +12,8 @@ 4 3456789 123456789 123 5 3 Columns downwards 6 FF-Arangements: Emp 7 \ftext; \f\ntext; 8 \f\ftext; \f\f\ntex 9 3456789 123456789 123 10 zzzzzzzzzzzzzzzzzzz 1 2 -3 line truncation befor 14 456789 123456789 123 +3 line truncation befor 14 456789 123456789 123 + {last_modified_time} {file_name} Page 3 @@ -26,7 +27,8 @@ 8 9 3456789 ab 20 DEFGHI 123 1 2 3 4 5 6 -27 no truncation before 28 no trunc +27 no truncation before 28 no trunc + {last_modified_time} {file_name} Page 5 diff --git a/tests/fixtures/pr/l24-FF b/tests/fixtures/pr/l24-FF index 497d2f33a..de219b2fb 100644 --- a/tests/fixtures/pr/l24-FF +++ b/tests/fixtures/pr/l24-FF @@ -51,6 +51,30 @@ {last_modified_time} {file_name} Page 3 + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 4 + + 15 xyzxyzxyz XYZXYZXYZ abcabcab 16 456789 123456789 xyzxyzxyz XYZXYZXYZ 7 12345678 @@ -69,50 +93,26 @@ - - - -{last_modified_time} {file_name} Page 4 - - - - - - - - - - - - - - - - - - - - {last_modified_time} {file_name} Page 5 -29 xyzxyzxyz XYZXYZXYZ abcabcab -30 456789 123456789 xyzxyzxyz XYZXYZXYZ -1 12345678 -2 3456789 abcdefghi -3 12345678 -4 12345678 -5 12345678 -6 12345678 -7 12345678 -8 12345678 -9 3456789 abcdefghi -40 DEFGHI 123456789 -41 yzxyzxyz XYZXYZXYZ abcabcab -42 456789 123456789 abcdefghi ABCDEDFHI + + + + + + + + + + + + + + @@ -147,20 +147,20 @@ {last_modified_time} {file_name} Page 7 - - - - - - - - - - - - - - +29 xyzxyzxyz XYZXYZXYZ abcabcab +30 456789 123456789 xyzxyzxyz XYZXYZXYZ +1 12345678 +2 3456789 abcdefghi +3 12345678 +4 12345678 +5 12345678 +6 12345678 +7 12345678 +8 12345678 +9 3456789 abcdefghi +40 DEFGHI 123456789 +41 yzxyzxyz XYZXYZXYZ abcabcab +42 456789 123456789 abcdefghi ABCDEDFHI @@ -171,6 +171,78 @@ {last_modified_time} {file_name} Page 8 + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 9 + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 10 + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 11 + + 43 xyzxyzxyz XYZXYZXYZ abcabcab 44 456789 123456789 xyzxyzxyz XYZXYZXYZ 5 12345678 @@ -192,7 +264,31 @@ -{last_modified_time} {file_name} Page 9 +{last_modified_time} {file_name} Page 12 + + + + + + + + + + + + + + + + + + + + + + + +{last_modified_time} {file_name} Page 13 57 xyzxyzxyz XYZXYZXYZ abcabcab diff --git a/tests/fixtures/pr/tFFt-ll b/tests/fixtures/pr/tFFt-ll new file mode 100644 index 000000000..39eca655f --- /dev/null +++ b/tests/fixtures/pr/tFFt-ll @@ -0,0 +1,56 @@ +1<<< -Test: FF's in Text >>> +2<<< -b -3 / -a -3 / ... >>> +3<<< >>> +4<<< 123456789 123456789 123456789 123456789 123456789 123456789 123456789 >>> + +6<<< -Arangements: One Empty Page >>> +7<<< \f\f\n; text\f\n\ftext; \f\ftext; >>> +8<<< f\f\n; \f\n\f\n; >>> +9<<< >>> +10<<< >>> +1<<< >>> +2<<< >>> +3<<< truncation before FF; r_r_o_l-test: >>> +14<<< 123456789 123456789 123456789 >>> 15<<< xyzxyzxyz XYZXYZXYZ abcabcab >>> +16<<< 123456789 xyzxyzxyz XYZXYZXYZ >>> +7<<< >>> +8<<< >>> +9<<< >>> +20<<< >>> +1<<< >>> + + +4<<< >>> +5<<< >>> +6<<< >>> +27<<< truncation before FF; (r_l-test): >>> +28<<< trunc 29<<>> +30<<< 123456789 xyzxyzxyz XYZXYZXYZ >>> +1<<< >>> +2<<< abcdefghi >>> +3<<< >>> +4<<< >>> +5<<< >>> +6<<< >>> +7<<< >>> +8<<< >>> +9<<< abcdefghi >>> +40<<< 123456789 >>> +41<<< XYZXYZXYZ abcabcab >>> +42<<< 123456789 abcdefghi ABCDEDFHI >>> 43<<< xyzxyzxyz XYZXYZXYZ abcabcab >>> +44<<< 123456789 xyzxyzxyz XYZXYZXYZ >>> +5<<< >>> +6<<< >>> +7<<< >>> +8<<< >>> +9<<< >>> +50<<< >>> +1<<< >>> +2<<< >>> +3<<< >>> +4<<< >>> +55<<< XYZXYZXYZ abcabcab >>> +56<<< 123456789 abcdefghi ABCDEDFHI >>> 57<<< xyzxyzxyz XYZXYZXYZ abcabcab >>> +58<<< 123456789 xyzxyzxyz XYZXYZXYZ >>> +9<<< >>> +60<<< 123456789 >>> diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 863486878..1026b77a9 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -492,6 +492,7 @@ fn test_with_pr_core_utils_tests() { ("-a -3 -f", vec!["0Fnt"], vec!["a3f-0F"], 0), ("+3 -a -3 -f", vec!["0Ft"], vec!["3a3f-0F"], 0), ("-l 24", vec!["FnFn"], vec!["l24-FF"], 0), + ("-W 20 -l24 -f", vec!["tFFt-ll"], vec!["W20l24f-ll"], 0), ]; for test_case in test_cases { From 40e7f3d9009e8caaa42b3033a69177635f39d111 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sun, 6 Jan 2019 16:12:23 +0530 Subject: [PATCH 040/126] pr: add -J and -S option pr: add -J option pr: add -S option --- src/pr/pr.rs | 105 +++++++--- .../pr/column_across_sep1.log.expected | 198 ++++++++++++++++++ tests/fixtures/pr/joined.log.expected | 132 ++++++++++++ tests/test_pr.rs | 31 +++ 4 files changed, 433 insertions(+), 33 deletions(-) create mode 100644 tests/fixtures/pr/column_across_sep1.log.expected create mode 100644 tests/fixtures/pr/joined.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index f463a9890..f60d24a4c 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -57,9 +57,11 @@ static COLUMN_WIDTH_OPTION: &str = "w"; static PAGE_WIDTH_OPTION: &str = "W"; static ACROSS_OPTION: &str = "a"; static COLUMN_OPTION: &str = "column"; -static COLUMN_SEPARATOR_OPTION: &str = "s"; +static COLUMN_CHAR_SEPARATOR_OPTION: &str = "s"; +static COLUMN_STRING_SEPARATOR_OPTION: &str = "S"; static MERGE_FILES_PRINT: &str = "m"; static OFFSET_SPACES_OPTION: &str = "o"; +static JOIN_LINES_OPTION: &str = "J"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; @@ -87,6 +89,7 @@ struct OutputOptions { offset_spaces: usize, form_feed_used: bool, page_width: Option, + join_lines: bool, } struct FileLine { @@ -332,8 +335,8 @@ pub fn uumain(args: Vec) -> i32 { ); opts.opt( - COLUMN_SEPARATOR_OPTION, - "", + COLUMN_CHAR_SEPARATOR_OPTION, + "separator", "Separate text columns by the single character char instead of by the appropriate number of s (default for char is the character).", "char", @@ -341,6 +344,17 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + COLUMN_STRING_SEPARATOR_OPTION, + "sep-string", + "separate columns by STRING, + without -S: Default separator with -J and + otherwise (same as -S\" \"), no effect on column options", + "string", + HasArg::Yes, + Occur::Optional, + ); + opts.opt( MERGE_FILES_PRINT, "merge", @@ -362,6 +376,16 @@ pub fn uumain(args: Vec) -> i32 { Occur::Optional, ); + opts.opt( + JOIN_LINES_OPTION, + "join-lines", + "merge full lines, turns off -W line truncation, no column + alignment, --sep-string[=STRING] sets separators", + "offset", + HasArg::No, + Occur::Optional, + ); + opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); @@ -648,10 +672,10 @@ fn build_options( x[0].to_string() }) .map(invalid_pages_map) - { - Some(res) => res?, - _ => start_page_in_plus_option, - }; + { + Some(res) => res?, + _ => start_page_in_plus_option, + }; let end_page: Option = match matches .opt_str(PAGE_RANGE_OPTION) @@ -661,10 +685,10 @@ fn build_options( x[1].to_string() }) .map(invalid_pages_map) - { - Some(res) => Some(res?), - _ => end_page_in_plus_option, - }; + { + Some(res) => Some(res?), + _ => end_page_in_plus_option, + }; if end_page.is_some() && start_page > end_page.unwrap() { return Err(PrError::EncounteredErrors(format!( @@ -699,12 +723,15 @@ fn build_options( let across_mode: bool = matches.opt_present(ACROSS_OPTION); - let column_separator: String = matches - .opt_str(COLUMN_SEPARATOR_OPTION) + let column_separator: String = match matches.opt_str(COLUMN_STRING_SEPARATOR_OPTION) + { + Some(x) => Some(x), + None => matches.opt_str(COLUMN_CHAR_SEPARATOR_OPTION), + } .unwrap_or(DEFAULT_COLUMN_SEPARATOR.to_string()); let default_column_width = if matches.opt_present(COLUMN_WIDTH_OPTION) - && matches.opt_present(COLUMN_SEPARATOR_OPTION) + && matches.opt_present(COLUMN_CHAR_SEPARATOR_OPTION) { DEFAULT_COLUMN_WIDTH_WITH_S_OPTION } else { @@ -713,9 +740,14 @@ fn build_options( let column_width: usize = parse_usize(matches, COLUMN_WIDTH_OPTION).unwrap_or(Ok(default_column_width))?; - let page_width: Option = match parse_usize(matches, PAGE_WIDTH_OPTION) { - Some(res) => Some(res?), - None => None, + + let page_width: Option = if matches.opt_present(JOIN_LINES_OPTION) { + None + } else { + match parse_usize(matches, PAGE_WIDTH_OPTION) { + Some(res) => Some(res?), + None => None, + } }; let re_col = Regex::new(r"\s*-(\d+)\s*").unwrap(); @@ -748,6 +780,8 @@ fn build_options( }; let offset_spaces: usize = parse_usize(matches, OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?; + let join_lines: bool = matches.opt_present(JOIN_LINES_OPTION); + Ok(OutputOptions { number: numbering_options, header, @@ -766,6 +800,7 @@ fn build_options( offset_spaces, form_feed_used, page_width, + join_lines, }) } @@ -1133,7 +1168,7 @@ fn write_columns( options.content_lines_per_page }; - let width: usize = options.number.as_ref().map(|i| i.width).unwrap_or(0); + let number_width: usize = options.number.as_ref().map(|i| i.width).unwrap_or(0); let number_separator: String = options .number .as_ref() @@ -1168,6 +1203,18 @@ fn write_columns( let page_width: Option = options.page_width; + let line_width: Option = if options.join_lines { + None + } else if columns > 1 { + options + .column_mode_options + .as_ref() + .map(|i| Some(i.width)) + .unwrap_or(Some(DEFAULT_COLUMN_WIDTH)) + } else { + options.page_width + }; + let across_mode = options .column_mode_options .as_ref() @@ -1208,18 +1255,17 @@ fn write_columns( spaces, get_line_for_printing( file_line, - &width, + &number_width, &number_separator, columns, - col_width, is_number_mode, &options.merge_files_print, &i, - page_width + line_width, ) ); out.write(trimmed_line.as_bytes())?; - if (i + 1) != indexes { + if (i + 1) != indexes && !options.join_lines { out.write(col_sep.as_bytes())?; } lines_printed += 1; @@ -1235,20 +1281,19 @@ fn write_columns( fn get_line_for_printing( file_line: &FileLine, - width: &usize, + number_width: &usize, separator: &String, columns: usize, - col_width: Option, is_number_mode: bool, merge_files_print: &Option, index: &usize, - page_width: Option, + line_width: Option, ) -> String { let should_show_line_number_merge_file = merge_files_print.is_none() || index == &usize::min_value(); let should_show_line_number = is_number_mode && should_show_line_number_merge_file; let fmtd_line_number: String = if should_show_line_number { - get_fmtd_line_number(&width, file_line.line_number, &separator) + get_fmtd_line_number(&number_width, file_line.line_number, &separator) } else { "".to_string() }; @@ -1263,13 +1308,7 @@ fn get_line_for_printing( let display_length = complete_line.len() + (tab_count * 7); // TODO Adjust the width according to -n option // TODO actual len of the string vs display len of string because of tabs - - let width: Option = match col_width { - Some(x) => Some(x), - None => page_width, - }; - - width + line_width .map(|i| { let min_width = (i - (columns - 1)) / columns; if display_length < min_width { diff --git a/tests/fixtures/pr/column_across_sep1.log.expected b/tests/fixtures/pr/column_across_sep1.log.expected new file mode 100644 index 000000000..f9dd454d7 --- /dev/null +++ b/tests/fixtures/pr/column_across_sep1.log.expected @@ -0,0 +1,198 @@ + + +{last_modified_time} column.log Page 3 + + + 337 337 divide 338 338 divide 339 339 + 340 340 divide 341 341 divide 342 342 + 343 343 divide 344 344 divide 345 345 + 346 346 divide 347 347 divide 348 348 + 349 349 divide 350 350 divide 351 351 + 352 352 divide 353 353 divide 354 354 + 355 355 divide 356 356 divide 357 357 + 358 358 divide 359 359 divide 360 360 + 361 361 divide 362 362 divide 363 363 + 364 364 divide 365 365 divide 366 366 + 367 367 divide 368 368 divide 369 369 + 370 370 divide 371 371 divide 372 372 + 373 373 divide 374 374 divide 375 375 + 376 376 divide 377 377 divide 378 378 + 379 379 divide 380 380 divide 381 381 + 382 382 divide 383 383 divide 384 384 + 385 385 divide 386 386 divide 387 387 + 388 388 divide 389 389 divide 390 390 + 391 391 divide 392 392 divide 393 393 + 394 394 divide 395 395 divide 396 396 + 397 397 divide 398 398 divide 399 399 + 400 400 divide 401 401 divide 402 402 + 403 403 divide 404 404 divide 405 405 + 406 406 divide 407 407 divide 408 408 + 409 409 divide 410 410 divide 411 411 + 412 412 divide 413 413 divide 414 414 + 415 415 divide 416 416 divide 417 417 + 418 418 divide 419 419 divide 420 420 + 421 421 divide 422 422 divide 423 423 + 424 424 divide 425 425 divide 426 426 + 427 427 divide 428 428 divide 429 429 + 430 430 divide 431 431 divide 432 432 + 433 433 divide 434 434 divide 435 435 + 436 436 divide 437 437 divide 438 438 + 439 439 divide 440 440 divide 441 441 + 442 442 divide 443 443 divide 444 444 + 445 445 divide 446 446 divide 447 447 + 448 448 divide 449 449 divide 450 450 + 451 451 divide 452 452 divide 453 453 + 454 454 divide 455 455 divide 456 456 + 457 457 divide 458 458 divide 459 459 + 460 460 divide 461 461 divide 462 462 + 463 463 divide 464 464 divide 465 465 + 466 466 divide 467 467 divide 468 468 + 469 469 divide 470 470 divide 471 471 + 472 472 divide 473 473 divide 474 474 + 475 475 divide 476 476 divide 477 477 + 478 478 divide 479 479 divide 480 480 + 481 481 divide 482 482 divide 483 483 + 484 484 divide 485 485 divide 486 486 + 487 487 divide 488 488 divide 489 489 + 490 490 divide 491 491 divide 492 492 + 493 493 divide 494 494 divide 495 495 + 496 496 divide 497 497 divide 498 498 + 499 499 divide 500 500 divide 501 501 + 502 502 divide 503 503 divide 504 504 + + + + + + + +{last_modified_time} column.log Page 4 + + + 505 505 divide 506 506 divide 507 507 + 508 508 divide 509 509 divide 510 510 + 511 511 divide 512 512 divide 513 513 + 514 514 divide 515 515 divide 516 516 + 517 517 divide 518 518 divide 519 519 + 520 520 divide 521 521 divide 522 522 + 523 523 divide 524 524 divide 525 525 + 526 526 divide 527 527 divide 528 528 + 529 529 divide 530 530 divide 531 531 + 532 532 divide 533 533 divide 534 534 + 535 535 divide 536 536 divide 537 537 + 538 538 divide 539 539 divide 540 540 + 541 541 divide 542 542 divide 543 543 + 544 544 divide 545 545 divide 546 546 + 547 547 divide 548 548 divide 549 549 + 550 550 divide 551 551 divide 552 552 + 553 553 divide 554 554 divide 555 555 + 556 556 divide 557 557 divide 558 558 + 559 559 divide 560 560 divide 561 561 + 562 562 divide 563 563 divide 564 564 + 565 565 divide 566 566 divide 567 567 + 568 568 divide 569 569 divide 570 570 + 571 571 divide 572 572 divide 573 573 + 574 574 divide 575 575 divide 576 576 + 577 577 divide 578 578 divide 579 579 + 580 580 divide 581 581 divide 582 582 + 583 583 divide 584 584 divide 585 585 + 586 586 divide 587 587 divide 588 588 + 589 589 divide 590 590 divide 591 591 + 592 592 divide 593 593 divide 594 594 + 595 595 divide 596 596 divide 597 597 + 598 598 divide 599 599 divide 600 600 + 601 601 divide 602 602 divide 603 603 + 604 604 divide 605 605 divide 606 606 + 607 607 divide 608 608 divide 609 609 + 610 610 divide 611 611 divide 612 612 + 613 613 divide 614 614 divide 615 615 + 616 616 divide 617 617 divide 618 618 + 619 619 divide 620 620 divide 621 621 + 622 622 divide 623 623 divide 624 624 + 625 625 divide 626 626 divide 627 627 + 628 628 divide 629 629 divide 630 630 + 631 631 divide 632 632 divide 633 633 + 634 634 divide 635 635 divide 636 636 + 637 637 divide 638 638 divide 639 639 + 640 640 divide 641 641 divide 642 642 + 643 643 divide 644 644 divide 645 645 + 646 646 divide 647 647 divide 648 648 + 649 649 divide 650 650 divide 651 651 + 652 652 divide 653 653 divide 654 654 + 655 655 divide 656 656 divide 657 657 + 658 658 divide 659 659 divide 660 660 + 661 661 divide 662 662 divide 663 663 + 664 664 divide 665 665 divide 666 666 + 667 667 divide 668 668 divide 669 669 + 670 670 divide 671 671 divide 672 672 + + + + + + + +{last_modified_time} column.log Page 5 + + + 673 673 divide 674 674 divide 675 675 + 676 676 divide 677 677 divide 678 678 + 679 679 divide 680 680 divide 681 681 + 682 682 divide 683 683 divide 684 684 + 685 685 divide 686 686 divide 687 687 + 688 688 divide 689 689 divide 690 690 + 691 691 divide 692 692 divide 693 693 + 694 694 divide 695 695 divide 696 696 + 697 697 divide 698 698 divide 699 699 + 700 700 divide 701 701 divide 702 702 + 703 703 divide 704 704 divide 705 705 + 706 706 divide 707 707 divide 708 708 + 709 709 divide 710 710 divide 711 711 + 712 712 divide 713 713 divide 714 714 + 715 715 divide 716 716 divide 717 717 + 718 718 divide 719 719 divide 720 720 + 721 721 divide 722 722 divide 723 723 + 724 724 divide 725 725 divide 726 726 + 727 727 divide 728 728 divide 729 729 + 730 730 divide 731 731 divide 732 732 + 733 733 divide 734 734 divide 735 735 + 736 736 divide 737 737 divide 738 738 + 739 739 divide 740 740 divide 741 741 + 742 742 divide 743 743 divide 744 744 + 745 745 divide 746 746 divide 747 747 + 748 748 divide 749 749 divide 750 750 + 751 751 divide 752 752 divide 753 753 + 754 754 divide 755 755 divide 756 756 + 757 757 divide 758 758 divide 759 759 + 760 760 divide 761 761 divide 762 762 + 763 763 divide 764 764 divide 765 765 + 766 766 divide 767 767 divide 768 768 + 769 769 divide 770 770 divide 771 771 + 772 772 divide 773 773 divide 774 774 + 775 775 divide 776 776 divide 777 777 + 778 778 divide 779 779 divide 780 780 + 781 781 divide 782 782 divide 783 783 + 784 784 divide 785 785 divide 786 786 + 787 787 divide 788 788 divide 789 789 + 790 790 divide 791 791 divide 792 792 + 793 793 divide 794 794 divide 795 795 + 796 796 divide 797 797 divide 798 798 + 799 799 divide 800 800 divide 801 801 + 802 802 divide 803 803 divide 804 804 + 805 805 divide 806 806 divide 807 807 + 808 808 divide 809 809 divide 810 810 + 811 811 divide 812 812 divide 813 813 + 814 814 divide 815 815 divide 816 816 + 817 817 divide 818 818 divide 819 819 + 820 820 divide 821 821 divide 822 822 + 823 823 divide 824 824 divide 825 825 + 826 826 divide 827 827 divide 828 828 + 829 829 divide 830 830 divide 831 831 + 832 832 divide 833 833 divide 834 834 + 835 835 divide 836 836 divide 837 837 + 838 838 divide 839 839 divide 840 840 + + + + + diff --git a/tests/fixtures/pr/joined.log.expected b/tests/fixtures/pr/joined.log.expected new file mode 100644 index 000000000..a9cee6e4f --- /dev/null +++ b/tests/fixtures/pr/joined.log.expected @@ -0,0 +1,132 @@ + + +{last_modified_time} Page 1 + + +##ntation processAirPortStateChanges]: pppConnectionState 0 +# Host DatabaseMon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +#Mon Dec 10 11:42:56.705 Info: 802.1X changed +# localhost is used to configure the loopback interfaceMon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +# when the system is booting. Do not change this entry.Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +##Mon Dec 10 11:42:56.854 Info: 802.1X changed +127.0.0.1 localhostMon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +127.0.0.1 Techopss-MacBook-Pro.localMon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +127.0.0.1 tilakprMon Dec 10 11:42:57.002 Info: 802.1X changed +255.255.255.255 broadcasthostMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +::1 localhostMon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed + + + + + + + +{last_modified_time} Page 2 + + +Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_END (en0) +Mon Dec 10 11:42:59.372 Info: Roaming ended on interface en0 +Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: RSN_HANDSHAKE_DONE (en0) +Mon Dec 10 11:42:59.373 Info: -[CWXPCInterfaceContext setRoamInProgress:reason:]_block_invoke: roam status metric data: CWAWDMetricRoamStatus: status:0 security: 4 profile:5 origin:<34fcb9>(-69) target:<6cf37f>(-56) latency:6.083439s +Mon Dec 10 11:42:59.373 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90046 +Mon Dec 10 11:42:59.373 Info: RESUME AWDL for interface en0, reason=Roam token=2685 +Mon Dec 10 11:42:59.373 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=5] +Mon Dec 10 11:42:59.374 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 0 +Mon Dec 10 11:43:01.072 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP' +Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP +Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: DHCP airport_changed = 1 +Mon Dec 10 11:43:01.073 Info: -[CWXPCSubsystem internal_submitIPConfigLatencyMetric:leaseDuration:]: IPConfig Latency metric data: CWAWDMetricIPConfigLatencyData: DHCP latency: 29010 msecs, duration: 480 mins, security: 4 +Mon Dec 10 11:43:01.073 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90007 +Mon Dec 10 11:43:01.073 SC: _setDHCPMessage: dhcpInfoKey "State:/Network/Interface/en0/AirPort/DHCP Message" = (null) +Mon Dec 10 11:43:10.369 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:10.369 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=162 Mbps +Mon Dec 10 11:43:10.369 Info: link quality changed +Mon Dec 10 11:43:23.376 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:23.377 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps +Mon Dec 10 11:43:23.377 Info: link quality changed +Mon Dec 10 11:43:28.380 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) +Mon Dec 10 11:43:28.380 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps +Mon Dec 10 11:43:28.380 Info: link quality changed +Mon Dec 10 11:43:31.744 AutoJoin: BACKGROUND SCAN request on interface en0 with SSID list (null) +Mon Dec 10 11:43:31.747 Scan: Cache-assisted scan request on channel 1 does not require a live scan +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 2 does not require a live scan +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 3 does not require a live scan +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.748 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.748 [channelNumber=1(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.748 [channelNumber=2(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.748 [channelNumber=3(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:43:31.748 )} took 0.0025 seconds, returned 10 results +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 4 does not require a live scan +Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 5 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 6 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.749 [channelNumber=4(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.749 [channelNumber=5(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.749 [channelNumber=6(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:43:31.749 )} took 0.0008 seconds, returned 7 results +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 7 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 8 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 9 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request does not require a live scan +Mon Dec 10 11:43:31.749 AutoJoin: Successful cache-assisted background scan request with channels {( +Mon Dec 10 11:43:31.749 [channelNumber=7(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.749 [channelNumber=8(2GHz), channelWidth={20MHz}, active], +Mon Dec 10 11:43:31.749 [channelNumber=9(2GHz), channelWidth={20MHz}, active] +Mon Dec 10 11:43:31.749 )} took 0.0002 seconds, returned 1 results +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 10 does not require a live scan +Mon Dec 10 11:43:31.749 Scan: Cache-assisted scan request on channel 11 does not require a live scan +Mon Dec 10 11:43:31.750 Scan: Cache-assisted scan request on channel 12 does not require a live scan + + + + + diff --git a/tests/test_pr.rs b/tests/test_pr.rs index 1026b77a9..b4ff61ed7 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -382,6 +382,7 @@ fn test_with_column_across_option() { fn test_with_column_across_option_and_column_separator() { let test_file_path = "column.log"; let expected_test_file_path = "column_across_sep.log.expected"; + let expected_test_file_path1 = "column_across_sep1.log.expected"; let mut scenario = new_ucmd!(); let value = file_last_modified_time(&scenario, test_file_path); scenario @@ -398,6 +399,21 @@ fn test_with_column_across_option_and_column_separator() { expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)], ); + + new_ucmd!() + .args(&[ + "--pages=3:5", + "--column=3", + "-Sdivide", + "-a", + "-n", + test_file_path, + ]) + .succeeds() + .stdout_is_templated_fixture( + expected_test_file_path1, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] @@ -526,3 +542,18 @@ fn test_with_pr_core_utils_tests() { ); } } + +#[test] +fn test_with_join_lines_option() { + let test_file_1 = "hosts.log"; + let test_file_2 = "test.log"; + let expected_file_path = "joined.log.expected"; + let mut scenario = new_ucmd!(); + scenario + .args(&["+1:2", "-J", "-m", test_file_1, test_file_2]) + .run() + .stdout_is_templated_fixture( + expected_file_path, + vec![(&"{last_modified_time}".to_string(), &now_time())], + ); +} From aefc2eb5402766551713be02e8f3c042b8ce783f Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sun, 13 Jan 2019 19:49:51 +0530 Subject: [PATCH 041/126] pr: reformat with rustfmt pr: refactor batching of pages in pr --- src/pr/pr.rs | 268 ++++++++++++++++++++------------------------------- 1 file changed, 106 insertions(+), 162 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index f60d24a4c..90387a7da 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -20,6 +20,7 @@ use chrono::offset::Local; use chrono::DateTime; use getopts::{HasArg, Occur}; use getopts::{Matches, Options}; +use itertools::structs::Batching; use itertools::structs::KMergeBy; use itertools::{GroupBy, Itertools}; use quick_error::ResultExt; @@ -350,9 +351,9 @@ pub fn uumain(args: Vec) -> i32 { "separate columns by STRING, without -S: Default separator with -J and otherwise (same as -S\" \"), no effect on column options", - "string", - HasArg::Yes, - Occur::Optional, + "string", + HasArg::Yes, + Occur::Optional, ); opts.opt( @@ -672,10 +673,10 @@ fn build_options( x[0].to_string() }) .map(invalid_pages_map) - { - Some(res) => res?, - _ => start_page_in_plus_option, - }; + { + Some(res) => res?, + _ => start_page_in_plus_option, + }; let end_page: Option = match matches .opt_str(PAGE_RANGE_OPTION) @@ -685,10 +686,10 @@ fn build_options( x[1].to_string() }) .map(invalid_pages_map) - { - Some(res) => Some(res?), - _ => end_page_in_plus_option, - }; + { + Some(res) => Some(res?), + _ => end_page_in_plus_option, + }; if end_page.is_some() && start_page > end_page.unwrap() { return Err(PrError::EncounteredErrors(format!( @@ -723,12 +724,11 @@ fn build_options( let across_mode: bool = matches.opt_present(ACROSS_OPTION); - let column_separator: String = match matches.opt_str(COLUMN_STRING_SEPARATOR_OPTION) - { - Some(x) => Some(x), - None => matches.opt_str(COLUMN_CHAR_SEPARATOR_OPTION), - } - .unwrap_or(DEFAULT_COLUMN_SEPARATOR.to_string()); + let column_separator: String = match matches.opt_str(COLUMN_STRING_SEPARATOR_OPTION) { + Some(x) => Some(x), + None => matches.opt_str(COLUMN_CHAR_SEPARATOR_OPTION), + } + .unwrap_or(DEFAULT_COLUMN_SEPARATOR.to_string()); let default_column_width = if matches.opt_present(COLUMN_WIDTH_OPTION) && matches.opt_present(COLUMN_CHAR_SEPARATOR_OPTION) @@ -832,128 +832,102 @@ fn open(path: &str) -> Result, PrError> { .unwrap_or(Err(PrError::NotExists(path.to_string()))) } -fn pr(path: &String, options: &OutputOptions) -> Result { - let start_page: &usize = &options.start_page; - let start_line_number: usize = get_start_line_number(options); - let last_page: Option<&usize> = options.end_page.as_ref(); - let lines_needed_per_page: usize = lines_to_read_for_page(options); - let is_form_feed_used = options.form_feed_used; - let lines: Map>>, _>, _, _>>, _>, _> = - BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) - .lines() - .map(|file_content: Result| { - file_content - .map(|content| { - let mut lines: Vec = Vec::new(); - let mut f_occurred: usize = 0; - let mut chunk: Vec = Vec::new(); - for byte in content.as_bytes() { - if byte == &FF { - f_occurred += 1; - } else { - if f_occurred != 0 { - // First time byte occurred in the scan - lines.push(FileLine { - line_content: Ok(String::from_utf8(chunk.clone()).unwrap()), - form_feeds_after: f_occurred, - ..FileLine::default() - }); - chunk.clear(); - } - chunk.push(*byte); - f_occurred = 0; - } - } - +fn split_lines_if_form_feed(file_content: Result) -> Vec { + file_content + .map(|content| { + let mut lines: Vec = Vec::new(); + let mut f_occurred: usize = 0; + let mut chunk: Vec = Vec::new(); + for byte in content.as_bytes() { + if byte == &FF { + f_occurred += 1; + } else { + if f_occurred != 0 { // First time byte occurred in the scan lines.push(FileLine { line_content: Ok(String::from_utf8(chunk.clone()).unwrap()), form_feeds_after: f_occurred, ..FileLine::default() }); + chunk.clear(); + } + chunk.push(*byte); + f_occurred = 0; + } + } - lines - }) - .unwrap_or_else(|e| { - vec![FileLine { - line_content: Err(e), - ..FileLine::default() - }] - }) - }) - .flat_map(|i| i) - .enumerate() - .map(|i: (usize, FileLine)| FileLine { - line_number: i.0, - ..i.1 - }) - .map(|file_line: FileLine| FileLine { - line_number: file_line.line_number + start_line_number, - ..file_line - }); // get display line number with line content + lines.push(FileLine { + line_content: Ok(String::from_utf8(chunk.clone()).unwrap()), + form_feeds_after: f_occurred, + ..FileLine::default() + }); + + lines + }) + .unwrap_or_else(|e| { + vec![FileLine { + line_content: Err(e), + ..FileLine::default() + }] + }) +} + +fn pr(path: &String, options: &OutputOptions) -> Result { + let start_page: &usize = &options.start_page; + let start_line_number: usize = get_start_line_number(options); + let last_page: Option<&usize> = options.end_page.as_ref(); + let lines_needed_per_page: usize = lines_to_read_for_page(options); + let pages: Batching< + Map>>, _>, _, _>>, _>, _>, + _, + > = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) + .lines() + .map(split_lines_if_form_feed) + .flat_map(|i: Vec| i) + .enumerate() + .map(|i: (usize, FileLine)| FileLine { + line_number: i.0, + ..i.1 + }) + .map(|file_line: FileLine| FileLine { + line_number: file_line.line_number + start_line_number, + ..file_line + }) // get display line number with line content + .batching(|it| { + let mut first_page: Vec = Vec::new(); + let mut page_with_lines: Vec> = Vec::new(); + for line in it { + let form_feeds_after = line.form_feeds_after; + first_page.push(line); + + if form_feeds_after > 1 { + // insert empty pages + page_with_lines.push(first_page); + for _i in 1..form_feeds_after { + page_with_lines.push(vec![]); + } + return Some(page_with_lines); + } + + if first_page.len() == lines_needed_per_page || form_feeds_after == 1 { + break; + } + } + + if first_page.len() == 0 { + return None; + } + page_with_lines.push(first_page); + return Some(page_with_lines); + }); let mut page_number = 1; - let mut page_lines: Vec = Vec::new(); - let mut feed_line_present = false; - for file_line in lines { - if file_line.line_content.is_err() { - return Err(file_line.line_content.unwrap_err().into()); - } - feed_line_present = is_form_feed_used; - let form_feeds_after: usize = file_line.form_feeds_after; - page_lines.push(file_line); - - if page_lines.len() == lines_needed_per_page || form_feeds_after > 0 { - if form_feeds_after > 1 { - print_page( - &page_lines, - options, - &page_number, - &start_page, - &last_page, - feed_line_present, - )?; - page_lines.clear(); - page_number += 1; - - // insert empty pages - let empty_pages_required = form_feeds_after - 1; - for _i in 0..empty_pages_required { - print_page( - &page_lines, - options, - &page_number, - &start_page, - &last_page, - feed_line_present, - )?; - page_number += 1; - } - } else { - print_page( - &page_lines, - options, - &page_number, - &start_page, - &last_page, - feed_line_present, - )?; - page_number += 1; - } - page_lines.clear(); + for page_set in pages { + for page in page_set { + print_page(&page, options, &page_number, &start_page, &last_page)?; + page_number += 1; } } - if page_lines.len() != 0 { - print_page( - &page_lines, - options, - &page_number, - &start_page, - &last_page, - feed_line_present, - )?; - } - return Ok(0); } @@ -1034,14 +1008,7 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { let new_page_number = file_line.page_number; if page_counter != new_page_number { fill_missing_lines(&mut lines, lines_needed_per_page, &nfiles, page_counter); - print_page( - &lines, - options, - &page_counter, - &start_page, - &last_page, - false, - )?; + print_page(&lines, options, &page_counter, &start_page, &last_page)?; lines = Vec::new(); } lines.push(file_line); @@ -1050,14 +1017,7 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { } fill_missing_lines(&mut lines, lines_needed_per_page, &nfiles, page_counter); - print_page( - &lines, - options, - &page_counter, - &start_page, - &last_page, - false, - )?; + print_page(&lines, options, &page_counter, &start_page, &last_page)?; return Ok(0); } @@ -1124,7 +1084,6 @@ fn print_page( page: &usize, start_page: &usize, last_page: &Option<&usize>, - feed_line_present: bool, ) -> Result { if (last_page.is_some() && page > last_page.unwrap()) || page < start_page { return Ok(0); @@ -1141,7 +1100,7 @@ fn print_page( out.write(x.as_bytes())?; out.write(line_separator)?; } - let lines_written = write_columns(lines, options, out, feed_line_present)?; + let lines_written = write_columns(lines, options, out)?; for index in 0..trailer_content.len() { let x: &String = trailer_content.get(index).unwrap(); @@ -1159,7 +1118,6 @@ fn write_columns( lines: &Vec, options: &OutputOptions, out: &mut Stdout, - feed_line_present: bool, ) -> Result { let line_separator = options.content_line_separator.as_bytes(); let content_lines_per_page = if options.double_space { @@ -1189,20 +1147,6 @@ fn write_columns( .unwrap_or(&blank_line), ); - // TODO simplify - let col_width: Option = options - .column_mode_options - .as_ref() - .map(|i| Some(i.width)) - .unwrap_or( - options - .merge_files_print - .map(|_k| Some(DEFAULT_COLUMN_WIDTH)) - .unwrap_or(None), - ); - - let page_width: Option = options.page_width; - let line_width: Option = if options.join_lines { None } else if columns > 1 { @@ -1238,7 +1182,7 @@ fn write_columns( }) .collect() }; - + let feed_line_present = options.form_feed_used; let spaces = " ".repeat(*offset_spaces); let mut not_found_break = false; for fetch_index in fetch_indexes { From a7def9386b1e731a7678814cdb80d86b620ae686 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Mon, 14 Jan 2019 20:29:20 +0530 Subject: [PATCH 042/126] pr: refactor common iterator between pr and mpr pr: refactor common iterator between pr and mpr pr: remove fill lines in mpr --- src/pr/pr.rs | 426 ++++++++++++++++++++++++++------------------------- 1 file changed, 217 insertions(+), 209 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 90387a7da..460d241a7 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -20,7 +20,6 @@ use chrono::offset::Local; use chrono::DateTime; use getopts::{HasArg, Occur}; use getopts::{Matches, Options}; -use itertools::structs::Batching; use itertools::structs::KMergeBy; use itertools::{GroupBy, Itertools}; use quick_error::ResultExt; @@ -28,8 +27,7 @@ use regex::Regex; use std::convert::From; use std::fs::{metadata, File, Metadata}; use std::io::{stderr, stdin, stdout, BufRead, BufReader, Lines, Read, Stdin, Stdout, Write}; -use std::iter::FlatMap; -use std::iter::{Enumerate, Map, SkipWhile, TakeWhile}; +use std::iter::{FlatMap, Map}; use std::num::ParseIntError; #[cfg(unix)] use std::os::unix::fs::FileTypeExt; @@ -873,72 +871,97 @@ fn split_lines_if_form_feed(file_content: Result) -> Vec Result { - let start_page: &usize = &options.start_page; + let start_page: usize = options.start_page; let start_line_number: usize = get_start_line_number(options); - let last_page: Option<&usize> = options.end_page.as_ref(); + let last_page: Option = options.end_page; let lines_needed_per_page: usize = lines_to_read_for_page(options); - let pages: Batching< - Map>>, _>, _, _>>, _>, _>, - _, - > = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?) - .lines() - .map(split_lines_if_form_feed) - .flat_map(|i: Vec| i) - .enumerate() - .map(|i: (usize, FileLine)| FileLine { - line_number: i.0, - ..i.1 - }) - .map(|file_line: FileLine| FileLine { - line_number: file_line.line_number + start_line_number, - ..file_line - }) // get display line number with line content - .batching(|it| { - let mut first_page: Vec = Vec::new(); - let mut page_with_lines: Vec> = Vec::new(); - for line in it { - let form_feeds_after = line.form_feeds_after; - first_page.push(line); + let lines: Lines>> = + BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines(); - if form_feeds_after > 1 { - // insert empty pages - page_with_lines.push(first_page); - for _i in 1..form_feeds_after { - page_with_lines.push(vec![]); - } - return Some(page_with_lines); - } + let pages: Box)>> = read_stream_and_create_pages( + lines, + start_line_number, + lines_needed_per_page, + start_page, + last_page, + 0, + ); - if first_page.len() == lines_needed_per_page || form_feeds_after == 1 { - break; - } - } - - if first_page.len() == 0 { - return None; - } - page_with_lines.push(first_page); - return Some(page_with_lines); - }); - - let mut page_number = 1; - for page_set in pages { - for page in page_set { - print_page(&page, options, &page_number, &start_page, &last_page)?; - page_number += 1; - } + for page_with_page_number in pages { + let page_number = page_with_page_number.0 + 1; + let page = page_with_page_number.1; + print_page(&page, options, &page_number)?; } return Ok(0); } +fn read_stream_and_create_pages( + lines: Lines>>, + start_line_number: usize, + lines_needed_per_page: usize, + start_page: usize, + last_page: Option, + file_id: usize, +) -> Box)>> { + return Box::new( + lines + .map(split_lines_if_form_feed) + .flat_map(|i: Vec| i) + .enumerate() + .map(move |i: (usize, FileLine)| FileLine { + line_number: i.0 + start_line_number, + file_id, + ..i.1 + }) // Add line number and file_id + .batching(move |it| { + let mut first_page: Vec = Vec::new(); + let mut page_with_lines: Vec> = Vec::new(); + for line in it { + let form_feeds_after = line.form_feeds_after; + first_page.push(line); + + if form_feeds_after > 1 { + // insert empty pages + page_with_lines.push(first_page); + for _i in 1..form_feeds_after { + page_with_lines.push(vec![]); + } + return Some(page_with_lines); + } + + if first_page.len() == lines_needed_per_page || form_feeds_after == 1 { + break; + } + } + + if first_page.len() == 0 { + return None; + } + page_with_lines.push(first_page); + return Some(page_with_lines); + }) // Create set of pages as form feeds could lead to empty pages + .flat_map(|x| x) // Flatten to pages from page sets + .enumerate() // Assign page number + .skip_while(move |x: &(usize, Vec)| { + // Skip the not needed pages + let current_page = x.0 + 1; + return current_page < start_page; + }) + .take_while(move |x: &(usize, Vec)| { + // Take only the required pages + let current_page = x.0 + 1; + return current_page >= start_page + && (last_page.is_none() || current_page <= last_page.unwrap()); + }), + ); +} + fn mpr(paths: &Vec, options: &OutputOptions) -> Result { let nfiles = paths.len(); let lines_needed_per_page: usize = lines_to_read_for_page(options); - let lines_needed_per_page_f64: f64 = lines_needed_per_page as f64; - let start_page: &usize = &options.start_page; - let last_page: Option<&usize> = options.end_page.as_ref(); - let start_line_index_of_start_page = (start_page - 1) * lines_needed_per_page; + let start_page: usize = options.start_page; + let last_page: Option = options.end_page; // Check if files exists for path in paths { @@ -947,46 +970,37 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { let file_line_groups: GroupBy< usize, - KMergeBy< - Map>>>, _>, _>, _>, _>, - _, - >, + KMergeBy)>>, _>, _, _>, _>, _, > = paths .into_iter() .enumerate() .map(|indexed_path: (usize, &String)| { let start_line_number: usize = get_start_line_number(options); - BufReader::with_capacity(READ_BUFFER_SIZE, open(indexed_path.1).unwrap()) - .lines() - .enumerate() - .map(move |i: (usize, Result)| FileLine { - file_id: indexed_path.0, - line_number: i.0, - line_content: i.1, - ..FileLine::default() - }) - .skip_while(move |file_line: &FileLine| { - // Skip the initial lines if not in page range - file_line.line_number < (start_line_index_of_start_page) - }) - .take_while(move |file_line: &FileLine| { - // Only read the file until provided last page reached - last_page - .map(|lp| file_line.line_number < ((*lp) * lines_needed_per_page)) - .unwrap_or(true) - }) - .map(move |file_line: FileLine| { - let page_number = ((file_line.line_number + 2 - start_line_number) as f64 - / (lines_needed_per_page_f64)) - .ceil() as usize; - FileLine { - line_number: file_line.line_number + start_line_number, + let lines = + BufReader::with_capacity(READ_BUFFER_SIZE, open(indexed_path.1).unwrap()).lines(); + + read_stream_and_create_pages( + lines, + start_line_number, + lines_needed_per_page, + start_page, + last_page, + indexed_path.0, + ) + .map(move |x: (usize, Vec)| { + let file_line = x.1; + let page_number = x.0 + 1; + file_line + .into_iter() + .map(|fl| FileLine { page_number, - group_key: page_number * nfiles + file_line.file_id, - ..file_line - } - }) // get display line number with line content + group_key: page_number * nfiles + fl.file_id, + ..fl + }) + .collect() + }) + .flat_map(|x: Vec| x) }) .kmerge_by(|a: &FileLine, b: &FileLine| { if a.group_key == b.group_key { @@ -997,9 +1011,10 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { }) .group_by(|file_line: &FileLine| file_line.group_key); - let mut lines: Vec = Vec::new(); let start_page: &usize = &options.start_page; + let mut lines: Vec = Vec::new(); let mut page_counter: usize = *start_page; + for (_key, file_line_group) in file_line_groups.into_iter() { for file_line in file_line_group { if file_line.line_content.is_err() { @@ -1007,87 +1022,24 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { } let new_page_number = file_line.page_number; if page_counter != new_page_number { - fill_missing_lines(&mut lines, lines_needed_per_page, &nfiles, page_counter); - print_page(&lines, options, &page_counter, &start_page, &last_page)?; + print_page(&lines, options, &page_counter)?; lines = Vec::new(); + page_counter = new_page_number; } lines.push(file_line); - page_counter = new_page_number; } } - fill_missing_lines(&mut lines, lines_needed_per_page, &nfiles, page_counter); - print_page(&lines, options, &page_counter, &start_page, &last_page)?; + print_page(&lines, options, &page_counter)?; return Ok(0); } -fn fill_missing_lines( - lines: &mut Vec, - lines_per_file: usize, - nfiles: &usize, - page_number: usize, -) { - let init_line_number = (page_number - 1) * lines_per_file + 1; - let mut file_id_counter: usize = 0; - let mut line_number_counter: usize = init_line_number; - let mut lines_processed_per_file: usize = 0; - for mut i in 0..lines_per_file * nfiles { - let file_id = lines - .get(i) - .map(|i: &FileLine| i.file_id) - .unwrap_or(file_id_counter); - let line_number = lines.get(i).map(|i: &FileLine| i.line_number).unwrap_or(1); - if lines_processed_per_file == lines_per_file { - line_number_counter = init_line_number; - file_id_counter += 1; - lines_processed_per_file = 0; - } - - if file_id != file_id_counter { - // Insert missing file_ids - lines.insert( - i, - FileLine { - file_id: file_id_counter, - line_number: line_number_counter, - line_content: Ok("".to_string()), - page_number, - ..FileLine::default() - }, - ); - line_number_counter += 1; - } else if line_number < line_number_counter { - // Insert missing lines for a file_id - line_number_counter += 1; - lines.insert( - i, - FileLine { - file_id, - line_number: line_number_counter, - line_content: Ok("".to_string()), - page_number, - ..FileLine::default() - }, - ); - } else { - line_number_counter = line_number; - } - - lines_processed_per_file += 1; - } -} - fn print_page( lines: &Vec, options: &OutputOptions, page: &usize, - start_page: &usize, - last_page: &Option<&usize>, ) -> Result { - if (last_page.is_some() && page > last_page.unwrap()) || page < start_page { - return Ok(0); - } let page_separator = options.page_separator_char.as_bytes(); let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(options); @@ -1159,67 +1111,123 @@ fn write_columns( options.page_width }; - let across_mode = options - .column_mode_options - .as_ref() - .map(|i| i.across_mode) - .unwrap_or(false); - let offset_spaces: &usize = &options.offset_spaces; - let mut lines_printed = 0; let is_number_mode = options.number.is_some(); - let fetch_indexes: Vec> = if across_mode { - (0..content_lines_per_page) - .map(|a| (0..columns).map(|i| a * columns + i).collect()) - .collect() - } else { - (0..content_lines_per_page) - .map(|start| { - (0..columns) - .map(|i| start + content_lines_per_page * i) - .collect() - }) - .collect() - }; let feed_line_present = options.form_feed_used; let spaces = " ".repeat(*offset_spaces); let mut not_found_break = false; - for fetch_index in fetch_indexes { - let indexes = fetch_index.len(); - for i in 0..indexes { - let index: usize = fetch_index[i]; - if lines.get(index).is_none() { - not_found_break = true; - break; - } - let file_line: &FileLine = lines.get(index).unwrap(); - let trimmed_line: String = format!( - "{}{}", - spaces, - get_line_for_printing( - file_line, - &number_width, - &number_separator, - columns, - is_number_mode, - &options.merge_files_print, - &i, - line_width, - ) - ); - out.write(trimmed_line.as_bytes())?; - if (i + 1) != indexes && !options.join_lines { - out.write(col_sep.as_bytes())?; - } - lines_printed += 1; - } - if not_found_break && feed_line_present { - break; + if options.merge_files_print.is_none() { + let across_mode = options + .column_mode_options + .as_ref() + .map(|i| i.across_mode) + .unwrap_or(false); + + let fetch_indexes: Vec> = if across_mode { + (0..content_lines_per_page) + .map(|a| (0..columns).map(|i| a * columns + i).collect()) + .collect() } else { - out.write(line_separator)?; + (0..content_lines_per_page) + .map(|start| { + (0..columns) + .map(|i| start + content_lines_per_page * i) + .collect() + }) + .collect() + }; + for fetch_index in fetch_indexes { + let indexes = fetch_index.len(); + for i in 0..indexes { + let index: usize = fetch_index[i]; + if lines.get(index).is_none() { + not_found_break = true; + break; + } + let file_line: &FileLine = lines.get(index).unwrap(); + let trimmed_line: String = format!( + "{}{}", + spaces, + get_line_for_printing( + file_line, + &number_width, + &number_separator, + columns, + is_number_mode, + &options.merge_files_print, + &i, + line_width, + ) + ); + out.write(trimmed_line.as_bytes())?; + if (i + 1) != indexes && !options.join_lines { + out.write(col_sep.as_bytes())?; + } + lines_printed += 1; + } + if not_found_break && feed_line_present { + break; + } else { + out.write(line_separator)?; + } + } + } else { + let mut index: usize = 0; + let mut batches: Vec> = Vec::new(); + for col in 0..columns { + let mut batch: Vec<&FileLine> = vec![]; + for i in index..lines.len() { + let line = lines.get(i).unwrap(); + if line.file_id != col { + break; + } + batch.push(line); + index += 1; + } + batches.push(batch); + } + + let blank_line = &&FileLine::default(); + + for _i in 0..content_lines_per_page { + for col_index in 0..columns { + let col: Option<&Vec<&FileLine>> = batches.get(col_index); + let file_line = if col.is_some() { + let opt_file_line: Option<&&FileLine> = col.unwrap().get(_i); + opt_file_line.unwrap_or(blank_line) + } else { + blank_line + }; + + let trimmed_line: String = format!( + "{}{}", + spaces, + get_line_for_printing( + file_line, + &number_width, + &number_separator, + columns, + is_number_mode, + &options.merge_files_print, + &col_index, + line_width, + ) + ); + out.write(trimmed_line.as_bytes())?; + if (col_index + 1) != columns && !options.join_lines { + out.write(col_sep.as_bytes())?; + } + lines_printed += 1; + } + if feed_line_present { + break; + } else { + out.write(line_separator)?; + } } } + Ok(lines_printed) } From f87ada5a11a766e3a680a226a7fe6bc1bedc48b2 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Wed, 16 Jan 2019 21:12:09 +0530 Subject: [PATCH 043/126] pr: refactor logic for -n --- src/pr/pr.rs | 79 +++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 460d241a7..0b02df778 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -388,9 +388,34 @@ pub fn uumain(args: Vec) -> i32 { opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); - // Remove -column option as getopts cannot parse things like -3 etc - let re = Regex::new(r"^-\d+").unwrap(); - let opt_args: Vec<&String> = args.iter().filter(|i| !re.is_match(i)).collect(); + // Remove -column and +page option as getopts cannot parse things like -3 etc + let column_page_option = Regex::new(r"^[-+]\d+.*").unwrap(); + let num_regex: Regex = Regex::new(r"(.\d+)|(\d+)|^[^-]$").unwrap(); + let a_file: Regex = Regex::new(r"^[^-+].*").unwrap(); + let n_regex: Regex = Regex::new(r"^-n\s*$").unwrap(); + let mut arguments = args.clone(); + let num_option: Option<(usize, &String)> = + args.iter().find_position(|x| n_regex.is_match(x.trim())); + if num_option.is_some() { + let (pos, _value) = num_option.unwrap(); + let num_val_opt = args.get(pos + 1); + if num_val_opt.is_some() { + if !num_regex.is_match(num_val_opt.unwrap()) { + let could_be_file = arguments.remove(pos + 1); + arguments.insert(pos + 1, format!("{}", NumberingMode::default().width)); + if a_file.is_match(could_be_file.trim().as_ref()) { + arguments.insert(pos + 2, could_be_file); + } else { + arguments.insert(pos + 2, could_be_file); + } + } + } + } + + let opt_args: Vec<&String> = arguments + .iter() + .filter(|i| !column_page_option.is_match(i)) + .collect(); let matches = match opts.parse(&opt_args[1..]) { Ok(m) => m, @@ -402,26 +427,8 @@ pub fn uumain(args: Vec) -> i32 { return 0; } - let mut files: Vec = matches - .free - .clone() - .iter() - .filter(|i| !i.starts_with('+') && !i.starts_with('-')) - .map(|i| i.to_string()) - .collect(); - - // -n value is optional if -n is given the opts gets confused - // if -n is used just before file path it might be captured as value of -n - if matches.opt_str(NUMBERING_MODE_OPTION).is_some() { - let maybe_a_file_path: String = matches.opt_str(NUMBERING_MODE_OPTION).unwrap(); - let is_file: bool = is_a_file(&maybe_a_file_path); - if !is_file && files.is_empty() { - print_error(&matches, PrError::NotExists(maybe_a_file_path)); - return 1; - } else if is_file { - files.insert(0, maybe_a_file_path); - } - } else if files.is_empty() { + let mut files: Vec = matches.free.clone(); + if files.is_empty() { //For stdin files.insert(0, FILE_STDIN.to_owned()); } @@ -439,16 +446,20 @@ pub fn uumain(args: Vec) -> i32 { for file_group in file_groups { let result_options: Result = build_options(&matches, &file_group, args.join(" ")); + if result_options.is_err() { print_error(&matches, result_options.err().unwrap()); return 1; } + let options: &OutputOptions = &result_options.unwrap(); + let cmd_result: Result = if file_group.len() == 1 { pr(&file_group.get(0).unwrap(), options) } else { mpr(&file_group, options) }; + let status: i32 = match cmd_result { Err(error) => { print_error(&matches, error); @@ -463,10 +474,6 @@ pub fn uumain(args: Vec) -> i32 { return 0; } -fn is_a_file(could_be_file: &String) -> bool { - could_be_file == FILE_STDIN || File::open(could_be_file).is_ok() -} - fn print_error(matches: &Matches, err: PrError) { if !matches.opt_present(SUPPRESS_PRINTING_ERROR) { writeln!(&mut stderr(), "{}", err); @@ -587,23 +594,15 @@ fn build_options( let parse_result: Result = i.parse::(); let separator: String = if parse_result.is_err() { - if is_a_file(&i) { - NumberingMode::default().separator - } else { - i[0..1].to_string() - } + i[0..1].to_string() } else { NumberingMode::default().separator }; let width: usize = if parse_result.is_err() { - if is_a_file(&i) { - NumberingMode::default().width - } else { - i[1..] - .parse::() - .unwrap_or(NumberingMode::default().width) - } + i[1..] + .parse::() + .unwrap_or(NumberingMode::default().width) } else { parse_result.unwrap() }; @@ -1258,8 +1257,6 @@ fn get_line_for_printing( let tab_count: usize = complete_line.chars().filter(|i| i == &TAB).count(); let display_length = complete_line.len() + (tab_count * 7); - // TODO Adjust the width according to -n option - // TODO actual len of the string vs display len of string because of tabs line_width .map(|i| { let min_width = (i - (columns - 1)) / columns; From 054c05d5d835d55540c982f0743e99bd7abf9d01 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Thu, 17 Jan 2019 12:35:20 +0530 Subject: [PATCH 044/126] pr: refactor get_lines_for_printing, write_columns, recreate_arguments pr: extract recreate_arguments pr: refactor get_line_for_printing pr: refactor get_lines_for_printing pr: refactor fetch_indexes generate for write_columns pr: refactor write_columns pr: refactor write_columns --- src/pr/pr.rs | 544 +++++++++--------- .../test_num_page_less_content.log.expected | 47 ++ 2 files changed, 304 insertions(+), 287 deletions(-) diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 0b02df778..ca35b6c1c 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -38,8 +38,8 @@ type IOError = std::io::Error; static NAME: &str = "pr"; static VERSION: &str = env!("CARGO_PKG_VERSION"); static TAB: char = '\t'; -static NEW_LINE: &str = "\n"; static LINES_PER_PAGE: usize = 66; +static LINES_PER_PAGE_FOR_FORM_FEED: usize = 63; static HEADER_LINES_PER_PAGE: usize = 5; static TRAILER_LINES_PER_PAGE: usize = 5; static STRING_HEADER_OPTION: &str = "h"; @@ -66,7 +66,6 @@ static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; static DEFAULT_COLUMN_WIDTH_WITH_S_OPTION: usize = 512; static DEFAULT_COLUMN_SEPARATOR: &char = &TAB; -static BLANK_STRING: &str = ""; static FF: u8 = 0x0C as u8; struct OutputOptions { @@ -79,16 +78,16 @@ struct OutputOptions { last_modified_time: String, start_page: usize, end_page: Option, - display_header: bool, - display_trailer: bool, + display_header_and_trailer: bool, content_lines_per_page: usize, page_separator_char: String, column_mode_options: Option, merge_files_print: Option, - offset_spaces: usize, + offset_spaces: String, form_feed_used: bool, - page_width: Option, join_lines: bool, + col_sep_for_printing: String, + line_width: Option, } struct FileLine { @@ -143,7 +142,7 @@ impl Default for FileLine { line_number: 0, page_number: 0, group_key: 0, - line_content: Ok(BLANK_STRING.to_string()), + line_content: Ok(String::new()), form_feeds_after: 0, } } @@ -388,34 +387,7 @@ pub fn uumain(args: Vec) -> i32 { opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); - // Remove -column and +page option as getopts cannot parse things like -3 etc - let column_page_option = Regex::new(r"^[-+]\d+.*").unwrap(); - let num_regex: Regex = Regex::new(r"(.\d+)|(\d+)|^[^-]$").unwrap(); - let a_file: Regex = Regex::new(r"^[^-+].*").unwrap(); - let n_regex: Regex = Regex::new(r"^-n\s*$").unwrap(); - let mut arguments = args.clone(); - let num_option: Option<(usize, &String)> = - args.iter().find_position(|x| n_regex.is_match(x.trim())); - if num_option.is_some() { - let (pos, _value) = num_option.unwrap(); - let num_val_opt = args.get(pos + 1); - if num_val_opt.is_some() { - if !num_regex.is_match(num_val_opt.unwrap()) { - let could_be_file = arguments.remove(pos + 1); - arguments.insert(pos + 1, format!("{}", NumberingMode::default().width)); - if a_file.is_match(could_be_file.trim().as_ref()) { - arguments.insert(pos + 2, could_be_file); - } else { - arguments.insert(pos + 2, could_be_file); - } - } - } - } - - let opt_args: Vec<&String> = arguments - .iter() - .filter(|i| !column_page_option.is_match(i)) - .collect(); + let opt_args: Vec = recreate_arguments(&args); let matches = match opts.parse(&opt_args[1..]) { Ok(m) => m, @@ -474,6 +446,40 @@ pub fn uumain(args: Vec) -> i32 { return 0; } +/// Returns re-written arguments which are passed to the program. +/// Removes -column and +page option as getopts cannot parse things like -3 etc +/// # Arguments +/// * `args` - Command line arguments +fn recreate_arguments(args: &Vec) -> Vec { + let column_page_option = Regex::new(r"^[-+]\d+.*").unwrap(); + let num_regex: Regex = Regex::new(r"(.\d+)|(\d+)|^[^-]$").unwrap(); + let a_file: Regex = Regex::new(r"^[^-+].*").unwrap(); + let n_regex: Regex = Regex::new(r"^-n\s*$").unwrap(); + let mut arguments = args.clone(); + let num_option: Option<(usize, &String)> = + args.iter().find_position(|x| n_regex.is_match(x.trim())); + if num_option.is_some() { + let (pos, _value) = num_option.unwrap(); + let num_val_opt = args.get(pos + 1); + if num_val_opt.is_some() { + if !num_regex.is_match(num_val_opt.unwrap()) { + let could_be_file = arguments.remove(pos + 1); + arguments.insert(pos + 1, format!("{}", NumberingMode::default().width)); + if a_file.is_match(could_be_file.trim().as_ref()) { + arguments.insert(pos + 2, could_be_file); + } else { + arguments.insert(pos + 2, could_be_file); + } + } + } + } + + return arguments + .into_iter() + .filter(|i| !column_page_option.is_match(i)) + .collect(); +} + fn print_error(matches: &Matches, err: PrError) { if !matches.opt_present(SUPPRESS_PRINTING_ERROR) { writeln!(&mut stderr(), "{}", err); @@ -545,24 +551,17 @@ fn build_options( let form_feed_used = matches.opt_present(FORM_FEED_OPTION) || matches.opt_present(FORM_FEED_OPTION_SMALL); - let invalid_pages_map = |i: String| { - let unparsed_value: String = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); - i.parse::().map_err(|_e| { - PrError::EncounteredErrors(format!("invalid --pages argument '{}'", unparsed_value)) - }) - }; - let is_merge_mode: bool = matches.opt_present(MERGE_FILES_PRINT); if is_merge_mode && matches.opt_present(COLUMN_OPTION) { let err_msg: String = - "cannot specify number of columns when printing in parallel".to_string(); + String::from("cannot specify number of columns when printing in parallel"); return Err(PrError::EncounteredErrors(err_msg)); } if is_merge_mode && matches.opt_present(ACROSS_OPTION) { let err_msg: String = - "cannot specify both printing across and printing in parallel".to_string(); + String::from("cannot specify both printing across and printing in parallel"); return Err(PrError::EncounteredErrors(err_msg)); } @@ -575,10 +574,10 @@ fn build_options( let header: String = matches .opt_str(STRING_HEADER_OPTION) .unwrap_or(if is_merge_mode { - "".to_string() + String::new() } else { if paths[0].to_string() == FILE_STDIN { - "".to_string() + String::new() } else { paths[0].to_string() } @@ -588,7 +587,7 @@ fn build_options( let first_number: usize = parse_usize(matches, FIRST_LINE_NUMBER_OPTION).unwrap_or(Ok(default_first_number))?; - let numbering_options: Option = matches + let number: Option = matches .opt_str(NUMBERING_MODE_OPTION) .map(|i| { let parse_result: Result = i.parse::(); @@ -623,22 +622,23 @@ fn build_options( let double_space: bool = matches.opt_present(DOUBLE_SPACE_OPTION); let content_line_separator: String = if double_space { - NEW_LINE.repeat(2) + "\n".repeat(2) } else { - NEW_LINE.to_string() + "\n".to_string() }; - let line_separator: String = NEW_LINE.to_string(); + let line_separator: String = "\n".to_string(); let last_modified_time: String = if is_merge_mode || paths[0].eq(FILE_STDIN) { - current_time() + let datetime: DateTime = Local::now(); + datetime.format("%b %d %H:%M %Y").to_string() } else { file_last_modified_time(paths.get(0).unwrap()) }; // +page option is less priority than --pages - let re = Regex::new(r"\s*\+(\d+:*\d*)\s*").unwrap(); - let start_page_in_plus_option: usize = match re.captures(&free_args).map(|i| { + let page_plus_re = Regex::new(r"\s*\+(\d+:*\d*)\s*").unwrap(); + let start_page_in_plus_option: usize = match page_plus_re.captures(&free_args).map(|i| { let unparsed_num = i.get(1).unwrap().as_str().trim(); let x: Vec<&str> = unparsed_num.split(":").collect(); x[0].to_string().parse::().map_err(|_e| { @@ -649,7 +649,7 @@ fn build_options( _ => 1, }; - let end_page_in_plus_option: Option = match re + let end_page_in_plus_option: Option = match page_plus_re .captures(&free_args) .map(|i| i.get(1).unwrap().as_str().trim()) .filter(|i| i.contains(":")) @@ -663,6 +663,13 @@ fn build_options( _ => None, }; + let invalid_pages_map = |i: String| { + let unparsed_value: String = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); + i.parse::().map_err(|_e| { + PrError::EncounteredErrors(format!("invalid --pages argument '{}'", unparsed_value)) + }) + }; + let start_page: usize = match matches .opt_str(PAGE_RANGE_OPTION) .map(|i| { @@ -696,7 +703,11 @@ fn build_options( ))); } - let default_lines_per_page = if form_feed_used { 63 } else { LINES_PER_PAGE }; + let default_lines_per_page = if form_feed_used { + LINES_PER_PAGE_FOR_FORM_FEED + } else { + LINES_PER_PAGE + }; let page_length: usize = parse_usize(matches, PAGE_LENGTH_OPTION).unwrap_or(Ok(default_lines_per_page))?; @@ -716,7 +727,7 @@ fn build_options( let bytes = vec![FF]; String::from_utf8(bytes).unwrap() } else { - NEW_LINE.to_string() + "\n".to_string() }; let across_mode: bool = matches.opt_present(ACROSS_OPTION); @@ -776,11 +787,37 @@ fn build_options( _ => None, }; - let offset_spaces: usize = parse_usize(matches, OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?; + let offset_spaces: String = + " ".repeat(parse_usize(matches, OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?); let join_lines: bool = matches.opt_present(JOIN_LINES_OPTION); + let col_sep_for_printing = column_mode_options + .as_ref() + .map(|i| i.column_separator.clone()) + .unwrap_or( + merge_files_print + .map(|_k| DEFAULT_COLUMN_SEPARATOR.to_string()) + .unwrap_or(String::new()), + ); + + let columns_to_print = + merge_files_print.unwrap_or(column_mode_options.as_ref().map(|i| i.columns).unwrap_or(1)); + + let line_width: Option = if join_lines { + None + } else if columns_to_print > 1 { + Some( + column_mode_options + .as_ref() + .map(|i| i.width) + .unwrap_or(DEFAULT_COLUMN_WIDTH), + ) + } else { + page_width + }; + Ok(OutputOptions { - number: numbering_options, + number, header, double_space, line_separator, @@ -788,16 +825,16 @@ fn build_options( last_modified_time, start_page, end_page, - display_header: display_header_and_trailer, - display_trailer: display_header_and_trailer, + display_header_and_trailer, content_lines_per_page, page_separator_char, column_mode_options, merge_files_print, offset_spaces, form_feed_used, - page_width, join_lines, + col_sep_for_printing, + line_width, }) } @@ -870,21 +907,11 @@ fn split_lines_if_form_feed(file_content: Result) -> Vec Result { - let start_page: usize = options.start_page; - let start_line_number: usize = get_start_line_number(options); - let last_page: Option = options.end_page; - let lines_needed_per_page: usize = lines_to_read_for_page(options); let lines: Lines>> = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines(); - let pages: Box)>> = read_stream_and_create_pages( - lines, - start_line_number, - lines_needed_per_page, - start_page, - last_page, - 0, - ); + let pages: Box)>> = + read_stream_and_create_pages(options, lines, 0); for page_with_page_number in pages { let page_number = page_with_page_number.0 + 1; @@ -895,13 +922,15 @@ fn pr(path: &String, options: &OutputOptions) -> Result { } fn read_stream_and_create_pages( + options: &OutputOptions, lines: Lines>>, - start_line_number: usize, - lines_needed_per_page: usize, - start_page: usize, - last_page: Option, file_id: usize, ) -> Box)>> { + let start_page: usize = options.start_page; + let start_line_number: usize = get_start_line_number(options); + let last_page: Option = options.end_page; + let lines_needed_per_page: usize = lines_to_read_for_page(options); + return Box::new( lines .map(split_lines_if_form_feed) @@ -958,10 +987,6 @@ fn read_stream_and_create_pages( fn mpr(paths: &Vec, options: &OutputOptions) -> Result { let nfiles = paths.len(); - let lines_needed_per_page: usize = lines_to_read_for_page(options); - let start_page: usize = options.start_page; - let last_page: Option = options.end_page; - // Check if files exists for path in paths { open(path)?; @@ -972,34 +997,26 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { KMergeBy)>>, _>, _, _>, _>, _, > = paths - .into_iter() + .iter() .enumerate() .map(|indexed_path: (usize, &String)| { - let start_line_number: usize = get_start_line_number(options); let lines = BufReader::with_capacity(READ_BUFFER_SIZE, open(indexed_path.1).unwrap()).lines(); - read_stream_and_create_pages( - lines, - start_line_number, - lines_needed_per_page, - start_page, - last_page, - indexed_path.0, - ) - .map(move |x: (usize, Vec)| { - let file_line = x.1; - let page_number = x.0 + 1; - file_line - .into_iter() - .map(|fl| FileLine { - page_number, - group_key: page_number * nfiles + fl.file_id, - ..fl - }) - .collect() - }) - .flat_map(|x: Vec| x) + read_stream_and_create_pages(options, lines, indexed_path.0) + .map(move |x: (usize, Vec)| { + let file_line = x.1; + let page_number = x.0 + 1; + file_line + .into_iter() + .map(|fl| FileLine { + page_number, + group_key: page_number * nfiles + fl.file_id, + ..fl + }) + .collect() + }) + .flat_map(|x: Vec| x) }) .kmerge_by(|a: &FileLine, b: &FileLine| { if a.group_key == b.group_key { @@ -1039,18 +1056,19 @@ fn print_page( options: &OutputOptions, page: &usize, ) -> Result { + let line_separator = options.line_separator.as_bytes(); let page_separator = options.page_separator_char.as_bytes(); + let header: Vec = header_content(options, page); let trailer_content: Vec = trailer_content(options); - let out: &mut Stdout = &mut stdout(); - let line_separator = options.line_separator.as_bytes(); out.lock(); for x in header { out.write(x.as_bytes())?; out.write(line_separator)?; } + let lines_written = write_columns(lines, options, out)?; for index in 0..trailer_content.len() { @@ -1071,159 +1089,90 @@ fn write_columns( out: &mut Stdout, ) -> Result { let line_separator = options.content_line_separator.as_bytes(); + let content_lines_per_page = if options.double_space { options.content_lines_per_page / 2 } else { options.content_lines_per_page }; - let number_width: usize = options.number.as_ref().map(|i| i.width).unwrap_or(0); - let number_separator: String = options - .number - .as_ref() - .map(|i| i.separator.to_string()) - .unwrap_or(NumberingMode::default().separator); - - let blank_line = "".to_string(); let columns = options.merge_files_print.unwrap_or(get_columns(options)); - let def_sep = DEFAULT_COLUMN_SEPARATOR.to_string(); - let col_sep: &String = options + let line_width: Option = options.line_width; + let mut lines_printed = 0; + let feed_line_present = options.form_feed_used; + let mut not_found_break = false; + + let across_mode = options .column_mode_options .as_ref() - .map(|i| &i.column_separator) - .unwrap_or( - options - .merge_files_print - .map(|_k| &def_sep) - .unwrap_or(&blank_line), - ); + .map(|i| i.across_mode) + .unwrap_or(false); - let line_width: Option = if options.join_lines { - None - } else if columns > 1 { - options - .column_mode_options - .as_ref() - .map(|i| Some(i.width)) - .unwrap_or(Some(DEFAULT_COLUMN_WIDTH)) - } else { - options.page_width - }; - - let offset_spaces: &usize = &options.offset_spaces; - let mut lines_printed = 0; - let is_number_mode = options.number.is_some(); - let feed_line_present = options.form_feed_used; - let spaces = " ".repeat(*offset_spaces); - let mut not_found_break = false; - if options.merge_files_print.is_none() { - let across_mode = options - .column_mode_options - .as_ref() - .map(|i| i.across_mode) - .unwrap_or(false); - - let fetch_indexes: Vec> = if across_mode { - (0..content_lines_per_page) - .map(|a| (0..columns).map(|i| a * columns + i).collect()) - .collect() - } else { - (0..content_lines_per_page) - .map(|start| { - (0..columns) - .map(|i| start + content_lines_per_page * i) - .collect() - }) - .collect() - }; - for fetch_index in fetch_indexes { - let indexes = fetch_index.len(); - for i in 0..indexes { - let index: usize = fetch_index[i]; - if lines.get(index).is_none() { - not_found_break = true; - break; - } - let file_line: &FileLine = lines.get(index).unwrap(); - let trimmed_line: String = format!( - "{}{}", - spaces, - get_line_for_printing( - file_line, - &number_width, - &number_separator, - columns, - is_number_mode, - &options.merge_files_print, - &i, - line_width, - ) - ); - out.write(trimmed_line.as_bytes())?; - if (i + 1) != indexes && !options.join_lines { - out.write(col_sep.as_bytes())?; - } - lines_printed += 1; - } - if not_found_break && feed_line_present { - break; - } else { - out.write(line_separator)?; - } - } - } else { - let mut index: usize = 0; - let mut batches: Vec> = Vec::new(); + let mut filled_lines: Vec> = Vec::new(); + if options.merge_files_print.is_some() { + let mut offset: usize = 0; for col in 0..columns { - let mut batch: Vec<&FileLine> = vec![]; - for i in index..lines.len() { + let mut inserted = 0; + for i in offset..lines.len() { let line = lines.get(i).unwrap(); if line.file_id != col { break; } - batch.push(line); - index += 1; + filled_lines.push(Some(line)); + offset += 1; + inserted += 1; + } + + for _i in inserted..content_lines_per_page { + filled_lines.push(None); } - batches.push(batch); } + } - let blank_line = &&FileLine::default(); + let table: Vec>> = (0..content_lines_per_page) + .map(move |a| { + (0..columns) + .map(|i| { + if across_mode { + lines.get(a * columns + i) + } else if options.merge_files_print.is_some() { + *filled_lines + .get(content_lines_per_page * i + a) + .unwrap_or(&None) + } else { + lines.get(content_lines_per_page * i + a) + } + }) + .collect() + }) + .collect(); - for _i in 0..content_lines_per_page { - for col_index in 0..columns { - let col: Option<&Vec<&FileLine>> = batches.get(col_index); - let file_line = if col.is_some() { - let opt_file_line: Option<&&FileLine> = col.unwrap().get(_i); - opt_file_line.unwrap_or(blank_line) - } else { - blank_line - }; + let blank_line: FileLine = FileLine::default(); + for row in table { + let indexes = row.len(); + for (i, cell) in row.iter().enumerate() { + if cell.is_none() && options.merge_files_print.is_some() { + out.write( + get_line_for_printing(&options, &blank_line, columns, &i, &line_width, indexes) + .as_bytes(), + )?; + } else if cell.is_none() { + not_found_break = true; + break; + } else if cell.is_some() { + let file_line: &FileLine = cell.unwrap(); - let trimmed_line: String = format!( - "{}{}", - spaces, - get_line_for_printing( - file_line, - &number_width, - &number_separator, - columns, - is_number_mode, - &options.merge_files_print, - &col_index, - line_width, - ) - ); - out.write(trimmed_line.as_bytes())?; - if (col_index + 1) != columns && !options.join_lines { - out.write(col_sep.as_bytes())?; - } + out.write( + get_line_for_printing(&options, file_line, columns, &i, &line_width, indexes) + .as_bytes(), + )?; lines_printed += 1; } - if feed_line_present { - break; - } else { - out.write(line_separator)?; - } + } + if not_found_break && feed_line_present { + break; + } else { + out.write(line_separator)?; } } @@ -1231,72 +1180,94 @@ fn write_columns( } fn get_line_for_printing( + options: &OutputOptions, file_line: &FileLine, - number_width: &usize, - separator: &String, columns: usize, - is_number_mode: bool, - merge_files_print: &Option, index: &usize, - line_width: Option, + line_width: &Option, + indexes: usize, ) -> String { - let should_show_line_number_merge_file = - merge_files_print.is_none() || index == &usize::min_value(); - let should_show_line_number = is_number_mode && should_show_line_number_merge_file; - let fmtd_line_number: String = if should_show_line_number { - get_fmtd_line_number(&number_width, file_line.line_number, &separator) - } else { - "".to_string() - }; + // Check this condition + let blank_line = String::new(); + let fmtd_line_number: String = get_fmtd_line_number(&options, file_line.line_number, index); + let mut complete_line = format!( "{}{}", fmtd_line_number, file_line.line_content.as_ref().unwrap() ); + let offset_spaces: &String = &options.offset_spaces; + let tab_count: usize = complete_line.chars().filter(|i| i == &TAB).count(); let display_length = complete_line.len() + (tab_count * 7); - line_width - .map(|i| { - let min_width = (i - (columns - 1)) / columns; - if display_length < min_width { - for _i in 0..(min_width - display_length) { - complete_line.push(' '); - } - } - complete_line.chars().take(min_width).collect() - }) - .unwrap_or(complete_line) + let sep = if (index + 1) != indexes && !options.join_lines { + &options.col_sep_for_printing + } else { + &blank_line + }; + + format!( + "{}{}{}", + offset_spaces, + line_width + .map(|i| { + let min_width = (i - (columns - 1)) / columns; + if display_length < min_width { + for _i in 0..(min_width - display_length) { + complete_line.push(' '); + } + } + + complete_line.chars().take(min_width).collect() + }) + .unwrap_or(complete_line), + sep + ) } -fn get_fmtd_line_number(width: &usize, line_number: usize, separator: &String) -> String { - let line_str = line_number.to_string(); - if line_str.len() >= *width { - format!( - "{:>width$}{}", - &line_str[line_str.len() - *width..], - separator, - width = width - ) +fn get_fmtd_line_number(opts: &OutputOptions, line_number: usize, index: &usize) -> String { + let should_show_line_number = + opts.number.is_some() && (opts.merge_files_print.is_none() || index == &0); + if should_show_line_number && line_number != 0 { + let line_str = line_number.to_string(); + let num_opt = opts.number.as_ref().unwrap(); + let width = num_opt.width; + let separator = &num_opt.separator; + if line_str.len() >= width { + format!( + "{:>width$}{}", + &line_str[line_str.len() - width..], + separator, + width = width + ) + } else { + format!("{:>width$}{}", line_str, separator, width = width) + } } else { - format!("{:>width$}{}", line_str, separator, width = width) + String::new() } } +/// Returns a five line header content if displaying header is not disabled by +/// using `NO_HEADER_TRAILER_OPTION` option. +/// # Arguments +/// * `options` - A reference to OutputOptions +/// * `page` - A reference to page number fn header_content(options: &OutputOptions, page: &usize) -> Vec { - if options.display_header { + if options.display_header_and_trailer { let first_line: String = format!( "{} {} Page {}", options.last_modified_time, options.header, page ); vec![ - BLANK_STRING.to_string(), - BLANK_STRING.to_string(), + String::new(), + String::new(), first_line, - BLANK_STRING.to_string(), - BLANK_STRING.to_string(), + String::new(), + String::new(), ] } else { Vec::new() @@ -1318,19 +1289,18 @@ fn file_last_modified_time(path: &str) -> String { .unwrap_or(String::new()); } -fn current_time() -> String { - let datetime: DateTime = Local::now(); - datetime.format("%b %d %H:%M %Y").to_string() -} - +/// Returns five empty lines as trailer content if displaying trailer +/// is not disabled by using `NO_HEADER_TRAILER_OPTION`option. +/// # Arguments +/// * `opts` - A reference to OutputOptions fn trailer_content(options: &OutputOptions) -> Vec { - if options.as_ref().display_trailer && !options.form_feed_used { + if options.display_header_and_trailer && !options.form_feed_used { vec![ - BLANK_STRING.to_string(), - BLANK_STRING.to_string(), - BLANK_STRING.to_string(), - BLANK_STRING.to_string(), - BLANK_STRING.to_string(), + String::new(), + String::new(), + String::new(), + String::new(), + String::new(), ] } else { Vec::new() diff --git a/tests/fixtures/pr/test_num_page_less_content.log.expected b/tests/fixtures/pr/test_num_page_less_content.log.expected index a3c733e01..8cd3cf6bc 100644 --- a/tests/fixtures/pr/test_num_page_less_content.log.expected +++ b/tests/fixtures/pr/test_num_page_less_content.log.expected @@ -17,3 +17,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 837780c3253581fae12886316574a7a6c004d99c Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Mon, 21 Jan 2019 20:55:52 +0530 Subject: [PATCH 045/126] pr: pre PR tasks --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7433f49e6..8071e66b2 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Why? Many GNU, Linux and other utilities are useful, and obviously [some](http://gnuwin32.sourceforge.net) [effort](http://unxutils.sourceforge.net) has been spent in the past to port them to Windows. However, those projects -are written in platform-specific C, a language considered unsafe compared to Rust, and +are written in platform-specific C, a language considered unsafe compared to Rust, and have other issues. Rust provides a good, platform-agnostic way of writing systems utilities that are easy @@ -287,12 +287,12 @@ Utilities | Done | Semi-Done | To Do | |-----------|-----------|--------| | arch | cp | chcon | -| base32 | expr | dd | -| base64 | install | numfmt | -| basename | ls | pr | -| cat | more | runcon | -| chgrp | od (`--strings` and 128-bit data types missing) | stty | -| chmod | printf | | +| base32 | expr | csplit | +| base64 | install | dd | +| basename | ls | df | +| cat | more | numfmt | +| chgrp | od (`--strings` and 128-bit data types missing) | runcon | +| chmod | printf | stty | | chown | sort | | | chroot | split | | | cksum | tail | | From 75b35e600287e422c6258dbefcc4f88053bb4a23 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sun, 28 Apr 2019 12:51:37 +0530 Subject: [PATCH 046/126] pr: remove not required tests --- tests/fixtures/pr/test_num_page.log.expected | 132 ------------------ .../pr/test_num_page_less_content.log | 7 - .../test_num_page_less_content.log.expected | 66 --------- tests/test_pr.rs | 69 ++------- 4 files changed, 12 insertions(+), 262 deletions(-) delete mode 100644 tests/fixtures/pr/test_num_page.log.expected delete mode 100644 tests/fixtures/pr/test_num_page_less_content.log delete mode 100644 tests/fixtures/pr/test_num_page_less_content.log.expected diff --git a/tests/fixtures/pr/test_num_page.log.expected b/tests/fixtures/pr/test_num_page.log.expected deleted file mode 100644 index 076d3f212..000000000 --- a/tests/fixtures/pr/test_num_page.log.expected +++ /dev/null @@ -1,132 +0,0 @@ - - -{last_modified_time} test_num_page.log Page 1 - - - 1 ntation processAirPortStateChanges]: pppConnectionState 0 - 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed - 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed - 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 8 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 9 Mon Dec 10 11:42:57.002 Info: 802.1X changed - 10 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 11 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 12 Mon Dec 10 11:42:57.152 Info: 802.1X changed - 13 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 14 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 15 Mon Dec 10 11:42:57.302 Info: 802.1X changed - 16 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 17 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 18 Mon Dec 10 11:42:57.449 Info: 802.1X changed - 19 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 20 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 21 Mon Dec 10 11:42:57.600 Info: 802.1X changed - 22 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 23 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 24 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 25 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 26 Mon Dec 10 11:42:57.749 Info: 802.1X changed - 27 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 28 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 29 Mon Dec 10 11:42:57.896 Info: 802.1X changed - 30 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 31 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 32 Mon Dec 10 11:42:58.045 Info: 802.1X changed - 33 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 34 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 35 Mon Dec 10 11:42:58.193 Info: 802.1X changed - 36 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 37 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 38 Mon Dec 10 11:42:58.342 Info: 802.1X changed - 39 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 40 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 41 Mon Dec 10 11:42:58.491 Info: 802.1X changed - 42 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 43 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 44 Mon Dec 10 11:42:58.640 Info: 802.1X changed - 45 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 46 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 47 Mon Dec 10 11:42:58.805 Info: 802.1X changed - 48 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 49 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 50 Mon Dec 10 11:42:58.958 Info: 802.1X changed - 51 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 52 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 53 Mon Dec 10 11:42:59.155 Info: 802.1X changed - 54 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 55 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 56 Mon Dec 10 11:42:59.352 Info: 802.1X changed - - - - - - - -{last_modified_time} test_num_page.log Page 2 - - - 57 ntation processAirPortStateChanges]: pppConnectionState 0 - 58 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 59 Mon Dec 10 11:42:56.705 Info: 802.1X changed - 60 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 61 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 62 Mon Dec 10 11:42:56.854 Info: 802.1X changed - 63 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 64 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 65 Mon Dec 10 11:42:57.002 Info: 802.1X changed - 66 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 67 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 68 Mon Dec 10 11:42:57.152 Info: 802.1X changed - 69 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 70 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 71 Mon Dec 10 11:42:57.302 Info: 802.1X changed - 72 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 73 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 74 Mon Dec 10 11:42:57.449 Info: 802.1X changed - 75 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 76 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 77 Mon Dec 10 11:42:57.600 Info: 802.1X changed - 78 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 79 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 80 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 81 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 82 Mon Dec 10 11:42:57.749 Info: 802.1X changed - 83 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 84 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 85 Mon Dec 10 11:42:57.896 Info: 802.1X changed - 86 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 87 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 88 Mon Dec 10 11:42:58.045 Info: 802.1X changed - 89 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 90 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 91 Mon Dec 10 11:42:58.193 Info: 802.1X changed - 92 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 93 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 94 Mon Dec 10 11:42:58.342 Info: 802.1X changed - 95 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 96 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 97 Mon Dec 10 11:42:58.491 Info: 802.1X changed - 98 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 99 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 100 Mon Dec 10 11:42:58.640 Info: 802.1X changed - 101 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 102 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 103 Mon Dec 10 11:42:58.805 Info: 802.1X changed - 104 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 105 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 106 Mon Dec 10 11:42:58.958 Info: 802.1X changed - 107 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 108 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 109 Mon Dec 10 11:42:59.155 Info: 802.1X changed - 110 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 111 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 112 Mon Dec 10 11:42:59.352 Info: 802.1X changed - - - - - diff --git a/tests/fixtures/pr/test_num_page_less_content.log b/tests/fixtures/pr/test_num_page_less_content.log deleted file mode 100644 index cf13a6862..000000000 --- a/tests/fixtures/pr/test_num_page_less_content.log +++ /dev/null @@ -1,7 +0,0 @@ -ntation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:56.705 Info: 802.1X changed -Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 -Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:56.854 Info: 802.1X changed -Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 \ No newline at end of file diff --git a/tests/fixtures/pr/test_num_page_less_content.log.expected b/tests/fixtures/pr/test_num_page_less_content.log.expected deleted file mode 100644 index 8cd3cf6bc..000000000 --- a/tests/fixtures/pr/test_num_page_less_content.log.expected +++ /dev/null @@ -1,66 +0,0 @@ - - -{last_modified_time} test_num_page_less_content.log Page 1 - - - 1 ntation processAirPortStateChanges]: pppConnectionState 0 - 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed - 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars - 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed - 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/test_pr.rs b/tests/test_pr.rs index b4ff61ed7..61b9a647c 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -40,36 +40,6 @@ fn test_without_any_options() { ); } -#[test] -fn test_with_numbering_option() { - let test_file_path = "test_num_page.log"; - let expected_test_file_path = "test_num_page.log.expected"; - let mut scenario = new_ucmd!(); - let value = file_last_modified_time(&scenario, test_file_path); - scenario - .args(&["-n", test_file_path]) - .succeeds() - .stdout_is_templated_fixture( - expected_test_file_path, - vec![(&"{last_modified_time}".to_string(), &value)], - ); -} - -#[test] -fn test_with_numbering_option_when_content_is_less_than_page() { - let test_file_path = "test_num_page_less_content.log"; - let expected_test_file_path = "test_num_page_less_content.log.expected"; - let mut scenario = new_ucmd!(); - let value = file_last_modified_time(&scenario, test_file_path); - scenario - .args(&["-n", test_file_path]) - .succeeds() - .stdout_is_templated_fixture( - expected_test_file_path, - vec![(&"{last_modified_time}".to_string(), &value)], - ); -} - #[test] fn test_with_numbering_option_with_number_width() { let test_file_path = "test_num_page.log"; @@ -85,25 +55,6 @@ fn test_with_numbering_option_with_number_width() { ); } -#[test] -fn test_with_header_option() { - let test_file_path = "test_one_page.log"; - let expected_test_file_path = "test_one_page_header.log.expected"; - let mut scenario = new_ucmd!(); - let value = file_last_modified_time(&scenario, test_file_path); - let header = "new file"; - scenario - .args(&["-h", header, test_file_path]) - .succeeds() - .stdout_is_templated_fixture( - expected_test_file_path, - vec![ - (&"{last_modified_time}".to_string(), &value), - (&"{header}".to_string(), &header.to_string()), - ], - ); -} - #[test] fn test_with_long_header_option() { let test_file_path = "test_one_page.log"; @@ -121,6 +72,17 @@ fn test_with_long_header_option() { (&"{header}".to_string(), &header.to_string()), ], ); + + new_ucmd!() + .args(&["-h", header, test_file_path]) + .succeeds() + .stdout_is_templated_fixture( + expected_test_file_path, + vec![ + (&"{last_modified_time}".to_string(), &value), + (&"{header}".to_string(), &header.to_string()), + ], + ); } #[test] @@ -136,15 +98,8 @@ fn test_with_double_space_option() { expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)], ); -} -#[test] -fn test_with_long_double_space_option() { - let test_file_path = "test_one_page.log"; - let expected_test_file_path = "test_one_page_double_line.log.expected"; - let mut scenario = new_ucmd!(); - let value = file_last_modified_time(&scenario, test_file_path); - scenario + new_ucmd!() .args(&["--double-space", test_file_path]) .succeeds() .stdout_is_templated_fixture( From 62fe68850e185672de62f63df79a97dce3be5083 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Fri, 26 Mar 2021 10:35:51 +0300 Subject: [PATCH 047/126] pr: Fixes after rebasing Only the minimum needed to: * Make everything compile without warnings * Move files according to the new project structure * Make tests pass --- Cargo.lock | 22 +++++++++++-- Cargo.toml | 3 +- README.md | 2 +- src/pr/Cargo.toml | 28 ---------------- src/uu/pr/Cargo.toml | 33 +++++++++++++++++++ src/uu/pr/src/main.rs | 1 + src/{pr => uu/pr/src}/pr.rs | 30 +++++++---------- tests/{ => by-util}/test_pr.rs | 13 ++++---- .../pr/test_one_page_no_ht.log.expected | 3 +- 9 files changed, 76 insertions(+), 59 deletions(-) delete mode 100644 src/pr/Cargo.toml create mode 100644 src/uu/pr/Cargo.toml create mode 100644 src/uu/pr/src/main.rs rename src/{pr => uu/pr/src}/pr.rs (98%) rename tests/{ => by-util}/test_pr.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index 4851a6e13..4f61fb1b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,6 +182,7 @@ dependencies = [ name = "coreutils" version = "0.0.4" dependencies = [ + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -251,6 +252,7 @@ dependencies = [ "uu_paste 0.0.4", "uu_pathchk 0.0.4", "uu_pinky 0.0.4", + "uu_pr 0.0.4", "uu_printenv 0.0.4", "uu_printf 0.0.4", "uu_ptx 0.0.4", @@ -441,7 +443,7 @@ dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -712,7 +714,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memoffset" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1884,6 +1886,20 @@ dependencies = [ "uucore_procs 0.0.5", ] +[[package]] +name = "uu_pr" +version = "0.0.4" +dependencies = [ + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.7", + "uucore_procs 0.0.5", +] + [[package]] name = "uu_printenv" version = "0.0.4" @@ -2530,7 +2546,7 @@ dependencies = [ "checksum md5 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "79c56d6a0b07f9e19282511c83fc5b086364cbae4ba8c7d5f190c3d9b0425a48" "checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" "checksum memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" -"checksum memoffset 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +"checksum memoffset 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cc14fc54a812b4472b4113facc3e44d099fbc0ea2ce0551fa5c703f8edfbfd38" "checksum nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4dbdc256eaac2e3bd236d93ad999d3479ef775c863dbda3068c4006a92eec51b" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum num-integer 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" diff --git a/Cargo.toml b/Cargo.toml index 8afd36761..1bd559763 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -286,7 +286,7 @@ od = { optional=true, version="0.0.4", package="uu_od", path="src/uu/od" } paste = { optional=true, version="0.0.4", package="uu_paste", path="src/uu/paste" } pathchk = { optional=true, version="0.0.4", package="uu_pathchk", path="src/uu/pathchk" } pinky = { optional=true, version="0.0.4", package="uu_pinky", path="src/uu/pinky" } -pr = { optional=true, path="src/pr" } +pr = { optional=true, version="0.0.4", package="uu_pr", path="src/uu/pr" } printenv = { optional=true, version="0.0.4", package="uu_printenv", path="src/uu/printenv" } printf = { optional=true, version="0.0.4", package="uu_printf", path="src/uu/printf" } ptx = { optional=true, version="0.0.4", package="uu_ptx", path="src/uu/ptx" } @@ -332,6 +332,7 @@ yes = { optional=true, version="0.0.4", package="uu_yes", path="src/uu/yes" #pin_cc = { version="1.0.61, < 1.0.62", package="cc" } ## cc v1.0.62 has compiler errors for MinRustV v1.32.0, requires 1.34 (for `std::str::split_ascii_whitespace()`) [dev-dependencies] +chrono = "0.4.11" conv = "0.3" filetime = "0.2" glob = "0.3.0" diff --git a/README.md b/README.md index 8071e66b2..f292b7184 100644 --- a/README.md +++ b/README.md @@ -301,7 +301,7 @@ Utilities | cut | join | | | dircolors | df | | | dirname | tac | | -| du | | | +| du | pr | | | echo | | | | env | | | | expand | | | diff --git a/src/pr/Cargo.toml b/src/pr/Cargo.toml deleted file mode 100644 index 481404b3a..000000000 --- a/src/pr/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "pr" -version = "0.0.1" -authors = ["Tilak Patidar "] -build = "../../mkmain.rs" - -[lib] -name = "uu_pr" -path = "pr.rs" - -[dependencies] -getopts = "0.2.18" -time = "0.1.40" -chrono = "0.4.6" -quick-error = "1.2.2" -itertools = "0.7.8" -regex = "1.0.1" - -[dependencies.uucore] -path = "../uucore" -features = ["libc"] - -[target.'cfg(unix)'.dependencies] -unix_socket = "0.5.0" - -[[bin]] -name = "pr" -path = "../../uumain.rs" diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml new file mode 100644 index 000000000..2eb8a03fe --- /dev/null +++ b/src/uu/pr/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "uu_pr" +version = "0.0.4" +authors = ["uutils developers"] +license = "MIT" +description = "pr ~ (uutils) convert text files for printing" + +homepage = "https://github.com/uutils/coreutils" +repository = "https://github.com/uutils/coreutils/tree/master/src/uu/pinky" +keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"] +categories = ["command-line-utilities"] +edition = "2018" + +[lib] +path = "src/pr.rs" + +[dependencies] +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["utmpx", "entries"] } +uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } +getopts = "0.2.21" +time = "0.1.41" +# A higher version would cause a conflict with time +chrono = "0.4.11" +quick-error = "1.2.3" +itertools = "0.10" +regex = "1.0" + +#[target.'cfg(unix)'.dependencies] +#unix_socket = "0.5.0" + +[[bin]] +name = "pr" +path = "src/main.rs" diff --git a/src/uu/pr/src/main.rs b/src/uu/pr/src/main.rs new file mode 100644 index 000000000..893145c3e --- /dev/null +++ b/src/uu/pr/src/main.rs @@ -0,0 +1 @@ +uucore_procs::main!(uu_pr); // spell-checker:ignore procs uucore diff --git a/src/pr/pr.rs b/src/uu/pr/src/pr.rs similarity index 98% rename from src/pr/pr.rs rename to src/uu/pr/src/pr.rs index ca35b6c1c..73386eaf0 100644 --- a/src/pr/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -6,15 +6,8 @@ // that was distributed with this source code. // -#[cfg(unix)] -extern crate unix_socket; #[macro_use] extern crate quick_error; -extern crate chrono; -extern crate getopts; -extern crate itertools; -extern crate regex; -extern crate uucore; use chrono::offset::Local; use chrono::DateTime; @@ -26,7 +19,7 @@ use quick_error::ResultExt; use regex::Regex; use std::convert::From; use std::fs::{metadata, File, Metadata}; -use std::io::{stderr, stdin, stdout, BufRead, BufReader, Lines, Read, Stdin, Stdout, Write}; +use std::io::{stdin, stdout, BufRead, BufReader, Lines, Read, Stdin, Stdout, Write}; use std::iter::{FlatMap, Map}; use std::num::ParseIntError; #[cfg(unix)] @@ -185,7 +178,8 @@ quick_error! { } } -pub fn uumain(args: Vec) -> i32 { +pub fn uumain(args: impl uucore::Args) -> i32 { + let args = args.collect_str(); let mut opts = getopts::Options::new(); opts.opt( @@ -482,7 +476,7 @@ fn recreate_arguments(args: &Vec) -> Vec { fn print_error(matches: &Matches, err: PrError) { if !matches.opt_present(SUPPRESS_PRINTING_ERROR) { - writeln!(&mut stderr(), "{}", err); + eprintln!("{}", err); } } @@ -838,10 +832,10 @@ fn build_options( }) } -fn open(path: &str) -> Result, PrError> { +fn open(path: &str) -> Result, PrError> { if path == FILE_STDIN { let stdin: Stdin = stdin(); - return Ok(Box::new(stdin) as Box); + return Ok(Box::new(stdin) as Box); } metadata(path) @@ -858,7 +852,7 @@ fn open(path: &str) -> Result, PrError> { ft if ft.is_socket() => Err(PrError::IsSocket(path_string)), ft if ft.is_dir() => Err(PrError::IsDirectory(path_string)), ft if ft.is_file() || ft.is_symlink() => { - Ok(Box::new(File::open(path).context(path)?) as Box) + Ok(Box::new(File::open(path).context(path)?) as Box) } _ => Err(PrError::UnknownFiletype(path_string)), } @@ -907,10 +901,10 @@ fn split_lines_if_form_feed(file_content: Result) -> Vec Result { - let lines: Lines>> = + let lines: Lines>> = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines(); - let pages: Box)>> = + let pages: Box)>> = read_stream_and_create_pages(options, lines, 0); for page_with_page_number in pages { @@ -923,9 +917,9 @@ fn pr(path: &String, options: &OutputOptions) -> Result { fn read_stream_and_create_pages( options: &OutputOptions, - lines: Lines>>, + lines: Lines>>, file_id: usize, -) -> Box)>> { +) -> Box)>> { let start_page: usize = options.start_page; let start_line_number: usize = get_start_line_number(options); let last_page: Option = options.end_page; @@ -994,7 +988,7 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { let file_line_groups: GroupBy< usize, - KMergeBy)>>, _>, _, _>, _>, + KMergeBy)>>, _>, _, _>, _>, _, > = paths .iter() diff --git a/tests/test_pr.rs b/tests/by-util/test_pr.rs similarity index 98% rename from tests/test_pr.rs rename to tests/by-util/test_pr.rs index 61b9a647c..1cd8fbdc8 100644 --- a/tests/test_pr.rs +++ b/tests/by-util/test_pr.rs @@ -1,9 +1,7 @@ -extern crate chrono; - -use common::util::*; +use crate::common::util::*; use std::fs::metadata; -use test_pr::chrono::offset::Local; -use test_pr::chrono::DateTime; +use chrono::offset::Local; +use chrono::DateTime; fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { let tmp_dir_path = ucmd.get_full_fixture_path(path); @@ -243,10 +241,11 @@ fn test_with_no_header_trailer_option() { let test_file_path = "test_one_page.log"; let expected_test_file_path = "test_one_page_no_ht.log.expected"; let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); scenario .args(&["-t", test_file_path]) .succeeds() - .stdout_is_fixture(expected_test_file_path); + .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); } #[test] @@ -480,7 +479,7 @@ fn test_with_pr_core_utils_tests() { arguments.extend(input_file.clone()); - let mut scenario_with_args = scenario.args(&arguments); + let scenario_with_args = scenario.args(&arguments); let scenario_with_expected_status = if return_code == 0 { scenario_with_args.succeeds() diff --git a/tests/fixtures/pr/test_one_page_no_ht.log.expected b/tests/fixtures/pr/test_one_page_no_ht.log.expected index 3d5131358..2abea9890 100644 --- a/tests/fixtures/pr/test_one_page_no_ht.log.expected +++ b/tests/fixtures/pr/test_one_page_no_ht.log.expected @@ -53,4 +53,5 @@ Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementati Mon Dec 10 11:42:59.155 Info: 802.1X changed Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars -Mon Dec 10 11:42:59.352 Info: 802.1X changed \ No newline at end of file +Mon Dec 10 11:42:59.352 Info: 802.1X changed + From bc2b385744e045d5f5499e0c8c4c44be0ae649d6 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Fri, 26 Mar 2021 17:16:05 +0300 Subject: [PATCH 048/126] pr: Fix a bunch of Clippy problems --- src/uu/pr/src/pr.rs | 119 +++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 56 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 73386eaf0..81a3dfe9a 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -437,7 +437,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { return status; } } - return 0; + + 0 } /// Returns re-written arguments which are passed to the program. @@ -447,7 +448,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { fn recreate_arguments(args: &Vec) -> Vec { let column_page_option = Regex::new(r"^[-+]\d+.*").unwrap(); let num_regex: Regex = Regex::new(r"(.\d+)|(\d+)|^[^-]$").unwrap(); - let a_file: Regex = Regex::new(r"^[^-+].*").unwrap(); + //let a_file: Regex = Regex::new(r"^[^-+].*").unwrap(); let n_regex: Regex = Regex::new(r"^-n\s*$").unwrap(); let mut arguments = args.clone(); let num_option: Option<(usize, &String)> = @@ -455,23 +456,24 @@ fn recreate_arguments(args: &Vec) -> Vec { if num_option.is_some() { let (pos, _value) = num_option.unwrap(); let num_val_opt = args.get(pos + 1); - if num_val_opt.is_some() { - if !num_regex.is_match(num_val_opt.unwrap()) { - let could_be_file = arguments.remove(pos + 1); - arguments.insert(pos + 1, format!("{}", NumberingMode::default().width)); - if a_file.is_match(could_be_file.trim().as_ref()) { - arguments.insert(pos + 2, could_be_file); - } else { - arguments.insert(pos + 2, could_be_file); - } - } + if num_val_opt.is_some() && !num_regex.is_match(num_val_opt.unwrap()) { + let could_be_file = arguments.remove(pos + 1); + arguments.insert(pos + 1, format!("{}", NumberingMode::default().width)); + // FIXME: the following line replaces the block below that had the same + // code for both conditional branches. Figure this out. + arguments.insert(pos + 2, could_be_file); + // if a_file.is_match(could_be_file.trim().as_ref()) { + // arguments.insert(pos + 2, could_be_file); + // } else { + // arguments.insert(pos + 2, could_be_file); + // } } } - return arguments + arguments .into_iter() .filter(|i| !column_page_option.is_match(i)) - .collect(); + .collect() } fn print_error(matches: &Matches, err: PrError) { @@ -520,7 +522,8 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { if matches.free.is_empty() { return 1; } - return 0; + + 0 } fn parse_usize(matches: &Matches, opt: &str) -> Option> { @@ -570,7 +573,7 @@ fn build_options( .unwrap_or(if is_merge_mode { String::new() } else { - if paths[0].to_string() == FILE_STDIN { + if paths[0] == FILE_STDIN { String::new() } else { paths[0].to_string() @@ -610,7 +613,8 @@ fn build_options( if matches.opt_present(NUMBERING_MODE_OPTION) { return Some(NumberingMode::default()); } - return None; + + None }); let double_space: bool = matches.opt_present(DOUBLE_SPACE_OPTION); @@ -634,7 +638,7 @@ fn build_options( let page_plus_re = Regex::new(r"\s*\+(\d+:*\d*)\s*").unwrap(); let start_page_in_plus_option: usize = match page_plus_re.captures(&free_args).map(|i| { let unparsed_num = i.get(1).unwrap().as_str().trim(); - let x: Vec<&str> = unparsed_num.split(":").collect(); + let x: Vec<&str> = unparsed_num.split(':').collect(); x[0].to_string().parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) }) @@ -646,9 +650,9 @@ fn build_options( let end_page_in_plus_option: Option = match page_plus_re .captures(&free_args) .map(|i| i.get(1).unwrap().as_str().trim()) - .filter(|i| i.contains(":")) + .filter(|i| i.contains(':')) .map(|unparsed_num| { - let x: Vec<&str> = unparsed_num.split(":").collect(); + let x: Vec<&str> = unparsed_num.split(':').collect(); x[1].to_string().parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) }) @@ -667,7 +671,7 @@ fn build_options( let start_page: usize = match matches .opt_str(PAGE_RANGE_OPTION) .map(|i| { - let x: Vec<&str> = i.split(":").collect(); + let x: Vec<&str> = i.split(':').collect(); x[0].to_string() }) .map(invalid_pages_map) @@ -678,9 +682,9 @@ fn build_options( let end_page: Option = match matches .opt_str(PAGE_RANGE_OPTION) - .filter(|i: &String| i.contains(":")) + .filter(|i: &String| i.contains(':')) .map(|i: String| { - let x: Vec<&str> = i.split(":").collect(); + let x: Vec<&str> = i.split(':').collect(); x[1].to_string() }) .map(invalid_pages_map) @@ -885,7 +889,7 @@ fn split_lines_if_form_feed(file_content: Result) -> Vec) -> Vec Result { +fn pr(path: &str, options: &OutputOptions) -> Result { let lines: Lines>> = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines(); @@ -910,9 +914,10 @@ fn pr(path: &String, options: &OutputOptions) -> Result { for page_with_page_number in pages { let page_number = page_with_page_number.0 + 1; let page = page_with_page_number.1; - print_page(&page, options, &page_number)?; + print_page(&page, options, page_number)?; } - return Ok(0); + + Ok(0) } fn read_stream_and_create_pages( @@ -925,10 +930,10 @@ fn read_stream_and_create_pages( let last_page: Option = options.end_page; let lines_needed_per_page: usize = lines_to_read_for_page(options); - return Box::new( + Box::new( lines .map(split_lines_if_form_feed) - .flat_map(|i: Vec| i) + .flatten() .enumerate() .map(move |i: (usize, FileLine)| FileLine { line_number: i.0 + start_line_number, @@ -956,26 +961,28 @@ fn read_stream_and_create_pages( } } - if first_page.len() == 0 { + if first_page.is_empty() { return None; } page_with_lines.push(first_page); - return Some(page_with_lines); + Some(page_with_lines) }) // Create set of pages as form feeds could lead to empty pages - .flat_map(|x| x) // Flatten to pages from page sets + .flatten() // Flatten to pages from page sets .enumerate() // Assign page number .skip_while(move |x: &(usize, Vec)| { // Skip the not needed pages let current_page = x.0 + 1; - return current_page < start_page; + + current_page < start_page }) .take_while(move |x: &(usize, Vec)| { // Take only the required pages let current_page = x.0 + 1; - return current_page >= start_page - && (last_page.is_none() || current_page <= last_page.unwrap()); + + current_page >= start_page + && (last_page.is_none() || current_page <= last_page.unwrap()) }), - ); + ) } fn mpr(paths: &Vec, options: &OutputOptions) -> Result { @@ -1021,9 +1028,9 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { }) .group_by(|file_line: &FileLine| file_line.group_key); - let start_page: &usize = &options.start_page; + let start_page: usize = options.start_page; let mut lines: Vec = Vec::new(); - let mut page_counter: usize = *start_page; + let mut page_counter = start_page; for (_key, file_line_group) in file_line_groups.into_iter() { for file_line in file_line_group { @@ -1032,7 +1039,7 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { } let new_page_number = file_line.page_number; if page_counter != new_page_number { - print_page(&lines, options, &page_counter)?; + print_page(&lines, options, page_counter)?; lines = Vec::new(); page_counter = new_page_number; } @@ -1040,15 +1047,15 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { } } - print_page(&lines, options, &page_counter)?; + print_page(&lines, options, page_counter)?; - return Ok(0); + Ok(0) } fn print_page( lines: &Vec, options: &OutputOptions, - page: &usize, + page: usize, ) -> Result { let line_separator = options.line_separator.as_bytes(); let page_separator = options.page_separator_char.as_bytes(); @@ -1059,20 +1066,20 @@ fn print_page( out.lock(); for x in header { - out.write(x.as_bytes())?; - out.write(line_separator)?; + out.write_all(x.as_bytes())?; + out.write_all(line_separator)?; } let lines_written = write_columns(lines, options, out)?; for index in 0..trailer_content.len() { let x: &String = trailer_content.get(index).unwrap(); - out.write(x.as_bytes())?; + out.write_all(x.as_bytes())?; if index + 1 != trailer_content.len() { - out.write(line_separator)?; + out.write_all(line_separator)?; } } - out.write(page_separator)?; + out.write_all(page_separator)?; out.flush()?; Ok(lines_written) } @@ -1146,8 +1153,8 @@ fn write_columns( let indexes = row.len(); for (i, cell) in row.iter().enumerate() { if cell.is_none() && options.merge_files_print.is_some() { - out.write( - get_line_for_printing(&options, &blank_line, columns, &i, &line_width, indexes) + out.write_all( + get_line_for_printing(&options, &blank_line, columns, i, &line_width, indexes) .as_bytes(), )?; } else if cell.is_none() { @@ -1156,8 +1163,8 @@ fn write_columns( } else if cell.is_some() { let file_line: &FileLine = cell.unwrap(); - out.write( - get_line_for_printing(&options, file_line, columns, &i, &line_width, indexes) + out.write_all( + get_line_for_printing(&options, file_line, columns, i, &line_width, indexes) .as_bytes(), )?; lines_printed += 1; @@ -1166,7 +1173,7 @@ fn write_columns( if not_found_break && feed_line_present { break; } else { - out.write(line_separator)?; + out.write_all(line_separator)?; } } @@ -1177,7 +1184,7 @@ fn get_line_for_printing( options: &OutputOptions, file_line: &FileLine, columns: usize, - index: &usize, + index: usize, line_width: &Option, indexes: usize, ) -> String { @@ -1222,9 +1229,9 @@ fn get_line_for_printing( ) } -fn get_fmtd_line_number(opts: &OutputOptions, line_number: usize, index: &usize) -> String { +fn get_fmtd_line_number(opts: &OutputOptions, line_number: usize, index: usize) -> String { let should_show_line_number = - opts.number.is_some() && (opts.merge_files_print.is_none() || index == &0); + opts.number.is_some() && (opts.merge_files_print.is_none() || index == 0); if should_show_line_number && line_number != 0 { let line_str = line_number.to_string(); let num_opt = opts.number.as_ref().unwrap(); @@ -1250,7 +1257,7 @@ fn get_fmtd_line_number(opts: &OutputOptions, line_number: usize, index: &usize) /// # Arguments /// * `options` - A reference to OutputOptions /// * `page` - A reference to page number -fn header_content(options: &OutputOptions, page: &usize) -> Vec { +fn header_content(options: &OutputOptions, page: usize) -> Vec { if options.display_header_and_trailer { let first_line: String = format!( "{} {} Page {}", From 9e759267ee8215fd34b5bd1ecc6e1675fcd71d7a Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Fri, 26 Mar 2021 18:19:52 +0300 Subject: [PATCH 049/126] pr: Remove commented out stuff from Cargo.toml --- src/uu/pr/Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 2eb8a03fe..0a86d3ac8 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -25,9 +25,6 @@ quick-error = "1.2.3" itertools = "0.10" regex = "1.0" -#[target.'cfg(unix)'.dependencies] -#unix_socket = "0.5.0" - [[bin]] name = "pr" path = "src/main.rs" From 0487360507a4204ca733b4351fa189fad55da159 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 29 May 2021 14:30:30 +0200 Subject: [PATCH 050/126] pr: make tests compile again --- Cargo.lock | 19 ++++++++++--------- src/uu/pr/Cargo.toml | 2 +- tests/common/util.rs | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c59af5c06..069fd04dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -206,6 +206,7 @@ dependencies = [ name = "coreutils" version = "0.0.6" dependencies = [ + "chrono", "conv", "filetime", "glob 0.3.0", @@ -2152,16 +2153,16 @@ dependencies = [ [[package]] name = "uu_pr" -version = "0.0.4" +version = "0.0.6" dependencies = [ - "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.7", - "uucore_procs 0.0.5", + "chrono", + "getopts", + "itertools 0.10.0", + "quick-error", + "regex", + "time", + "uucore", + "uucore_procs", ] [[package]] diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 0a86d3ac8..53f2a69b6 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pr" -version = "0.0.4" +version = "0.0.6" authors = ["uutils developers"] license = "MIT" description = "pr ~ (uutils) convert text files for printing" diff --git a/tests/common/util.rs b/tests/common/util.rs index fa6ae29c5..9b6942bac 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -205,8 +205,8 @@ impl CmdResult { } /// like stdout_is_fixture(...), but replaces the data in fixture file based on values provided in template_vars /// command output - pub fn stdout_is_templated_fixture>(&self, file_rel_path: T, template_vars: Vec<(&String, &String)>) -> Box<&CmdResult> { - let mut contents = read_scenario_fixture(&self.tmpd, file_rel_path); + pub fn stdout_is_templated_fixture>(&self, file_rel_path: T, template_vars: Vec<(&String, &String)>) -> &CmdResult { + let mut contents = String::from_utf8(read_scenario_fixture(&self.tmpd, file_rel_path)).unwrap(); for kv in template_vars { contents = contents.replace(kv.0, kv.1); } From d94ee87d15063c299135cc8e446c954c5c3c2c40 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 29 May 2021 14:42:24 +0200 Subject: [PATCH 051/126] pr: move options into mod --- src/uu/pr/src/pr.rs | 143 ++++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 70 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 81a3dfe9a..aa9510690 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -12,7 +12,7 @@ extern crate quick_error; use chrono::offset::Local; use chrono::DateTime; use getopts::{HasArg, Occur}; -use getopts::{Matches, Options}; +use getopts::Matches; use itertools::structs::KMergeBy; use itertools::{GroupBy, Itertools}; use quick_error::ResultExt; @@ -35,25 +35,6 @@ static LINES_PER_PAGE: usize = 66; static LINES_PER_PAGE_FOR_FORM_FEED: usize = 63; static HEADER_LINES_PER_PAGE: usize = 5; static TRAILER_LINES_PER_PAGE: usize = 5; -static STRING_HEADER_OPTION: &str = "h"; -static DOUBLE_SPACE_OPTION: &str = "d"; -static NUMBERING_MODE_OPTION: &str = "n"; -static FIRST_LINE_NUMBER_OPTION: &str = "N"; -static PAGE_RANGE_OPTION: &str = "pages"; -static NO_HEADER_TRAILER_OPTION: &str = "t"; -static PAGE_LENGTH_OPTION: &str = "l"; -static SUPPRESS_PRINTING_ERROR: &str = "r"; -static FORM_FEED_OPTION: &str = "F"; -static FORM_FEED_OPTION_SMALL: &str = "f"; -static COLUMN_WIDTH_OPTION: &str = "w"; -static PAGE_WIDTH_OPTION: &str = "W"; -static ACROSS_OPTION: &str = "a"; -static COLUMN_OPTION: &str = "column"; -static COLUMN_CHAR_SEPARATOR_OPTION: &str = "s"; -static COLUMN_STRING_SEPARATOR_OPTION: &str = "S"; -static MERGE_FILES_PRINT: &str = "m"; -static OFFSET_SPACES_OPTION: &str = "o"; -static JOIN_LINES_OPTION: &str = "J"; static FILE_STDIN: &str = "-"; static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; @@ -61,6 +42,28 @@ static DEFAULT_COLUMN_WIDTH_WITH_S_OPTION: usize = 512; static DEFAULT_COLUMN_SEPARATOR: &char = &TAB; static FF: u8 = 0x0C as u8; +mod options { + pub static STRING_HEADER_OPTION: &str = "h"; + pub static DOUBLE_SPACE_OPTION: &str = "d"; + pub static NUMBERING_MODE_OPTION: &str = "n"; + pub static FIRST_LINE_NUMBER_OPTION: &str = "N"; + pub static PAGE_RANGE_OPTION: &str = "pages"; + pub static NO_HEADER_TRAILER_OPTION: &str = "t"; + pub static PAGE_LENGTH_OPTION: &str = "l"; + pub static SUPPRESS_PRINTING_ERROR: &str = "r"; + pub static FORM_FEED_OPTION: &str = "F"; + pub static FORM_FEED_OPTION_SMALL: &str = "f"; + pub static COLUMN_WIDTH_OPTION: &str = "w"; + pub static PAGE_WIDTH_OPTION: &str = "W"; + pub static ACROSS_OPTION: &str = "a"; + pub static COLUMN_OPTION: &str = "column"; + pub static COLUMN_CHAR_SEPARATOR_OPTION: &str = "s"; + pub static COLUMN_STRING_SEPARATOR_OPTION: &str = "S"; + pub static MERGE_FILES_PRINT: &str = "m"; + pub static OFFSET_SPACES_OPTION: &str = "o"; + pub static JOIN_LINES_OPTION: &str = "J"; +} + struct OutputOptions { /// Line numbering mode number: Option, @@ -184,7 +187,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { opts.opt( "", - PAGE_RANGE_OPTION, + options::PAGE_RANGE_OPTION, "Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]", "FIRST_PAGE[:LAST_PAGE]", HasArg::Yes, @@ -192,7 +195,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - STRING_HEADER_OPTION, + options::STRING_HEADER_OPTION, "header", "Use the string header to replace the file name \ in the header line.", @@ -202,7 +205,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - DOUBLE_SPACE_OPTION, + options::DOUBLE_SPACE_OPTION, "double-space", "Produce output that is double spaced. An extra character is output following every found in the input.", @@ -212,7 +215,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - NUMBERING_MODE_OPTION, + options::NUMBERING_MODE_OPTION, "number-lines", "Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies the first width column positions of each text column or each line of -m output. If char (any nondigit @@ -224,7 +227,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - FIRST_LINE_NUMBER_OPTION, + options::FIRST_LINE_NUMBER_OPTION, "first-line-number", "start counting with NUMBER at 1st line of first page printed", "NUMBER", @@ -233,7 +236,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - NO_HEADER_TRAILER_OPTION, + options::NO_HEADER_TRAILER_OPTION, "omit-header", "Write neither the five-line identifying header nor the five-line trailer usually supplied for each page. Quit writing after the last line of each file without spacing to the end of the page.", @@ -243,7 +246,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - PAGE_LENGTH_OPTION, + options::PAGE_LENGTH_OPTION, "length", "Override the 66-line default (default number of lines of text 56, and with -F 63) and reset the page length to lines. If lines is not greater than the sum of both the header and trailer depths (in lines), the pr utility shall suppress both the header and trailer, as if the @@ -254,7 +257,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - SUPPRESS_PRINTING_ERROR, + options::SUPPRESS_PRINTING_ERROR, "no-file-warnings", "omit warning when a file cannot be opened", "", @@ -263,7 +266,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - FORM_FEED_OPTION, + options::FORM_FEED_OPTION, "form-feed", "Use a for new pages, instead of the default behavior that uses a sequence of s.", "", @@ -271,7 +274,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Occur::Optional, ); opts.opt( - FORM_FEED_OPTION_SMALL, + options::FORM_FEED_OPTION_SMALL, "form-feed", "Same as -F but pause before beginning the first page if standard output is a terminal.", @@ -282,7 +285,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { opts.opt( "", - COLUMN_OPTION, + options::COLUMN_OPTION, "Produce multi-column output that is arranged in column columns (the default shall be 1) and is written down each column in the order in which the text is received from the input file. This option should not be used with -m. The options -e and -i shall be assumed for multiple text-column output. Whether or not text columns are pro‐ @@ -294,7 +297,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - COLUMN_WIDTH_OPTION, + options::COLUMN_WIDTH_OPTION, "width", "Set the width of the line to width column positions for multiple text-column output only. If the -w option is not specified and the -s option is not specified, the default width shall be 72. If the -w option is not speci‐ @@ -305,7 +308,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - PAGE_WIDTH_OPTION, + options::PAGE_WIDTH_OPTION, "page-width", "set page width to PAGE_WIDTH (72) characters always, truncate lines, except -J option is set, no interference @@ -316,7 +319,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - ACROSS_OPTION, + options::ACROSS_OPTION, "across", "Modify the effect of the - column option so that the columns are filled across the page in a round-robin order (for example, when column is 2, the first input line heads column 1, the second heads column 2, the third is the @@ -327,7 +330,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - COLUMN_CHAR_SEPARATOR_OPTION, + options::COLUMN_CHAR_SEPARATOR_OPTION, "separator", "Separate text columns by the single character char instead of by the appropriate number of s (default for char is the character).", @@ -337,7 +340,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - COLUMN_STRING_SEPARATOR_OPTION, + options::COLUMN_STRING_SEPARATOR_OPTION, "sep-string", "separate columns by STRING, without -S: Default separator with -J and @@ -348,7 +351,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - MERGE_FILES_PRINT, + options::MERGE_FILES_PRINT, "merge", "Merge files. Standard output shall be formatted so the pr utility writes one line from each file specified by a file operand, side by side into text columns of equal fixed widths, in terms of the number of column positions. @@ -359,7 +362,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - OFFSET_SPACES_OPTION, + options::OFFSET_SPACES_OPTION, "indent", "Each line of output shall be preceded by offset s. If the -o option is not specified, the default offset shall be zero. The space taken is in addition to the output line width (see the -w option below).", @@ -369,7 +372,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ); opts.opt( - JOIN_LINES_OPTION, + options::JOIN_LINES_OPTION, "join-lines", "merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators", @@ -403,7 +406,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { return print_usage(&mut opts, &matches); } - let file_groups: Vec> = if matches.opt_present(MERGE_FILES_PRINT) { + let file_groups: Vec> = if matches.opt_present(options::MERGE_FILES_PRINT) { vec![files] } else { files.into_iter().map(|i| vec![i]).collect() @@ -477,12 +480,12 @@ fn recreate_arguments(args: &Vec) -> Vec { } fn print_error(matches: &Matches, err: PrError) { - if !matches.opt_present(SUPPRESS_PRINTING_ERROR) { + if !matches.opt_present(options::SUPPRESS_PRINTING_ERROR) { eprintln!("{}", err); } } -fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { +fn print_usage(opts: &mut getopts::Options, matches: &Matches) -> i32 { println!("{} {} -- print files", NAME, VERSION); println!(); println!( @@ -517,7 +520,7 @@ fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { println!(" +page \t\tBegin output at page number page of the formatted input."); println!( " -column \t\tProduce multi-column output. Refer --{}", - COLUMN_OPTION + options::COLUMN_OPTION ); if matches.free.is_empty() { return 1; @@ -546,30 +549,30 @@ fn build_options( free_args: String, ) -> Result { let form_feed_used = - matches.opt_present(FORM_FEED_OPTION) || matches.opt_present(FORM_FEED_OPTION_SMALL); + matches.opt_present(options::FORM_FEED_OPTION) || matches.opt_present(options::FORM_FEED_OPTION_SMALL); - let is_merge_mode: bool = matches.opt_present(MERGE_FILES_PRINT); + let is_merge_mode: bool = matches.opt_present(options::MERGE_FILES_PRINT); - if is_merge_mode && matches.opt_present(COLUMN_OPTION) { + if is_merge_mode && matches.opt_present(options::COLUMN_OPTION) { let err_msg: String = String::from("cannot specify number of columns when printing in parallel"); return Err(PrError::EncounteredErrors(err_msg)); } - if is_merge_mode && matches.opt_present(ACROSS_OPTION) { + if is_merge_mode && matches.opt_present(options::ACROSS_OPTION) { let err_msg: String = String::from("cannot specify both printing across and printing in parallel"); return Err(PrError::EncounteredErrors(err_msg)); } - let merge_files_print: Option = if matches.opt_present(MERGE_FILES_PRINT) { + let merge_files_print: Option = if matches.opt_present(options::MERGE_FILES_PRINT) { Some(paths.len()) } else { None }; let header: String = matches - .opt_str(STRING_HEADER_OPTION) + .opt_str(options::STRING_HEADER_OPTION) .unwrap_or(if is_merge_mode { String::new() } else { @@ -582,10 +585,10 @@ fn build_options( let default_first_number: usize = NumberingMode::default().first_number; let first_number: usize = - parse_usize(matches, FIRST_LINE_NUMBER_OPTION).unwrap_or(Ok(default_first_number))?; + parse_usize(matches, options::FIRST_LINE_NUMBER_OPTION).unwrap_or(Ok(default_first_number))?; let number: Option = matches - .opt_str(NUMBERING_MODE_OPTION) + .opt_str(options::NUMBERING_MODE_OPTION) .map(|i| { let parse_result: Result = i.parse::(); @@ -610,14 +613,14 @@ fn build_options( } }) .or_else(|| { - if matches.opt_present(NUMBERING_MODE_OPTION) { + if matches.opt_present(options::NUMBERING_MODE_OPTION) { return Some(NumberingMode::default()); } None }); - let double_space: bool = matches.opt_present(DOUBLE_SPACE_OPTION); + let double_space: bool = matches.opt_present(options::DOUBLE_SPACE_OPTION); let content_line_separator: String = if double_space { "\n".repeat(2) @@ -662,14 +665,14 @@ fn build_options( }; let invalid_pages_map = |i: String| { - let unparsed_value: String = matches.opt_str(PAGE_RANGE_OPTION).unwrap(); + let unparsed_value: String = matches.opt_str(options::PAGE_RANGE_OPTION).unwrap(); i.parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid --pages argument '{}'", unparsed_value)) }) }; let start_page: usize = match matches - .opt_str(PAGE_RANGE_OPTION) + .opt_str(options::PAGE_RANGE_OPTION) .map(|i| { let x: Vec<&str> = i.split(':').collect(); x[0].to_string() @@ -681,7 +684,7 @@ fn build_options( }; let end_page: Option = match matches - .opt_str(PAGE_RANGE_OPTION) + .opt_str(options::PAGE_RANGE_OPTION) .filter(|i: &String| i.contains(':')) .map(|i: String| { let x: Vec<&str> = i.split(':').collect(); @@ -708,12 +711,12 @@ fn build_options( }; let page_length: usize = - parse_usize(matches, PAGE_LENGTH_OPTION).unwrap_or(Ok(default_lines_per_page))?; + parse_usize(matches, options::PAGE_LENGTH_OPTION).unwrap_or(Ok(default_lines_per_page))?; let page_length_le_ht: bool = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); let display_header_and_trailer: bool = - !(page_length_le_ht) && !matches.opt_present(NO_HEADER_TRAILER_OPTION); + !(page_length_le_ht) && !matches.opt_present(options::NO_HEADER_TRAILER_OPTION); let content_lines_per_page: usize = if page_length_le_ht { page_length @@ -721,23 +724,23 @@ fn build_options( page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE) }; - let page_separator_char: String = if matches.opt_present(FORM_FEED_OPTION) { + let page_separator_char: String = if matches.opt_present(options::FORM_FEED_OPTION) { let bytes = vec![FF]; String::from_utf8(bytes).unwrap() } else { "\n".to_string() }; - let across_mode: bool = matches.opt_present(ACROSS_OPTION); + let across_mode: bool = matches.opt_present(options::ACROSS_OPTION); - let column_separator: String = match matches.opt_str(COLUMN_STRING_SEPARATOR_OPTION) { + let column_separator: String = match matches.opt_str(options::COLUMN_STRING_SEPARATOR_OPTION) { Some(x) => Some(x), - None => matches.opt_str(COLUMN_CHAR_SEPARATOR_OPTION), + None => matches.opt_str(options::COLUMN_CHAR_SEPARATOR_OPTION), } .unwrap_or(DEFAULT_COLUMN_SEPARATOR.to_string()); - let default_column_width = if matches.opt_present(COLUMN_WIDTH_OPTION) - && matches.opt_present(COLUMN_CHAR_SEPARATOR_OPTION) + let default_column_width = if matches.opt_present(options::COLUMN_WIDTH_OPTION) + && matches.opt_present(options::COLUMN_CHAR_SEPARATOR_OPTION) { DEFAULT_COLUMN_WIDTH_WITH_S_OPTION } else { @@ -745,12 +748,12 @@ fn build_options( }; let column_width: usize = - parse_usize(matches, COLUMN_WIDTH_OPTION).unwrap_or(Ok(default_column_width))?; + parse_usize(matches, options::COLUMN_WIDTH_OPTION).unwrap_or(Ok(default_column_width))?; - let page_width: Option = if matches.opt_present(JOIN_LINES_OPTION) { + let page_width: Option = if matches.opt_present(options::JOIN_LINES_OPTION) { None } else { - match parse_usize(matches, PAGE_WIDTH_OPTION) { + match parse_usize(matches, options::PAGE_WIDTH_OPTION) { Some(res) => Some(res?), None => None, } @@ -770,7 +773,7 @@ fn build_options( // --column has more priority than -column - let column_option_value: Option = match parse_usize(matches, COLUMN_OPTION) { + let column_option_value: Option = match parse_usize(matches, options::COLUMN_OPTION) { Some(res) => Some(res?), _ => start_column_option, }; @@ -786,8 +789,8 @@ fn build_options( }; let offset_spaces: String = - " ".repeat(parse_usize(matches, OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?); - let join_lines: bool = matches.opt_present(JOIN_LINES_OPTION); + " ".repeat(parse_usize(matches, options::OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?); + let join_lines: bool = matches.opt_present(options::JOIN_LINES_OPTION); let col_sep_for_printing = column_mode_options .as_ref() From 12287fcc9cd616c86d9dd6e2af1852fea20faf10 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 29 May 2021 18:44:12 +0200 Subject: [PATCH 052/126] pr: fix clippy lints --- src/uu/pr/src/pr.rs | 107 ++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 63 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index aa9510690..988327c63 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -11,20 +11,17 @@ extern crate quick_error; use chrono::offset::Local; use chrono::DateTime; -use getopts::{HasArg, Occur}; use getopts::Matches; -use itertools::structs::KMergeBy; -use itertools::{GroupBy, Itertools}; +use getopts::{HasArg, Occur}; +use itertools::Itertools; use quick_error::ResultExt; use regex::Regex; use std::convert::From; use std::fs::{metadata, File, Metadata}; use std::io::{stdin, stdout, BufRead, BufReader, Lines, Read, Stdin, Stdout, Write}; -use std::iter::{FlatMap, Map}; use std::num::ParseIntError; #[cfg(unix)] use std::os::unix::fs::FileTypeExt; -use std::vec::Vec; type IOError = std::io::Error; @@ -40,7 +37,7 @@ static READ_BUFFER_SIZE: usize = 1024 * 64; static DEFAULT_COLUMN_WIDTH: usize = 72; static DEFAULT_COLUMN_WIDTH_WITH_S_OPTION: usize = 512; static DEFAULT_COLUMN_SEPARATOR: &char = &TAB; -static FF: u8 = 0x0C as u8; +static FF: u8 = 0x0C_u8; mod options { pub static STRING_HEADER_OPTION: &str = "h"; @@ -448,16 +445,15 @@ pub fn uumain(args: impl uucore::Args) -> i32 { /// Removes -column and +page option as getopts cannot parse things like -3 etc /// # Arguments /// * `args` - Command line arguments -fn recreate_arguments(args: &Vec) -> Vec { +fn recreate_arguments(args: &[String]) -> Vec { let column_page_option = Regex::new(r"^[-+]\d+.*").unwrap(); let num_regex: Regex = Regex::new(r"(.\d+)|(\d+)|^[^-]$").unwrap(); //let a_file: Regex = Regex::new(r"^[^-+].*").unwrap(); let n_regex: Regex = Regex::new(r"^-n\s*$").unwrap(); - let mut arguments = args.clone(); + let mut arguments = args.to_owned(); let num_option: Option<(usize, &String)> = args.iter().find_position(|x| n_regex.is_match(x.trim())); - if num_option.is_some() { - let (pos, _value) = num_option.unwrap(); + if let Some((pos, _value)) = num_option { let num_val_opt = args.get(pos + 1); if num_val_opt.is_some() && !num_regex.is_match(num_val_opt.unwrap()) { let could_be_file = arguments.remove(pos + 1); @@ -545,11 +541,11 @@ fn parse_usize(matches: &Matches, opt: &str) -> Option> { fn build_options( matches: &Matches, - paths: &Vec, + paths: &[String], free_args: String, ) -> Result { - let form_feed_used = - matches.opt_present(options::FORM_FEED_OPTION) || matches.opt_present(options::FORM_FEED_OPTION_SMALL); + let form_feed_used = matches.opt_present(options::FORM_FEED_OPTION) + || matches.opt_present(options::FORM_FEED_OPTION_SMALL); let is_merge_mode: bool = matches.opt_present(options::MERGE_FILES_PRINT); @@ -571,21 +567,17 @@ fn build_options( None }; - let header: String = matches - .opt_str(options::STRING_HEADER_OPTION) - .unwrap_or(if is_merge_mode { + let header: String = matches.opt_str(options::STRING_HEADER_OPTION).unwrap_or( + if is_merge_mode || paths[0] == FILE_STDIN { String::new() } else { - if paths[0] == FILE_STDIN { - String::new() - } else { - paths[0].to_string() - } - }); + paths[0].to_string() + }, + ); let default_first_number: usize = NumberingMode::default().first_number; - let first_number: usize = - parse_usize(matches, options::FIRST_LINE_NUMBER_OPTION).unwrap_or(Ok(default_first_number))?; + let first_number: usize = parse_usize(matches, options::FIRST_LINE_NUMBER_OPTION) + .unwrap_or(Ok(default_first_number))?; let number: Option = matches .opt_str(options::NUMBERING_MODE_OPTION) @@ -598,12 +590,11 @@ fn build_options( NumberingMode::default().separator }; - let width: usize = if parse_result.is_err() { - i[1..] + let width: usize = match parse_result { + Ok(res) => res, + Err(_) => i[1..] .parse::() - .unwrap_or(NumberingMode::default().width) - } else { - parse_result.unwrap() + .unwrap_or(NumberingMode::default().width), }; NumberingMode { @@ -737,7 +728,7 @@ fn build_options( Some(x) => Some(x), None => matches.opt_str(options::COLUMN_CHAR_SEPARATOR_OPTION), } - .unwrap_or(DEFAULT_COLUMN_SEPARATOR.to_string()); + .unwrap_or_else(|| DEFAULT_COLUMN_SEPARATOR.to_string()); let default_column_width = if matches.opt_present(options::COLUMN_WIDTH_OPTION) && matches.opt_present(options::COLUMN_CHAR_SEPARATOR_OPTION) @@ -778,15 +769,13 @@ fn build_options( _ => start_column_option, }; - let column_mode_options: Option = match column_option_value { - Some(columns) => Some(ColumnModeOptions { + let column_mode_options: Option = + column_option_value.map(|columns| ColumnModeOptions { columns, width: column_width, column_separator, across_mode, - }), - _ => None, - }; + }); let offset_spaces: String = " ".repeat(parse_usize(matches, options::OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?); @@ -795,14 +784,14 @@ fn build_options( let col_sep_for_printing = column_mode_options .as_ref() .map(|i| i.column_separator.clone()) - .unwrap_or( + .unwrap_or_else(|| { merge_files_print .map(|_k| DEFAULT_COLUMN_SEPARATOR.to_string()) - .unwrap_or(String::new()), - ); + .unwrap_or_default() + }); - let columns_to_print = - merge_files_print.unwrap_or(column_mode_options.as_ref().map(|i| i.columns).unwrap_or(1)); + let columns_to_print = merge_files_print + .unwrap_or_else(|| column_mode_options.as_ref().map(|i| i.columns).unwrap_or(1)); let line_width: Option = if join_lines { None @@ -864,7 +853,7 @@ fn open(path: &str) -> Result, PrError> { _ => Err(PrError::UnknownFiletype(path_string)), } }) - .unwrap_or(Err(PrError::NotExists(path.to_string()))) + .unwrap_or_else(|_| Err(PrError::NotExists(path.to_string()))) } fn split_lines_if_form_feed(file_content: Result) -> Vec { @@ -988,7 +977,7 @@ fn read_stream_and_create_pages( ) } -fn mpr(paths: &Vec, options: &OutputOptions) -> Result { +fn mpr(paths: &[String], options: &OutputOptions) -> Result { let nfiles = paths.len(); // Check if files exists @@ -996,11 +985,7 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { open(path)?; } - let file_line_groups: GroupBy< - usize, - KMergeBy)>>, _>, _, _>, _>, - _, - > = paths + let file_line_groups = paths .iter() .enumerate() .map(|indexed_path: (usize, &String)| { @@ -1018,9 +1003,9 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { group_key: page_number * nfiles + fl.file_id, ..fl }) - .collect() + .collect::>() }) - .flat_map(|x: Vec| x) + .flatten() }) .kmerge_by(|a: &FileLine, b: &FileLine| { if a.group_key == b.group_key { @@ -1055,11 +1040,7 @@ fn mpr(paths: &Vec, options: &OutputOptions) -> Result { Ok(0) } -fn print_page( - lines: &Vec, - options: &OutputOptions, - page: usize, -) -> Result { +fn print_page(lines: &[FileLine], options: &OutputOptions, page: usize) -> Result { let line_separator = options.line_separator.as_bytes(); let page_separator = options.page_separator_char.as_bytes(); @@ -1088,7 +1069,7 @@ fn print_page( } fn write_columns( - lines: &Vec, + lines: &[FileLine], options: &OutputOptions, out: &mut Stdout, ) -> Result { @@ -1100,7 +1081,9 @@ fn write_columns( options.content_lines_per_page }; - let columns = options.merge_files_print.unwrap_or(get_columns(options)); + let columns = options + .merge_files_print + .unwrap_or_else(|| get_columns(options)); let line_width: Option = options.line_width; let mut lines_printed = 0; let feed_line_present = options.form_feed_used; @@ -1123,9 +1106,9 @@ fn write_columns( break; } filled_lines.push(Some(line)); - offset += 1; inserted += 1; } + offset += inserted; for _i in inserted..content_lines_per_page { filled_lines.push(None); @@ -1279,18 +1262,16 @@ fn header_content(options: &OutputOptions, page: usize) -> Vec { } fn file_last_modified_time(path: &str) -> String { - let file_metadata = metadata(path); - return file_metadata + metadata(path) .map(|i| { - return i - .modified() + i.modified() .map(|x| { let datetime: DateTime = x.into(); datetime.format("%b %d %H:%M %Y").to_string() }) - .unwrap_or(String::new()); + .unwrap_or_default() }) - .unwrap_or(String::new()); + .unwrap_or_default() } /// Returns five empty lines as trailer content if displaying trailer From 0913a776673c9a6416ae170a1c2ea0a4a3d32c95 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 29 May 2021 18:58:23 +0200 Subject: [PATCH 053/126] pr: let type inference do its works --- src/uu/pr/src/pr.rs | 224 +++++++++++++++++++++----------------------- 1 file changed, 107 insertions(+), 117 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 988327c63..06e358898 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -17,9 +17,8 @@ use itertools::Itertools; use quick_error::ResultExt; use regex::Regex; use std::convert::From; -use std::fs::{metadata, File, Metadata}; -use std::io::{stdin, stdout, BufRead, BufReader, Lines, Read, Stdin, Stdout, Write}; -use std::num::ParseIntError; +use std::fs::{metadata, File}; +use std::io::{stdin, stdout, BufRead, BufReader, Lines, Read, Stdout, Write}; #[cfg(unix)] use std::os::unix::fs::FileTypeExt; @@ -381,7 +380,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { opts.optflag("", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); - let opt_args: Vec = recreate_arguments(&args); + let opt_args = recreate_arguments(&args); let matches = match opts.parse(&opt_args[1..]) { Ok(m) => m, @@ -393,7 +392,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { return 0; } - let mut files: Vec = matches.free.clone(); + let mut files = matches.free.clone(); if files.is_empty() { //For stdin files.insert(0, FILE_STDIN.to_owned()); @@ -403,30 +402,29 @@ pub fn uumain(args: impl uucore::Args) -> i32 { return print_usage(&mut opts, &matches); } - let file_groups: Vec> = if matches.opt_present(options::MERGE_FILES_PRINT) { + let file_groups: Vec<_> = if matches.opt_present(options::MERGE_FILES_PRINT) { vec![files] } else { files.into_iter().map(|i| vec![i]).collect() }; for file_group in file_groups { - let result_options: Result = - build_options(&matches, &file_group, args.join(" ")); + let result_options = build_options(&matches, &file_group, args.join(" ")); if result_options.is_err() { print_error(&matches, result_options.err().unwrap()); return 1; } - let options: &OutputOptions = &result_options.unwrap(); + let options = &result_options.unwrap(); - let cmd_result: Result = if file_group.len() == 1 { + let cmd_result = if file_group.len() == 1 { pr(&file_group.get(0).unwrap(), options) } else { mpr(&file_group, options) }; - let status: i32 = match cmd_result { + let status = match cmd_result { Err(error) => { print_error(&matches, error); 1 @@ -447,12 +445,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 { /// * `args` - Command line arguments fn recreate_arguments(args: &[String]) -> Vec { let column_page_option = Regex::new(r"^[-+]\d+.*").unwrap(); - let num_regex: Regex = Regex::new(r"(.\d+)|(\d+)|^[^-]$").unwrap(); + let num_regex = Regex::new(r"(.\d+)|(\d+)|^[^-]$").unwrap(); //let a_file: Regex = Regex::new(r"^[^-+].*").unwrap(); - let n_regex: Regex = Regex::new(r"^-n\s*$").unwrap(); + let n_regex = Regex::new(r"^-n\s*$").unwrap(); let mut arguments = args.to_owned(); - let num_option: Option<(usize, &String)> = - args.iter().find_position(|x| n_regex.is_match(x.trim())); + let num_option = args.iter().find_position(|x| n_regex.is_match(x.trim())); if let Some((pos, _value)) = num_option { let num_val_opt = args.get(pos + 1); if num_val_opt.is_some() && !num_regex.is_match(num_val_opt.unwrap()) { @@ -529,7 +526,7 @@ fn parse_usize(matches: &Matches, opt: &str) -> Option> { let from_parse_error_to_pr_error = |value_to_parse: (String, String)| { let i = value_to_parse.0; let option = value_to_parse.1; - i.parse::().map_err(|_e| { + i.parse().map_err(|_e| { PrError::EncounteredErrors(format!("invalid {} argument '{}'", option, i)) }) }; @@ -547,27 +544,25 @@ fn build_options( let form_feed_used = matches.opt_present(options::FORM_FEED_OPTION) || matches.opt_present(options::FORM_FEED_OPTION_SMALL); - let is_merge_mode: bool = matches.opt_present(options::MERGE_FILES_PRINT); + let is_merge_mode = matches.opt_present(options::MERGE_FILES_PRINT); if is_merge_mode && matches.opt_present(options::COLUMN_OPTION) { - let err_msg: String = - String::from("cannot specify number of columns when printing in parallel"); + let err_msg = String::from("cannot specify number of columns when printing in parallel"); return Err(PrError::EncounteredErrors(err_msg)); } if is_merge_mode && matches.opt_present(options::ACROSS_OPTION) { - let err_msg: String = - String::from("cannot specify both printing across and printing in parallel"); + let err_msg = String::from("cannot specify both printing across and printing in parallel"); return Err(PrError::EncounteredErrors(err_msg)); } - let merge_files_print: Option = if matches.opt_present(options::MERGE_FILES_PRINT) { + let merge_files_print = if matches.opt_present(options::MERGE_FILES_PRINT) { Some(paths.len()) } else { None }; - let header: String = matches.opt_str(options::STRING_HEADER_OPTION).unwrap_or( + let header = matches.opt_str(options::STRING_HEADER_OPTION).unwrap_or( if is_merge_mode || paths[0] == FILE_STDIN { String::new() } else { @@ -575,22 +570,22 @@ fn build_options( }, ); - let default_first_number: usize = NumberingMode::default().first_number; - let first_number: usize = parse_usize(matches, options::FIRST_LINE_NUMBER_OPTION) + let default_first_number = NumberingMode::default().first_number; + let first_number = parse_usize(matches, options::FIRST_LINE_NUMBER_OPTION) .unwrap_or(Ok(default_first_number))?; - let number: Option = matches + let number = matches .opt_str(options::NUMBERING_MODE_OPTION) .map(|i| { - let parse_result: Result = i.parse::(); + let parse_result = i.parse::(); - let separator: String = if parse_result.is_err() { + let separator = if parse_result.is_err() { i[0..1].to_string() } else { NumberingMode::default().separator }; - let width: usize = match parse_result { + let width = match parse_result { Ok(res) => res, Err(_) => i[1..] .parse::() @@ -605,24 +600,24 @@ fn build_options( }) .or_else(|| { if matches.opt_present(options::NUMBERING_MODE_OPTION) { - return Some(NumberingMode::default()); + Some(NumberingMode::default()) + } else { + None } - - None }); - let double_space: bool = matches.opt_present(options::DOUBLE_SPACE_OPTION); + let double_space = matches.opt_present(options::DOUBLE_SPACE_OPTION); - let content_line_separator: String = if double_space { + let content_line_separator = if double_space { "\n".repeat(2) } else { "\n".to_string() }; - let line_separator: String = "\n".to_string(); + let line_separator = "\n".to_string(); - let last_modified_time: String = if is_merge_mode || paths[0].eq(FILE_STDIN) { - let datetime: DateTime = Local::now(); + let last_modified_time = if is_merge_mode || paths[0].eq(FILE_STDIN) { + let datetime = Local::now(); datetime.format("%b %d %H:%M %Y").to_string() } else { file_last_modified_time(paths.get(0).unwrap()) @@ -630,9 +625,9 @@ fn build_options( // +page option is less priority than --pages let page_plus_re = Regex::new(r"\s*\+(\d+:*\d*)\s*").unwrap(); - let start_page_in_plus_option: usize = match page_plus_re.captures(&free_args).map(|i| { + let start_page_in_plus_option = match page_plus_re.captures(&free_args).map(|i| { let unparsed_num = i.get(1).unwrap().as_str().trim(); - let x: Vec<&str> = unparsed_num.split(':').collect(); + let x: Vec<_> = unparsed_num.split(':').collect(); x[0].to_string().parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) }) @@ -641,12 +636,12 @@ fn build_options( _ => 1, }; - let end_page_in_plus_option: Option = match page_plus_re + let end_page_in_plus_option = match page_plus_re .captures(&free_args) .map(|i| i.get(1).unwrap().as_str().trim()) .filter(|i| i.contains(':')) .map(|unparsed_num| { - let x: Vec<&str> = unparsed_num.split(':').collect(); + let x: Vec<_> = unparsed_num.split(':').collect(); x[1].to_string().parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) }) @@ -656,16 +651,16 @@ fn build_options( }; let invalid_pages_map = |i: String| { - let unparsed_value: String = matches.opt_str(options::PAGE_RANGE_OPTION).unwrap(); + let unparsed_value = matches.opt_str(options::PAGE_RANGE_OPTION).unwrap(); i.parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid --pages argument '{}'", unparsed_value)) }) }; - let start_page: usize = match matches + let start_page = match matches .opt_str(options::PAGE_RANGE_OPTION) .map(|i| { - let x: Vec<&str> = i.split(':').collect(); + let x: Vec<_> = i.split(':').collect(); x[0].to_string() }) .map(invalid_pages_map) @@ -674,11 +669,11 @@ fn build_options( _ => start_page_in_plus_option, }; - let end_page: Option = match matches + let end_page = match matches .opt_str(options::PAGE_RANGE_OPTION) - .filter(|i: &String| i.contains(':')) - .map(|i: String| { - let x: Vec<&str> = i.split(':').collect(); + .filter(|i| i.contains(':')) + .map(|i| { + let x: Vec<_> = i.split(':').collect(); x[1].to_string() }) .map(invalid_pages_map) @@ -701,30 +696,30 @@ fn build_options( LINES_PER_PAGE }; - let page_length: usize = + let page_length = parse_usize(matches, options::PAGE_LENGTH_OPTION).unwrap_or(Ok(default_lines_per_page))?; - let page_length_le_ht: bool = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); + let page_length_le_ht = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); - let display_header_and_trailer: bool = + let display_header_and_trailer = !(page_length_le_ht) && !matches.opt_present(options::NO_HEADER_TRAILER_OPTION); - let content_lines_per_page: usize = if page_length_le_ht { + let content_lines_per_page = if page_length_le_ht { page_length } else { page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE) }; - let page_separator_char: String = if matches.opt_present(options::FORM_FEED_OPTION) { + let page_separator_char = if matches.opt_present(options::FORM_FEED_OPTION) { let bytes = vec![FF]; String::from_utf8(bytes).unwrap() } else { "\n".to_string() }; - let across_mode: bool = matches.opt_present(options::ACROSS_OPTION); + let across_mode = matches.opt_present(options::ACROSS_OPTION); - let column_separator: String = match matches.opt_str(options::COLUMN_STRING_SEPARATOR_OPTION) { + let column_separator = match matches.opt_str(options::COLUMN_STRING_SEPARATOR_OPTION) { Some(x) => Some(x), None => matches.opt_str(options::COLUMN_CHAR_SEPARATOR_OPTION), } @@ -738,10 +733,10 @@ fn build_options( DEFAULT_COLUMN_WIDTH }; - let column_width: usize = + let column_width = parse_usize(matches, options::COLUMN_WIDTH_OPTION).unwrap_or(Ok(default_column_width))?; - let page_width: Option = if matches.opt_present(options::JOIN_LINES_OPTION) { + let page_width = if matches.opt_present(options::JOIN_LINES_OPTION) { None } else { match parse_usize(matches, options::PAGE_WIDTH_OPTION) { @@ -752,7 +747,7 @@ fn build_options( let re_col = Regex::new(r"\s*-(\d+)\s*").unwrap(); - let start_column_option: Option = match re_col.captures(&free_args).map(|i| { + let start_column_option = match re_col.captures(&free_args).map(|i| { let unparsed_num = i.get(1).unwrap().as_str().trim(); unparsed_num.parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid {} argument '{}'", "-", unparsed_num)) @@ -764,22 +759,21 @@ fn build_options( // --column has more priority than -column - let column_option_value: Option = match parse_usize(matches, options::COLUMN_OPTION) { + let column_option_value = match parse_usize(matches, options::COLUMN_OPTION) { Some(res) => Some(res?), _ => start_column_option, }; - let column_mode_options: Option = - column_option_value.map(|columns| ColumnModeOptions { - columns, - width: column_width, - column_separator, - across_mode, - }); + let column_mode_options = column_option_value.map(|columns| ColumnModeOptions { + columns, + width: column_width, + column_separator, + across_mode, + }); - let offset_spaces: String = + let offset_spaces = " ".repeat(parse_usize(matches, options::OFFSET_SPACES_OPTION).unwrap_or(Ok(0))?); - let join_lines: bool = matches.opt_present(options::JOIN_LINES_OPTION); + let join_lines = matches.opt_present(options::JOIN_LINES_OPTION); let col_sep_for_printing = column_mode_options .as_ref() @@ -793,7 +787,7 @@ fn build_options( let columns_to_print = merge_files_print .unwrap_or_else(|| column_mode_options.as_ref().map(|i| i.columns).unwrap_or(1)); - let line_width: Option = if join_lines { + let line_width = if join_lines { None } else if columns_to_print > 1 { Some( @@ -830,12 +824,12 @@ fn build_options( fn open(path: &str) -> Result, PrError> { if path == FILE_STDIN { - let stdin: Stdin = stdin(); + let stdin = stdin(); return Ok(Box::new(stdin) as Box); } metadata(path) - .map(|i: Metadata| { + .map(|i| { let path_string = path.to_string(); match i.file_type() { #[cfg(unix)] @@ -859,9 +853,9 @@ fn open(path: &str) -> Result, PrError> { fn split_lines_if_form_feed(file_content: Result) -> Vec { file_content .map(|content| { - let mut lines: Vec = Vec::new(); - let mut f_occurred: usize = 0; - let mut chunk: Vec = Vec::new(); + let mut lines = Vec::new(); + let mut f_occurred = 0; + let mut chunk = Vec::new(); for byte in content.as_bytes() { if byte == &FF { f_occurred += 1; @@ -897,11 +891,9 @@ fn split_lines_if_form_feed(file_content: Result) -> Vec Result { - let lines: Lines>> = - BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines(); + let lines = BufReader::with_capacity(READ_BUFFER_SIZE, open(path)?).lines(); - let pages: Box)>> = - read_stream_and_create_pages(options, lines, 0); + let pages = read_stream_and_create_pages(options, lines, 0); for page_with_page_number in pages { let page_number = page_with_page_number.0 + 1; @@ -917,24 +909,24 @@ fn read_stream_and_create_pages( lines: Lines>>, file_id: usize, ) -> Box)>> { - let start_page: usize = options.start_page; - let start_line_number: usize = get_start_line_number(options); - let last_page: Option = options.end_page; - let lines_needed_per_page: usize = lines_to_read_for_page(options); + let start_page = options.start_page; + let start_line_number = get_start_line_number(options); + let last_page = options.end_page; + let lines_needed_per_page = lines_to_read_for_page(options); Box::new( lines .map(split_lines_if_form_feed) .flatten() .enumerate() - .map(move |i: (usize, FileLine)| FileLine { - line_number: i.0 + start_line_number, + .map(move |(i, line)| FileLine { + line_number: i + start_line_number, file_id, - ..i.1 + ..line }) // Add line number and file_id .batching(move |it| { - let mut first_page: Vec = Vec::new(); - let mut page_with_lines: Vec> = Vec::new(); + let mut first_page = Vec::new(); + let mut page_with_lines = Vec::new(); for line in it { let form_feeds_after = line.form_feeds_after; first_page.push(line); @@ -961,15 +953,14 @@ fn read_stream_and_create_pages( }) // Create set of pages as form feeds could lead to empty pages .flatten() // Flatten to pages from page sets .enumerate() // Assign page number - .skip_while(move |x: &(usize, Vec)| { + .skip_while(move |(x, _)| { // Skip the not needed pages - let current_page = x.0 + 1; - + let current_page = x + 1; current_page < start_page }) - .take_while(move |x: &(usize, Vec)| { + .take_while(move |(x, _)| { // Take only the required pages - let current_page = x.0 + 1; + let current_page = x + 1; current_page >= start_page && (last_page.is_none() || current_page <= last_page.unwrap()) @@ -988,14 +979,13 @@ fn mpr(paths: &[String], options: &OutputOptions) -> Result { let file_line_groups = paths .iter() .enumerate() - .map(|indexed_path: (usize, &String)| { - let lines = - BufReader::with_capacity(READ_BUFFER_SIZE, open(indexed_path.1).unwrap()).lines(); + .map(|(i, path)| { + let lines = BufReader::with_capacity(READ_BUFFER_SIZE, open(path).unwrap()).lines(); - read_stream_and_create_pages(options, lines, indexed_path.0) - .map(move |x: (usize, Vec)| { - let file_line = x.1; - let page_number = x.0 + 1; + read_stream_and_create_pages(options, lines, i) + .map(move |(x, line)| { + let file_line = line; + let page_number = x + 1; file_line .into_iter() .map(|fl| FileLine { @@ -1007,17 +997,17 @@ fn mpr(paths: &[String], options: &OutputOptions) -> Result { }) .flatten() }) - .kmerge_by(|a: &FileLine, b: &FileLine| { + .kmerge_by(|a, b| { if a.group_key == b.group_key { a.line_number < b.line_number } else { a.group_key < b.group_key } }) - .group_by(|file_line: &FileLine| file_line.group_key); + .group_by(|file_line| file_line.group_key); - let start_page: usize = options.start_page; - let mut lines: Vec = Vec::new(); + let start_page = options.start_page; + let mut lines = Vec::new(); let mut page_counter = start_page; for (_key, file_line_group) in file_line_groups.into_iter() { @@ -1044,9 +1034,9 @@ fn print_page(lines: &[FileLine], options: &OutputOptions, page: usize) -> Resul let line_separator = options.line_separator.as_bytes(); let page_separator = options.page_separator_char.as_bytes(); - let header: Vec = header_content(options, page); - let trailer_content: Vec = trailer_content(options); - let out: &mut Stdout = &mut stdout(); + let header = header_content(options, page); + let trailer_content = trailer_content(options); + let out = &mut stdout(); out.lock(); for x in header { @@ -1057,7 +1047,7 @@ fn print_page(lines: &[FileLine], options: &OutputOptions, page: usize) -> Resul let lines_written = write_columns(lines, options, out)?; for index in 0..trailer_content.len() { - let x: &String = trailer_content.get(index).unwrap(); + let x = trailer_content.get(index).unwrap(); out.write_all(x.as_bytes())?; if index + 1 != trailer_content.len() { out.write_all(line_separator)?; @@ -1084,7 +1074,7 @@ fn write_columns( let columns = options .merge_files_print .unwrap_or_else(|| get_columns(options)); - let line_width: Option = options.line_width; + let line_width = options.line_width; let mut lines_printed = 0; let feed_line_present = options.form_feed_used; let mut not_found_break = false; @@ -1095,9 +1085,9 @@ fn write_columns( .map(|i| i.across_mode) .unwrap_or(false); - let mut filled_lines: Vec> = Vec::new(); + let mut filled_lines = Vec::new(); if options.merge_files_print.is_some() { - let mut offset: usize = 0; + let mut offset = 0; for col in 0..columns { let mut inserted = 0; for i in offset..lines.len() { @@ -1116,7 +1106,7 @@ fn write_columns( } } - let table: Vec>> = (0..content_lines_per_page) + let table: Vec> = (0..content_lines_per_page) .map(move |a| { (0..columns) .map(|i| { @@ -1134,7 +1124,7 @@ fn write_columns( }) .collect(); - let blank_line: FileLine = FileLine::default(); + let blank_line = FileLine::default(); for row in table { let indexes = row.len(); for (i, cell) in row.iter().enumerate() { @@ -1147,7 +1137,7 @@ fn write_columns( not_found_break = true; break; } else if cell.is_some() { - let file_line: &FileLine = cell.unwrap(); + let file_line = cell.unwrap(); out.write_all( get_line_for_printing(&options, file_line, columns, i, &line_width, indexes) @@ -1176,7 +1166,7 @@ fn get_line_for_printing( ) -> String { // Check this condition let blank_line = String::new(); - let fmtd_line_number: String = get_fmtd_line_number(&options, file_line.line_number, index); + let fmtd_line_number = get_fmtd_line_number(&options, file_line.line_number, index); let mut complete_line = format!( "{}{}", @@ -1184,9 +1174,9 @@ fn get_line_for_printing( file_line.line_content.as_ref().unwrap() ); - let offset_spaces: &String = &options.offset_spaces; + let offset_spaces = &options.offset_spaces; - let tab_count: usize = complete_line.chars().filter(|i| i == &TAB).count(); + let tab_count = complete_line.chars().filter(|i| i == &TAB).count(); let display_length = complete_line.len() + (tab_count * 7); @@ -1245,7 +1235,7 @@ fn get_fmtd_line_number(opts: &OutputOptions, line_number: usize, index: usize) /// * `page` - A reference to page number fn header_content(options: &OutputOptions, page: usize) -> Vec { if options.display_header_and_trailer { - let first_line: String = format!( + let first_line = format!( "{} {} Page {}", options.last_modified_time, options.header, page ); From 2e1035b3502dfcd90a8ff4e0e5c212ca787b41a1 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 29 May 2021 19:02:42 +0200 Subject: [PATCH 054/126] pr: static to const --- src/uu/pr/src/pr.rs | 64 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 06e358898..425a72878 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -24,40 +24,40 @@ use std::os::unix::fs::FileTypeExt; type IOError = std::io::Error; -static NAME: &str = "pr"; -static VERSION: &str = env!("CARGO_PKG_VERSION"); -static TAB: char = '\t'; -static LINES_PER_PAGE: usize = 66; -static LINES_PER_PAGE_FOR_FORM_FEED: usize = 63; -static HEADER_LINES_PER_PAGE: usize = 5; -static TRAILER_LINES_PER_PAGE: usize = 5; -static FILE_STDIN: &str = "-"; -static READ_BUFFER_SIZE: usize = 1024 * 64; -static DEFAULT_COLUMN_WIDTH: usize = 72; -static DEFAULT_COLUMN_WIDTH_WITH_S_OPTION: usize = 512; -static DEFAULT_COLUMN_SEPARATOR: &char = &TAB; -static FF: u8 = 0x0C_u8; +const NAME: &str = "pr"; +const VERSION: &str = env!("CARGO_PKG_VERSION"); +const TAB: char = '\t'; +const LINES_PER_PAGE: usize = 66; +const LINES_PER_PAGE_FOR_FORM_FEED: usize = 63; +const HEADER_LINES_PER_PAGE: usize = 5; +const TRAILER_LINES_PER_PAGE: usize = 5; +const FILE_STDIN: &str = "-"; +const READ_BUFFER_SIZE: usize = 1024 * 64; +const DEFAULT_COLUMN_WIDTH: usize = 72; +const DEFAULT_COLUMN_WIDTH_WITH_S_OPTION: usize = 512; +const DEFAULT_COLUMN_SEPARATOR: &char = &TAB; +const FF: u8 = 0x0C_u8; mod options { - pub static STRING_HEADER_OPTION: &str = "h"; - pub static DOUBLE_SPACE_OPTION: &str = "d"; - pub static NUMBERING_MODE_OPTION: &str = "n"; - pub static FIRST_LINE_NUMBER_OPTION: &str = "N"; - pub static PAGE_RANGE_OPTION: &str = "pages"; - pub static NO_HEADER_TRAILER_OPTION: &str = "t"; - pub static PAGE_LENGTH_OPTION: &str = "l"; - pub static SUPPRESS_PRINTING_ERROR: &str = "r"; - pub static FORM_FEED_OPTION: &str = "F"; - pub static FORM_FEED_OPTION_SMALL: &str = "f"; - pub static COLUMN_WIDTH_OPTION: &str = "w"; - pub static PAGE_WIDTH_OPTION: &str = "W"; - pub static ACROSS_OPTION: &str = "a"; - pub static COLUMN_OPTION: &str = "column"; - pub static COLUMN_CHAR_SEPARATOR_OPTION: &str = "s"; - pub static COLUMN_STRING_SEPARATOR_OPTION: &str = "S"; - pub static MERGE_FILES_PRINT: &str = "m"; - pub static OFFSET_SPACES_OPTION: &str = "o"; - pub static JOIN_LINES_OPTION: &str = "J"; + pub const STRING_HEADER_OPTION: &str = "h"; + pub const DOUBLE_SPACE_OPTION: &str = "d"; + pub const NUMBERING_MODE_OPTION: &str = "n"; + pub const FIRST_LINE_NUMBER_OPTION: &str = "N"; + pub const PAGE_RANGE_OPTION: &str = "pages"; + pub const NO_HEADER_TRAILER_OPTION: &str = "t"; + pub const PAGE_LENGTH_OPTION: &str = "l"; + pub const SUPPRESS_PRINTING_ERROR: &str = "r"; + pub const FORM_FEED_OPTION: &str = "F"; + pub const FORM_FEED_OPTION_SMALL: &str = "f"; + pub const COLUMN_WIDTH_OPTION: &str = "w"; + pub const PAGE_WIDTH_OPTION: &str = "W"; + pub const ACROSS_OPTION: &str = "a"; + pub const COLUMN_OPTION: &str = "column"; + pub const COLUMN_CHAR_SEPARATOR_OPTION: &str = "s"; + pub const COLUMN_STRING_SEPARATOR_OPTION: &str = "S"; + pub const MERGE_FILES_PRINT: &str = "m"; + pub const OFFSET_SPACES_OPTION: &str = "o"; + pub const JOIN_LINES_OPTION: &str = "J"; } struct OutputOptions { From 4744b3579685cb757a11baea893a8d286b7d425a Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 29 May 2021 19:09:50 +0200 Subject: [PATCH 055/126] pr: explicit none in match expressions --- src/uu/pr/src/pr.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 425a72878..65fb20c19 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -633,7 +633,7 @@ fn build_options( }) }) { Some(res) => res?, - _ => 1, + None => 1, }; let end_page_in_plus_option = match page_plus_re @@ -647,7 +647,7 @@ fn build_options( }) }) { Some(res) => Some(res?), - _ => None, + None => None, }; let invalid_pages_map = |i: String| { @@ -666,7 +666,7 @@ fn build_options( .map(invalid_pages_map) { Some(res) => res?, - _ => start_page_in_plus_option, + None => start_page_in_plus_option, }; let end_page = match matches @@ -679,7 +679,7 @@ fn build_options( .map(invalid_pages_map) { Some(res) => Some(res?), - _ => end_page_in_plus_option, + None => end_page_in_plus_option, }; if end_page.is_some() && start_page > end_page.unwrap() { @@ -754,14 +754,14 @@ fn build_options( }) }) { Some(res) => Some(res?), - _ => None, + None => None, }; // --column has more priority than -column let column_option_value = match parse_usize(matches, options::COLUMN_OPTION) { Some(res) => Some(res?), - _ => start_column_option, + None => start_column_option, }; let column_mode_options = column_option_value.map(|columns| ColumnModeOptions { From b0bf3e7e0fc6d23ff26dbdeac56780169600cdee Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 29 May 2021 19:34:17 +0200 Subject: [PATCH 056/126] pr: rustfmt test_pr.rs and utils.rs --- tests/by-util/test_pr.rs | 7 +++++-- tests/common/util.rs | 11 ++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/by-util/test_pr.rs b/tests/by-util/test_pr.rs index 1cd8fbdc8..aae0cc058 100644 --- a/tests/by-util/test_pr.rs +++ b/tests/by-util/test_pr.rs @@ -1,7 +1,7 @@ use crate::common::util::*; -use std::fs::metadata; use chrono::offset::Local; use chrono::DateTime; +use std::fs::metadata; fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { let tmp_dir_path = ucmd.get_full_fixture_path(path); @@ -245,7 +245,10 @@ fn test_with_no_header_trailer_option() { scenario .args(&["-t", test_file_path]) .succeeds() - .stdout_is_templated_fixture(expected_test_file_path, vec![(&"{last_modified_time}".to_string(), &value)]); + .stdout_is_templated_fixture( + expected_test_file_path, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test] diff --git a/tests/common/util.rs b/tests/common/util.rs index cbe33e950..722417acf 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -226,8 +226,13 @@ impl CmdResult { } /// like stdout_is_fixture(...), but replaces the data in fixture file based on values provided in template_vars /// command output - pub fn stdout_is_templated_fixture>(&self, file_rel_path: T, template_vars: Vec<(&String, &String)>) -> &CmdResult { - let mut contents = String::from_utf8(read_scenario_fixture(&self.tmpd, file_rel_path)).unwrap(); + pub fn stdout_is_templated_fixture>( + &self, + file_rel_path: T, + template_vars: Vec<(&String, &String)>, + ) -> &CmdResult { + let mut contents = + String::from_utf8(read_scenario_fixture(&self.tmpd, file_rel_path)).unwrap(); for kv in template_vars { contents = contents.replace(kv.0, kv.1); } @@ -923,7 +928,7 @@ impl UCommand { cmd_result } - pub fn get_full_fixture_path(&self, file_rel_path: &str) -> String{ + pub fn get_full_fixture_path(&self, file_rel_path: &str) -> String { let tmpdir_path = self.tmpd.as_ref().unwrap().path(); format!("{}/{}", tmpdir_path.to_str().unwrap(), file_rel_path) } From a54fc7a4baf0ae345135b3c01a1d8401ee75ca9e Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 30 May 2021 00:28:44 +0200 Subject: [PATCH 057/126] pr: remove unused asref implementations --- src/uu/pr/src/pr.rs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 8ac9e5bba..8df267959 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -91,12 +91,6 @@ struct FileLine { form_feeds_after: usize, } -impl AsRef for FileLine { - fn as_ref(&self) -> &FileLine { - self - } -} - struct ColumnModeOptions { width: usize, columns: usize, @@ -104,12 +98,6 @@ struct ColumnModeOptions { across_mode: bool, } -impl AsRef for OutputOptions { - fn as_ref(&self) -> &OutputOptions { - self - } -} - struct NumberingMode { /// Line numbering mode width: usize, From f9bc80e42c65e4f93d7be6dac55f4d56f8bf3240 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 30 May 2021 00:32:33 +0200 Subject: [PATCH 058/126] pr: remove comments that are obvious through types --- src/uu/pr/src/pr.rs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 8df267959..055a40d2f 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -98,8 +98,8 @@ struct ColumnModeOptions { across_mode: bool, } +/// Line numbering mode struct NumberingMode { - /// Line numbering mode width: usize, separator: String, first_number: usize, @@ -384,7 +384,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let mut files = matches.free.clone(); if files.is_empty() { - //For stdin files.insert(0, FILE_STDIN.to_owned()); } @@ -445,14 +444,7 @@ fn recreate_arguments(args: &[String]) -> Vec { if num_val_opt.is_some() && !num_regex.is_match(num_val_opt.unwrap()) { let could_be_file = arguments.remove(pos + 1); arguments.insert(pos + 1, format!("{}", NumberingMode::default().width)); - // FIXME: the following line replaces the block below that had the same - // code for both conditional branches. Figure this out. arguments.insert(pos + 2, could_be_file); - // if a_file.is_match(could_be_file.trim().as_ref()) { - // arguments.insert(pos + 2, could_be_file); - // } else { - // arguments.insert(pos + 2, could_be_file); - // } } } @@ -1154,7 +1146,6 @@ fn get_line_for_printing( line_width: &Option, indexes: usize, ) -> String { - // Check this condition let blank_line = String::new(); let fmtd_line_number = get_fmtd_line_number(&options, file_line.line_number, index); @@ -1220,9 +1211,6 @@ fn get_fmtd_line_number(opts: &OutputOptions, line_number: usize, index: usize) /// Returns a five line header content if displaying header is not disabled by /// using `NO_HEADER_TRAILER_OPTION` option. -/// # Arguments -/// * `options` - A reference to OutputOptions -/// * `page` - A reference to page number fn header_content(options: &OutputOptions, page: usize) -> Vec { if options.display_header_and_trailer { let first_line = format!( @@ -1256,8 +1244,6 @@ fn file_last_modified_time(path: &str) -> String { /// Returns five empty lines as trailer content if displaying trailer /// is not disabled by using `NO_HEADER_TRAILER_OPTION`option. -/// # Arguments -/// * `opts` - A reference to OutputOptions fn trailer_content(options: &OutputOptions) -> Vec { if options.display_header_and_trailer && !options.form_feed_used { vec![ @@ -1275,8 +1261,6 @@ fn trailer_content(options: &OutputOptions) -> Vec { /// Returns starting line number for the file to be printed. /// If -N is specified the first line number changes otherwise /// default is 1. -/// # Arguments -/// * `opts` - A reference to OutputOptions fn get_start_line_number(opts: &OutputOptions) -> usize { opts.number.as_ref().map(|i| i.first_number).unwrap_or(1) } @@ -1284,8 +1268,6 @@ fn get_start_line_number(opts: &OutputOptions) -> usize { /// Returns number of lines to read from input for constructing one page of pr output. /// If double space -d is used lines are halved. /// If columns --columns is used the lines are multiplied by the value. -/// # Arguments -/// * `opts` - A reference to OutputOptions fn lines_to_read_for_page(opts: &OutputOptions) -> usize { let content_lines_per_page = opts.content_lines_per_page; let columns = get_columns(opts); @@ -1297,8 +1279,6 @@ fn lines_to_read_for_page(opts: &OutputOptions) -> usize { } /// Returns number of columns to output -/// # Arguments -/// * `opts` - A reference to OutputOptions fn get_columns(opts: &OutputOptions) -> usize { opts.column_mode_options .as_ref() From f787326e70acc9a5d62de6f76b180bc048351aea Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 31 May 2021 00:15:24 +0200 Subject: [PATCH 059/126] pr: add to GNUMakefile --- GNUmakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/GNUmakefile b/GNUmakefile index 409a527cd..e2c608c8f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -82,6 +82,7 @@ PROGS := \ nproc \ od \ paste \ + pr \ printenv \ printf \ ptx \ From 6c4479f82de0961b32615b68334972219813776e Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 31 May 2021 09:39:11 +0200 Subject: [PATCH 060/126] pr: add to other list in GNUMakefile --- GNUmakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/GNUmakefile b/GNUmakefile index e2c608c8f..7d91989e8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -189,6 +189,7 @@ TEST_PROGS := \ paste \ pathchk \ pinky \ + pr \ printf \ ptx \ pwd \ From 77a0a077b89923b596b4e6ed910be2e55fd87f37 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 31 May 2021 14:48:12 +0200 Subject: [PATCH 061/126] pr: update dependencies --- Cargo.lock | 10 ++++++++-- src/uu/pr/Cargo.toml | 6 +++--- src/uu/pr/src/pr.rs | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7fa8f23b..4af8b5c9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1206,6 +1206,12 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quickcheck" version = "0.9.2" @@ -1929,7 +1935,7 @@ dependencies = [ "filetime", "ioctl-sys", "libc", - "quick-error", + "quick-error 1.2.3", "uucore", "uucore_procs", "walkdir", @@ -2420,7 +2426,7 @@ dependencies = [ "chrono", "getopts", "itertools 0.10.0", - "quick-error", + "quick-error 2.0.1", "regex", "time", "uucore", diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 53f2a69b6..6d9ec2304 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" description = "pr ~ (uutils) convert text files for printing" homepage = "https://github.com/uutils/coreutils" -repository = "https://github.com/uutils/coreutils/tree/master/src/uu/pinky" +repository = "https://github.com/uutils/coreutils/tree/master/src/uu/pr" keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"] categories = ["command-line-utilities"] edition = "2018" @@ -20,8 +20,8 @@ uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_p getopts = "0.2.21" time = "0.1.41" # A higher version would cause a conflict with time -chrono = "0.4.11" -quick-error = "1.2.3" +chrono = "0.4.19" +quick-error = "2.0.1" itertools = "0.10" regex = "1.0" diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 055a40d2f..266f605c5 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -140,7 +140,7 @@ quick_error! { Input(err: IOError, path: String) { context(path: &'a str, err: IOError) -> (err, path.to_owned()) display("pr: Reading from input {0} gave error", path) - cause(err) + source(err) } UnknownFiletype(path: String) { From 27c59417d67c1a7568ba09c55ef2961c850d2832 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Thu, 27 May 2021 17:47:26 -0500 Subject: [PATCH 062/126] maint/dev ~ update EditorConfig --- .editorconfig | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.editorconfig b/.editorconfig index 95dfec676..d93fa7c0e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,22 +3,38 @@ # * top-most EditorConfig file root = true -# Unix-style newlines with a newline ending every file [*] +# default ~ utf-8, unix-style newlines with a newline ending every file, 4 space indentation charset = utf-8 end_of_line = lf indent_size = 4 indent_style = space insert_final_newline = true +max_line_length = 100 trim_trailing_whitespace = true -[*.{bat,cmd,[Bb][Aa][Tt],[Cc][Mm][Dd]}] -# DOS/Win requires BAT/CMD files to have CRLF EOLNs -end_of_line = crlf - -[[Mm]akefile{,.*}] -# TAB-style indentation +[[Mm]akefile{,.*}, *.{mk,[Mm][Kk]}] +# makefiles ~ TAB-style indentation indent_style = tab -[*.{yml,[Yy][Mm][Ll]}] +[*.{bat,cmd,[Bb][Aa][Tt],[Cc][Mm][Dd]}] +# BAT/CMD ~ DOS/Win requires BAT/CMD files to have CRLF EOLNs +end_of_line = crlf + +[*.go] +# go ~ TAB-style indentation (SPACE-style alignment); ref: @@ +indent_style = tab + +[*.{cjs,js,json,mjs,ts}] +# js/ts indent_size = 2 + +[*.{markdown,md,mkd,[Mm][Dd],[Mm][Kk][Dd],[Mm][Dd][Oo][Ww][Nn],[Mm][Kk][Dd][Oo][Ww][Nn],[Mm][Aa][Rr][Kk][Dd][Oo][Ww][Nn]}] +# markdown +indent_size = 2 +indent_style = space + +[*.{yaml,yml,[Yy][Mm][Ll],[Yy][Aa][Mm][Ll]}] +# YAML +indent_size = 2 +indent_style = space From 03260f065da3d40cecf7d563df219f3825c9fd67 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Thu, 27 May 2021 17:51:00 -0500 Subject: [PATCH 063/126] maint/dev ~ (VSCode) add cspell spell-checker extension to recommendations --- .vscode/extensions.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index cb28d8883..46b105d37 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,10 +1,12 @@ { - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format + // spell-checker:ignore (misc) matklad + // see for the documentation about the extensions.json format "recommendations": [ // Rust language support. "rust-lang.rust", // Provides support for rust-analyzer: novel LSP server for the Rust programming language. - "matklad.rust-analyzer" + "matklad.rust-analyzer", + // `cspell` spell-checker support + "streetsidesoftware.code-spell-checker" ] } From ecdf32d1bc1790c765614b53779a5c5f7bb21d92 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 29 May 2021 22:26:16 -0500 Subject: [PATCH 064/126] maint/dev ~ add codespell configuration --- .codespell.rc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .codespell.rc diff --git a/.codespell.rc b/.codespell.rc new file mode 100644 index 000000000..914ca2951 --- /dev/null +++ b/.codespell.rc @@ -0,0 +1,3 @@ +[codespell] +ignore-words-list = crate +skip = ./.git/**,./.vscode/cspell.dictionaries/**,./target/**,./tests/fixtures/** From 1c62c912b44b2dbb9ea75ef373687731027f25a8 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Thu, 27 May 2021 20:47:17 -0500 Subject: [PATCH 065/126] docs/spell ~ reconfigure cspell (for workspace dictionaries) --- .vscode/cSpell.json | 365 ++------------------------------------------ 1 file changed, 16 insertions(+), 349 deletions(-) diff --git a/.vscode/cSpell.json b/.vscode/cSpell.json index 8561d69ad..9869923a4 100644 --- a/.vscode/cSpell.json +++ b/.vscode/cSpell.json @@ -1,352 +1,19 @@ // `cspell` settings { - "version": "0.1", // Version of the setting file. Always 0.1 - "language": "en", // language - current active spelling language - // ignoreWords - "ignoreWords": [ - // abbrev/acronyms - "Cygwin", - "FreeBSD", - "Gmail", - "GNUEABI", - "GNUEABIhf", - "Irix", - "MacOS", - "MinGW", - "Minix", - "MS-DOS", - "MSDOS", - "NetBSD", - "Novell", - "OpenBSD", - "POSIX", - "SELinux", - "Solaris", - "Xenix", - "flac", - "lzma", - // cargo - "cdylib", - "rlib", - // crates - "advapi", - "advapi32-sys", - "aho-corasick", - "backtrace", - "byteorder", - "chacha", - "chrono", - "conv", - "corasick", - "filetime", - "formatteriteminfo", - "getopts", - "itertools", - "memchr", - "multifilereader", - "onig", - "peekreader", - "quickcheck", - "rand_chacha", - "smallvec", - "tempfile", - "termion", - "termios", - "termsize", - "termwidth", - "textwrap", - "walkdir", - "winapi", - "xattr", - // jargon - "AST", // abstract syntax tree - "CPU", - "CPUs", - "FIFO", - "FIFOs", - "FQDN", // fully qualified domain name - "GID", // group ID - "GIDs", - "POSIXLY", - "RNG", // random number generator - "RNGs", - "UID", // user ID - "UIDs", - "UUID", // universally unique identifier - "arity", - "bitmask", - "canonicalization", - "canonicalize", - "colorizable", - "colorize", - "consts", - "dedup", - "demangle", - "deque", - "dequeue", - "enqueue", - "executable", - "executables", - "gibibytes", - "hardfloat", - "hardlink", - "hardlinks", - "hashsums", - "kibibytes", - "mebibytes", - "mergeable", - "multibyte", - "nonportable", - "peekable", - "precompiled", - "precompute", - "preload", - "prepend", - "prepended", - "primality", - "pseudoprime", - "pseudoprimes", - "procs", - "readonly", - "seedable", - "semver", - "shortcode", - "shortcodes", - "symlink", - "symlinks", - "syscall", - "toekenize", - "unbuffered", - "unportable", - "whitespace", - // names - "Akira Hayakawa", "Akira", "Hayakawa", - "Alan Andrade", "Alan", "Andrade", - "Alex Lyon", "Alex", "Lyon", - "Alexander Batischev", "Alexander", "Batischev", - "Aleksander Bielawski", "Aleksander", "Bielawski", - "Alexander Fomin", "Alexander", "Fomin", - "Anthony Deschamps", "Anthony", "Deschamps", - "Ben Eills", "Ben", "Eills", - "Ben Hirsch", "Ben", "Hirsch", - "Benoit Benedetti", "Benoit", "Benedetti", - "Boden Garman", "Boden", "Garman", - "Chirag B Jadwani", "Chirag", "Jadwani", - "Derek Chiang", "Derek", "Chiang", - "Dorota Kapturkiewicz", "Dorota", "Kapturkiewicz", - "Evgeniy Klyuchikov", "Evgeniy", "Klyuchikov", - "Fangxu Hu", "Fangxu", "Hu", - "Gil Cottle", "Gil", "Cottle", - "Haitao Li", "Haitao", "Li", - "Inokentiy Babushkin", "Inokentiy", "Babushkin", - "Joao Oliveira", "Joao", "Oliveira", - "Jeremiah Peschka", "Jeremiah", "Peschka", - "Jian Zeng", "Jian", "Zeng", - "Jimmy Lu", "Jimmy", "Lu", - "Jordi Boggiano", "Jordi", "Boggiano", - "Jordy Dickinson", "Jordy", "Dickinson", - "Joseph Crail", "Joseph", "Crail", - "Joshua S Miller", "Joshua", "Miller", - "KokaKiwi", - "Konstantin Pospelov", "Konstantin", "Pospelov", - "Mahkoh", - "Maciej Dziardziel", "Maciej", "Dziardziel", - "Michael Gehring", "Michael", "Gehring", - "Martin Kysel", "Martin", "Kysel", - "Morten Olsen Lysgaard", "Morten", "Olsen", "Lysgaard", - "Nicholas Juszczak", "Nicholas", "Juszczak", - "Nick Platt", "Nick", "Platt", - "Orvar Segerström", "Orvar", "Segerström", - "Peter Atashian", "Peter", "Atashian", - "Rolf Morel", "Rolf", "Morel", - "Roman Gafiyatullin", "Roman", "Gafiyatullin", - "Roy Ivy III", "Roy", "Ivy", "III", - "Sergey 'Shnatsel' Davidoff", "Sergey", "Shnatsel", "Davidoff", - "Sokovikov Evgeniy", "Sokovikov", "Evgeniy", - "Sunrin SHIMURA", "Sunrin", "SHIMURA", - "Smigle00", "Smigle", - "Sylvestre Ledru", "Sylvestre", "Ledru", - "T Jameson Little", "Jameson", "Little", - "Tobias Bohumir Schottdorf", "Tobias", "Bohumir", "Schottdorf", - "Virgile Andreani", "Virgile", "Andreani", - "Vsevolod Velichko", "Vsevolod", "Velichko", - "Wiktor Kuropatwa", "Wiktor", "Kuropatwa", - "Yury Krivopalov", "Yury", "Krivopalov", - "anonymousknight", - "kwantam", - "nicoo", - "rivy", - // rust - "clippy", - "concat", - "fract", - "powi", - "println", - "repr", - "rfind", - "rustc", - "rustfmt", - "struct", - "structs", - "substr", - "splitn", - "trunc", - // shell - "passwd", - "pipefail", - "tcsh", - // tags - "Maint", - // uutils - "chcon", - "chgrp", - "chmod", - "chown", - "chroot", - "cksum", - "csplit", - "dircolors", - "hashsum", - "hostid", - "logname", - "mkdir", - "mkfifo", - "mknod", - "mktemp", - "nohup", - "nproc", - "numfmt", - "pathchk", - "printenv", - "printf", - "readlink", - "realpath", - "relpath", - "rmdir", - "runcon", - "shuf", - "stdbuf", - "stty", - "tsort", - "uname", - "unexpand", - "whoami", - // vars/errno - "errno", - "EOPNOTSUPP", - // vars/fcntl - "F_GETFL", - "GETFL", - "fcntl", - "vmsplice", - // vars/libc - "FILENO", - "HOSTSIZE", - "IDSIZE", - "IFIFO", - "IFREG", - "IRGRP", - "IROTH", - "IRUSR", - "ISGID", - "ISUID", - "ISVTX", - "IWGRP", - "IWOTH", - "IWUSR", - "IXGRP", - "IXOTH", - "IXUSR", - "LINESIZE", - "NAMESIZE", - "USERSIZE", - "addrinfo", - "addrlen", - "canonname", - "chroot", - "freeaddrinfo", - "getaddrinfo", - "getegid", - "geteuid", - "getgid", - "getgrgid", - "getgrnam", - "getgrouplist", - "getgroups", - "getpwnam", - "getpwuid", - "getuid", - "inode", - "isatty", - "lchown", - "setgid", - "setgroups", - "setuid", - "socktype", - "umask", - "waitpid", - // vars/nix - "iovec", - "unistd", - // vars/signals - "SIGPIPE", - // vars/sync - "Condvar", - // vars/stat - "fstat", - "stat", - // vars/time - "Timespec", - "nsec", - "nsecs", - "strftime", - "usec", - "usecs", - // vars/utmpx - "endutxent", - "getutxent", - "getutxid", - "getutxline", - "pututxline", - "setutxent", - "utmp", - "utmpx", - "utmpxname", - // vars/winapi - "errhandlingapi", - "fileapi", - "handleapi", - "lmcons", - "minwindef", - "processthreadsapi", - "synchapi", - "sysinfoapi", - "winbase", - "winerror", - "winnt", - "winsock", - "DWORD", - "LPWSTR", - "WCHAR", - // uucore - "optflag", - "optflagmulti", - "optflagopt", - "optmulti", - "optopt", - // uutils - "coreopts", - "coreutils", - "libc", - "libstdbuf", - "musl", - "ucmd", - "utmpx", - "uucore", - "uucore_procs", - "uumain", - "uutils" - ], - // words - list of words to be always considered correct - "words": [] + "version": "0.1", // Version of the setting file. Always 0.1 + "language": "en", // language - current active spelling language + "dictionaries": ["acronyms+names", "jargon", "people", "shell", "workspace"], + "dictionaryDefinitions": [ + { "name": "acronyms+names", "path": "./cspell.dictionaries/acronyms+names.wordlist.txt" }, + { "name": "jargon", "path": "./cspell.dictionaries/jargon.wordlist.txt" }, + { "name": "people", "path": "./cspell.dictionaries/people.wordlist.txt" }, + { "name": "shell", "path": "./cspell.dictionaries/shell.wordlist.txt" }, + { "name": "workspace", "path": "./cspell.dictionaries/workspace.wordlist.txt" } + ], + // ignorePaths - a list of globs to specify which files are to be ignored + "ignorePaths": ["Cargo.lock", "target/**", "tests/**/fixtures/**"], + // ignoreWords - a list of words to be ignored (even if they are in the flagWords) + "ignoreWords": [], + // words - list of words to be always considered correct + "words": [] } From 7510b65d6bff1913197d97629149e68bd3628e7e Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Thu, 27 May 2021 20:47:39 -0500 Subject: [PATCH 066/126] docs/spell ~ add cspell workspace dictionaries --- .../acronyms+names.wordlist.txt | 64 ++++ .../cspell.dictionaries/jargon.wordlist.txt | 110 +++++++ .../cspell.dictionaries/people.wordlist.txt | 171 ++++++++++ .../cspell.dictionaries/shell.wordlist.txt | 93 ++++++ .../workspace.wordlist.txt | 295 ++++++++++++++++++ 5 files changed, 733 insertions(+) create mode 100644 .vscode/cspell.dictionaries/acronyms+names.wordlist.txt create mode 100644 .vscode/cspell.dictionaries/jargon.wordlist.txt create mode 100644 .vscode/cspell.dictionaries/people.wordlist.txt create mode 100644 .vscode/cspell.dictionaries/shell.wordlist.txt create mode 100644 .vscode/cspell.dictionaries/workspace.wordlist.txt diff --git a/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt b/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt new file mode 100644 index 000000000..3956d1d8a --- /dev/null +++ b/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt @@ -0,0 +1,64 @@ +# * abbreviations / acronyms +AIX +ASLR # address space layout randomization +AST # abstract syntax tree +CICD # continuous integration/deployment +CPU +CPUs +DevOps +Ext3 +FIFO +FIFOs +FQDN # fully qualified domain name +GID # group ID +GIDs +GNUEABI +GNUEABIhf +JFS +MSRV # minimum supported rust version +MSVC +NixOS +POSIX +POSIXLY +RISC +RISCV +RNG # random number generator +RNGs +ReiserFS +Solaris +UID # user ID +UIDs +UUID # universally unique identifier +WASI +WASM +XFS +aarch +flac +lzma + +# * names +BusyBox +BusyTest +Codacy +Cygwin +Deno +EditorConfig +FreeBSD +Gmail +Irix +MS-DOS +MSDOS +MacOS +MinGW +Minix +NetBSD +Novell +OpenBSD +POSIX +PowerPC +SELinux +SkyPack +Solaris +SysV +Xenix +Yargs diff --git a/.vscode/cspell.dictionaries/jargon.wordlist.txt b/.vscode/cspell.dictionaries/jargon.wordlist.txt new file mode 100644 index 000000000..89af1b153 --- /dev/null +++ b/.vscode/cspell.dictionaries/jargon.wordlist.txt @@ -0,0 +1,110 @@ +arity +autogenerate +autogenerated +autogenerates +bitmask +bitwise +bytewise +canonicalization +canonicalize +canonicalizing +colorizable +colorize +coprime +consts +cyclomatic +dedup +deduplication +demangle +denoland +deque +dequeue +dev +devs +discoverability +duplicative +enqueue +errored +executable +executables +exponentiate +eval +falsey +flamegraph +gibibytes +glob +globbing +hardfloat +hardlink +hardlinks +hasher +hashsums +kibi +kibibytes +mebi +mebibytes +mergeable +microbenchmark +microbenchmarks +microbenchmarking +multibyte +multicall +nonportable +nonprinting +peekable +performant +precompiled +precompute +preload +prepend +prepended +primality +pseudoprime +pseudoprimes +quantiles +readonly +reparse +seedable +semver +semiprime +semiprimes +shortcode +shortcodes +subcommand +subexpression +submodule +symlink +symlinks +syscall +syscalls +tokenize +truthy +unbuffered +unescape +unintuitive +unprefixed +unportable +unsync +whitespace +wordlist +wordlists + +# * abbreviations +consts +deps +dev +maint +proc +procs + +# * constants +xffff + +# * variables +delim +errno +progname +retval +subdir +val +vals diff --git a/.vscode/cspell.dictionaries/people.wordlist.txt b/.vscode/cspell.dictionaries/people.wordlist.txt new file mode 100644 index 000000000..01cfa4a3e --- /dev/null +++ b/.vscode/cspell.dictionaries/people.wordlist.txt @@ -0,0 +1,171 @@ +Akira Hayakawa + Akira + Hayakawa +Alan Andrade + Alan + Andrade +Aleksander Bielawski + Aleksander + Bielawski +Alex Lyon + Alex + Lyon +Alexander Batischev + Alexander + Batischev +Alexander Fomin + Alexander + Fomin +Anthony Deschamps + Anthony + Deschamps +Árni Dagur + Árni + Dagur +Ben Eills + Ben + Eills +Ben Hirsch + Ben + Hirsch +Benoit Benedetti + Benoit + Benedetti +Boden Garman + Boden + Garman +Chirag B Jadwani + Chirag + Jadwani +Derek Chiang + Derek + Chiang +Dorota Kapturkiewicz + Dorota + Kapturkiewicz +Evgeniy Klyuchikov + Evgeniy + Klyuchikov +Fangxu Hu + Fangxu + Hu +Gil Cottle + Gil + Cottle +Haitao Li + Haitao + Li +Inokentiy Babushkin + Inokentiy + Babushkin +Jeremiah Peschka + Jeremiah + Peschka +Jian Zeng + Jian + Zeng +Jimmy Lu + Jimmy + Lu +Joao Oliveira + Joao + Oliveira +Jordi Boggiano + Jordi + Boggiano +Jordy Dickinson + Jordy + Dickinson +Joseph Crail + Joseph + Crail +Joshua S Miller + Joshua + Miller +Konstantin Pospelov + Konstantin + Pospelov +Maciej Dziardziel + Maciej + Dziardziel +Martin Kysel + Martin + Kysel +Michael Debertol + Michael + Debertol +Michael Gehring + Michael + Gehring +Morten Olsen Lysgaard + Morten + Olsen + Lysgaard +Nicholas Juszczak + Nicholas + Juszczak +Nick Platt + Nick + Platt +Orvar Segerström + Orvar + Segerström +Peter Atashian + Peter + Atashian +Robert Swinford + Robert + Swinford +Rolf Morel + Rolf + Morel +Roman Gafiyatullin + Roman + Gafiyatullin +Roy Ivy III * rivy + Roy + Ivy + III + rivy +Sergey "Shnatsel" Davidoff + Sergey Shnatsel Davidoff + Sergey + Shnatsel + Davidoff +Sokovikov Evgeniy + Sokovikov + Evgeniy +Sunrin SHIMURA + Sunrin + SHIMURA +Sylvestre Ledru + Sylvestre + Ledru +T Jameson Little + Jameson + Little +Tobias Bohumir Schottdorf + Tobias + Bohumir + Schottdorf +Virgile Andreani + Virgile + Andreani +Vsevolod Velichko + Vsevolod + Velichko +Wiktor Kuropatwa + Wiktor + Kuropatwa +Yury Krivopalov + Yury + Krivopalov + +KokaKiwi +Mahkoh +Smigle00 + Smigle00 + Smigle +anonymousknight +kwantam +nicoo diff --git a/.vscode/cspell.dictionaries/shell.wordlist.txt b/.vscode/cspell.dictionaries/shell.wordlist.txt new file mode 100644 index 000000000..d8f297d21 --- /dev/null +++ b/.vscode/cspell.dictionaries/shell.wordlist.txt @@ -0,0 +1,93 @@ +# * Mac +clonefile + +# * POSIX +TMPDIR +adduser +csh +globstar +inotify +localtime +mountinfo +mountpoint +mtab +nullglob +passwd +pipefail +popd +ptmx +pushd +setarch +sh +sudo +sudoedit +tcsh +tzselect +urandom +wtmp +zsh + +# * Windows +APPDATA +COMSPEC +HKCU +HKLM +HOMEDRIVE +HOMEPATH +LOCALAPPDATA +PATHEXT +PATHEXT +SYSTEMROOT +USERDOMAIN +USERNAME +USERPROFILE +procmon + +# * `git` +gitattributes +gitignore + +# * `make` (`gmake`) +CURDIR +GNUMAKEFLAGS +GNUMakefile +LIBPATTERNS +MAKECMDGOALS +MAKEFILES +MAKEFLAGS +MAKELEVEL +MAKESHELL +SHELLSTATUS +VPATH +abspath +addprefix +addsuffix +endef +firstword +ifeq +ifneq +lastword +notdir +patsubst + + +# * `npm` +preversion + +# * utilities +cachegrind +chglog +codespell +commitlint +dprint +dtrace +gcov +gmake +grcov +grep +markdownlint +rerast +rollup +sed +wslpath +xargs diff --git a/.vscode/cspell.dictionaries/workspace.wordlist.txt b/.vscode/cspell.dictionaries/workspace.wordlist.txt new file mode 100644 index 000000000..b567a6c21 --- /dev/null +++ b/.vscode/cspell.dictionaries/workspace.wordlist.txt @@ -0,0 +1,295 @@ +# * cargo +cdylib +rlib + +# * crates +advapi +advapi32-sys +aho-corasick +backtrace +bstr +byteorder +chacha +chrono +conv +corasick +crossterm +filetime +formatteriteminfo +fsext +getopts +getrandom +globset +itertools +lscolors +memchr +multifilereader +onig +ouroboros +peekreader +quickcheck +rand_chacha +ringbuffer +smallvec +tempdir +tempfile +termion +termios +termsize +termwidth +textwrap +thiserror +walkdir +winapi +xattr + +# * rust/rustc +RUSTDOCFLAGS +RUSTFLAGS +bitxor # BitXor trait function +clippy +concat +fract +powi +println +repr +rfind +rustc +rustfmt +struct +structs +substr +splitn +trunc + +# * uutils +chcon +chgrp +chmod +chown +chroot +cksum +csplit +dircolors +hashsum +hostid +logname +mkdir +mkfifo +mknod +mktemp +nohup +nproc +numfmt +pathchk +printenv +printf +readlink +realpath +relpath +rmdir +runcon +shuf +sprintf +stdbuf +stty +tsort +uname +unexpand +whoami + +# * vars/errno +errno +EEXIST +ENOENT +ENOSYS +EPERM +EOPNOTSUPP + +# * vars/fcntl +F_GETFL + GETFL +fcntl +vmsplice + +# * vars/libc +FILENO +HOSTSIZE +IDSIZE +IFBLK +IFCHR +IFDIR +IFIFO +IFLNK +IFMT +IFREG +IFSOCK +IRGRP +IROTH +IRUSR +ISGID +ISUID +ISVTX +IWGRP +IWOTH +IWUSR +IXGRP +IXOTH +IXUSR +LINESIZE +NAMESIZE +RTLD_NEXT + RTLD +SIGINT +SIGKILL +SIGTERM +SYS_fdatasync +SYS_syncfs +USERSIZE +addrinfo +addrlen +blocksize +canonname +chroot +dlsym +fdatasync +freeaddrinfo +getaddrinfo +getegid +geteuid +getgid +getgrgid +getgrnam +getgrouplist +getgroups +getpwnam +getpwuid +getuid +inode +inodes +isatty +lchown +setgid +setgroups +settime +setuid +socktype +statfs +statvfs +strcmp +strerror +syncfs +umask +waitpid +wcslen + +# * vars/nix +iovec +unistd + +# * vars/signals +SIGPIPE + +# * vars/std +CString +pathbuf + +# * vars/stat +bavail +bfree +bsize +ffree +frsize +fsid +fstat +fstype +namelen +# unix::fs::MetadataExt +atime # access time +blksize # blocksize for file system I/O +blocks # number of blocks allocated to file +ctime # creation time +dev # ID of device containing the file +gid # group ID of file owner +ino # inode number +mode # permissions +mtime # modification time +nlink # number of hard links to file +rdev # device ID if file is a character/block special file +size # total size of file in bytes +uid # user ID of file owner +nsec # nanosecond measurement scale +# freebsd::MetadataExt +iosize + +# * vars/time +Timespec +isdst +nanos +nsec +nsecs +strftime +strptime +subsec +usec +usecs +utcoff + +# * vars/utmpx +endutxent +getutxent +getutxid +getutxline +pututxline +setutxent +utmp +utmpx +utmpxname + +# * vars/winapi +DWORD +SYSTEMTIME +LPVOID +LPWSTR +ULONG +ULONGLONG +UNLEN +WCHAR +errhandlingapi +fileapi +handleapi +lmcons +minwinbase +minwindef +processthreadsapi +synchapi +sysinfoapi +winbase +winerror +winnt +winsock + +# * vars/uucore +optflag +optflagmulti +optflagopt +optmulti +optopt + +# * uutils +ccmd +coreopts +coreutils +keepenv +libc +libstdbuf +musl +tmpd +ucmd +ucommand +utmpx +uucore +uucore_procs +uumain +uutil +uutils From 9c0c8eb59f337ca878078946f7474742fa486002 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 29 May 2021 22:19:41 -0500 Subject: [PATCH 067/126] change ~ remove 'main.rs' spell-checker exceptions --- src/uu/arch/src/main.rs | 2 +- src/uu/base32/src/main.rs | 2 +- src/uu/base64/src/main.rs | 2 +- src/uu/basename/src/main.rs | 2 +- src/uu/cat/src/main.rs | 2 +- src/uu/chgrp/src/main.rs | 2 +- src/uu/chmod/src/main.rs | 2 +- src/uu/chown/src/main.rs | 2 +- src/uu/chroot/src/main.rs | 2 +- src/uu/cksum/src/main.rs | 2 +- src/uu/comm/src/main.rs | 2 +- src/uu/cp/src/main.rs | 2 +- src/uu/csplit/src/main.rs | 2 +- src/uu/cut/src/main.rs | 2 +- src/uu/date/src/main.rs | 2 +- src/uu/df/src/main.rs | 2 +- src/uu/dircolors/src/main.rs | 2 +- src/uu/dirname/src/main.rs | 2 +- src/uu/du/src/du.rs | 2 -- src/uu/du/src/main.rs | 2 +- src/uu/echo/src/main.rs | 2 +- src/uu/env/src/main.rs | 2 +- src/uu/expand/src/main.rs | 2 +- src/uu/expr/src/main.rs | 2 +- src/uu/factor/src/main.rs | 2 +- src/uu/false/src/main.rs | 2 +- src/uu/fmt/src/main.rs | 2 +- src/uu/fold/src/main.rs | 2 +- src/uu/groups/src/main.rs | 2 +- src/uu/hashsum/src/main.rs | 2 +- src/uu/head/src/main.rs | 2 +- src/uu/hostid/src/main.rs | 2 +- src/uu/hostname/src/main.rs | 2 +- src/uu/id/src/main.rs | 2 +- src/uu/install/src/main.rs | 2 +- src/uu/join/src/main.rs | 2 +- src/uu/kill/src/main.rs | 2 +- src/uu/link/src/main.rs | 2 +- src/uu/ln/src/main.rs | 2 +- src/uu/logname/src/main.rs | 2 +- src/uu/ls/src/main.rs | 2 +- src/uu/mkdir/src/main.rs | 2 +- src/uu/mkfifo/src/main.rs | 2 +- src/uu/mknod/src/main.rs | 2 +- src/uu/mktemp/src/main.rs | 2 +- src/uu/more/src/main.rs | 2 +- src/uu/mv/src/main.rs | 2 +- src/uu/nice/src/main.rs | 2 +- src/uu/nl/src/main.rs | 2 +- src/uu/nohup/src/main.rs | 2 +- src/uu/nproc/src/main.rs | 2 +- src/uu/numfmt/src/main.rs | 2 +- src/uu/od/src/main.rs | 2 +- src/uu/paste/src/main.rs | 2 +- src/uu/pathchk/src/main.rs | 2 +- src/uu/pinky/src/main.rs | 2 +- src/uu/printenv/src/main.rs | 2 +- src/uu/printf/src/main.rs | 2 +- src/uu/ptx/src/main.rs | 2 +- src/uu/pwd/src/main.rs | 2 +- src/uu/readlink/src/main.rs | 2 +- src/uu/realpath/src/main.rs | 2 +- src/uu/relpath/src/main.rs | 2 +- src/uu/rm/src/main.rs | 2 +- src/uu/rmdir/src/main.rs | 2 +- src/uu/seq/src/main.rs | 2 +- src/uu/shred/src/main.rs | 2 +- src/uu/shuf/src/main.rs | 2 +- src/uu/sleep/src/main.rs | 2 +- src/uu/sort/src/main.rs | 2 +- src/uu/split/src/main.rs | 2 +- src/uu/stat/src/main.rs | 2 +- src/uu/stdbuf/src/main.rs | 2 +- src/uu/sum/src/main.rs | 2 +- src/uu/sync/src/main.rs | 2 +- src/uu/tac/src/main.rs | 2 +- src/uu/tail/src/main.rs | 2 +- src/uu/tee/src/main.rs | 2 +- src/uu/test/src/main.rs | 2 +- src/uu/timeout/src/main.rs | 2 +- src/uu/touch/src/main.rs | 2 +- src/uu/tr/src/main.rs | 2 +- src/uu/true/src/main.rs | 2 +- src/uu/truncate/src/main.rs | 2 +- src/uu/tsort/src/main.rs | 2 +- src/uu/tty/src/main.rs | 2 +- src/uu/uname/src/main.rs | 2 +- src/uu/unexpand/src/main.rs | 2 +- src/uu/uniq/src/main.rs | 2 +- src/uu/unlink/src/main.rs | 2 +- src/uu/uptime/src/main.rs | 2 +- src/uu/users/src/main.rs | 2 +- src/uu/wc/src/main.rs | 2 +- src/uu/who/src/main.rs | 2 +- src/uu/whoami/src/main.rs | 2 +- src/uu/yes/src/main.rs | 2 +- 96 files changed, 95 insertions(+), 97 deletions(-) diff --git a/src/uu/arch/src/main.rs b/src/uu/arch/src/main.rs index 43e0af5bf..e2668864c 100644 --- a/src/uu/arch/src/main.rs +++ b/src/uu/arch/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_arch); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_arch); diff --git a/src/uu/base32/src/main.rs b/src/uu/base32/src/main.rs index b59cb89f0..83a0b6607 100644 --- a/src/uu/base32/src/main.rs +++ b/src/uu/base32/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_base32); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_base32); diff --git a/src/uu/base64/src/main.rs b/src/uu/base64/src/main.rs index 07ed34256..cae6cb3c4 100644 --- a/src/uu/base64/src/main.rs +++ b/src/uu/base64/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_base64); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_base64); diff --git a/src/uu/basename/src/main.rs b/src/uu/basename/src/main.rs index d1aa19f2b..aa452f750 100644 --- a/src/uu/basename/src/main.rs +++ b/src/uu/basename/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_basename); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_basename); diff --git a/src/uu/cat/src/main.rs b/src/uu/cat/src/main.rs index 2b7969473..1adab666b 100644 --- a/src/uu/cat/src/main.rs +++ b/src/uu/cat/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cat); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_cat); diff --git a/src/uu/chgrp/src/main.rs b/src/uu/chgrp/src/main.rs index 2faba7ba4..ee6f70a8b 100644 --- a/src/uu/chgrp/src/main.rs +++ b/src/uu/chgrp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chgrp); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_chgrp); diff --git a/src/uu/chmod/src/main.rs b/src/uu/chmod/src/main.rs index 604bd9a7d..adaf887f8 100644 --- a/src/uu/chmod/src/main.rs +++ b/src/uu/chmod/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chmod); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_chmod); diff --git a/src/uu/chown/src/main.rs b/src/uu/chown/src/main.rs index ee5aeeba0..b3ed39970 100644 --- a/src/uu/chown/src/main.rs +++ b/src/uu/chown/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chown); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_chown); diff --git a/src/uu/chroot/src/main.rs b/src/uu/chroot/src/main.rs index a177c9301..0ca88cfaf 100644 --- a/src/uu/chroot/src/main.rs +++ b/src/uu/chroot/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chroot); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_chroot); diff --git a/src/uu/cksum/src/main.rs b/src/uu/cksum/src/main.rs index 50f424f41..b8a8f6b33 100644 --- a/src/uu/cksum/src/main.rs +++ b/src/uu/cksum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cksum); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_cksum); diff --git a/src/uu/comm/src/main.rs b/src/uu/comm/src/main.rs index 149098c3c..07ac07544 100644 --- a/src/uu/comm/src/main.rs +++ b/src/uu/comm/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_comm); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_comm); diff --git a/src/uu/cp/src/main.rs b/src/uu/cp/src/main.rs index 425d490e7..acfcfd1b2 100644 --- a/src/uu/cp/src/main.rs +++ b/src/uu/cp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cp); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_cp); diff --git a/src/uu/csplit/src/main.rs b/src/uu/csplit/src/main.rs index 97aeb3821..b0b144e8c 100644 --- a/src/uu/csplit/src/main.rs +++ b/src/uu/csplit/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_csplit); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_csplit); diff --git a/src/uu/cut/src/main.rs b/src/uu/cut/src/main.rs index 065a01f40..8822335f6 100644 --- a/src/uu/cut/src/main.rs +++ b/src/uu/cut/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cut); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_cut); diff --git a/src/uu/date/src/main.rs b/src/uu/date/src/main.rs index 13edc0fba..9064c7f67 100644 --- a/src/uu/date/src/main.rs +++ b/src/uu/date/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_date); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_date); diff --git a/src/uu/df/src/main.rs b/src/uu/df/src/main.rs index 6062603db..a6d403782 100644 --- a/src/uu/df/src/main.rs +++ b/src/uu/df/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_df); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_df); diff --git a/src/uu/dircolors/src/main.rs b/src/uu/dircolors/src/main.rs index 10c96ecd9..a6a820bd9 100644 --- a/src/uu/dircolors/src/main.rs +++ b/src/uu/dircolors/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_dircolors); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_dircolors); diff --git a/src/uu/dirname/src/main.rs b/src/uu/dirname/src/main.rs index e4be3372a..bf923e86a 100644 --- a/src/uu/dirname/src/main.rs +++ b/src/uu/dirname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_dirname); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_dirname); diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 6bd4f23e4..b0940d93d 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -5,8 +5,6 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) BLOCKSIZE inode inodes ment strs - #[macro_use] extern crate uucore; diff --git a/src/uu/du/src/main.rs b/src/uu/du/src/main.rs index de1967bc8..de9bfc1a5 100644 --- a/src/uu/du/src/main.rs +++ b/src/uu/du/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_du); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_du); diff --git a/src/uu/echo/src/main.rs b/src/uu/echo/src/main.rs index 00b84e983..b8d3b4b32 100644 --- a/src/uu/echo/src/main.rs +++ b/src/uu/echo/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_echo); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_echo); diff --git a/src/uu/env/src/main.rs b/src/uu/env/src/main.rs index 8b654eb00..9c19a3ab4 100644 --- a/src/uu/env/src/main.rs +++ b/src/uu/env/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_env); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_env); diff --git a/src/uu/expand/src/main.rs b/src/uu/expand/src/main.rs index d80b6090f..a154b36be 100644 --- a/src/uu/expand/src/main.rs +++ b/src/uu/expand/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_expand); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_expand); diff --git a/src/uu/expr/src/main.rs b/src/uu/expr/src/main.rs index 4268865df..6fdd6be14 100644 --- a/src/uu/expr/src/main.rs +++ b/src/uu/expr/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_expr); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_expr); diff --git a/src/uu/factor/src/main.rs b/src/uu/factor/src/main.rs index b251716b5..4d8b281b6 100644 --- a/src/uu/factor/src/main.rs +++ b/src/uu/factor/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_factor); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_factor); diff --git a/src/uu/false/src/main.rs b/src/uu/false/src/main.rs index 0cede3b5e..382a16fc7 100644 --- a/src/uu/false/src/main.rs +++ b/src/uu/false/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_false); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_false); diff --git a/src/uu/fmt/src/main.rs b/src/uu/fmt/src/main.rs index d7e883ba7..35531a8b4 100644 --- a/src/uu/fmt/src/main.rs +++ b/src/uu/fmt/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_fmt); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_fmt); diff --git a/src/uu/fold/src/main.rs b/src/uu/fold/src/main.rs index abdf80211..1802f2cf8 100644 --- a/src/uu/fold/src/main.rs +++ b/src/uu/fold/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_fold); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_fold); diff --git a/src/uu/groups/src/main.rs b/src/uu/groups/src/main.rs index 0a37ec7f4..6efe64b54 100644 --- a/src/uu/groups/src/main.rs +++ b/src/uu/groups/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_groups); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_groups); diff --git a/src/uu/hashsum/src/main.rs b/src/uu/hashsum/src/main.rs index 12bd3b393..bc4e2f3be 100644 --- a/src/uu/hashsum/src/main.rs +++ b/src/uu/hashsum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hashsum); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_hashsum); diff --git a/src/uu/head/src/main.rs b/src/uu/head/src/main.rs index fbeb3381e..3e66a50d0 100644 --- a/src/uu/head/src/main.rs +++ b/src/uu/head/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_head); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_head); diff --git a/src/uu/hostid/src/main.rs b/src/uu/hostid/src/main.rs index 12b1178ec..9645ed4a6 100644 --- a/src/uu/hostid/src/main.rs +++ b/src/uu/hostid/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hostid); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_hostid); diff --git a/src/uu/hostname/src/main.rs b/src/uu/hostname/src/main.rs index a483a8b1a..1d6e6733e 100644 --- a/src/uu/hostname/src/main.rs +++ b/src/uu/hostname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hostname); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_hostname); diff --git a/src/uu/id/src/main.rs b/src/uu/id/src/main.rs index 389e2deff..c8f6fe6aa 100644 --- a/src/uu/id/src/main.rs +++ b/src/uu/id/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_id); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_id); diff --git a/src/uu/install/src/main.rs b/src/uu/install/src/main.rs index 289079daf..d296ec4a2 100644 --- a/src/uu/install/src/main.rs +++ b/src/uu/install/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_install); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_install); diff --git a/src/uu/join/src/main.rs b/src/uu/join/src/main.rs index 75be18875..5114252cd 100644 --- a/src/uu/join/src/main.rs +++ b/src/uu/join/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_join); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_join); diff --git a/src/uu/kill/src/main.rs b/src/uu/kill/src/main.rs index c9f639967..91d0a28f0 100644 --- a/src/uu/kill/src/main.rs +++ b/src/uu/kill/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_kill); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_kill); diff --git a/src/uu/link/src/main.rs b/src/uu/link/src/main.rs index d837b4278..ccc565fed 100644 --- a/src/uu/link/src/main.rs +++ b/src/uu/link/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_link); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_link); diff --git a/src/uu/ln/src/main.rs b/src/uu/ln/src/main.rs index de14d10bd..060001972 100644 --- a/src/uu/ln/src/main.rs +++ b/src/uu/ln/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ln); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_ln); diff --git a/src/uu/logname/src/main.rs b/src/uu/logname/src/main.rs index 48a4063f1..f9cf6160e 100644 --- a/src/uu/logname/src/main.rs +++ b/src/uu/logname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_logname); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_logname); diff --git a/src/uu/ls/src/main.rs b/src/uu/ls/src/main.rs index f45314577..d867c3843 100644 --- a/src/uu/ls/src/main.rs +++ b/src/uu/ls/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ls); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_ls); diff --git a/src/uu/mkdir/src/main.rs b/src/uu/mkdir/src/main.rs index 3850113b9..fa6855c93 100644 --- a/src/uu/mkdir/src/main.rs +++ b/src/uu/mkdir/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mkdir); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_mkdir); diff --git a/src/uu/mkfifo/src/main.rs b/src/uu/mkfifo/src/main.rs index 489dc8ffd..3ad5a3bed 100644 --- a/src/uu/mkfifo/src/main.rs +++ b/src/uu/mkfifo/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mkfifo); // spell-checker:ignore procs uucore mkfifo +uucore_procs::main!(uu_mkfifo); diff --git a/src/uu/mknod/src/main.rs b/src/uu/mknod/src/main.rs index f3878199b..b65a20cd4 100644 --- a/src/uu/mknod/src/main.rs +++ b/src/uu/mknod/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mknod); // spell-checker:ignore procs uucore mknod +uucore_procs::main!(uu_mknod); diff --git a/src/uu/mktemp/src/main.rs b/src/uu/mktemp/src/main.rs index 217f09372..020284655 100644 --- a/src/uu/mktemp/src/main.rs +++ b/src/uu/mktemp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mktemp); // spell-checker:ignore procs uucore mktemp +uucore_procs::main!(uu_mktemp); diff --git a/src/uu/more/src/main.rs b/src/uu/more/src/main.rs index 1f3137265..15fbf51f9 100644 --- a/src/uu/more/src/main.rs +++ b/src/uu/more/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_more); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_more); diff --git a/src/uu/mv/src/main.rs b/src/uu/mv/src/main.rs index c7e321234..49f7956e8 100644 --- a/src/uu/mv/src/main.rs +++ b/src/uu/mv/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mv); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_mv); diff --git a/src/uu/nice/src/main.rs b/src/uu/nice/src/main.rs index 25da035aa..039f40d9d 100644 --- a/src/uu/nice/src/main.rs +++ b/src/uu/nice/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nice); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_nice); diff --git a/src/uu/nl/src/main.rs b/src/uu/nl/src/main.rs index fac355069..072fad504 100644 --- a/src/uu/nl/src/main.rs +++ b/src/uu/nl/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nl); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_nl); diff --git a/src/uu/nohup/src/main.rs b/src/uu/nohup/src/main.rs index d46ceb7cb..2007711f6 100644 --- a/src/uu/nohup/src/main.rs +++ b/src/uu/nohup/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nohup); // spell-checker:ignore procs uucore nohup +uucore_procs::main!(uu_nohup); diff --git a/src/uu/nproc/src/main.rs b/src/uu/nproc/src/main.rs index 7650cce09..356c2101f 100644 --- a/src/uu/nproc/src/main.rs +++ b/src/uu/nproc/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nproc); // spell-checker:ignore procs uucore nproc +uucore_procs::main!(uu_nproc); diff --git a/src/uu/numfmt/src/main.rs b/src/uu/numfmt/src/main.rs index 084d494f2..f4d991727 100644 --- a/src/uu/numfmt/src/main.rs +++ b/src/uu/numfmt/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_numfmt); // spell-checker:ignore procs uucore numfmt +uucore_procs::main!(uu_numfmt); diff --git a/src/uu/od/src/main.rs b/src/uu/od/src/main.rs index d5e96180c..3f30d15e8 100644 --- a/src/uu/od/src/main.rs +++ b/src/uu/od/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_od); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_od); diff --git a/src/uu/paste/src/main.rs b/src/uu/paste/src/main.rs index bb9b25a68..1d4458b9e 100644 --- a/src/uu/paste/src/main.rs +++ b/src/uu/paste/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_paste); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_paste); diff --git a/src/uu/pathchk/src/main.rs b/src/uu/pathchk/src/main.rs index e16353196..2b7c3b3ee 100644 --- a/src/uu/pathchk/src/main.rs +++ b/src/uu/pathchk/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pathchk); // spell-checker:ignore procs uucore pathchk +uucore_procs::main!(uu_pathchk); diff --git a/src/uu/pinky/src/main.rs b/src/uu/pinky/src/main.rs index 1bf1e618a..5414c42cc 100644 --- a/src/uu/pinky/src/main.rs +++ b/src/uu/pinky/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pinky); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_pinky); diff --git a/src/uu/printenv/src/main.rs b/src/uu/printenv/src/main.rs index 328c3b485..b61cbe90a 100644 --- a/src/uu/printenv/src/main.rs +++ b/src/uu/printenv/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_printenv); // spell-checker:ignore procs uucore printenv +uucore_procs::main!(uu_printenv); diff --git a/src/uu/printf/src/main.rs b/src/uu/printf/src/main.rs index aa9a45be5..9def7dafe 100644 --- a/src/uu/printf/src/main.rs +++ b/src/uu/printf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_printf); // spell-checker:ignore procs uucore printf +uucore_procs::main!(uu_printf); diff --git a/src/uu/ptx/src/main.rs b/src/uu/ptx/src/main.rs index 0b235443a..b627b801f 100644 --- a/src/uu/ptx/src/main.rs +++ b/src/uu/ptx/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ptx); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_ptx); diff --git a/src/uu/pwd/src/main.rs b/src/uu/pwd/src/main.rs index 4445b7891..c5716d2c9 100644 --- a/src/uu/pwd/src/main.rs +++ b/src/uu/pwd/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pwd); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_pwd); diff --git a/src/uu/readlink/src/main.rs b/src/uu/readlink/src/main.rs index e5aab3cb6..651fd73ca 100644 --- a/src/uu/readlink/src/main.rs +++ b/src/uu/readlink/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_readlink); // spell-checker:ignore procs uucore readlink +uucore_procs::main!(uu_readlink); diff --git a/src/uu/realpath/src/main.rs b/src/uu/realpath/src/main.rs index 3a74bc5f6..8b8a8dc5e 100644 --- a/src/uu/realpath/src/main.rs +++ b/src/uu/realpath/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_realpath); // spell-checker:ignore procs uucore realpath +uucore_procs::main!(uu_realpath); diff --git a/src/uu/relpath/src/main.rs b/src/uu/relpath/src/main.rs index a5f866bb2..22aa68d53 100644 --- a/src/uu/relpath/src/main.rs +++ b/src/uu/relpath/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_relpath); // spell-checker:ignore procs uucore relpath +uucore_procs::main!(uu_relpath); diff --git a/src/uu/rm/src/main.rs b/src/uu/rm/src/main.rs index ebb998c39..960867359 100644 --- a/src/uu/rm/src/main.rs +++ b/src/uu/rm/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_rm); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_rm); diff --git a/src/uu/rmdir/src/main.rs b/src/uu/rmdir/src/main.rs index ab1939b4a..92ff22c07 100644 --- a/src/uu/rmdir/src/main.rs +++ b/src/uu/rmdir/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_rmdir); // spell-checker:ignore procs uucore rmdir +uucore_procs::main!(uu_rmdir); diff --git a/src/uu/seq/src/main.rs b/src/uu/seq/src/main.rs index c984ed61a..266ac5d11 100644 --- a/src/uu/seq/src/main.rs +++ b/src/uu/seq/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_seq); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_seq); diff --git a/src/uu/shred/src/main.rs b/src/uu/shred/src/main.rs index 2880499eb..ea7a42f65 100644 --- a/src/uu/shred/src/main.rs +++ b/src/uu/shred/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_shred); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_shred); diff --git a/src/uu/shuf/src/main.rs b/src/uu/shuf/src/main.rs index 1ecff5d21..fc6e2b4ae 100644 --- a/src/uu/shuf/src/main.rs +++ b/src/uu/shuf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_shuf); // spell-checker:ignore procs uucore shuf +uucore_procs::main!(uu_shuf); diff --git a/src/uu/sleep/src/main.rs b/src/uu/sleep/src/main.rs index 46ecd0969..16c3100aa 100644 --- a/src/uu/sleep/src/main.rs +++ b/src/uu/sleep/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sleep); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_sleep); diff --git a/src/uu/sort/src/main.rs b/src/uu/sort/src/main.rs index a59375b2f..ab463776d 100644 --- a/src/uu/sort/src/main.rs +++ b/src/uu/sort/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sort); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_sort); diff --git a/src/uu/split/src/main.rs b/src/uu/split/src/main.rs index 2f0640db4..87f15f529 100644 --- a/src/uu/split/src/main.rs +++ b/src/uu/split/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_split); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_split); diff --git a/src/uu/stat/src/main.rs b/src/uu/stat/src/main.rs index 6e483c850..839eff7de 100644 --- a/src/uu/stat/src/main.rs +++ b/src/uu/stat/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_stat); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_stat); diff --git a/src/uu/stdbuf/src/main.rs b/src/uu/stdbuf/src/main.rs index c020a7a07..1989a3b8d 100644 --- a/src/uu/stdbuf/src/main.rs +++ b/src/uu/stdbuf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_stdbuf); // spell-checker:ignore procs uucore stdbuf +uucore_procs::main!(uu_stdbuf); diff --git a/src/uu/sum/src/main.rs b/src/uu/sum/src/main.rs index 64b0d4254..85f4d0079 100644 --- a/src/uu/sum/src/main.rs +++ b/src/uu/sum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sum); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_sum); diff --git a/src/uu/sync/src/main.rs b/src/uu/sync/src/main.rs index 06d85b278..9786fc371 100644 --- a/src/uu/sync/src/main.rs +++ b/src/uu/sync/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sync); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_sync); diff --git a/src/uu/tac/src/main.rs b/src/uu/tac/src/main.rs index 93d91e2b7..018821c73 100644 --- a/src/uu/tac/src/main.rs +++ b/src/uu/tac/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tac); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tac); diff --git a/src/uu/tail/src/main.rs b/src/uu/tail/src/main.rs index 52818fad6..dd89ce2c7 100644 --- a/src/uu/tail/src/main.rs +++ b/src/uu/tail/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tail); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tail); diff --git a/src/uu/tee/src/main.rs b/src/uu/tee/src/main.rs index 1314f353e..2b483d9d8 100644 --- a/src/uu/tee/src/main.rs +++ b/src/uu/tee/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tee); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tee); diff --git a/src/uu/test/src/main.rs b/src/uu/test/src/main.rs index 5018a5c8c..9f4e6985f 100644 --- a/src/uu/test/src/main.rs +++ b/src/uu/test/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_test); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_test); diff --git a/src/uu/timeout/src/main.rs b/src/uu/timeout/src/main.rs index 20c4271d9..2479f91c1 100644 --- a/src/uu/timeout/src/main.rs +++ b/src/uu/timeout/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_timeout); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_timeout); diff --git a/src/uu/touch/src/main.rs b/src/uu/touch/src/main.rs index bad67efd4..e8a2729a2 100644 --- a/src/uu/touch/src/main.rs +++ b/src/uu/touch/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_touch); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_touch); diff --git a/src/uu/tr/src/main.rs b/src/uu/tr/src/main.rs index 8bed990e5..9118c3628 100644 --- a/src/uu/tr/src/main.rs +++ b/src/uu/tr/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tr); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tr); diff --git a/src/uu/true/src/main.rs b/src/uu/true/src/main.rs index 7e009be8a..b30f4d4cb 100644 --- a/src/uu/true/src/main.rs +++ b/src/uu/true/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_true); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_true); diff --git a/src/uu/truncate/src/main.rs b/src/uu/truncate/src/main.rs index 91fe70b6d..46e65faea 100644 --- a/src/uu/truncate/src/main.rs +++ b/src/uu/truncate/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_truncate); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_truncate); diff --git a/src/uu/tsort/src/main.rs b/src/uu/tsort/src/main.rs index 6b108cc5e..0694678d4 100644 --- a/src/uu/tsort/src/main.rs +++ b/src/uu/tsort/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tsort); // spell-checker:ignore procs uucore tsort +uucore_procs::main!(uu_tsort); diff --git a/src/uu/tty/src/main.rs b/src/uu/tty/src/main.rs index 8cb1cbb4b..01a01e5ca 100644 --- a/src/uu/tty/src/main.rs +++ b/src/uu/tty/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tty); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tty); diff --git a/src/uu/uname/src/main.rs b/src/uu/uname/src/main.rs index f40104670..5252f4716 100644 --- a/src/uu/uname/src/main.rs +++ b/src/uu/uname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uname); // spell-checker:ignore procs uucore uname +uucore_procs::main!(uu_uname); diff --git a/src/uu/unexpand/src/main.rs b/src/uu/unexpand/src/main.rs index 82d11dd95..2e7b1d967 100644 --- a/src/uu/unexpand/src/main.rs +++ b/src/uu/unexpand/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_unexpand); // spell-checker:ignore procs uucore unexpand +uucore_procs::main!(uu_unexpand); diff --git a/src/uu/uniq/src/main.rs b/src/uu/uniq/src/main.rs index dd4b6da1a..361c39f14 100644 --- a/src/uu/uniq/src/main.rs +++ b/src/uu/uniq/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uniq); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_uniq); diff --git a/src/uu/unlink/src/main.rs b/src/uu/unlink/src/main.rs index f01b6bac3..b03d4a675 100644 --- a/src/uu/unlink/src/main.rs +++ b/src/uu/unlink/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_unlink); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_unlink); diff --git a/src/uu/uptime/src/main.rs b/src/uu/uptime/src/main.rs index 352703eb3..be5d5ab01 100644 --- a/src/uu/uptime/src/main.rs +++ b/src/uu/uptime/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uptime); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_uptime); diff --git a/src/uu/users/src/main.rs b/src/uu/users/src/main.rs index f065c633c..f30a01ecb 100644 --- a/src/uu/users/src/main.rs +++ b/src/uu/users/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_users); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_users); diff --git a/src/uu/wc/src/main.rs b/src/uu/wc/src/main.rs index ce5629e51..b58b9cac7 100644 --- a/src/uu/wc/src/main.rs +++ b/src/uu/wc/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_wc); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_wc); diff --git a/src/uu/who/src/main.rs b/src/uu/who/src/main.rs index bc0015a80..a093201a1 100644 --- a/src/uu/who/src/main.rs +++ b/src/uu/who/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_who); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_who); diff --git a/src/uu/whoami/src/main.rs b/src/uu/whoami/src/main.rs index 0439923ee..40de26564 100644 --- a/src/uu/whoami/src/main.rs +++ b/src/uu/whoami/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_whoami); // spell-checker:ignore procs uucore whoami +uucore_procs::main!(uu_whoami); diff --git a/src/uu/yes/src/main.rs b/src/uu/yes/src/main.rs index 597eb5b57..dc5bf6a0c 100644 --- a/src/uu/yes/src/main.rs +++ b/src/uu/yes/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_yes); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_yes); From 48e509546a88604529650dc563f8b89489867220 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:38:33 -0500 Subject: [PATCH 068/126] refactor/uucore ~ polish spelling (comments, names, and exceptions) --- src/uucore/src/lib/features/fsext.rs | 73 +++++++++++++---------- src/uucore/src/lib/features/perms.rs | 12 ++-- src/uucore/src/lib/features/ringbuffer.rs | 6 +- src/uucore/src/lib/features/utmpx.rs | 4 +- src/uucore/src/lib/lib.rs | 4 +- src/uucore/src/lib/macros.rs | 6 +- src/uucore/src/lib/mods/os.rs | 3 + 7 files changed, 61 insertions(+), 47 deletions(-) diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index 6343ecd50..e1cb67097 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -7,7 +7,7 @@ // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. -// spell-checker:ignore (ToDO) strerror IFBLK IFCHR IFDIR IFLNK IFIFO IFMT IFREG IFSOCK subsec nanos gnulib statfs Sstatfs bitrig statvfs iosize blksize fnodes fsid namelen bsize bfree bavail ffree frsize namemax errno fstype adfs acfs aufs affs autofs befs bdevfs binfmt ceph cgroups cifs configfs cramfs cgroupfs debugfs devfs devpts ecryptfs btrfs efivarfs exofs fhgfs fuseblk fusectl futexfs gpfs hfsx hostfs hpfs inodefs ibrix inotifyfs isofs jffs logfs hugetlbfs mqueue nsfs ntfs ocfs panfs pipefs ramfs romfs nfsd nilfs pstorefs reiserfs securityfs smackfs snfs sockfs squashfs sysfs sysv tempfs tracefs ubifs usbdevfs vmhgfs tmpfs vxfs wslfs xenfs vzfs openprom overlayfs +// spell-checker:ignore (arch) bitrig ; (fs) cifs smbfs extern crate time; @@ -88,7 +88,7 @@ use std::time::UNIX_EPOCH; target_os = "android", target_os = "freebsd" ))] -pub use libc::statfs as Sstatfs; +pub use libc::statfs as StatFs; #[cfg(any( target_os = "openbsd", target_os = "netbsd", @@ -96,7 +96,7 @@ pub use libc::statfs as Sstatfs; target_os = "bitrig", target_os = "dragonfly" ))] -pub use libc::statvfs as Sstatfs; +pub use libc::statvfs as StatFs; #[cfg(any( target_os = "linux", @@ -168,6 +168,7 @@ impl MountInfo { } } // set MountInfo::dummy + // spell-checker:disable match self.fs_type.as_ref() { "autofs" | "proc" | "subfs" /* for Linux 2.6/3.x */ @@ -181,6 +182,7 @@ impl MountInfo { _ => self.dummy = self.fs_type == "none" && !self.mount_option.contains(MOUNT_OPT_BIND) } + // spell-checker:enable // set MountInfo::remote #[cfg(windows)] { @@ -203,6 +205,7 @@ impl MountInfo { #[cfg(target_os = "linux")] fn new(file_name: &str, raw: Vec<&str>) -> Option { match file_name { + // spell-checker:ignore (word) noatime // Format: 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue // "man proc" for more details LINUX_MOUNTINFO => { @@ -307,21 +310,24 @@ impl MountInfo { #[cfg(any(target_vendor = "apple", target_os = "freebsd"))] use std::ffi::CStr; #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] -impl From for MountInfo { - fn from(statfs: Sstatfs) -> Self { +impl From for MountInfo { + fn from(statfs: StatFs) -> Self { let mut info = MountInfo { dev_id: "".to_string(), dev_name: unsafe { + // spell-checker:disable-next-line CStr::from_ptr(&statfs.f_mntfromname[0]) .to_string_lossy() .into_owned() }, fs_type: unsafe { + // spell-checker:disable-next-line CStr::from_ptr(&statfs.f_fstypename[0]) .to_string_lossy() .into_owned() }, mount_dir: unsafe { + // spell-checker:disable-next-line CStr::from_ptr(&statfs.f_mntonname[0]) .to_string_lossy() .into_owned() @@ -341,14 +347,15 @@ use libc::c_int; #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] extern "C" { #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] - #[link_name = "getmntinfo$INODE64"] - fn getmntinfo(mntbufp: *mut *mut Sstatfs, flags: c_int) -> c_int; + #[link_name = "getmntinfo$INODE64"] // spell-checker:disable-line + fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int; #[cfg(any( all(target_os = "freebsd"), all(target_vendor = "apple", target_arch = "aarch64") ))] - fn getmntinfo(mntbufp: *mut *mut Sstatfs, flags: c_int) -> c_int; + #[link_name = "getmntinfo"] // spell-checker:disable-line + fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int; } #[cfg(target_os = "linux")] @@ -363,11 +370,11 @@ use std::slice; pub fn read_fs_list() -> Vec { #[cfg(target_os = "linux")] { - let (file_name, fobj) = File::open(LINUX_MOUNTINFO) + let (file_name, f) = File::open(LINUX_MOUNTINFO) .map(|f| (LINUX_MOUNTINFO, f)) .or_else(|_| File::open(LINUX_MTAB).map(|f| (LINUX_MTAB, f))) .expect("failed to find mount list files"); - let reader = BufReader::new(fobj); + let reader = BufReader::new(f); reader .lines() .filter_map(|line| line.ok()) @@ -379,12 +386,12 @@ pub fn read_fs_list() -> Vec { } #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] { - let mut mptr: *mut Sstatfs = ptr::null_mut(); - let len = unsafe { getmntinfo(&mut mptr, 1_i32) }; + let mut mount_buffer_ptr: *mut StatFs = ptr::null_mut(); + let len = unsafe { get_mount_info(&mut mount_buffer_ptr, 1_i32) }; if len < 0 { - crash!(1, "getmntinfo failed"); + crash!(1, "get_mount_info() failed"); } - let mounts = unsafe { slice::from_raw_parts(mptr, len as usize) }; + let mounts = unsafe { slice::from_raw_parts(mount_buffer_ptr, len as usize) }; mounts .iter() .map(|m| MountInfo::from(*m)) @@ -446,7 +453,7 @@ pub struct FsUsage { impl FsUsage { #[cfg(unix)] - pub fn new(statvfs: Sstatfs) -> FsUsage { + pub fn new(statvfs: StatFs) -> FsUsage { { FsUsage { blocksize: statvfs.f_bsize as u64, // or `statvfs.f_frsize` ? @@ -523,20 +530,20 @@ impl FsUsage { #[cfg(unix)] pub trait FsMeta { fn fs_type(&self) -> i64; - fn iosize(&self) -> u64; - fn blksize(&self) -> i64; + fn io_size(&self) -> u64; + fn block_size(&self) -> i64; fn total_blocks(&self) -> u64; fn free_blocks(&self) -> u64; fn avail_blocks(&self) -> u64; - fn total_fnodes(&self) -> u64; - fn free_fnodes(&self) -> u64; + fn total_file_nodes(&self) -> u64; + fn free_file_nodes(&self) -> u64; fn fsid(&self) -> u64; fn namelen(&self) -> u64; } #[cfg(unix)] -impl FsMeta for Sstatfs { - fn blksize(&self) -> i64 { +impl FsMeta for StatFs { + fn block_size(&self) -> i64 { self.f_bsize as i64 } fn total_blocks(&self) -> u64 { @@ -548,10 +555,10 @@ impl FsMeta for Sstatfs { fn avail_blocks(&self) -> u64 { self.f_bavail as u64 } - fn total_fnodes(&self) -> u64 { + fn total_file_nodes(&self) -> u64 { self.f_files as u64 } - fn free_fnodes(&self) -> u64 { + fn free_file_nodes(&self) -> u64 { self.f_ffree as u64 } #[cfg(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd"))] @@ -565,16 +572,16 @@ impl FsMeta for Sstatfs { } #[cfg(target_os = "linux")] - fn iosize(&self) -> u64 { + fn io_size(&self) -> u64 { self.f_frsize as u64 } #[cfg(any(target_vendor = "apple", target_os = "freebsd"))] - fn iosize(&self) -> u64 { + fn io_size(&self) -> u64 { self.f_iosize as u64 } // XXX: dunno if this is right #[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))] - fn iosize(&self) -> u64 { + fn io_size(&self) -> u64 { self.f_bsize as u64 } @@ -605,23 +612,23 @@ impl FsMeta for Sstatfs { } #[cfg(target_os = "freebsd")] fn namelen(&self) -> u64 { - self.f_namemax as u64 + self.f_namemax as u64 // spell-checker:disable-line } // XXX: should everything just use statvfs? #[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))] fn namelen(&self) -> u64 { - self.f_namemax as u64 + self.f_namemax as u64 // spell-checker:disable-line } } #[cfg(unix)] -pub fn statfs>(path: P) -> Result +pub fn statfs>(path: P) -> Result where Vec: From

, { match CString::new(path) { Ok(p) => { - let mut buffer: Sstatfs = unsafe { mem::zeroed() }; + let mut buffer: StatFs = unsafe { mem::zeroed() }; unsafe { match statfs_fn(p.as_ptr(), &mut buffer) { 0 => Ok(buffer), @@ -667,12 +674,13 @@ pub fn pretty_filetype<'a>(mode: mode_t, size: u64) -> &'a str { S_IFIFO => "fifo", S_IFSOCK => "socket", // TODO: Other file types - // See coreutils/gnulib/lib/file-type.c + // See coreutils/gnulib/lib/file-type.c // spell-checker:disable-line _ => "weird file", } } pub fn pretty_fstype<'a>(fstype: i64) -> Cow<'a, str> { + // spell-checker:disable match fstype { 0x6163_6673 => "acfs".into(), 0xADF5 => "adfs".into(), @@ -790,6 +798,7 @@ pub fn pretty_fstype<'a>(fstype: i64) -> Cow<'a, str> { 0x2FC1_2FC1 => "zfs".into(), other => format!("UNKNOWN ({:#x})", other).into(), } + // spell-checker:enable } #[cfg(test)] @@ -808,6 +817,7 @@ mod tests { #[test] fn test_fs_type() { + // spell-checker:disable assert_eq!("ext2/ext3", pretty_fstype(0xEF53)); assert_eq!("tmpfs", pretty_fstype(0x01021994)); assert_eq!("nfs", pretty_fstype(0x6969)); @@ -817,5 +827,6 @@ mod tests { assert_eq!("ntfs", pretty_fstype(0x5346544e)); assert_eq!("fat", pretty_fstype(0x4006)); assert_eq!("UNKNOWN (0x1234)", pretty_fstype(0x1234)); + // spell-checker:enable } } diff --git a/src/uucore/src/lib/features/perms.rs b/src/uucore/src/lib/features/perms.rs index 36f56206d..eb6cca102 100644 --- a/src/uucore/src/lib/features/perms.rs +++ b/src/uucore/src/lib/features/perms.rs @@ -26,14 +26,14 @@ pub enum Verbosity { } /// Actually perform the change of group on a path -fn chgrp>(path: P, dgid: gid_t, follow: bool) -> IOResult<()> { +fn chgrp>(path: P, gid: gid_t, follow: bool) -> IOResult<()> { let path = path.as_ref(); let s = CString::new(path.as_os_str().as_bytes()).unwrap(); let ret = unsafe { if follow { - libc::chown(s.as_ptr(), 0_u32.wrapping_sub(1), dgid) + libc::chown(s.as_ptr(), 0_u32.wrapping_sub(1), gid) } else { - lchown(s.as_ptr(), 0_u32.wrapping_sub(1), dgid) + lchown(s.as_ptr(), 0_u32.wrapping_sub(1), gid) } }; if ret == 0 { @@ -100,14 +100,14 @@ pub fn wrap_chgrp>( } /// Actually perform the change of owner on a path -fn chown>(path: P, duid: uid_t, dgid: gid_t, follow: bool) -> IOResult<()> { +fn chown>(path: P, uid: uid_t, gid: gid_t, follow: bool) -> IOResult<()> { let path = path.as_ref(); let s = CString::new(path.as_os_str().as_bytes()).unwrap(); let ret = unsafe { if follow { - libc::chown(s.as_ptr(), duid, dgid) + libc::chown(s.as_ptr(), uid, gid) } else { - lchown(s.as_ptr(), duid, dgid) + lchown(s.as_ptr(), uid, gid) } }; if ret == 0 { diff --git a/src/uucore/src/lib/features/ringbuffer.rs b/src/uucore/src/lib/features/ringbuffer.rs index 60847df8f..1cb0d2b0d 100644 --- a/src/uucore/src/lib/features/ringbuffer.rs +++ b/src/uucore/src/lib/features/ringbuffer.rs @@ -47,11 +47,11 @@ impl RingBuffer { } pub fn from_iter(iter: impl Iterator, size: usize) -> RingBuffer { - let mut ringbuf = RingBuffer::new(size); + let mut ring_buffer = RingBuffer::new(size); for value in iter { - ringbuf.push_back(value); + ring_buffer.push_back(value); } - ringbuf + ring_buffer } /// Append a value to the end of the ring buffer. diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 826831ba6..a794b01da 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -238,8 +238,8 @@ impl UtmpxIter { /// If not set, default record file will be used(file path depends on the target OS) pub fn read_from(self, f: &str) -> Self { let res = unsafe { - let cstr = CString::new(f).unwrap(); - utmpxname(cstr.as_ptr()) + let cstring = CString::new(f).unwrap(); + utmpxname(cstring.as_ptr()) }; if res != 0 { show_warning!("utmpxname: {}", IOError::last_os_error()); diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index e7f29e20c..0b0d0fddf 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -130,7 +130,7 @@ pub trait Args: Iterator + Sized { full_conversion = false; let lossy_conversion = s_ret.to_string_lossy(); eprintln!( - "Input with broken encoding occured! (s = '{}') ", + "Input with broken encoding occurred! (s = '{}') ", &lossy_conversion ); match handling { @@ -159,7 +159,7 @@ pub trait Args: Iterator + Sized { } } - /// convience function for a more slim interface + /// convenience function for a more slim interface fn collect_str_lossy(self) -> ConversionResult { self.collect_str(InvalidEncodingHandling::ConvertLossy) } diff --git a/src/uucore/src/lib/macros.rs b/src/uucore/src/lib/macros.rs index 438fec960..07d47eed8 100644 --- a/src/uucore/src/lib/macros.rs +++ b/src/uucore/src/lib/macros.rs @@ -21,7 +21,7 @@ macro_rules! executable( }) ); -/// Show an error to stderr in a silimar style to GNU coreutils. +/// Show an error to stderr in a similar style to GNU coreutils. #[macro_export] macro_rules! show_error( ($($args:tt)+) => ({ @@ -30,7 +30,7 @@ macro_rules! show_error( }) ); -/// Show a warning to stderr in a silimar style to GNU coreutils. +/// Show a warning to stderr in a similar style to GNU coreutils. #[macro_export] macro_rules! show_error_custom_description ( ($err:expr,$($args:tt)+) => ({ @@ -47,7 +47,7 @@ macro_rules! show_warning( }) ); -/// Show a bad inocation help message in a similar style to GNU coreutils. +/// Show a bad invocation help message in a similar style to GNU coreutils. #[macro_export] macro_rules! show_usage_error( ($($args:tt)+) => ({ diff --git a/src/uucore/src/lib/mods/os.rs b/src/uucore/src/lib/mods/os.rs index da2002161..dd06f4739 100644 --- a/src/uucore/src/lib/mods/os.rs +++ b/src/uucore/src/lib/mods/os.rs @@ -1,5 +1,8 @@ /// Test if the program is running under WSL // ref: @@ + +// spell-checker:ignore (path) osrelease + pub fn is_wsl_1() -> bool { #[cfg(target_os = "linux")] { From 43f5c13a7ff7860bfc4c5684699ba8f30854210f Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:43:33 -0500 Subject: [PATCH 069/126] refactor/chmod ~ polish spelling (comments, names, and exceptions) --- src/uu/chmod/src/chmod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index c4bf309d6..62faacffe 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -112,7 +112,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Arg::with_name(options::MODE) .required_unless(options::REFERENCE) .takes_value(true), - // It would be nice if clap could parse with delimeter, e.g. "g-x,u+x", + // It would be nice if clap could parse with delimiter, e.g. "g-x,u+x", // however .multiple(true) cannot be used here because FILE already needs that. // Only one positional argument with .multiple(true) set is allowed per command ) From fc5451b5e7ab48755dbab4cbd5708aa0c54c1e8c Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 00:01:36 -0500 Subject: [PATCH 070/126] refactor/cksum ~ polish spelling (comments, names, and exceptions) --- src/uu/cksum/src/cksum.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 1d45c1332..b6f798d5e 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -99,15 +99,15 @@ const fn crc_entry(input: u8) -> u32 { // i += 1; //} unroll!(8, |_i| { - let if_cond = crc & 0x8000_0000; + let if_condition = crc & 0x8000_0000; let if_body = (crc << 1) ^ 0x04c1_1db7; let else_body = crc << 1; // NOTE: i feel like this is easier to understand than emulating an if statement in bitwise // ops - let cond_table = [else_body, if_body]; + let condition_table = [else_body, if_body]; - crc = cond_table[(if_cond != 0) as usize]; + crc = condition_table[(if_condition != 0) as usize]; }); crc From 1b1086146ba820a0e48c38a452711ae26cfbfe18 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:43:23 -0500 Subject: [PATCH 071/126] refactor/cp ~ polish spelling (comments, names, and exceptions) --- src/uu/cp/src/cp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 4d9e5965e..b7c64928f 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1335,7 +1335,7 @@ fn copy_on_write_macos(source: &Path, dest: &Path, mode: ReflinkMode) -> CopyRes } if raw_pfn.is_null() || error != 0 { - // clonefile(2) is not supported or it error'ed out (possibly because the FS does not + // clonefile(2) is either not supported or it errored out (possibly because the FS does not // support COW). match mode { ReflinkMode::Always => { From dfe594e91883b17b7c7bf972bb43f7b1f9fed5e3 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:43:11 -0500 Subject: [PATCH 072/126] refactor/date ~ polish spelling (comments, names, and exceptions) --- src/uu/date/src/date.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 1fe80c03f..02aa7a60d 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -6,8 +6,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (format) MMDDhhmm -// spell-checker:ignore (ToDO) DATEFILE +// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes #[macro_use] extern crate uucore; From 6e1bd6027adb0b8b05a53b860cdf2ed797bba8d1 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 29 May 2021 22:23:11 -0500 Subject: [PATCH 073/126] refactor/du ~ polish spelling (comments, names, and exceptions) --- src/uu/df/src/df.rs | 30 ++++++++++++++---------------- src/uu/du/src/du.rs | 23 +++++++++++------------ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 8219b0a27..07f8b0214 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -6,9 +6,6 @@ // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. -// spell-checker:ignore (ToDO) mountinfo BLOCKSIZE fobj mptr noatime Iused overmounted -// spell-checker:ignore (libc/fs) asyncreads asyncwrites autofs bavail bfree bsize charspare cifs debugfs devfs devpts ffree frsize fsid fstypename fusectl inode inodes iosize kernfs mntbufp mntfromname mntonname mqueue namemax pipefs smbfs statvfs subfs syncreads syncwrites sysfs wcslen - #[macro_use] extern crate uucore; #[cfg(unix)] @@ -78,7 +75,7 @@ struct Options { #[derive(Debug, Clone)] struct Filesystem { - mountinfo: MountInfo, + mount_info: MountInfo, usage: FsUsage, } @@ -131,19 +128,19 @@ impl Options { } impl Filesystem { - // TODO: resolve uuid in `mountinfo.dev_name` if exists - fn new(mountinfo: MountInfo) -> Option { - let _stat_path = if !mountinfo.mount_dir.is_empty() { - mountinfo.mount_dir.clone() + // TODO: resolve uuid in `mount_info.dev_name` if exists + fn new(mount_info: MountInfo) -> Option { + let _stat_path = if !mount_info.mount_dir.is_empty() { + mount_info.mount_dir.clone() } else { #[cfg(unix)] { - mountinfo.dev_name.clone() + mount_info.dev_name.clone() } #[cfg(windows)] { // On windows, we expect the volume id - mountinfo.dev_id.clone() + mount_info.dev_id.clone() } }; #[cfg(unix)] @@ -154,14 +151,14 @@ impl Filesystem { None } else { Some(Filesystem { - mountinfo, + mount_info, usage: FsUsage::new(statvfs), }) } } #[cfg(windows)] Some(Filesystem { - mountinfo, + mount_info, usage: FsUsage::new(Path::new(&_stat_path)), }) } @@ -205,7 +202,7 @@ fn filter_mount_list(vmi: Vec, paths: &[String], opt: &Options) -> Ve if (!mi.dev_name.starts_with('/') || seen.dev_name.starts_with('/')) // let points towards the root of the device win. && (!target_nearer_root || source_below_root) - // let an entry overmounted on a new device win... + // let an entry over-mounted on a new device win... && (seen.dev_name == mi.dev_name /* ... but only when matching an existing mnt point, to avoid problematic replacement when given @@ -431,6 +428,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { header.push("Type"); } header.extend_from_slice(&if opt.show_inode_instead { + // spell-checker:disable-next-line ["Inodes", "Iused", "IFree", "IUses%"] } else { [ @@ -462,9 +460,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } println!(); for fs in fs_list.iter() { - print!("{0: <16} ", fs.mountinfo.dev_name); + print!("{0: <16} ", fs.mount_info.dev_name); if opt.show_fs_type { - print!("{0: <5} ", fs.mountinfo.fs_type); + print!("{0: <5} ", fs.mount_info.fs_type); } if opt.show_inode_instead { print!( @@ -508,7 +506,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } print!("{0: >5} ", use_size(free_size, total_size)); } - print!("{0: <16}", fs.mountinfo.mount_dir); + print!("{0: <16}", fs.mount_info.mount_dir); println!(); } diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index b0940d93d..0bc8b30c8 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -60,14 +60,13 @@ const VERSION: &str = env!("CARGO_PKG_VERSION"); const NAME: &str = "du"; const SUMMARY: &str = "estimate file space usage"; const LONG_HELP: &str = " - Display values are in units of the first available SIZE from - --block-size, and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environ‐ - ment variables. Otherwise, units default to 1024 bytes (or 512 if - POSIXLY_CORRECT is set). +Display values are in units of the first available SIZE from --block-size, +and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. +Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). - SIZE is an integer and optional unit (example: 10M is 10*1024*1024). - Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (pow‐ - ers of 1000). +SIZE is an integer and optional unit (example: 10M is 10*1024*1024). +Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB,... (powers +of 1000). "; // TODO: Support Z & Y (currently limited by size of u64) @@ -586,7 +585,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { separate_dirs: matches.is_present(options::SEPARATE_DIRS), }; - let strs = match matches.value_of(options::FILE) { + let files = match matches.value_of(options::FILE) { Some(_) => matches.values_of(options::FILE).unwrap().collect(), None => { vec!["./"] // TODO: gnu `du` doesn't use trailing "/" here @@ -644,8 +643,8 @@ Try '{} --help' for more information.", }; let mut grand_total = 0; - for path_str in strs { - let path = PathBuf::from(&path_str); + for path_string in files { + let path = PathBuf::from(&path_string); match Stat::new(path) { Ok(stat) => { let mut inodes: HashSet = HashSet::new(); @@ -707,13 +706,13 @@ Try '{} --help' for more information.", } if options.total && index == (len - 1) { // The last element will be the total size of the the path under - // path_str. We add it to the grand total. + // path_string. We add it to the grand total. grand_total += size; } } } Err(_) => { - show_error!("{}: {}", path_str, "No such file or directory"); + show_error!("{}: {}", path_string, "No such file or directory"); } } } From ba7939e142dd0aeb6c4078521b820b26fc9e5b3f Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:43:03 -0500 Subject: [PATCH 074/126] refactor/env ~ polish spelling (comments, names, and exceptions) --- src/uu/env/src/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 83927b160..50a327260 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -7,7 +7,7 @@ /* last synced with: env (GNU coreutils) 8.13 */ -// spell-checker:ignore (ToDO) execvp progname subcommand subcommands unsets +// spell-checker:ignore (ToDO) chdir execvp progname subcommand subcommands unsets #[macro_use] extern crate clap; From 1a37d502d113e411c0fabeb9e8efcca9ee733b81 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 00:09:01 -0500 Subject: [PATCH 075/126] refactor/factor ~ polish spelling (comments, names, and exceptions) --- src/uu/factor/BENCHMARKING.md | 16 +++++++++------- src/uu/factor/build.rs | 18 ++++++++---------- src/uu/factor/src/factor.rs | 2 ++ src/uu/factor/src/miller_rabin.rs | 5 +++-- src/uu/factor/src/numeric/gcd.rs | 2 +- src/uu/factor/src/numeric/modular_inverse.rs | 20 ++++++++++---------- src/uu/factor/src/numeric/montgomery.rs | 8 ++++---- src/uu/factor/src/table.rs | 4 ++-- 8 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/uu/factor/BENCHMARKING.md b/src/uu/factor/BENCHMARKING.md index e174d62b7..7b611db4b 100644 --- a/src/uu/factor/BENCHMARKING.md +++ b/src/uu/factor/BENCHMARKING.md @@ -1,5 +1,7 @@ # Benchmarking `factor` + + The benchmarks for `factor` are located under `tests/benches/factor` and can be invoked with `cargo bench` in that directory. @@ -13,7 +15,7 @@ a newer version of `rustc`. We currently use [`criterion`] to benchmark deterministic functions, such as `gcd` and `table::factor`. -However, µbenchmarks are by nature unstable: not only are they specific to +However, microbenchmarks are by nature unstable: not only are they specific to the hardware, operating system version, etc., but they are noisy and affected by other tasks on the system (browser, compile jobs, etc.), which can cause `criterion` to report spurious performance improvements and regressions. @@ -33,13 +35,13 @@ as possible: [`criterion`]: https://bheisler.github.io/criterion.rs/book/index.html [lemire]: https://lemire.me/blog/2018/01/16/microbenchmarking-calls-for-idealized-conditions/ [isolate a **physical** core]: https://pyperf.readthedocs.io/en/latest/system.html#isolate-cpus-on-linux -[frequency stays constant]: XXXTODO +[frequency stays constant]: ... -### Guidance for designing µbenchmarks +### Guidance for designing microbenchmarks *Note:* this guidance is specific to `factor` and takes its application domain -into account; do not expect it to generalise to other projects. It is based +into account; do not expect it to generalize to other projects. It is based on Daniel Lemire's [*Microbenchmarking calls for idealized conditions*][lemire], which I recommend reading if you want to add benchmarks to `factor`. @@ -71,7 +73,7 @@ which I recommend reading if you want to add benchmarks to `factor`. ### Configurable statistical estimators -`criterion` always uses the arithmetic average as estimator; in µbenchmarks, +`criterion` always uses the arithmetic average as estimator; in microbenchmarks, where the code under test is fully deterministic and the measurements are subject to additive, positive noise, [the minimum is more appropriate][lemire]. @@ -81,10 +83,10 @@ subject to additive, positive noise, [the minimum is more appropriate][lemire]. Measuring performance on real hardware is important, as it relates directly to what users of `factor` experience; however, such measurements are subject to the constraints of the real-world, and aren't perfectly reproducible. -Moreover, the mitigations for it (described above) aren't achievable in +Moreover, the mitigation for it (described above) isn't achievable in virtualized, multi-tenant environments such as CI. -Instead, we could run the µbenchmarks in a simulated CPU with [`cachegrind`], +Instead, we could run the microbenchmarks in a simulated CPU with [`cachegrind`], measure execution “time” in that model (in CI), and use it to detect and report performance improvements and regressions. diff --git a/src/uu/factor/build.rs b/src/uu/factor/build.rs index eff21ae2f..32640d61a 100644 --- a/src/uu/factor/build.rs +++ b/src/uu/factor/build.rs @@ -13,8 +13,6 @@ //! 2 has no multiplicative inverse mode 2^64 because 2 | 2^64, //! and in any case divisibility by two is trivial by checking the LSB. -// spell-checker:ignore (ToDO) invs newr newrp newtp outstr - #![cfg_attr(test, allow(dead_code))] use std::env::{self, args}; @@ -60,13 +58,13 @@ fn main() { let mut x = primes.next().unwrap(); for next in primes { // format the table - let outstr = format!("({}, {}, {}),", x, modular_inverse(x), std::u64::MAX / x); - if cols + outstr.len() > MAX_WIDTH { - write!(file, "\n {}", outstr).unwrap(); - cols = 4 + outstr.len(); + let output = format!("({}, {}, {}),", x, modular_inverse(x), std::u64::MAX / x); + if cols + output.len() > MAX_WIDTH { + write!(file, "\n {}", output).unwrap(); + cols = 4 + output.len(); } else { - write!(file, " {}", outstr).unwrap(); - cols += 1 + outstr.len(); + write!(file, " {}", output).unwrap(); + cols += 1 + output.len(); } x = next; @@ -81,7 +79,7 @@ fn main() { } #[test] -fn test_generator_isprime() { +fn test_generator_is_prime() { assert_eq!(Sieve::odd_primes.take(10_000).all(is_prime)); } @@ -106,5 +104,5 @@ const PREAMBLE: &str = r##"/* // re-run src/factor/gen_tables.rs. #[allow(clippy::unreadable_literal)] -pub const P_INVS_U64: &[(u64, u64, u64)] = &[ +pub const PRIME_INVERSIONS_U64: &[(u64, u64, u64)] = &[ "##; diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index b279de7fc..54ad0bdd4 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -17,6 +17,7 @@ type Exponent = u8; #[derive(Clone, Debug)] struct Decomposition(SmallVec<[(u64, Exponent); NUM_FACTORS_INLINE]>); +// spell-checker:ignore (names) Erdős–Kac * Erdős Kac // The number of factors to inline directly into a `Decomposition` object. // As a consequence of the Erdős–Kac theorem, the average number of prime factors // of integers < 10²⁵ ≃ 2⁸³ is 4, so we can use a slightly higher value. @@ -250,6 +251,7 @@ impl Distribution for Standard { let mut g = 1u64; let mut n = u64::MAX; + // spell-checker:ignore (names) Adam Kalai * Kalai's // Adam Kalai's algorithm for generating uniformly-distributed // integers and their factorization. // diff --git a/src/uu/factor/src/miller_rabin.rs b/src/uu/factor/src/miller_rabin.rs index 2a3b7bdf1..ec6d81c0f 100644 --- a/src/uu/factor/src/miller_rabin.rs +++ b/src/uu/factor/src/miller_rabin.rs @@ -21,6 +21,7 @@ impl Basis for Montgomery { } impl Basis for Montgomery { + // spell-checker:ignore (names) Steve Worley // Small set of bases for the Miller-Rabin prime test, valid for all 32b integers; // discovered by Steve Worley on 2013-05-27, see miller-rabin.appspot.com #[allow(clippy::unreadable_literal)] @@ -121,8 +122,8 @@ mod tests { } fn odd_primes() -> impl Iterator { - use crate::table::{NEXT_PRIME, P_INVS_U64}; - P_INVS_U64 + use crate::table::{NEXT_PRIME, PRIME_INVERSIONS_U64}; + PRIME_INVERSIONS_U64 .iter() .map(|(p, _, _)| *p) .chain(iter::once(NEXT_PRIME)) diff --git a/src/uu/factor/src/numeric/gcd.rs b/src/uu/factor/src/numeric/gcd.rs index 36ad833a6..004ef1515 100644 --- a/src/uu/factor/src/numeric/gcd.rs +++ b/src/uu/factor/src/numeric/gcd.rs @@ -93,7 +93,7 @@ mod tests { gcd(a, gcd(b, c)) == gcd(gcd(a, b), c) } - fn scalar_mult(a: u64, b: u64, k: u64) -> bool { + fn scalar_multiplication(a: u64, b: u64, k: u64) -> bool { gcd(k * a, k * b) == k * gcd(a, b) } diff --git a/src/uu/factor/src/numeric/modular_inverse.rs b/src/uu/factor/src/numeric/modular_inverse.rs index 763ee90a0..e4827a3ee 100644 --- a/src/uu/factor/src/numeric/modular_inverse.rs +++ b/src/uu/factor/src/numeric/modular_inverse.rs @@ -16,11 +16,11 @@ pub(crate) fn modular_inverse(a: T) -> T { debug_assert!(a % (one + one) == one, "{:?} is not odd", a); let mut t = zero; - let mut newt = one; + let mut new_t = one; let mut r = zero; - let mut newr = a; + let mut new_r = a; - while newr != zero { + while new_r != zero { let quot = if r == zero { // special case when we're just starting out // This works because we know that @@ -28,15 +28,15 @@ pub(crate) fn modular_inverse(a: T) -> T { T::max_value() } else { r - } / newr; + } / new_r; - let newtp = t.wrapping_sub(".wrapping_mul(&newt)); - t = newt; - newt = newtp; + let new_tp = t.wrapping_sub(".wrapping_mul(&new_t)); + t = new_t; + new_t = new_tp; - let newrp = r.wrapping_sub(".wrapping_mul(&newr)); - r = newr; - newr = newrp; + let new_rp = r.wrapping_sub(".wrapping_mul(&new_r)); + r = new_r; + new_r = new_rp; } debug_assert_eq!(r, one); diff --git a/src/uu/factor/src/numeric/montgomery.rs b/src/uu/factor/src/numeric/montgomery.rs index 8c38464bc..485025d87 100644 --- a/src/uu/factor/src/numeric/montgomery.rs +++ b/src/uu/factor/src/numeric/montgomery.rs @@ -69,7 +69,7 @@ impl Montgomery { let t_bits = T::zero().count_zeros() as usize; debug_assert!(x < (self.n.as_double_width()) << t_bits); - // TODO: optimiiiiiiise + // TODO: optimize let Montgomery { a, n } = self; let m = T::from_double_width(x).wrapping_mul(a); let nm = (n.as_double_width()) * (m.as_double_width()); @@ -138,7 +138,7 @@ impl Arithmetic for Montgomery { r + self.n.wrapping_neg() }; - // Normalise to [0; n[ + // Normalize to [0; n[ let r = if r < self.n { r } else { r - self.n }; // Check that r (reduced back to the usual representation) equals @@ -200,7 +200,7 @@ mod tests { } parametrized_check!(test_add); - fn test_mult() { + fn test_multiplication() { for n in 0..100 { let n = 2 * n + 1; let m = Montgomery::::new(n); @@ -213,7 +213,7 @@ mod tests { } } } - parametrized_check!(test_mult); + parametrized_check!(test_multiplication); fn test_roundtrip() { for n in 0..100 { diff --git a/src/uu/factor/src/table.rs b/src/uu/factor/src/table.rs index 518d4f241..6d4047e49 100644 --- a/src/uu/factor/src/table.rs +++ b/src/uu/factor/src/table.rs @@ -13,7 +13,7 @@ use crate::Factors; include!(concat!(env!("OUT_DIR"), "/prime_table.rs")); pub fn factor(num: &mut u64, factors: &mut Factors) { - for &(prime, inv, ceil) in P_INVS_U64 { + for &(prime, inv, ceil) in PRIME_INVERSIONS_U64 { if *num == 1 { break; } @@ -45,7 +45,7 @@ pub fn factor(num: &mut u64, factors: &mut Factors) { pub const CHUNK_SIZE: usize = 8; pub fn factor_chunk(n_s: &mut [u64; CHUNK_SIZE], f_s: &mut [Factors; CHUNK_SIZE]) { - for &(prime, inv, ceil) in P_INVS_U64 { + for &(prime, inv, ceil) in PRIME_INVERSIONS_U64 { if n_s[0] == 1 && n_s[1] == 1 && n_s[2] == 1 && n_s[3] == 1 { break; } From a481e8230be2bee019e62a6c11fde1dbe4d5bdc9 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:31:07 -0500 Subject: [PATCH 076/126] refactor/hashsum ~ polish spelling (comments, names, and exceptions) --- src/uu/hashsum/src/hashsum.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index b1ba3c217..b39b5788c 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -370,7 +370,7 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 { ); if !is_custom_binary(&binary_name) { - let algos = &[ + let algorithms = &[ ("md5", "work with MD5"), ("sha1", "work with SHA1"), ("sha224", "work with SHA224"), @@ -393,7 +393,7 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 { ("b2sum", "work with BLAKE2"), ]; - for (name, desc) in algos { + for (name, desc) in algorithms { app = app.arg(Arg::with_name(name).long(name).help(desc)); } } From 785343db7f042525aff9666fabe40bdfe212203f Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:31:55 -0500 Subject: [PATCH 077/126] refactor/head ~ polish spelling (comments, names, and exceptions) --- src/uu/head/src/head.rs | 60 +++++++++++++++++++++------------------- src/uu/head/src/lines.rs | 2 ++ src/uu/head/src/parse.rs | 6 ++-- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 3602b4a73..ff5ef2355 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (vars) zlines + use clap::{App, Arg}; use std::convert::TryFrom; use std::ffi::OsString; @@ -210,7 +212,7 @@ impl Default for HeadOptions { } } -fn rbuf_n_bytes(input: R, n: usize) -> std::io::Result<()> +fn read_n_bytes(input: R, n: usize) -> std::io::Result<()> where R: Read, { @@ -226,7 +228,7 @@ where Ok(()) } -fn rbuf_n_lines(input: &mut impl std::io::BufRead, n: usize, zero: bool) -> std::io::Result<()> { +fn read_n_lines(input: &mut impl std::io::BufRead, n: usize, zero: bool) -> std::io::Result<()> { if n == 0 { return Ok(()); } @@ -249,18 +251,18 @@ fn rbuf_n_lines(input: &mut impl std::io::BufRead, n: usize, zero: bool) -> std: }) } -fn rbuf_but_last_n_bytes(input: &mut impl std::io::BufRead, n: usize) -> std::io::Result<()> { +fn read_but_last_n_bytes(input: &mut impl std::io::BufRead, n: usize) -> std::io::Result<()> { if n == 0 { //prints everything - return rbuf_n_bytes(input, std::usize::MAX); + return read_n_bytes(input, std::usize::MAX); } let stdout = std::io::stdout(); let mut stdout = stdout.lock(); - let mut ringbuf = vec![0u8; n]; + let mut ring_buffer = vec![0u8; n]; // first we fill the ring buffer - if let Err(e) = input.read_exact(&mut ringbuf) { + if let Err(e) = input.read_exact(&mut ring_buffer) { if e.kind() == ErrorKind::UnexpectedEof { return Ok(()); } else { @@ -281,22 +283,22 @@ fn rbuf_but_last_n_bytes(input: &mut impl std::io::BufRead, n: usize) -> std::io if read == 0 { return Ok(()); } else if read >= n { - stdout.write_all(&ringbuf)?; + stdout.write_all(&ring_buffer)?; stdout.write_all(&buffer[..read - n])?; for i in 0..n { - ringbuf[i] = buffer[read - n + i]; + ring_buffer[i] = buffer[read - n + i]; } } else { - stdout.write_all(&ringbuf[..read])?; + stdout.write_all(&ring_buffer[..read])?; for i in 0..n - read { - ringbuf[i] = ringbuf[read + i]; + ring_buffer[i] = ring_buffer[read + i]; } - ringbuf[n - read..].copy_from_slice(&buffer[..read]); + ring_buffer[n - read..].copy_from_slice(&buffer[..read]); } } } -fn rbuf_but_last_n_lines( +fn read_but_last_n_lines( input: impl std::io::BufRead, n: usize, zero: bool, @@ -325,7 +327,7 @@ fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std: return Ok(()); } else { input.seek(SeekFrom::Start(0))?; - rbuf_n_bytes( + read_n_bytes( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), size - n, )?; @@ -364,7 +366,7 @@ fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std: } }; input.seek(SeekFrom::Start(0))?; - rbuf_n_bytes( + read_n_bytes( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), size - found, )?; @@ -379,9 +381,9 @@ fn head_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Resul } else { match options.mode { Modes::Bytes(n) => { - rbuf_n_bytes(&mut std::io::BufReader::with_capacity(BUF_SIZE, input), n) + read_n_bytes(&mut std::io::BufReader::with_capacity(BUF_SIZE, input), n) } - Modes::Lines(n) => rbuf_n_lines( + Modes::Lines(n) => read_n_lines( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), n, options.zeroed, @@ -393,8 +395,8 @@ fn head_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Resul fn uu_head(options: &HeadOptions) -> Result<(), u32> { let mut error_count = 0; let mut first = true; - for fname in &options.files { - let res = match fname.as_str() { + for file in &options.files { + let res = match file.as_str() { "-" => { if (options.files.len() > 1 && !options.quiet) || options.verbose { if !first { @@ -407,16 +409,16 @@ fn uu_head(options: &HeadOptions) -> Result<(), u32> { match options.mode { Modes::Bytes(n) => { if options.all_but_last { - rbuf_but_last_n_bytes(&mut stdin, n) + read_but_last_n_bytes(&mut stdin, n) } else { - rbuf_n_bytes(&mut stdin, n) + read_n_bytes(&mut stdin, n) } } Modes::Lines(n) => { if options.all_but_last { - rbuf_but_last_n_lines(&mut stdin, n, options.zeroed) + read_but_last_n_lines(&mut stdin, n, options.zeroed) } else { - rbuf_n_lines(&mut stdin, n, options.zeroed) + read_n_lines(&mut stdin, n, options.zeroed) } } } @@ -451,10 +453,10 @@ fn uu_head(options: &HeadOptions) -> Result<(), u32> { } }; if res.is_err() { - let name = if fname.as_str() == "-" { + let name = if file.as_str() == "-" { "standard input" } else { - fname + file }; let prefix = format!("error reading {}", name); show_error_custom_description!(prefix, "Input/output error"); @@ -502,7 +504,7 @@ mod tests { } #[test] fn test_gnu_compatibility() { - let args = options("-n 1 -c 1 -n 5 -c kiB -vqvqv").unwrap(); + let args = options("-n 1 -c 1 -n 5 -c kiB -vqvqv").unwrap(); // spell-checker:disable-line assert!(args.mode == Modes::Bytes(1024)); assert!(args.verbose); assert_eq!(options("-5").unwrap().mode, Modes::Lines(5)); @@ -584,7 +586,7 @@ mod tests { ); //test that the obsolete syntax is unrolled assert_eq!( - arg_outputs("head -123qvqvqzc"), + arg_outputs("head -123qvqvqzc"), // spell-checker:disable-line Ok("head -q -z -c 123".to_owned()) ); //test that bad obsoletes are an error @@ -604,9 +606,9 @@ mod tests { ); } #[test] - fn rbuf_early_exit() { + fn read_early_exit() { let mut empty = std::io::BufReader::new(std::io::Cursor::new(Vec::new())); - assert!(rbuf_n_bytes(&mut empty, 0).is_ok()); - assert!(rbuf_n_lines(&mut empty, 0, false).is_ok()); + assert!(read_n_bytes(&mut empty, 0).is_ok()); + assert!(read_n_lines(&mut empty, 0, false).is_ok()); } } diff --git a/src/uu/head/src/lines.rs b/src/uu/head/src/lines.rs index dcae27bc8..118aba17f 100644 --- a/src/uu/head/src/lines.rs +++ b/src/uu/head/src/lines.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (vars) zline zlines + //! Iterate over zero-terminated lines. use std::io::BufRead; diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 0cf20be42..f1c97561d 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -7,7 +7,7 @@ pub enum ParseError { Overflow, } /// Parses obsolete syntax -/// head -NUM[kmzv] +/// head -NUM[kmzv] // spell-checker:disable-line pub fn parse_obsolete(src: &str) -> Option, ParseError>> { let mut chars = src.char_indices(); if let Some((_, '-')) = chars.next() { @@ -242,7 +242,7 @@ mod tests { assert_eq!(obsolete("-1mmk"), obsolete_result(&["-c", "1024"])); assert_eq!(obsolete("-1vz"), obsolete_result(&["-v", "-z", "-n", "1"])); assert_eq!( - obsolete("-1vzqvq"), + obsolete("-1vzqvq"), // spell-checker:disable-line obsolete_result(&["-q", "-z", "-n", "1"]) ); assert_eq!(obsolete("-1vzc"), obsolete_result(&["-v", "-z", "-c", "1"])); @@ -257,7 +257,7 @@ mod tests { assert_eq!(obsolete("-5c5"), Some(Err(ParseError::Syntax))); } #[test] - fn test_parse_obsolete_nomatch() { + fn test_parse_obsolete_no_match() { assert_eq!(obsolete("-k"), None); assert_eq!(obsolete("asd"), None); } From 96faa4efb6ba845099ffc802709553152d598e57 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:32:20 -0500 Subject: [PATCH 078/126] refactor/ln ~ polish spelling (comments, names, and exceptions) --- src/uu/ln/src/ln.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 04358a415..2a14f3c9c 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -371,21 +371,21 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings) } fn relative_path<'a>(src: &Path, dst: &Path) -> Result> { - let abssrc = canonicalize(src, CanonicalizeMode::Normal)?; - let absdst = canonicalize(dst, CanonicalizeMode::Normal)?; - let suffix_pos = abssrc + let src_abs = canonicalize(src, CanonicalizeMode::Normal)?; + let dst_abs = canonicalize(dst, CanonicalizeMode::Normal)?; + let suffix_pos = src_abs .components() - .zip(absdst.components()) + .zip(dst_abs.components()) .take_while(|(s, d)| s == d) .count(); - let srciter = abssrc.components().skip(suffix_pos).map(|x| x.as_os_str()); + let src_iter = src_abs.components().skip(suffix_pos).map(|x| x.as_os_str()); - let result: PathBuf = absdst + let result: PathBuf = dst_abs .components() .skip(suffix_pos + 1) .map(|_| OsStr::new("..")) - .chain(srciter) + .chain(src_iter) .collect(); Ok(result.into()) } From 5942ba05ef3a12c522d4610a106763cf78452b99 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:32:40 -0500 Subject: [PATCH 079/126] refactor/ls ~ polish spelling (comments, names, and exceptions) --- src/uu/ls/src/ls.rs | 19 ++++++++++--------- src/uu/ls/src/quoting_style.rs | 2 ++ src/uu/ls/src/version_cmp.rs | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 5846cb0aa..3e8e908dd 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -60,7 +60,7 @@ fn get_usage() -> String { pub mod options { pub mod format { - pub static ONELINE: &str = "1"; + pub static ONE_LINE: &str = "1"; pub static LONG: &str = "long"; pub static COLUMNS: &str = "C"; pub static ACROSS: &str = "x"; @@ -248,7 +248,7 @@ impl Config { // -og should hide both owner and group. Furthermore, they are not // reset if -l or --format=long is used. So these should just show the // group: -gl or "-g --format=long". Finally, they are also not reset - // when switching to a different format option inbetween like this: + // when switching to a different format option in-between like this: // -ogCl or "-og --format=vertical --format=long". // // -1 has a similar issue: it does nothing if the format is long. This @@ -275,7 +275,7 @@ impl Config { .any(|i| i >= idx) { format = Format::Long; - } else if let Some(mut indices) = options.indices_of(options::format::ONELINE) { + } else if let Some(mut indices) = options.indices_of(options::format::ONE_LINE) { if indices.any(|i| i > idx) { format = Format::OneLine; } @@ -636,8 +636,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { // ls -1g1 // even though `ls -11` and `ls -1 -g -1` work. .arg( - Arg::with_name(options::format::ONELINE) - .short(options::format::ONELINE) + Arg::with_name(options::format::ONE_LINE) + .short(options::format::ONE_LINE) .help("List one file per line.") .multiple(true) ) @@ -1130,7 +1130,7 @@ impl PathData { let display_name = if let Some(name) = file_name { name } else { - let display_osstr = if command_line { + let display_os_str = if command_line { p_buf.as_os_str() } else { p_buf @@ -1138,7 +1138,7 @@ impl PathData { .unwrap_or_else(|| p_buf.iter().next_back().unwrap()) }; - display_osstr.to_string_lossy().into_owned() + display_os_str.to_string_lossy().into_owned() }; let must_dereference = match &config.dereference { Dereference::All => true, @@ -1624,6 +1624,7 @@ fn display_date(metadata: &Metadata, config: &Config) -> String { TimeStyle::Locale => { let fmt = if recent { "%b %e %H:%M" } else { "%b %e %Y" }; + // spell-checker:ignore (word) datetime //In this version of chrono translating can be done //The function is chrono::datetime::DateTime::format_localized //However it's currently still hard to get the current pure-rust-locale @@ -1678,7 +1679,7 @@ fn display_size_or_rdev(metadata: &Metadata, config: &Config) -> String { } fn display_size(size: u64, config: &Config) -> String { - // NOTE: The human-readable behaviour deviates from the GNU ls. + // NOTE: The human-readable behavior deviates from the GNU ls. // The GNU ls uses binary prefixes by default. match config.size_format { SizeFormat::Binary => format_prefixed(NumberPrefix::binary(size as f64)), @@ -1692,7 +1693,7 @@ fn file_is_executable(md: &Metadata) -> bool { // Mode always returns u32, but the flags might not be, based on the platform // e.g. linux has u32, mac has u16. // S_IXUSR -> user has execute permission - // S_IXGRP -> group has execute persmission + // S_IXGRP -> group has execute permission // S_IXOTH -> other users have execute permission md.mode() & ((S_IXUSR | S_IXGRP | S_IXOTH) as u32) != 0 } diff --git a/src/uu/ls/src/quoting_style.rs b/src/uu/ls/src/quoting_style.rs index 01bffa7ec..f9ba55f7b 100644 --- a/src/uu/ls/src/quoting_style.rs +++ b/src/uu/ls/src/quoting_style.rs @@ -304,6 +304,8 @@ pub(super) fn escape_name(name: &str, style: &QuotingStyle) -> String { #[cfg(test)] mod tests { + // spell-checker:ignore (tests/words) one\'two one'two + use crate::quoting_style::{escape_name, Quotes, QuotingStyle}; fn get_style(s: &str) -> QuotingStyle { match s { diff --git a/src/uu/ls/src/version_cmp.rs b/src/uu/ls/src/version_cmp.rs index 4cd39f916..e3f7e29e3 100644 --- a/src/uu/ls/src/version_cmp.rs +++ b/src/uu/ls/src/version_cmp.rs @@ -83,7 +83,7 @@ pub(crate) fn version_cmp(a: &Path, b: &Path) -> Ordering { Ordering::Equal => {} x => return x, }, - // Otherise, we compare the options (because None < Some(_)) + // Otherwise, we compare the options (because None < Some(_)) (a_opt, b_opt) => match a_opt.cmp(&b_opt) { // If they are completely equal except for leading zeroes, we use the leading zeroes. Ordering::Equal => return leading_zeroes, @@ -203,6 +203,7 @@ mod tests { ); assert_eq!( + // spell-checker:disable-next-line version_cmp(&PathBuf::from("file1000"), &PathBuf::from("fileapple")), Ordering::Less, "Numbers in the middle of the name are sorted before other characters" From e3784eff471905a7492edc1ceaef0d087a1ccb21 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:42:15 -0500 Subject: [PATCH 080/126] refactor/mknod ~ polish spelling (comments, names, and exceptions) --- src/uu/mknod/src/mknod.rs | 10 +++++----- src/uu/mknod/src/parsemode.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index e0cf62024..57bdd3052 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -50,12 +50,12 @@ fn makedev(maj: u64, min: u64) -> dev_t { } #[cfg(windows)] -fn _makenod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { +fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { panic!("Unsupported for windows platform") } #[cfg(unix)] -fn _makenod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { +fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { let c_str = CString::new(file_name).expect("Failed to convert to CString"); // the user supplied a mode @@ -158,7 +158,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { eprintln!("Try '{} --help' for more information.", NAME); 1 } else { - _makenod(file_name, S_IFIFO | mode, 0) + _mknod(file_name, S_IFIFO | mode, 0) } } else { match (matches.value_of("major"), matches.value_of("minor")) { @@ -174,10 +174,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let dev = makedev(major, minor); if ch == 'b' { // block special file - _makenod(file_name, S_IFBLK | mode, dev) + _mknod(file_name, S_IFBLK | mode, dev) } else if ch == 'c' || ch == 'u' { // char special file - _makenod(file_name, S_IFCHR | mode, dev) + _mknod(file_name, S_IFCHR | mode, dev) } else { unreachable!("{} was validated to be only b, c or u", ch); } diff --git a/src/uu/mknod/src/parsemode.rs b/src/uu/mknod/src/parsemode.rs index 026fc4a56..2767cb303 100644 --- a/src/uu/mknod/src/parsemode.rs +++ b/src/uu/mknod/src/parsemode.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) fperm +// spell-checker:ignore (path) osrelease use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; From 57e342d2b222e1261dee4c1090b4294eb85625cd Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:33:06 -0500 Subject: [PATCH 081/126] refactor/mktemp ~ polish spelling (comments, names, and exceptions) --- src/uu/mktemp/src/mktemp.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index f6c244bf2..f7c87495c 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -6,7 +6,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) tempfile tempdir SUFF TMPDIR tmpname +// spell-checker:ignore (paths) GPGHome #[macro_use] extern crate uucore; @@ -67,10 +67,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Arg::with_name(OPT_SUFFIX) .long(OPT_SUFFIX) .help( - "append SUFF to TEMPLATE; SUFF must not contain a path separator. \ + "append SUFFIX to TEMPLATE; SUFFIX must not contain a path separator. \ This option is implied if TEMPLATE does not end with X.", ) - .value_name("SUFF"), + .value_name("SUFFIX"), ) .arg( Arg::with_name(OPT_TMPDIR) From 00c02505a1ddf95175332ecc0cdee5adac68c327 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Mon, 31 May 2021 08:11:06 -0500 Subject: [PATCH 082/126] refactor/more ~ polish spelling (comments, names, and exceptions) --- src/uu/more/src/more.rs | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index c4a13aa1b..482c5491d 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -5,7 +5,7 @@ // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. -// spell-checker:ignore (ToDO) lflag ICANON tcgetattr tcsetattr TCSADRAIN +// spell-checker:ignore (methods) isnt #[macro_use] extern crate uucore; @@ -100,7 +100,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .long(options::LINES) .value_name("number") .takes_value(true) - .help("The number of lines per screenful"), + .help("The number of lines per screen full"), ) .arg( Arg::with_name(options::NUMBER) @@ -135,30 +135,27 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .help("Path to the files to be read"), ) .get_matches_from(args); - + let mut buff = String::new(); - if let Some(filenames) = matches.values_of(options::FILES) { + if let Some(files) = matches.values_of(options::FILES) { let mut stdout = setup_term(); - let length = filenames.len(); - for (idx, fname) in filenames.enumerate() { - let fname = Path::new(fname); - if fname.is_dir() { + let length = files.len(); + for (idx, file) in files.enumerate() { + let file = Path::new(file); + if file.is_dir() { terminal::disable_raw_mode().unwrap(); - show_usage_error!("'{}' is a directory.", fname.display()); + show_usage_error!("'{}' is a directory.", file.display()); return 1; } - if !fname.exists() { + if !file.exists() { terminal::disable_raw_mode().unwrap(); - show_error!( - "cannot open {}: No such file or directory", - fname.display() - ); + show_error!("cannot open {}: No such file or directory", file.display()); return 1; } if length > 1 { - buff.push_str(&MULTI_FILE_TOP_PROMPT.replace("{}", fname.to_str().unwrap())); + buff.push_str(&MULTI_FILE_TOP_PROMPT.replace("{}", file.to_str().unwrap())); } - let mut reader = BufReader::new(File::open(fname).unwrap()); + let mut reader = BufReader::new(File::open(file).unwrap()); reader.read_to_string(&mut buff).unwrap(); let is_last = idx + 1 == length; more(&buff, &mut stdout, is_last); @@ -220,7 +217,7 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) { ); // Specifies whether we have reached the end of the file and should - // return on the next keypress. However, we immediately return when + // return on the next key press. However, we immediately return when // this is the last file. let mut to_be_done = false; if lines_left == 0 && is_last { @@ -230,7 +227,7 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) { to_be_done = true; } } - + loop { if event::poll(Duration::from_millis(10)).unwrap() { match event::read().unwrap() { @@ -254,7 +251,6 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) { modifiers: KeyModifiers::NONE, }) => { upper_mark = upper_mark.saturating_add(rows.saturating_sub(1)); - } Event::Key(KeyEvent { code: KeyCode::Up, @@ -275,7 +271,7 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) { if lines_left == 0 { if to_be_done || is_last { - return + return; } to_be_done = true; } From 5079972ba674ede5517cab8cc88c17ccb18152a6 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:41:53 -0500 Subject: [PATCH 083/126] refactor/nl ~ polish spelling (comments, names, and exceptions) --- src/uu/nl/src/helper.rs | 4 ++-- src/uu/nl/src/nl.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/uu/nl/src/helper.rs b/src/uu/nl/src/helper.rs index e31477c62..562cdeb93 100644 --- a/src/uu/nl/src/helper.rs +++ b/src/uu/nl/src/helper.rs @@ -29,7 +29,7 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) -> // This vector holds error messages encountered. let mut errs: Vec = vec![]; settings.renumber = !opts.is_present(options::NO_RENUMBER); - match opts.value_of(options::NUMER_SEPARATOR) { + match opts.value_of(options::NUMBER_SEPARATOR) { None => {} Some(val) => { settings.number_separator = val.to_owned(); @@ -118,7 +118,7 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) -> } } } - match opts.value_of(options::STARTING_LINE_NUMER) { + match opts.value_of(options::STARTING_LINE_NUMBER) { None => {} Some(val) => { let conv: Option = val.parse().ok(); diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 7c5f01811..69adbed41 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -79,8 +79,8 @@ pub mod options { pub const JOIN_BLANK_LINES: &str = "join-blank-lines"; pub const NUMBER_FORMAT: &str = "number-format"; pub const NO_RENUMBER: &str = "no-renumber"; - pub const NUMER_SEPARATOR: &str = "number-separator"; - pub const STARTING_LINE_NUMER: &str = "starting-line-number"; + pub const NUMBER_SEPARATOR: &str = "number-separator"; + pub const STARTING_LINE_NUMBER: &str = "starting-line-number"; pub const NUMBER_WIDTH: &str = "number-width"; } @@ -150,16 +150,16 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .help("do not reset line numbers at logical pages"), ) .arg( - Arg::with_name(options::NUMER_SEPARATOR) + Arg::with_name(options::NUMBER_SEPARATOR) .short("s") - .long(options::NUMER_SEPARATOR) + .long(options::NUMBER_SEPARATOR) .help("add STRING after (possible) line number") .value_name("STRING"), ) .arg( - Arg::with_name(options::STARTING_LINE_NUMER) + Arg::with_name(options::STARTING_LINE_NUMBER) .short("v") - .long(options::STARTING_LINE_NUMER) + .long(options::STARTING_LINE_NUMBER) .help("first line number on each logical page") .value_name("NUMBER"), ) From aa385cf23cb30cdd1a0ac943b30d1beede94260a Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:33:37 -0500 Subject: [PATCH 084/126] refactor/od ~ polish spelling (comments, names, and exceptions) --- src/uu/od/src/od.rs | 3 +- src/uu/od/src/prn_char.rs | 20 +++++------ src/uu/od/src/prn_int.rs | 76 +++++++++++++++++++-------------------- 3 files changed, 48 insertions(+), 51 deletions(-) diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index 571ca543d..7359047b2 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -5,6 +5,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. +// spell-checker:ignore (clap) DontDelimitTrailingValues // spell-checker:ignore (ToDO) formatteriteminfo inputdecoder inputoffset mockstream nrofbytes partialreader odfunc multifile exitcode #[macro_use] @@ -455,7 +456,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ]); let clap_matches = clap_opts - .clone() // Clone to reuse clap_otps to print help + .clone() // Clone to reuse clap_opts to print help .get_matches_from(args.clone()); if clap_matches.is_present(options::VERSION) { diff --git a/src/uu/od/src/prn_char.rs b/src/uu/od/src/prn_char.rs index cbbb370ce..742229dd7 100644 --- a/src/uu/od/src/prn_char.rs +++ b/src/uu/od/src/prn_char.rs @@ -1,5 +1,3 @@ -// spell-checker:ignore (ToDO) CHRS itembytes MUTF - use std::str::from_utf8; use crate::formatteriteminfo::*; @@ -16,7 +14,7 @@ pub static FORMAT_ITEM_C: FormatterItemInfo = FormatterItemInfo { formatter: FormatWriter::MultibyteWriter(format_item_c), }; -static A_CHRS: [&str; 128] = [ +static A_CHARS: [&str; 128] = [ "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "ht", "nl", "vt", "ff", "cr", "so", "si", "dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb", "can", "em", "sub", "esc", "fs", "gs", "rs", "us", "sp", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", @@ -28,12 +26,12 @@ static A_CHRS: [&str; 128] = [ ]; fn format_item_a(p: u64) -> String { - // itembytes == 1 + // item-bytes == 1 let b = (p & 0x7f) as u8; - format!("{:>4}", A_CHRS.get(b as usize).unwrap_or(&"??")) + format!("{:>4}", A_CHARS.get(b as usize).unwrap_or(&"??")) } -static C_CHRS: [&str; 128] = [ +static C_CHARS: [&str; 128] = [ "\\0", "001", "002", "003", "004", "005", "006", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "016", "017", "020", "021", "022", "023", "024", "025", "026", "027", "030", "031", "032", "033", "034", "035", "036", "037", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", @@ -45,11 +43,11 @@ static C_CHRS: [&str; 128] = [ ]; fn format_item_c(bytes: &[u8]) -> String { - // itembytes == 1 + // item-bytes == 1 let b = bytes[0]; if b & 0x80 == 0x00 { - match C_CHRS.get(b as usize) { + match C_CHARS.get(b as usize) { Some(s) => format!("{:>4}", s), None => format!("{:>4}", b), } @@ -86,7 +84,7 @@ pub fn format_ascii_dump(bytes: &[u8]) -> String { result.push('>'); for c in bytes.iter() { if *c >= 0x20 && *c <= 0x7e { - result.push_str(C_CHRS[*c as usize]); + result.push_str(C_CHARS[*c as usize]); } else { result.push('.'); } @@ -136,12 +134,12 @@ fn test_format_item_c() { format_item_c(&[0xf0, 0x9f, 0x92, 0x96, 0x21]) ); - assert_eq!(" 300", format_item_c(&[0xc0, 0x80])); // invalid utf-8 (MUTF-8 null) + assert_eq!(" 300", format_item_c(&[0xc0, 0x80])); // invalid utf-8 (UTF-8 null) assert_eq!(" 301", format_item_c(&[0xc1, 0xa1])); // invalid utf-8 assert_eq!(" 303", format_item_c(&[0xc3, 0xc3])); // invalid utf-8 assert_eq!(" 360", format_item_c(&[0xf0, 0x82, 0x82, 0xac])); // invalid utf-8 (overlong) assert_eq!(" 360", format_item_c(&[0xf0, 0x9f, 0x92])); // invalid utf-8 (missing octet) - assert_eq!(" \u{10FFFD}", format_item_c(&[0xf4, 0x8f, 0xbf, 0xbd])); // largest valid utf-8 + assert_eq!(" \u{10FFFD}", format_item_c(&[0xf4, 0x8f, 0xbf, 0xbd])); // largest valid utf-8 // spell-checker:ignore 10FFFD FFFD assert_eq!(" 364", format_item_c(&[0xf4, 0x90, 0x00, 0x00])); // invalid utf-8 assert_eq!(" 365", format_item_c(&[0xf5, 0x80, 0x80, 0x80])); // invalid utf-8 assert_eq!(" 377", format_item_c(&[0xff])); // invalid utf-8 diff --git a/src/uu/od/src/prn_int.rs b/src/uu/od/src/prn_int.rs index b8397b01b..5e31da9dd 100644 --- a/src/uu/od/src/prn_int.rs +++ b/src/uu/od/src/prn_int.rs @@ -1,5 +1,3 @@ -// spell-checker:ignore (ToDO) itembytes - use crate::formatteriteminfo::*; /// format string to print octal using `int_writer_unsigned` @@ -60,9 +58,9 @@ macro_rules! int_writer_signed { }; } -/// Extends a signed number in `item` of `itembytes` bytes into a (signed) i64 -fn sign_extend(item: u64, itembytes: usize) -> i64 { - let shift = 64 - itembytes * 8; +/// Extends a signed number in `item` of `item_bytes` bytes into a (signed) i64 +fn sign_extend(item: u64, item_bytes: usize) -> i64 { + let shift = 64 - item_bytes * 8; (item << shift) as i64 >> shift } @@ -89,46 +87,46 @@ int_writer_signed!(FORMAT_ITEM_DEC64S, 8, 21, format_item_dec_s64, DEC!()); // m #[test] fn test_sign_extend() { assert_eq!( - 0xffffffffffffff80u64 as i64, - sign_extend(0x0000000000000080, 1) + 0xffff_ffff_ffff_ff80u64 as i64, + sign_extend(0x0000_0000_0000_0080, 1) ); assert_eq!( - 0xffffffffffff8000u64 as i64, - sign_extend(0x0000000000008000, 2) + 0xffff_ffff_ffff_8000u64 as i64, + sign_extend(0x0000_0000_0000_8000, 2) ); assert_eq!( - 0xffffffffff800000u64 as i64, - sign_extend(0x0000000000800000, 3) + 0xffff_ffff_ff80_0000u64 as i64, + sign_extend(0x0000_0000_0080_0000, 3) ); assert_eq!( - 0xffffffff80000000u64 as i64, - sign_extend(0x0000000080000000, 4) + 0xffff_ffff_8000_0000u64 as i64, + sign_extend(0x0000_0000_8000_0000, 4) ); assert_eq!( - 0xffffff8000000000u64 as i64, - sign_extend(0x0000008000000000, 5) + 0xffff_ff80_0000_0000u64 as i64, + sign_extend(0x0000_0080_0000_0000, 5) ); assert_eq!( - 0xffff800000000000u64 as i64, - sign_extend(0x0000800000000000, 6) + 0xffff_8000_0000_0000u64 as i64, + sign_extend(0x0000_8000_0000_0000, 6) ); assert_eq!( - 0xff80000000000000u64 as i64, - sign_extend(0x0080000000000000, 7) + 0xff80_0000_0000_0000u64 as i64, + sign_extend(0x0080_0000_0000_0000, 7) ); assert_eq!( - 0x8000000000000000u64 as i64, - sign_extend(0x8000000000000000, 8) + 0x8000_0000_0000_0000u64 as i64, + sign_extend(0x8000_0000_0000_0000, 8) ); - assert_eq!(0x000000000000007f, sign_extend(0x000000000000007f, 1)); - assert_eq!(0x0000000000007fff, sign_extend(0x0000000000007fff, 2)); - assert_eq!(0x00000000007fffff, sign_extend(0x00000000007fffff, 3)); - assert_eq!(0x000000007fffffff, sign_extend(0x000000007fffffff, 4)); - assert_eq!(0x0000007fffffffff, sign_extend(0x0000007fffffffff, 5)); - assert_eq!(0x00007fffffffffff, sign_extend(0x00007fffffffffff, 6)); - assert_eq!(0x007fffffffffffff, sign_extend(0x007fffffffffffff, 7)); - assert_eq!(0x7fffffffffffffff, sign_extend(0x7fffffffffffffff, 8)); + assert_eq!(0x0000_0000_0000_007f, sign_extend(0x0000_0000_0000_007f, 1)); + assert_eq!(0x0000_0000_0000_7fff, sign_extend(0x0000_0000_0000_7fff, 2)); + assert_eq!(0x0000_0000_007f_ffff, sign_extend(0x0000_0000_007f_ffff, 3)); + assert_eq!(0x0000_0000_7fff_ffff, sign_extend(0x0000_0000_7fff_ffff, 4)); + assert_eq!(0x0000_007f_ffff_ffff, sign_extend(0x0000_007f_ffff_ffff, 5)); + assert_eq!(0x0000_7fff_ffff_ffff, sign_extend(0x0000_7fff_ffff_ffff, 6)); + assert_eq!(0x007f_ffff_ffff_ffff, sign_extend(0x007f_ffff_ffff_ffff, 7)); + assert_eq!(0x7fff_ffff_ffff_ffff, sign_extend(0x7fff_ffff_ffff_ffff, 8)); } #[test] @@ -138,11 +136,11 @@ fn test_format_item_oct() { assert_eq!(" 000000", format_item_oct16(0)); assert_eq!(" 177777", format_item_oct16(0xffff)); assert_eq!(" 00000000000", format_item_oct32(0)); - assert_eq!(" 37777777777", format_item_oct32(0xffffffff)); + assert_eq!(" 37777777777", format_item_oct32(0xffff_ffff)); assert_eq!(" 0000000000000000000000", format_item_oct64(0)); assert_eq!( " 1777777777777777777777", - format_item_oct64(0xffffffffffffffff) + format_item_oct64(0xffff_ffff_ffff_ffff) ); } @@ -153,9 +151,9 @@ fn test_format_item_hex() { assert_eq!(" 0000", format_item_hex16(0)); assert_eq!(" ffff", format_item_hex16(0xffff)); assert_eq!(" 00000000", format_item_hex32(0)); - assert_eq!(" ffffffff", format_item_hex32(0xffffffff)); + assert_eq!(" ffffffff", format_item_hex32(0xffff_ffff)); assert_eq!(" 0000000000000000", format_item_hex64(0)); - assert_eq!(" ffffffffffffffff", format_item_hex64(0xffffffffffffffff)); + assert_eq!(" ffffffffffffffff", format_item_hex64(0xffff_ffff_ffff_ffff)); } #[test] @@ -165,11 +163,11 @@ fn test_format_item_dec_u() { assert_eq!(" 0", format_item_dec_u16(0)); assert_eq!(" 65535", format_item_dec_u16(0xffff)); assert_eq!(" 0", format_item_dec_u32(0)); - assert_eq!(" 4294967295", format_item_dec_u32(0xffffffff)); + assert_eq!(" 4294967295", format_item_dec_u32(0xffff_ffff)); assert_eq!(" 0", format_item_dec_u64(0)); assert_eq!( " 18446744073709551615", - format_item_dec_u64(0xffffffffffffffff) + format_item_dec_u64(0xffff_ffff_ffff_ffff) ); } @@ -182,15 +180,15 @@ fn test_format_item_dec_s() { assert_eq!(" 32767", format_item_dec_s16(0x7fff)); assert_eq!(" -32768", format_item_dec_s16(0x8000)); assert_eq!(" 0", format_item_dec_s32(0)); - assert_eq!(" 2147483647", format_item_dec_s32(0x7fffffff)); - assert_eq!(" -2147483648", format_item_dec_s32(0x80000000)); + assert_eq!(" 2147483647", format_item_dec_s32(0x7fff_ffff)); + assert_eq!(" -2147483648", format_item_dec_s32(0x8000_0000)); assert_eq!(" 0", format_item_dec_s64(0)); assert_eq!( " 9223372036854775807", - format_item_dec_s64(0x7fffffffffffffff) + format_item_dec_s64(0x7fff_ffff_ffff_ffff) ); assert_eq!( " -9223372036854775808", - format_item_dec_s64(0x8000000000000000) + format_item_dec_s64(0x8000_0000_0000_0000) ); } From 324605c78c08c83d03e7b04e7734441d93ae453b Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:34:39 -0500 Subject: [PATCH 085/126] refactor/printf ~ polish spelling (comments, names, and exceptions) --- .../src/tokenize/num_format/format_field.rs | 2 +- .../src/tokenize/num_format/formatter.rs | 5 +- .../num_format/formatters/base_conv/mod.rs | 2 +- .../num_format/formatters/base_conv/tests.rs | 4 +- .../formatters/cninetyninehexfloatf.rs | 29 ++++---- .../tokenize/num_format/formatters/decf.rs | 30 ++++----- .../num_format/formatters/float_common.rs | 29 ++++---- .../tokenize/num_format/formatters/floatf.rs | 13 ++-- .../tokenize/num_format/formatters/intf.rs | 67 ++++++++++--------- .../src/tokenize/num_format/formatters/mod.rs | 2 +- .../tokenize/num_format/formatters/scif.rs | 12 ++-- .../src/tokenize/num_format/num_format.rs | 52 +++++++------- src/uu/printf/src/tokenize/sub.rs | 8 +-- 13 files changed, 130 insertions(+), 125 deletions(-) diff --git a/src/uu/printf/src/tokenize/num_format/format_field.rs b/src/uu/printf/src/tokenize/num_format/format_field.rs index 68786e815..02998cde5 100644 --- a/src/uu/printf/src/tokenize/num_format/format_field.rs +++ b/src/uu/printf/src/tokenize/num_format/format_field.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix hexifying glibc floatnum rten rhex arrnum fprim interp +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety //! Primitives used by Sub Tokenizer //! and num_format modules diff --git a/src/uu/printf/src/tokenize/num_format/formatter.rs b/src/uu/printf/src/tokenize/num_format/formatter.rs index 35faff2a9..9fd5954ed 100644 --- a/src/uu/printf/src/tokenize/num_format/formatter.rs +++ b/src/uu/printf/src/tokenize/num_format/formatter.rs @@ -1,4 +1,3 @@ -// spell-checker:ignore (ToDO) inprefix for conv //! Primitives used by num_format and sub_modules. //! never dealt with above (e.g. Sub Tokenizer never uses these) @@ -41,7 +40,7 @@ pub enum Base { // information from the beginning of a numeric argument // the precedes the beginning of a numeric value -pub struct InPrefix { +pub struct InitialPrefix { pub radix_in: Base, pub sign: i8, pub offset: usize, @@ -54,7 +53,7 @@ pub trait Formatter { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + in_prefix: &InitialPrefix, str_in: &str, ) -> Option; // return a string from a FormatPrimitive, diff --git a/src/uu/printf/src/tokenize/num_format/formatters/base_conv/mod.rs b/src/uu/printf/src/tokenize/num_format/formatters/base_conv/mod.rs index 7d1d805c6..a20f03a95 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/base_conv/mod.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/base_conv/mod.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) arrnum mult basenum bufferval refd vals arrfloat conv intermed addl +// spell-checker:ignore (ToDO) arrnum arr_num mult basenum bufferval refd vals arrfloat conv intermed addl pub fn arrnum_int_mult(arr_num: &[u8], basenum: u8, base_ten_int_fact: u8) -> Vec { let mut carry: u16 = 0; diff --git a/src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs b/src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs index fcac4392e..7945d41ac 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) conv arrnum mult shortcircuit +// spell-checker:ignore (ToDO) arrnum mult #[cfg(test)] use super::*; @@ -29,7 +29,7 @@ fn test_arrnum_int_non_base_10() { } #[test] -fn test_arrnum_int_div_shortcircuit() { +fn test_arrnum_int_div_short_circuit() { // ( let arrnum: Vec = vec![5, 5, 5, 5, 0]; let base_num = 10; diff --git a/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs b/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs index 870e64712..104e55ef3 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs @@ -1,8 +1,9 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix hexifying glibc floatnum rten rhex arrnum +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety +// spell-checker:ignore (ToDO) arrnum //! formatter for %a %F C99 Hex-floating-point subs use super::super::format_field::FormatField; -use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; +use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::base_conv; use super::base_conv::RadixDef; use super::float_common::{primitive_to_str_common, FloatAnalysis}; @@ -20,15 +21,15 @@ impl Formatter for CninetyNineHexFloatf { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; let analysis = - FloatAnalysis::analyze(&str_in, inprefix, Some(second_field as usize), None, true); + FloatAnalysis::analyze(&str_in, initial_prefix, Some(second_field as usize), None, true); let f = get_primitive_hex( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, *field.field_char == 'A', @@ -44,13 +45,13 @@ impl Formatter for CninetyNineHexFloatf { // on the todo list is to have a trait for get_primitive that is implemented by each float formatter and can override a default. when that happens we can take the parts of get_primitive_dec specific to dec and spin them out to their own functions that can be overridden. fn get_primitive_hex( - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, _str_in: &str, _analysis: &FloatAnalysis, _last_dec_place: usize, capitalized: bool, ) -> FormatPrimitive { - let prefix = Some(String::from(if inprefix.sign == -1 { "-0x" } else { "0x" })); + let prefix = Some(String::from(if initial_prefix.sign == -1 { "-0x" } else { "0x" })); // TODO actual conversion, make sure to get back mantissa. // for hex to hex, it's really just a matter of moving the @@ -63,7 +64,7 @@ fn get_primitive_hex( // the difficult part of this (arrnum_int_div_step) is already implemented. // the hex float name may be a bit misleading in terms of how to go about the - // conversion. The best way to do it is to just convert the floatnum + // conversion. The best way to do it is to just convert the float number // directly to base 2 and then at the end translate back to hex. let mantissa = 0; let suffix = Some({ @@ -82,15 +83,15 @@ fn get_primitive_hex( } fn to_hex(src: &str, before_decimal: bool) -> String { - let rten = base_conv::RadixTen; - let rhex = base_conv::RadixHex; + let radix_ten = base_conv::RadixTen; + let radix_hex = base_conv::RadixHex; if before_decimal { - base_conv::base_conv_str(src, &rten, &rhex) + base_conv::base_conv_str(src, &radix_ten, &radix_hex) } else { - let as_arrnum_ten = base_conv::str_to_arrnum(src, &rten); + let as_arrnum_ten = base_conv::str_to_arrnum(src, &radix_ten); let s = format!( "{}", - base_conv::base_conv_float(&as_arrnum_ten, rten.get_max(), rhex.get_max()) + base_conv::base_conv_float(&as_arrnum_ten, radix_ten.get_max(), radix_hex.get_max()) ); if s.len() > 2 { String::from(&s[2..]) diff --git a/src/uu/printf/src/tokenize/num_format/formatters/decf.rs b/src/uu/printf/src/tokenize/num_format/formatters/decf.rs index 448771f22..4d729f0ce 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/decf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/decf.rs @@ -1,22 +1,22 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix hexifying glibc floatnum rten rhex arrnum fprim interp +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety //! formatter for %g %G decimal subs use super::super::format_field::FormatField; -use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; +use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; -fn get_len_fprim(fprim: &FormatPrimitive) -> usize { +fn get_len_fmt_primitive(fmt: &FormatPrimitive) -> usize { let mut len = 0; - if let Some(ref s) = fprim.prefix { + if let Some(ref s) = fmt.prefix { len += s.len(); } - if let Some(ref s) = fprim.pre_decimal { + if let Some(ref s) = fmt.pre_decimal { len += s.len(); } - if let Some(ref s) = fprim.post_decimal { + if let Some(ref s) = fmt.post_decimal { len += s.len(); } - if let Some(ref s) = fprim.suffix { + if let Some(ref s) = fmt.suffix { len += s.len(); } len @@ -33,22 +33,22 @@ impl Formatter for Decf { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; - // default to scif interp. so as to not truncate input vals + // default to scif interpretation so as to not truncate input vals // (that would be displayed in scif) based on relation to decimal place let analysis = FloatAnalysis::analyze( str_in, - inprefix, + initial_prefix, Some(second_field as usize + 1), None, false, ); let mut f_sci = get_primitive_dec( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, Some(*field.field_char == 'G'), @@ -70,13 +70,13 @@ impl Formatter for Decf { } } let f_fl = get_primitive_dec( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, None, ); - Some(if get_len_fprim(&f_fl) >= get_len_fprim(&f_sci) { + Some(if get_len_fmt_primitive(&f_fl) >= get_len_fmt_primitive(&f_sci) { f_sci } else { f_fl diff --git a/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs b/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs index a107078ae..4cbb496e4 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs @@ -1,7 +1,8 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix hexifying glibc floatnum rten rhex arrnum +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety +// spell-checker:ignore (ToDO) arrnum use super::super::format_field::FormatField; -use super::super::formatter::{get_it_at, warn_incomplete_conv, Base, FormatPrimitive, InPrefix}; +use super::super::formatter::{get_it_at, warn_incomplete_conv, Base, FormatPrimitive, InitialPrefix}; use super::base_conv; use super::base_conv::RadixDef; @@ -39,7 +40,7 @@ fn has_enough_digits( impl FloatAnalysis { pub fn analyze( str_in: &str, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, max_sd_opt: Option, max_after_dec_opt: Option, hex_output: bool, @@ -47,13 +48,13 @@ impl FloatAnalysis { // this fn assumes // the input string // has no leading spaces or 0s - let str_it = get_it_at(inprefix.offset, str_in); + let str_it = get_it_at(initial_prefix.offset, str_in); let mut ret = FloatAnalysis { len_important: 0, decimal_pos: None, follow: None, }; - let hex_input = match inprefix.radix_in { + let hex_input = match initial_prefix.radix_in { Base::Hex => true, Base::Ten => false, Base::Octal => { @@ -126,15 +127,15 @@ impl FloatAnalysis { } fn de_hex(src: &str, before_decimal: bool) -> String { - let rten = base_conv::RadixTen; - let rhex = base_conv::RadixHex; + let radix_ten = base_conv::RadixTen; + let radix_hex = base_conv::RadixHex; if before_decimal { - base_conv::base_conv_str(src, &rhex, &rten) + base_conv::base_conv_str(src, &radix_hex, &radix_ten) } else { - let as_arrnum_hex = base_conv::str_to_arrnum(src, &rhex); + let as_arrnum_hex = base_conv::str_to_arrnum(src, &radix_hex); let s = format!( "{}", - base_conv::base_conv_float(&as_arrnum_hex, rhex.get_max(), rten.get_max()) + base_conv::base_conv_float(&as_arrnum_hex, radix_hex.get_max(), radix_ten.get_max()) ); if s.len() > 2 { String::from(&s[2..]) @@ -200,7 +201,7 @@ fn round_terminal_digit( } pub fn get_primitive_dec( - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, analysis: &FloatAnalysis, last_dec_place: usize, @@ -209,7 +210,7 @@ pub fn get_primitive_dec( let mut f: FormatPrimitive = Default::default(); // add negative sign section - if inprefix.sign == -1 { + if initial_prefix.sign == -1 { f.prefix = Some(String::from("-")); } @@ -223,8 +224,8 @@ pub fn get_primitive_dec( if first_segment_raw.is_empty() { first_segment_raw = "0"; } - // convert to string, de_hexifying if input is in hex. - let (first_segment, second_segment) = match inprefix.radix_in { + // convert to string, de_hexifying if input is in hex // spell-checker:disable-line + let (first_segment, second_segment) = match initial_prefix.radix_in { Base::Hex => ( de_hex(first_segment_raw, true), de_hex(second_segment_raw, false), diff --git a/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs b/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs index b3de2f98a..79bb51fb8 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs @@ -1,8 +1,9 @@ -// spell-checker:ignore (ToDO) floatf inprefix +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety +// spell-checker:ignore (ToDO) arrnum //! formatter for %f %F common-notation floating-point subs use super::super::format_field::FormatField; -use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; +use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; pub struct Floatf; @@ -15,15 +16,15 @@ impl Formatter for Floatf { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; let analysis = - FloatAnalysis::analyze(&str_in, inprefix, None, Some(second_field as usize), false); + FloatAnalysis::analyze(&str_in, initial_prefix, None, Some(second_field as usize), false); let f = get_primitive_dec( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, None, diff --git a/src/uu/printf/src/tokenize/num_format/formatters/intf.rs b/src/uu/printf/src/tokenize/num_format/formatters/intf.rs index 2e4e67047..1e9e25560 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/intf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/intf.rs @@ -1,11 +1,12 @@ -// spell-checker:ignore (ToDO) fchar conv decr inprefix intf ints finalstr +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety +// spell-checker:ignore (ToDO) arrnum //! formatter for unsigned and signed int subs -//! unsigned ints: %X %x (hex u64) %o (octal u64) %u (base ten u64) -//! signed ints: %i %d (both base ten i64) +//! unsigned int: %X %x (hex u64) %o (octal u64) %u (base ten u64) +//! signed int: %i %d (both base ten i64) use super::super::format_field::FormatField; use super::super::formatter::{ - get_it_at, warn_incomplete_conv, Base, FormatPrimitive, Formatter, InPrefix, + get_it_at, warn_incomplete_conv, Base, FormatPrimitive, Formatter, InitialPrefix, }; use std::i64; use std::u64; @@ -38,19 +39,19 @@ impl Intf { // is_zero: true if number is zero, false otherwise // len_digits: length of digits used to create the int // important, for example, if we run into a non-valid character - fn analyze(str_in: &str, signed_out: bool, inprefix: &InPrefix) -> IntAnalysis { + fn analyze(str_in: &str, signed_out: bool, initial_prefix: &InitialPrefix) -> IntAnalysis { // the maximum number of digits we could conceivably // have before the decimal point without exceeding the // max - let mut str_it = get_it_at(inprefix.offset, str_in); + let mut str_it = get_it_at(initial_prefix.offset, str_in); let max_sd_in = if signed_out { - match inprefix.radix_in { + match initial_prefix.radix_in { Base::Ten => 19, Base::Octal => 21, Base::Hex => 16, } } else { - match inprefix.radix_in { + match initial_prefix.radix_in { Base::Ten => 20, Base::Octal => 22, Base::Hex => 16, @@ -118,13 +119,13 @@ impl Intf { } // get a FormatPrimitive of the maximum value for the field char // and given sign - fn get_max(fchar: char, sign: i8) -> FormatPrimitive { - let mut fmt_prim: FormatPrimitive = Default::default(); - fmt_prim.pre_decimal = Some(String::from(match fchar { + fn get_max(field_char: char, sign: i8) -> FormatPrimitive { + let mut fmt_primitive: FormatPrimitive = Default::default(); + fmt_primitive.pre_decimal = Some(String::from(match field_char { 'd' | 'i' => match sign { 1 => "9223372036854775807", _ => { - fmt_prim.prefix = Some(String::from("-")); + fmt_primitive.prefix = Some(String::from("-")); "9223372036854775808" } }, @@ -132,7 +133,7 @@ impl Intf { 'o' => "1777777777777777777777", /* 'u' | */ _ => "18446744073709551615", })); - fmt_prim + fmt_primitive } // conv_from_segment contract: // 1. takes @@ -149,8 +150,8 @@ impl Intf { // - if the string falls outside bounds: // for i64 output, the int minimum or int max (depending on sign) // for u64 output, the u64 max in the output radix - fn conv_from_segment(segment: &str, radix_in: Base, fchar: char, sign: i8) -> FormatPrimitive { - match fchar { + fn conv_from_segment(segment: &str, radix_in: Base, field_char: char, sign: i8) -> FormatPrimitive { + match field_char { 'i' | 'd' => match i64::from_str_radix(segment, radix_in as u32) { Ok(i) => { let mut fmt_prim: FormatPrimitive = Default::default(); @@ -160,13 +161,13 @@ impl Intf { fmt_prim.pre_decimal = Some(format!("{}", i)); fmt_prim } - Err(_) => Intf::get_max(fchar, sign), + Err(_) => Intf::get_max(field_char, sign), }, _ => match u64::from_str_radix(segment, radix_in as u32) { Ok(u) => { let mut fmt_prim: FormatPrimitive = Default::default(); let u_f = if sign == -1 { u64::MAX - (u - 1) } else { u }; - fmt_prim.pre_decimal = Some(match fchar { + fmt_prim.pre_decimal = Some(match field_char { 'X' => format!("{:X}", u_f), 'x' => format!("{:x}", u_f), 'o' => format!("{:o}", u_f), @@ -174,7 +175,7 @@ impl Intf { }); fmt_prim } - Err(_) => Intf::get_max(fchar, sign), + Err(_) => Intf::get_max(field_char, sign), }, } } @@ -183,17 +184,17 @@ impl Formatter for Intf { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { - let begin = inprefix.offset; + let begin = initial_prefix.offset; // get information about the string. see Intf::Analyze // def above. let convert_hints = Intf::analyze( str_in, *field.field_char == 'i' || *field.field_char == 'd', - inprefix, + initial_prefix, ); // We always will have a format primitive to return Some(if convert_hints.len_digits == 0 || convert_hints.is_zero { @@ -209,22 +210,22 @@ impl Formatter for Intf { 'x' | 'X' => Base::Hex, /* 'o' | */ _ => Base::Octal, }; - let radix_mismatch = !radix_out.eq(&inprefix.radix_in); - let decr_from_max: bool = inprefix.sign == -1 && *field.field_char != 'i'; + let radix_mismatch = !radix_out.eq(&initial_prefix.radix_in); + let decrease_from_max: bool = initial_prefix.sign == -1 && *field.field_char != 'i'; let end = begin + convert_hints.len_digits as usize; // convert to int if any one of these is true: // - number of digits in int indicates it may be past max // - we're subtracting from the max // - we're converting the base - if convert_hints.check_past_max || decr_from_max || radix_mismatch { + if convert_hints.check_past_max || decrease_from_max || radix_mismatch { // radix of in and out is the same. let segment = String::from(&str_in[begin..end]); Intf::conv_from_segment( &segment, - inprefix.radix_in.clone(), + initial_prefix.radix_in.clone(), *field.field_char, - inprefix.sign, + initial_prefix.sign, ) } else { // otherwise just do a straight string copy. @@ -233,20 +234,20 @@ impl Formatter for Intf { // this is here and not earlier because // zero doesn't get a sign, and conv_from_segment // creates its format primitive separately - if inprefix.sign == -1 && *field.field_char == 'i' { + if initial_prefix.sign == -1 && *field.field_char == 'i' { fmt_prim.prefix = Some(String::from("-")); } fmt_prim.pre_decimal = Some(String::from(&str_in[begin..end])); fmt_prim } } else { - Intf::get_max(*field.field_char, inprefix.sign) + Intf::get_max(*field.field_char, initial_prefix.sign) }) } fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String { - let mut finalstr: String = String::new(); + let mut final_str: String = String::new(); if let Some(ref prefix) = prim.prefix { - finalstr.push_str(&prefix); + final_str.push_str(&prefix); } // integral second fields is zero-padded minimum-width // which gets handled before general minimum-width @@ -256,11 +257,11 @@ impl Formatter for Intf { let mut i = min; let len = pre_decimal.len() as u32; while i > len { - finalstr.push('0'); + final_str.push('0'); i -= 1; } } - finalstr.push_str(&pre_decimal); + final_str.push_str(&pre_decimal); } None => { panic!( @@ -269,6 +270,6 @@ impl Formatter for Intf { ); } } - finalstr + final_str } } diff --git a/src/uu/printf/src/tokenize/num_format/formatters/mod.rs b/src/uu/printf/src/tokenize/num_format/formatters/mod.rs index ccbcdb1e7..e23230071 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/mod.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/mod.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) conv cninetyninehexfloatf floatf intf scif +// spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety mod base_conv; pub mod cninetyninehexfloatf; diff --git a/src/uu/printf/src/tokenize/num_format/formatters/scif.rs b/src/uu/printf/src/tokenize/num_format/formatters/scif.rs index ebac1565e..c46c7d423 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/scif.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/scif.rs @@ -1,8 +1,8 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix +// spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety //! formatter for %e %E scientific notation subs use super::super::format_field::FormatField; -use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; +use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; pub struct Scif; @@ -16,20 +16,20 @@ impl Formatter for Scif { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; let analysis = FloatAnalysis::analyze( str_in, - inprefix, + initial_prefix, Some(second_field as usize + 1), None, false, ); let f = get_primitive_dec( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, Some(*field.field_char == 'E'), diff --git a/src/uu/printf/src/tokenize/num_format/num_format.rs b/src/uu/printf/src/tokenize/num_format/num_format.rs index 812f51b5a..a8a60cc57 100644 --- a/src/uu/printf/src/tokenize/num_format/num_format.rs +++ b/src/uu/printf/src/tokenize/num_format/num_format.rs @@ -1,12 +1,14 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety qchar topchar structs fmtr fchar inprefix devs octals cninetyninehexfloatf +// spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety //! handles creating printed output for numeric substitutions +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety + use std::env; use std::vec::Vec; use super::format_field::{FieldType, FormatField}; -use super::formatter::{Base, FormatPrimitive, Formatter, InPrefix}; +use super::formatter::{Base, FormatPrimitive, Formatter, InitialPrefix}; use super::formatters::cninetyninehexfloatf::CninetyNineHexFloatf; use super::formatters::decf::Decf; use super::formatters::floatf::Floatf; @@ -46,8 +48,8 @@ fn get_provided(str_in_opt: Option<&String>) -> Option { match str_in_opt { Some(str_in) => { let mut byte_it = str_in.bytes(); - if let Some(qchar) = byte_it.next() { - match qchar { + if let Some(ch) = byte_it.next() { + match ch { C_S_QUOTE | C_D_QUOTE => { Some(match byte_it.next() { Some(second_byte) => { @@ -62,7 +64,7 @@ fn get_provided(str_in_opt: Option<&String>) -> Option { } // no byte after quote None => { - let so_far = (qchar as u8 as char).to_string(); + let so_far = (ch as u8 as char).to_string(); warn_expected_numeric(&so_far); 0_u8 } @@ -84,30 +86,30 @@ fn get_provided(str_in_opt: Option<&String>) -> Option { // a base, // and an offset for index after all // initial spacing, sign, base prefix, and leading zeroes -fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix { +fn get_initial_prefix(str_in: &str, field_type: &FieldType) -> InitialPrefix { let mut str_it = str_in.chars(); - let mut ret = InPrefix { + let mut ret = InitialPrefix { radix_in: Base::Ten, sign: 1, offset: 0, }; - let mut topchar = str_it.next(); - // skip spaces and ensure topchar is the first non-space char + let mut top_char = str_it.next(); + // skip spaces and ensure top_char is the first non-space char // (or None if none exists) - while let Some(' ') = topchar { + while let Some(' ') = top_char { ret.offset += 1; - topchar = str_it.next(); + top_char = str_it.next(); } // parse sign - match topchar { + match top_char { Some('+') => { ret.offset += 1; - topchar = str_it.next(); + top_char = str_it.next(); } Some('-') => { ret.sign = -1; ret.offset += 1; - topchar = str_it.next(); + top_char = str_it.next(); } _ => {} } @@ -125,7 +127,7 @@ fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix { // final offset. If the zero could be before // a decimal point we don't move past the zero. let mut is_hex = false; - if Some('0') == topchar { + if Some('0') == top_char { if let Some(base) = str_it.next() { // lead zeroes can only exist in // octal and hex base @@ -152,7 +154,7 @@ fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix { let mut first = true; for ch_zero in str_it { // see notes on offset above: - // this is why the offset for octals and decimals + // this is why the offset for octal and decimal numbers // that reach this branch is 1 even though // they have already eaten the characters '00' // this is also why when hex encounters its @@ -194,21 +196,21 @@ fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix { // if it is a numeric field, passing the field details // and an iterator to the argument pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option { - let fchar = field.field_char; + let field_char = field.field_char; // num format mainly operates by further delegating to one of // several Formatter structs depending on the field // see formatter.rs for more details // to do switch to static dispatch - let fmtr: Box = match *field.field_type { + let formatter: Box = match *field.field_type { FieldType::Intf => Box::new(Intf::new()), FieldType::Floatf => Box::new(Floatf::new()), FieldType::CninetyNineHexFloatf => Box::new(CninetyNineHexFloatf::new()), FieldType::Scif => Box::new(Scif::new()), FieldType::Decf => Box::new(Decf::new()), _ => { - panic!("asked to do num format with non-num fieldtype"); + panic!("asked to do num format with non-num field type"); } }; let prim_opt= @@ -216,7 +218,7 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option { tmp.pre_decimal = Some( format!("{}", provided_num)); @@ -231,11 +233,11 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option { let as_str = format!("{}", provided_num); - let inprefix = get_inprefix( + let initial_prefix = get_initial_prefix( &as_str, &field.field_type ); - tmp=fmtr.get_primitive(field, &inprefix, &as_str) + tmp=formatter.get_primitive(field, &initial_prefix, &as_str) .expect("err during default provided num"); }, _ => { @@ -254,14 +256,14 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option FieldType::Charf, _ => { // should be unreachable. - println!("Invalid fieldtype"); + println!("Invalid field type"); exit(cli::EXIT_ERR); } }; @@ -130,7 +130,7 @@ impl SubParser { } } fn build_token(parser: SubParser) -> Box { - // not a self method so as to allow move of subparser vals. + // not a self method so as to allow move of sub-parser vals. // return new Sub struct as token let t: Box = Box::new(Sub::new( if parser.min_width_is_asterisk { @@ -354,7 +354,7 @@ impl token::Token for Sub { // field char let pre_min_width_opt: Option = match *field.field_type { // if %s just return arg - // if %b use UnescapedText module's unescaping-fn + // if %b use UnescapedText module's unescape-fn // if %c return first char of arg FieldType::Strf | FieldType::Charf => { match pf_arg { From 13561cb5ae412e9671c6062cc85b67ec7518f310 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:35:46 -0500 Subject: [PATCH 086/126] refactor/ptx ~ polish spelling (comments, names, and exceptions) --- src/uu/ptx/src/ptx.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index a17f7c810..5b0c35093 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -246,7 +246,7 @@ fn read_input(input_files: &[String], config: &Config) -> FileMap { file_map } -/// Go through every lines in the input files and record each match occurance as a `WordRef`. +/// Go through every lines in the input files and record each match occurrence as a `WordRef`. fn create_word_set(config: &Config, filter: &WordFilter, file_map: &FileMap) -> BTreeSet { let reg = Regex::new(&filter.word_regex).unwrap(); let ref_reg = Regex::new(&config.context_regex).unwrap(); @@ -412,7 +412,7 @@ fn get_output_chunks( 0, ) as usize; - // the tail chunk takes text starting from where the after chunk ends (with whitespaces trimmed). + // the tail chunk takes text starting from where the after chunk ends (with whitespace trimmed). let (tail_beg, _) = trim_idx(all_after, after_end, all_after.len()); // end = begin + max length @@ -493,10 +493,10 @@ fn format_tex_line( output.push_str(&format!("\\{} ", config.macro_name)); let all_before = if config.input_ref { let before = &line[0..word_ref.position]; - let before_start_trimoff = + let before_start_trim_offset = word_ref.position - before.trim_start_matches(reference).trim_start().len(); let before_end_index = before.len(); - &chars_line[before_start_trimoff..cmp::max(before_end_index, before_start_trimoff)] + &chars_line[before_start_trim_offset..cmp::max(before_end_index, before_start_trim_offset)] } else { let before_chars_trim_idx = (0, word_ref.position); &chars_line[before_chars_trim_idx.0..before_chars_trim_idx.1] @@ -536,10 +536,10 @@ fn format_roff_line( output.push_str(&format!(".{}", config.macro_name)); let all_before = if config.input_ref { let before = &line[0..word_ref.position]; - let before_start_trimoff = + let before_start_trim_offset = word_ref.position - before.trim_start_matches(reference).trim_start().len(); let before_end_index = before.len(); - &chars_line[before_start_trimoff..cmp::max(before_end_index, before_start_trimoff)] + &chars_line[before_start_trim_offset..cmp::max(before_end_index, before_start_trim_offset)] } else { let before_chars_trim_idx = (0, word_ref.position); &chars_line[before_chars_trim_idx.0..before_chars_trim_idx.1] From a15f8af99ffbe2234b6981af1c712c2c1a4f9430 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:36:05 -0500 Subject: [PATCH 087/126] refactor/shred ~ polish spelling (comments, names, and exceptions) --- src/uu/shred/src/shred.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 15a4eff26..e371ad6b2 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -6,7 +6,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore (ToDO) NAMESET FILESIZE fstab coeff journaling writeback REiser journaled +// spell-checker:ignore (words) writeback wipesync use clap::{App, Arg}; use rand::{Rng, ThreadRng}; @@ -25,7 +25,7 @@ extern crate uucore; static NAME: &str = "shred"; static VERSION_STR: &str = "1.0.0"; const BLOCK_SIZE: usize = 512; -const NAMESET: &str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_."; +const NAME_CHARSET: &str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_."; // Patterns as shown in the GNU coreutils shred implementation const PATTERNS: [&[u8]; 22] = [ @@ -59,10 +59,10 @@ enum PassType<'a> { Random, } -// Used to generate all possible filenames of a certain length using NAMESET as an alphabet +// Used to generate all possible filenames of a certain length using NAME_CHARSET as an alphabet struct FilenameGenerator { name_len: usize, - nameset_indices: RefCell>, // Store the indices of the letters of our filename in NAMESET + name_charset_indices: RefCell>, // Store the indices of the letters of our filename in NAME_CHARSET exhausted: Cell, } @@ -71,7 +71,7 @@ impl FilenameGenerator { let indices: Vec = vec![0; name_len]; FilenameGenerator { name_len, - nameset_indices: RefCell::new(indices), + name_charset_indices: RefCell::new(indices), exhausted: Cell::new(false), } } @@ -85,25 +85,25 @@ impl Iterator for FilenameGenerator { return None; } - let mut nameset_indices = self.nameset_indices.borrow_mut(); + let mut name_charset_indices = self.name_charset_indices.borrow_mut(); // Make the return value, then increment let mut ret = String::new(); - for i in nameset_indices.iter() { - let c: char = NAMESET.chars().nth(*i).unwrap(); + for i in name_charset_indices.iter() { + let c: char = NAME_CHARSET.chars().nth(*i).unwrap(); ret.push(c); } - if nameset_indices[0] == NAMESET.len() - 1 { + if name_charset_indices[0] == NAME_CHARSET.len() - 1 { self.exhausted.set(true) } // Now increment the least significant index for i in (0..self.name_len).rev() { - if nameset_indices[i] == NAMESET.len() - 1 { - nameset_indices[i] = 0; // Carry the 1 + if name_charset_indices[i] == NAME_CHARSET.len() - 1 { + name_charset_indices[i] = 0; // Carry the 1 continue; } else { - nameset_indices[i] += 1; + name_charset_indices[i] += 1; break; } } @@ -233,7 +233,7 @@ static AFTER_HELP: &str = assumption. The following are examples of file systems on which shred is\n\ not effective, or is not guaranteed to be effective in all file system modes:\n\ \n\ - * log-structured or journaled file systems, such as those supplied with\n\ + * log-structured or journal file systems, such as those supplied with\n\ AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)\n\ \n\ * file systems that write redundant data and carry on even if some writes\n\ @@ -250,7 +250,7 @@ static AFTER_HELP: &str = and shred is thus of limited effectiveness) only in data=journal mode,\n\ which journals file data in addition to just metadata. In both the\n\ data=ordered (default) and data=writeback modes, shred works as usual.\n\ - Ext3 journaling modes can be changed by adding the data=something option\n\ + Ext3 journal modes can be changed by adding the data=something option\n\ to the mount options for a particular file system in the /etc/fstab file,\n\ as documented in the mount man page (man mount).\n\ \n\ @@ -412,7 +412,7 @@ fn get_size(size_str_opt: Option) -> Option { _ => 1u64, }; - let coeff = match size_str.parse::() { + let coefficient = match size_str.parse::() { Ok(u) => u, Err(_) => { println!("{}: {}: Invalid file size", NAME, size_str_opt.unwrap()); @@ -420,7 +420,7 @@ fn get_size(size_str_opt: Option) -> Option { } }; - Some(coeff * unit) + Some(coefficient * unit) } fn pass_name(pass_type: PassType) -> String { From f8e04c562b59fbdf2dd1a2a4b353d0d7e51c8777 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:36:19 -0500 Subject: [PATCH 088/126] refactor/sort ~ polish spelling (comments, names, and exceptions) --- src/uu/sort/BENCHMARKING.md | 4 +++- src/uu/sort/src/sort.rs | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/uu/sort/BENCHMARKING.md b/src/uu/sort/BENCHMARKING.md index 560d6b438..77186318a 100644 --- a/src/uu/sort/BENCHMARKING.md +++ b/src/uu/sort/BENCHMARKING.md @@ -1,5 +1,7 @@ # Benchmarking sort + + Most of the time when sorting is spent comparing lines. The comparison functions however differ based on which arguments are passed to `sort`, therefore it is important to always benchmark multiple scenarios. This is an overview over what was benchmarked, and if you make changes to `sort`, you are encouraged to check @@ -96,7 +98,7 @@ When invoked with -c, we simply check if the input is already ordered. The input Try to run the above benchmarks by piping the input through stdin (standard input) and redirect the output through stdout (standard output): -- Remove the input file from the arguments and add `cat [inputfile] | ` at the beginning. +- Remove the input file from the arguments and add `cat [input_file] | ` at the beginning. - Remove `-o output.txt` and add `> output.txt` at the end. Example: `hyperfine "target/release/coreutils sort shuffled_numbers.txt -n -o output.txt"` becomes diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index a3b79e5d7..ab3b06451 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -11,7 +11,8 @@ // https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html // https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html -// spell-checker:ignore (ToDO) outfile nondictionary +// spell-checker:ignore (misc) HFKJFK Mbdfhn + #[macro_use] extern crate uucore; @@ -143,7 +144,7 @@ pub struct GlobalSettings { ignore_non_printing: bool, merge: bool, reverse: bool, - outfile: Option, + output_file: Option, stable: bool, unique: bool, check: bool, @@ -187,7 +188,7 @@ impl GlobalSettings { } fn out_writer(&self) -> BufWriter> { - match self.outfile { + match self.output_file { Some(ref filename) => match File::create(Path::new(&filename)) { Ok(f) => BufWriter::new(Box::new(f) as Box), Err(e) => { @@ -211,7 +212,7 @@ impl Default for GlobalSettings { ignore_non_printing: false, merge: false, reverse: false, - outfile: None, + output_file: None, stable: false, unique: false, check: false, @@ -1168,7 +1169,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { settings.ignore_blanks = matches.is_present(OPT_IGNORE_BLANKS); - settings.outfile = matches.value_of(OPT_OUTPUT).map(String::from); + settings.output_file = matches.value_of(OPT_OUTPUT).map(String::from); settings.reverse = matches.is_present(OPT_REVERSE); settings.stable = matches.is_present(OPT_STABLE); settings.unique = matches.is_present(OPT_UNIQUE); From 00a2e17c8032f9dc40eb511e00ef7fd314c92a77 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 00:07:01 -0500 Subject: [PATCH 089/126] refactor/splice ~ polish spelling (comments, names, and exceptions) --- src/uu/cat/src/splice.rs | 2 +- src/uu/csplit/src/csplit.rs | 6 +++--- src/uu/csplit/src/patterns.rs | 4 +++- .../csplit/src/{splitname.rs => split_name.rs} | 16 ++++++++++------ 4 files changed, 17 insertions(+), 11 deletions(-) rename src/uu/csplit/src/{splitname.rs => split_name.rs} (98%) diff --git a/src/uu/cat/src/splice.rs b/src/uu/cat/src/splice.rs index bd6be60f1..0b46fc662 100644 --- a/src/uu/cat/src/splice.rs +++ b/src/uu/cat/src/splice.rs @@ -9,7 +9,7 @@ const BUF_SIZE: usize = 1024 * 16; /// This function is called from `write_fast()` on Linux and Android. The /// function `splice()` is used to move data between two file descriptors -/// without copying between kernel- and userspace. This results in a large +/// without copying between kernel and user spaces. This results in a large /// speedup. /// /// The `bool` in the result value indicates if we need to fall back to normal diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index 43f95fff5..a2eb8604a 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -13,10 +13,10 @@ use std::{ mod csplit_error; mod patterns; -mod splitname; +mod split_name; use crate::csplit_error::CsplitError; -use crate::splitname::SplitName; +use crate::split_name::SplitName; use uucore::InvalidEncodingHandling; static VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -77,7 +77,7 @@ impl CsplitOptions { /// # Errors /// /// - [`io::Error`] if there is some problem reading/writing from/to a file. -/// - [`::CsplitError::LineOutOfRange`] if the linenum pattern is larger than the number of input +/// - [`::CsplitError::LineOutOfRange`] if the line number pattern is larger than the number of input /// lines. /// - [`::CsplitError::LineOutOfRangeOnRepetition`], like previous but after applying the pattern /// more than once. diff --git a/src/uu/csplit/src/patterns.rs b/src/uu/csplit/src/patterns.rs index d2f14578a..5621d18a3 100644 --- a/src/uu/csplit/src/patterns.rs +++ b/src/uu/csplit/src/patterns.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (regex) SKIPTO UPTO ; (vars) ntimes + use crate::csplit_error::CsplitError; use regex::Regex; @@ -167,7 +169,7 @@ fn validate_line_numbers(patterns: &[Pattern]) -> Result<(), CsplitError> { .try_fold(0, |prev_ln, ¤t_ln| match (prev_ln, current_ln) { // a line number cannot be zero (_, 0) => Err(CsplitError::LineNumberIsZero), - // two consecutifs numbers should not be equal + // two consecutive numbers should not be equal (n, m) if n == m => { show_warning!("line number '{}' is the same as preceding line number", n); Ok(n) diff --git a/src/uu/csplit/src/splitname.rs b/src/uu/csplit/src/split_name.rs similarity index 98% rename from src/uu/csplit/src/splitname.rs rename to src/uu/csplit/src/split_name.rs index 66b17ba67..6db781e9b 100644 --- a/src/uu/csplit/src/splitname.rs +++ b/src/uu/csplit/src/split_name.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (regex) diuox + use regex::Regex; use crate::csplit_error::CsplitError; @@ -225,6 +227,8 @@ impl SplitName { #[cfg(test)] mod tests { + // spell-checker:ignore (path) xxcst + use super::*; #[test] @@ -319,13 +323,13 @@ mod tests { } #[test] - fn zero_padding_lower_hexa() { + fn zero_padding_lower_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%03x-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst-02a-"); } #[test] - fn zero_padding_upper_hexa() { + fn zero_padding_upper_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%03X-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst-02A-"); } @@ -337,13 +341,13 @@ mod tests { } #[test] - fn alternate_form_lower_hexa() { + fn alternate_form_lower_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%#10x-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst- 0x2a-"); } #[test] - fn alternate_form_upper_hexa() { + fn alternate_form_upper_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%#10X-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst- 0x2A-"); } @@ -373,13 +377,13 @@ mod tests { } #[test] - fn left_adjusted_lower_hexa() { + fn left_adjusted_lower_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%-10x-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst-0x2a -"); } #[test] - fn left_adjusted_upper_hexa() { + fn left_adjusted_upper_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%-10X-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst-0x2A -"); } From 451110bba017bd278f7d2b2bbe637410ffb0bf29 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:41:19 -0500 Subject: [PATCH 090/126] refactor/split ~ polish spelling (comments, names, and exceptions) --- src/uu/split/src/split.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 39bd577cb..85ed5f183 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -157,13 +157,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 { settings.verbose = matches.occurrences_of("verbose") > 0; // check that the user is not specifying more than one strategy - // note: right now, this exact behaviour cannot be handled by ArgGroup since ArgGroup + // note: right now, this exact behavior cannot be handled by ArgGroup since ArgGroup // considers a default value Arg as "defined" let explicit_strategies = vec![OPT_LINE_BYTES, OPT_LINES, OPT_BYTES] .into_iter() - .fold(0, |count, strat| { - if matches.occurrences_of(strat) > 0 { + .fold(0, |count, strategy| { + if matches.occurrences_of(strategy) > 0 { count + 1 } else { count @@ -177,10 +177,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { settings.strategy = String::from(OPT_LINES); settings.strategy_param = matches.value_of(OPT_LINES).unwrap().to_owned(); // take any (other) defined strategy - for strat in vec![OPT_LINE_BYTES, OPT_BYTES].into_iter() { - if matches.occurrences_of(strat) > 0 { - settings.strategy = String::from(strat); - settings.strategy_param = matches.value_of(strat).unwrap().to_owned(); + for strategy in vec![OPT_LINE_BYTES, OPT_BYTES].into_iter() { + if matches.occurrences_of(strategy) > 0 { + settings.strategy = String::from(strategy); + settings.strategy_param = matches.value_of(strategy).unwrap().to_owned(); } } From 8e824742a120ab0f93e18a1eb7d6cf4399a26b69 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:36:46 -0500 Subject: [PATCH 091/126] refactor/stat ~ polish spelling (comments, names, and exceptions) --- src/uu/stat/src/stat.rs | 199 ++++++++++++++++++++-------------------- 1 file changed, 98 insertions(+), 101 deletions(-) diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 582d59841..83567e447 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -5,8 +5,6 @@ // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. -// spell-checker:ignore (ToDO) showfs otype fmtstr prec ftype blocksize nlink rdev fnodes fsid namelen blksize inodes fstype iosize statfs gnulib NBLOCKSIZE - #[macro_use] extern crate uucore; use uucore::entries; @@ -208,7 +206,7 @@ pub fn group_num(s: &str) -> Cow { pub struct Stater { follow: bool, - showfs: bool, + show_fs: bool, from_user: bool, files: Vec, mount_list: Option>, @@ -217,7 +215,7 @@ pub struct Stater { } #[allow(clippy::cognitive_complexity)] -fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32) { +fn print_it(arg: &str, output_type: OutputType, flag: u8, width: usize, precision: i32) { // If the precision is given as just '.', the precision is taken to be zero. // A negative precision is taken as if the precision were omitted. // This gives the minimum number of digits to appear for d, i, o, u, x, and X conversions, @@ -248,7 +246,7 @@ fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32 // By default, a sign is used only for negative numbers. // A + overrides a space if both are used. - if otype == OutputType::Unknown { + if output_type == OutputType::Unknown { return print!("?"); } @@ -262,7 +260,7 @@ fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32 let has_sign = has!(flag, F_SIGN) || has!(flag, F_SPACE); let should_alter = has!(flag, F_ALTER); - let prefix = match otype { + let prefix = match output_type { OutputType::UnsignedOct => "0", OutputType::UnsignedHex => "0x", OutputType::Integer => { @@ -275,7 +273,7 @@ fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32 _ => "", }; - match otype { + match output_type { OutputType::Str => { let limit = cmp::min(precision, arg.len() as i32); let s: &str = if limit >= 0 { @@ -334,10 +332,10 @@ fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32 } impl Stater { - pub fn generate_tokens(fmtstr: &str, use_printf: bool) -> Result, String> { + pub fn generate_tokens(format_str: &str, use_printf: bool) -> Result, String> { let mut tokens = Vec::new(); - let bound = fmtstr.len(); - let chars = fmtstr.chars().collect::>(); + let bound = format_str.len(); + let chars = format_str.chars().collect::>(); let mut i = 0_usize; while i < bound { match chars[i] { @@ -370,32 +368,32 @@ impl Stater { } i += 1; } - check_bound!(fmtstr, bound, old, i); + check_bound!(format_str, bound, old, i); let mut width = 0_usize; let mut precision = -1_i32; let mut j = i; - if let Some((field_width, offset)) = fmtstr[j..].scan_num::() { + if let Some((field_width, offset)) = format_str[j..].scan_num::() { width = field_width; j += offset; } - check_bound!(fmtstr, bound, old, j); + check_bound!(format_str, bound, old, j); if chars[j] == '.' { j += 1; - check_bound!(fmtstr, bound, old, j); + check_bound!(format_str, bound, old, j); - match fmtstr[j..].scan_num::() { - Some((prec, offset)) => { - if prec >= 0 { - precision = prec; + match format_str[j..].scan_num::() { + Some((value, offset)) => { + if value >= 0 { + precision = value; } j += offset; } None => precision = 0, } - check_bound!(fmtstr, bound, old, j); + check_bound!(format_str, bound, old, j); } i = j; @@ -418,7 +416,7 @@ impl Stater { } match chars[i] { 'x' if i + 1 < bound => { - if let Some((c, offset)) = fmtstr[i + 1..].scan_char(16) { + if let Some((c, offset)) = format_str[i + 1..].scan_char(16) { tokens.push(Token::Char(c)); i += offset; } else { @@ -427,7 +425,7 @@ impl Stater { } } '0'..='7' => { - let (c, offset) = fmtstr[i..].scan_char(8).unwrap(); + let (c, offset) = format_str[i..].scan_char(8).unwrap(); tokens.push(Token::Char(c)); i += offset - 1; } @@ -452,7 +450,7 @@ impl Stater { } i += 1; } - if !use_printf && !fmtstr.ends_with('\n') { + if !use_printf && !format_str.ends_with('\n') { tokens.push(Token::Char('\n')); } Ok(tokens) @@ -464,7 +462,7 @@ impl Stater { .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(); - let fmtstr = if matches.is_present(options::PRINTF) { + let format_str = if matches.is_present(options::PRINTF) { matches .value_of(options::PRINTF) .expect("Invalid format string") @@ -474,17 +472,17 @@ impl Stater { let use_printf = matches.is_present(options::PRINTF); let terse = matches.is_present(options::TERSE); - let showfs = matches.is_present(options::FILE_SYSTEM); + let show_fs = matches.is_present(options::FILE_SYSTEM); - let default_tokens = if fmtstr.is_empty() { - Stater::generate_tokens(&Stater::default_fmt(showfs, terse, false), use_printf).unwrap() + let default_tokens = if format_str.is_empty() { + Stater::generate_tokens(&Stater::default_format(show_fs, terse, false), use_printf).unwrap() } else { - Stater::generate_tokens(&fmtstr, use_printf)? + Stater::generate_tokens(&format_str, use_printf)? }; let default_dev_tokens = - Stater::generate_tokens(&Stater::default_fmt(showfs, terse, true), use_printf).unwrap(); + Stater::generate_tokens(&Stater::default_format(show_fs, terse, true), use_printf).unwrap(); - let mount_list = if showfs { + let mount_list = if show_fs { // mount points aren't displayed when showing filesystem information None } else { @@ -500,8 +498,8 @@ impl Stater { Ok(Stater { follow: matches.is_present(options::DEREFERENCE), - showfs, - from_user: !fmtstr.is_empty(), + show_fs, + from_user: !format_str.is_empty(), files, default_tokens, default_dev_tokens, @@ -533,7 +531,7 @@ impl Stater { } fn do_stat(&self, file: &str) -> i32 { - if !self.showfs { + if !self.show_fs { let result = if self.follow { fs::metadata(file) } else { @@ -541,9 +539,9 @@ impl Stater { }; match result { Ok(meta) => { - let ftype = meta.file_type(); + let file_type = meta.file_type(); let tokens = - if self.from_user || !(ftype.is_char_device() || ftype.is_block_device()) { + if self.from_user || !(file_type.is_char_device() || file_type.is_block_device()) { &self.default_tokens } else { &self.default_dev_tokens @@ -559,91 +557,91 @@ impl Stater { format, } => { let arg: String; - let otype: OutputType; + let output_type: OutputType; match format { // access rights in octal 'a' => { arg = format!("{:o}", 0o7777 & meta.mode()); - otype = OutputType::UnsignedOct; + output_type = OutputType::UnsignedOct; } // access rights in human readable form 'A' => { arg = display_permissions(&meta, true); - otype = OutputType::Str; + output_type = OutputType::Str; } // number of blocks allocated (see %B) 'b' => { arg = format!("{}", meta.blocks()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // the size in bytes of each block reported by %b // FIXME: blocksize differs on various platform - // See coreutils/gnulib/lib/stat-size.h ST_NBLOCKSIZE + // See coreutils/gnulib/lib/stat-size.h ST_NBLOCKSIZE // spell-checker:disable-line 'B' => { // the size in bytes of each block reported by %b arg = format!("{}", 512); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // device number in decimal 'd' => { arg = format!("{}", meta.dev()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // device number in hex 'D' => { arg = format!("{:x}", meta.dev()); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // raw mode in hex 'f' => { arg = format!("{:x}", meta.mode()); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // file type 'F' => { arg = pretty_filetype(meta.mode() as mode_t, meta.len()) .to_owned(); - otype = OutputType::Str; + output_type = OutputType::Str; } // group ID of owner 'g' => { arg = format!("{}", meta.gid()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // group name of owner 'G' => { arg = entries::gid2grp(meta.gid()) .unwrap_or_else(|_| "UNKNOWN".to_owned()); - otype = OutputType::Str; + output_type = OutputType::Str; } // number of hard links 'h' => { arg = format!("{}", meta.nlink()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // inode number 'i' => { arg = format!("{}", meta.ino()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // mount point 'm' => { arg = self.find_mount_point(file).unwrap(); - otype = OutputType::Str; + output_type = OutputType::Str; } // file name 'n' => { arg = file.to_owned(); - otype = OutputType::Str; + output_type = OutputType::Str; } // quoted file name with dereference if symbolic link 'N' => { - if ftype.is_symlink() { + if file_type.is_symlink() { let dst = match fs::read_link(file) { Ok(path) => path, Err(e) => { @@ -659,91 +657,91 @@ impl Stater { } else { arg = file.to_string(); } - otype = OutputType::Str; + output_type = OutputType::Str; } // optimal I/O transfer size hint 'o' => { arg = format!("{}", meta.blksize()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // total size, in bytes 's' => { arg = format!("{}", meta.len()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // major device type in hex, for character/block device special // files 't' => { arg = format!("{:x}", meta.rdev() >> 8); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // minor device type in hex, for character/block device special // files 'T' => { arg = format!("{:x}", meta.rdev() & 0xff); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // user ID of owner 'u' => { arg = format!("{}", meta.uid()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // user name of owner 'U' => { arg = entries::uid2usr(meta.uid()) .unwrap_or_else(|_| "UNKNOWN".to_owned()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of file birth, human-readable; - if unknown 'w' => { arg = meta.pretty_birth(); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of file birth, seconds since Epoch; 0 if unknown 'W' => { arg = meta.birth(); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // time of last access, human-readable 'x' => { arg = pretty_time(meta.atime(), meta.atime_nsec()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of last access, seconds since Epoch 'X' => { arg = format!("{}", meta.atime()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // time of last data modification, human-readable 'y' => { arg = pretty_time(meta.mtime(), meta.mtime_nsec()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of last data modification, seconds since Epoch 'Y' => { arg = format!("{}", meta.mtime()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of last status change, human-readable 'z' => { arg = pretty_time(meta.ctime(), meta.ctime_nsec()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of last status change, seconds since Epoch 'Z' => { arg = format!("{}", meta.ctime()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } _ => { arg = "?".to_owned(); - otype = OutputType::Unknown; + output_type = OutputType::Unknown; } } - print_it(&arg, otype, flag, width, precision); + print_it(&arg, output_type, flag, width, precision); } } } @@ -768,75 +766,75 @@ impl Stater { format, } => { let arg: String; - let otype: OutputType; + let output_type: OutputType; match format { // free blocks available to non-superuser 'a' => { arg = format!("{}", meta.avail_blocks()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // total data blocks in file system 'b' => { arg = format!("{}", meta.total_blocks()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // total file nodes in file system 'c' => { - arg = format!("{}", meta.total_fnodes()); - otype = OutputType::Unsigned; + arg = format!("{}", meta.total_file_nodes()); + output_type = OutputType::Unsigned; } // free file nodes in file system 'd' => { - arg = format!("{}", meta.free_fnodes()); - otype = OutputType::Integer; + arg = format!("{}", meta.free_file_nodes()); + output_type = OutputType::Integer; } // free blocks in file system 'f' => { arg = format!("{}", meta.free_blocks()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // file system ID in hex 'i' => { arg = format!("{:x}", meta.fsid()); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // maximum length of filenames 'l' => { arg = format!("{}", meta.namelen()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // file name 'n' => { arg = file.to_owned(); - otype = OutputType::Str; + output_type = OutputType::Str; } // block size (for faster transfers) 's' => { - arg = format!("{}", meta.iosize()); - otype = OutputType::Unsigned; + arg = format!("{}", meta.io_size()); + output_type = OutputType::Unsigned; } // fundamental block size (for block counts) 'S' => { - arg = format!("{}", meta.blksize()); - otype = OutputType::Unsigned; + arg = format!("{}", meta.block_size()); + output_type = OutputType::Unsigned; } // file system type in hex 't' => { arg = format!("{:x}", meta.fs_type()); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // file system type in human readable form 'T' => { arg = pretty_fstype(meta.fs_type()).into_owned(); - otype = OutputType::Str; + output_type = OutputType::Str; } _ => { arg = "?".to_owned(); - otype = OutputType::Unknown; + output_type = OutputType::Unknown; } } - print_it(&arg, otype, flag, width, precision); + print_it(&arg, output_type, flag, width, precision); } } } @@ -850,34 +848,33 @@ impl Stater { 0 } - // taken from coreutils/src/stat.c - fn default_fmt(showfs: bool, terse: bool, dev: bool) -> String { + fn default_format(show_fs: bool, terse: bool, show_dev_type: bool) -> String { // SELinux related format is *ignored* - let mut fmtstr = String::with_capacity(36); - if showfs { + let mut format_str = String::with_capacity(36); + if show_fs { if terse { - fmtstr.push_str("%n %i %l %t %s %S %b %f %a %c %d\n"); + format_str.push_str("%n %i %l %t %s %S %b %f %a %c %d\n"); } else { - fmtstr.push_str( + format_str.push_str( " File: \"%n\"\n ID: %-8i Namelen: %-7l Type: %T\nBlock \ size: %-10s Fundamental block size: %S\nBlocks: Total: %-10b \ Free: %-10f Available: %a\nInodes: Total: %-10c Free: %d\n", ); } } else if terse { - fmtstr.push_str("%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %W %o\n"); + format_str.push_str("%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %W %o\n"); } else { - fmtstr.push_str(" File: %N\n Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"); - if dev { - fmtstr.push_str("Device: %Dh/%dd\tInode: %-10i Links: %-5h Device type: %t,%T\n"); + format_str.push_str(" File: %N\n Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"); + if show_dev_type { + format_str.push_str("Device: %Dh/%dd\tInode: %-10i Links: %-5h Device type: %t,%T\n"); } else { - fmtstr.push_str("Device: %Dh/%dd\tInode: %-10i Links: %h\n"); + format_str.push_str("Device: %Dh/%dd\tInode: %-10i Links: %h\n"); } - fmtstr.push_str("Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"); - fmtstr.push_str("Access: %x\nModify: %y\nChange: %z\n Birth: %w\n"); + format_str.push_str("Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"); + format_str.push_str("Access: %x\nModify: %y\nChange: %z\n Birth: %w\n"); } - fmtstr + format_str } } From 879ac263bd378316525fb073d3fd122fbf429d22 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:37:45 -0500 Subject: [PATCH 092/126] refactor/test ~ polish spelling (comments, names, and exceptions) --- src/uu/test/src/parser.rs | 2 ++ src/uu/test/src/test.rs | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/uu/test/src/parser.rs b/src/uu/test/src/parser.rs index a77bfabb3..d4302bd67 100644 --- a/src/uu/test/src/parser.rs +++ b/src/uu/test/src/parser.rs @@ -5,6 +5,8 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +// spell-checker:ignore (grammar) BOOLOP STRLEN FILETEST FILEOP INTOP STRINGOP ; (vars) LParen StrlenOp + use std::ffi::OsString; use std::iter::Peekable; diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index 86950ecc2..acf0f7eca 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -6,7 +6,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) retval paren prec subprec cond +// spell-checker:ignore (vars) FiletestOp StrlenOp mod parser; @@ -122,7 +122,7 @@ fn eval(stack: &mut Vec) -> Result { } } -fn integers(a: &OsStr, b: &OsStr, cond: &OsStr) -> Result { +fn integers(a: &OsStr, b: &OsStr, op: &OsStr) -> Result { let format_err = |value| format!("invalid integer ‘{}’", value); let a = a.to_string_lossy(); @@ -131,15 +131,15 @@ fn integers(a: &OsStr, b: &OsStr, cond: &OsStr) -> Result { let b = b.to_string_lossy(); let b: i64 = b.parse().map_err(|_| format_err(b))?; - let cond = cond.to_string_lossy(); - Ok(match cond.as_ref() { + let operator = op.to_string_lossy(); + Ok(match operator.as_ref() { "-eq" => a == b, "-ne" => a != b, "-gt" => a > b, "-ge" => a >= b, "-lt" => a < b, "-le" => a <= b, - _ => return Err(format!("unknown operator ‘{}’", cond)), + _ => return Err(format!("unknown operator ‘{}’", operator)), }) } @@ -177,7 +177,7 @@ enum PathCondition { } #[cfg(not(windows))] -fn path(path: &OsStr, cond: PathCondition) -> bool { +fn path(path: &OsStr, condition: PathCondition) -> bool { use std::fs::{self, Metadata}; use std::os::unix::fs::{FileTypeExt, MetadataExt}; @@ -208,7 +208,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { } }; - let metadata = if cond == PathCondition::SymLink { + let metadata = if condition == PathCondition::SymLink { fs::symlink_metadata(path) } else { fs::metadata(path) @@ -223,7 +223,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { let file_type = metadata.file_type(); - match cond { + match condition { PathCondition::BlockSpecial => file_type.is_block_device(), PathCondition::CharacterSpecial => file_type.is_char_device(), PathCondition::Directory => file_type.is_dir(), @@ -242,7 +242,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { } #[cfg(windows)] -fn path(path: &OsStr, cond: PathCondition) -> bool { +fn path(path: &OsStr, condition: PathCondition) -> bool { use std::fs::metadata; let stat = match metadata(path) { @@ -250,7 +250,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { _ => return false, }; - match cond { + match condition { PathCondition::BlockSpecial => false, PathCondition::CharacterSpecial => false, PathCondition::Directory => stat.is_dir(), From b1a2f6e044c3d1c98854435c6455679071da171f Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:41:09 -0500 Subject: [PATCH 093/126] refactor/tee ~ polish spelling (comments, names, and exceptions) --- src/uu/tee/src/tee.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index c21559b3b..82a06daa2 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -119,7 +119,7 @@ fn tee(options: Options) -> Result<()> { // TODO: replaced generic 'copy' call to be able to stop copying // if all outputs are closed (due to errors) - if copy(input, &mut output).is_err() || output.flush().is_err() || output.error_occured() { + if copy(input, &mut output).is_err() || output.flush().is_err() || output.error_occurred() { Err(Error::new(ErrorKind::Other, "")) } else { Ok(()) @@ -155,7 +155,7 @@ impl MultiWriter { writers, } } - fn error_occured(&self) -> bool { + fn error_occurred(&self) -> bool { self.writers.len() != self.initial_len } } From f6a079a77fe99d6769c1ddec68dd8e8beab507e3 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:38:03 -0500 Subject: [PATCH 094/126] refactor/timeout ~ polish spelling (comments, names, and exceptions) --- src/uu/timeout/src/timeout.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index 7d557f1ce..dc8979143 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -159,8 +159,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ) } -/// TODO: Improve exit codes, and make them consistent with the GNU Coreutil -/// exit codes. +/// TODO: Improve exit codes, and make them consistent with the GNU Coreutils exit codes. fn timeout( cmdname: &str, From 954b3436d940e31954ec60f074fd3170ecbcdd20 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 11:53:40 -0500 Subject: [PATCH 095/126] refactor/truncate ~ polish spelling (comments, names, and exceptions) --- src/uu/truncate/src/truncate.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 3a6077b3c..50ab5c45e 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -40,13 +40,13 @@ impl TruncateMode { /// ``` fn to_size(&self, fsize: u64) -> u64 { match self { - TruncateMode::Absolute(modsize) => *modsize, - TruncateMode::Extend(modsize) => fsize + modsize, - TruncateMode::Reduce(modsize) => fsize - modsize, - TruncateMode::AtMost(modsize) => fsize.min(*modsize), - TruncateMode::AtLeast(modsize) => fsize.max(*modsize), - TruncateMode::RoundDown(modsize) => fsize - fsize % modsize, - TruncateMode::RoundUp(modsize) => fsize + fsize % modsize, + TruncateMode::Absolute(size) => *size, + TruncateMode::Extend(size) => fsize + size, + TruncateMode::Reduce(size) => fsize - size, + TruncateMode::AtMost(size) => fsize.min(*size), + TruncateMode::AtLeast(size) => fsize.max(*size), + TruncateMode::RoundDown(size) => fsize - fsize % size, + TruncateMode::RoundUp(size) => fsize + fsize % size, } } } From 40e136d0923275af260ab10640812f2bc854a2a8 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 29 May 2021 22:25:46 -0500 Subject: [PATCH 096/126] refactor/uucore ~ polish spelling (comments, names, and exceptions) --- src/uucore/src/lib/features/fs.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index afaa07af1..38cdbef94 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -390,8 +390,8 @@ mod tests { test: "C:/you/later", }, NormalizePathTestCase { - path: "\\networkshare/a//foo//./bar", - test: "\\networkshare/a/foo/bar", + path: "\\networkShare/a//foo//./bar", + test: "\\networkShare/a/foo/bar", }, ]; @@ -411,6 +411,7 @@ mod tests { #[cfg(unix)] #[test] fn test_display_permissions() { + // spell-checker:ignore (perms) brwsr drwxr rwxr assert_eq!( "drwxr-xr-x", display_permissions_unix(S_IFDIR | 0o755, true) From 3d42454ebc52578a8e797a15fc56bbb736fefc48 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:38:16 -0500 Subject: [PATCH 097/126] refactor/users ~ polish spelling (comments, names, and exceptions) --- src/uu/users/src/users.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index 99e06c1af..664ff55f3 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -6,6 +6,8 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. +// spell-checker:ignore (paths) wtmp + #[macro_use] extern crate uucore; From dff33a0edbb7f406652047a0e689c23cdcc14167 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 11:59:16 -0500 Subject: [PATCH 098/126] refactor/wc ~ polish spelling (comments, names, and exceptions) --- src/uu/wc/src/wc.rs | 6 ++---- src/uu/wc/src/{wordcount.rs => word_count.rs} | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) rename src/uu/wc/src/{wordcount.rs => word_count.rs} (98%) diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 6e95254ee..d990c6679 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -5,17 +5,15 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore (ToDO) fpath - #[macro_use] extern crate uucore; mod count_bytes; mod countable; -mod wordcount; +mod word_count; use count_bytes::count_bytes_fast; use countable::WordCountable; -use wordcount::{TitledWordCount, WordCount}; +use word_count::{TitledWordCount, WordCount}; use clap::{App, Arg, ArgMatches}; use thiserror::Error; diff --git a/src/uu/wc/src/wordcount.rs b/src/uu/wc/src/word_count.rs similarity index 98% rename from src/uu/wc/src/wordcount.rs rename to src/uu/wc/src/word_count.rs index 9e2a81fca..bdb510f58 100644 --- a/src/uu/wc/src/wordcount.rs +++ b/src/uu/wc/src/word_count.rs @@ -123,7 +123,7 @@ impl WordCount { /// This struct supplements the actual word count with an optional title that is /// displayed to the user at the end of the program. /// The reason we don't simply include title in the `WordCount` struct is that -/// it would result in unneccesary copying of `String`. +/// it would result in unnecessary copying of `String`. #[derive(Debug, Default, Clone)] pub struct TitledWordCount<'a> { pub title: Option<&'a str>, From 5c9b474cc8438a1df83990bfe5f6747d9e514b4f Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 29 May 2021 22:24:30 -0500 Subject: [PATCH 099/126] refactor/whoami ~ polish spelling (comments, names, and exceptions) --- src/uu/whoami/src/platform/mod.rs | 4 ++-- src/uu/whoami/src/platform/unix.rs | 2 +- src/uu/whoami/src/platform/windows.rs | 4 +--- src/uu/whoami/src/whoami.rs | 4 +--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/uu/whoami/src/platform/mod.rs b/src/uu/whoami/src/platform/mod.rs index ab0b856e6..b5064a8d2 100644 --- a/src/uu/whoami/src/platform/mod.rs +++ b/src/uu/whoami/src/platform/mod.rs @@ -10,10 +10,10 @@ // spell-checker:ignore (ToDO) getusername #[cfg(unix)] -pub use self::unix::getusername; +pub use self::unix::get_username; #[cfg(windows)] -pub use self::windows::getusername; +pub use self::windows::get_username; #[cfg(unix)] mod unix; diff --git a/src/uu/whoami/src/platform/unix.rs b/src/uu/whoami/src/platform/unix.rs index 33bfa6025..3d5fc6f54 100644 --- a/src/uu/whoami/src/platform/unix.rs +++ b/src/uu/whoami/src/platform/unix.rs @@ -14,7 +14,7 @@ use std::io::Result; use uucore::entries::uid2usr; use uucore::libc::geteuid; -pub unsafe fn getusername() -> Result { +pub unsafe fn get_username() -> Result { // Get effective user id let uid = geteuid(); uid2usr(uid) diff --git a/src/uu/whoami/src/platform/windows.rs b/src/uu/whoami/src/platform/windows.rs index 1d65281bd..5d648877b 100644 --- a/src/uu/whoami/src/platform/windows.rs +++ b/src/uu/whoami/src/platform/windows.rs @@ -7,8 +7,6 @@ * file that was distributed with this source code. */ -// spell-checker:ignore (ToDO) advapi lmcons winnt getusername WCHAR UNLEN - extern crate winapi; use self::winapi::shared::lmcons; @@ -18,7 +16,7 @@ use std::io::{Error, Result}; use std::mem; use uucore::wide::FromWide; -pub unsafe fn getusername() -> Result { +pub unsafe fn get_username() -> Result { #[allow(deprecated)] let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized(); let mut len = buffer.len() as minwindef::DWORD; diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index 21e170dec..383fb40b5 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -7,8 +7,6 @@ /* last synced with: whoami (GNU coreutils) 8.21 */ -// spell-checker:ignore (ToDO) getusername - #[macro_use] extern crate clap; #[macro_use] @@ -38,7 +36,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { pub fn exec() { unsafe { - match platform::getusername() { + match platform::get_username() { Ok(username) => println!("{}", username), Err(err) => match err.raw_os_error() { Some(0) | None => crash!(1, "failed to get username"), From 4e20dedf584daba1fa62b2ebeebac6706a5dcf89 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 00:10:54 -0500 Subject: [PATCH 100/126] tests ~ refactor/polish spelling (comments, names, and exceptions) --- tests/benches/factor/benches/gcd.rs | 2 +- tests/benches/factor/benches/table.rs | 4 +- tests/by-util/test_base32.rs | 14 +-- tests/by-util/test_base64.rs | 13 +-- tests/by-util/test_basename.rs | 8 +- tests/by-util/test_cat.rs | 22 +++-- tests/by-util/test_chgrp.rs | 2 + tests/by-util/test_chmod.rs | 24 +++--- tests/by-util/test_chown.rs | 2 + tests/by-util/test_chroot.rs | 2 + tests/by-util/test_cksum.rs | 18 ++-- tests/by-util/test_comm.rs | 14 +-- tests/by-util/test_cp.rs | 12 +-- tests/by-util/test_csplit.rs | 28 +++--- tests/by-util/test_date.rs | 2 +- tests/by-util/test_dircolors.rs | 6 +- tests/by-util/test_du.rs | 2 + tests/by-util/test_echo.rs | 6 +- tests/by-util/test_env.rs | 2 + tests/by-util/test_factor.rs | 86 ++++++++++--------- tests/by-util/test_fold.rs | 16 ++-- tests/by-util/test_head.rs | 2 + tests/by-util/test_install.rs | 2 + tests/by-util/test_join.rs | 4 +- tests/by-util/test_kill.rs | 3 +- tests/by-util/test_ln.rs | 8 +- tests/by-util/test_ls.rs | 4 +- tests/by-util/test_mktemp.rs | 6 +- tests/by-util/test_more.rs | 2 +- tests/by-util/test_mv.rs | 2 +- tests/by-util/test_nice.rs | 2 +- tests/by-util/test_nl.rs | 4 +- tests/by-util/test_numfmt.rs | 4 +- tests/by-util/test_od.rs | 40 +++++---- tests/by-util/test_pinky.rs | 18 ++-- tests/by-util/test_printf.rs | 36 ++++---- tests/by-util/test_ptx.rs | 20 ++--- tests/by-util/test_pwd.rs | 2 +- tests/by-util/test_relpath.rs | 8 +- tests/by-util/test_rm.rs | 2 +- tests/by-util/test_shuf.rs | 2 +- tests/by-util/test_sort.rs | 20 +++-- tests/by-util/test_split.rs | 4 +- tests/by-util/test_stat.rs | 28 +++--- tests/by-util/test_tail.rs | 8 +- tests/by-util/test_test.rs | 26 +++--- tests/by-util/test_timeout.rs | 2 +- tests/by-util/test_touch.rs | 10 ++- tests/by-util/test_tr.rs | 22 ++--- tests/by-util/test_truncate.rs | 62 ++++++------- tests/by-util/test_uname.rs | 2 +- tests/by-util/test_unexpand.rs | 6 +- tests/by-util/test_uptime.rs | 2 +- tests/by-util/test_users.rs | 2 +- tests/by-util/test_wc.rs | 2 + tests/by-util/test_who.rs | 2 + tests/common/util.rs | 10 ++- ...ctories_and_file_and_stdin.stderr.expected | 2 +- ..._ext_disabled_rightward_auto_ref.expected} | 0 ...ext_disabled_rightward_input_ref.expected} | 0 ...nu_ext_disabled_rightward_no_ref.expected} | 0 ...ard_no_ref_word_regexp_exc_space.expected} | 0 .../foobar_follow_multiple_appended.expected | 4 +- 63 files changed, 368 insertions(+), 302 deletions(-) rename tests/fixtures/ptx/{gnu_ext_disabled_roff_auto_ref.expected => gnu_ext_disabled_rightward_auto_ref.expected} (100%) rename tests/fixtures/ptx/{gnu_ext_disabled_roff_input_ref.expected => gnu_ext_disabled_rightward_input_ref.expected} (100%) rename tests/fixtures/ptx/{gnu_ext_disabled_roff_no_ref.expected => gnu_ext_disabled_rightward_no_ref.expected} (100%) rename tests/fixtures/ptx/{gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected => gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space.expected} (100%) diff --git a/tests/benches/factor/benches/gcd.rs b/tests/benches/factor/benches/gcd.rs index 803c37d3c..f2bae51c7 100644 --- a/tests/benches/factor/benches/gcd.rs +++ b/tests/benches/factor/benches/gcd.rs @@ -3,7 +3,7 @@ use uu_factor::numeric; fn gcd(c: &mut Criterion) { let inputs = { - // Deterministic RNG; use an explicitely-named RNG to guarantee stability + // Deterministic RNG; use an explicitly-named RNG to guarantee stability use rand::{RngCore, SeedableRng}; use rand_chacha::ChaCha8Rng; const SEED: u64 = 0xa_b4d_1dea_dead_cafe; diff --git a/tests/benches/factor/benches/table.rs b/tests/benches/factor/benches/table.rs index 0b31b2b4c..d8859d940 100644 --- a/tests/benches/factor/benches/table.rs +++ b/tests/benches/factor/benches/table.rs @@ -15,10 +15,10 @@ fn table(c: &mut Criterion) { CHUNK_SIZE ); let inputs = { - // Deterministic RNG; use an explicitely-named RNG to guarantee stability + // Deterministic RNG; use an explicitly-named RNG to guarantee stability use rand::{RngCore, SeedableRng}; use rand_chacha::ChaCha8Rng; - const SEED: u64 = 0xdead_bebe_ea75_cafe; + const SEED: u64 = 0xdead_bebe_ea75_cafe; // spell-checker:disable-line let mut rng = ChaCha8Rng::seed_from_u64(SEED); std::iter::repeat_with(move || array_init::<_, _, INPUT_SIZE>(|_| rng.next_u64())) diff --git a/tests/by-util/test_base32.rs b/tests/by-util/test_base32.rs index 788b85efa..8e3e780c5 100644 --- a/tests/by-util/test_base32.rs +++ b/tests/by-util/test_base32.rs @@ -14,14 +14,14 @@ fn test_encode() { new_ucmd!() .pipe_in(input) .succeeds() - .stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); + .stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); // spell-checker:disable-line // Using '-' as our file new_ucmd!() .arg("-") .pipe_in(input) .succeeds() - .stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); + .stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); // spell-checker:disable-line } #[test] @@ -29,13 +29,13 @@ fn test_base32_encode_file() { new_ucmd!() .arg("input-simple.txt") .succeeds() - .stdout_only("JBSWY3DPFQQFO33SNRSCCCQ=\n"); + .stdout_only("JBSWY3DPFQQFO33SNRSCCCQ=\n"); // spell-checker:disable-line } #[test] fn test_decode() { for decode_param in &["-d", "--decode"] { - let input = "JBSWY3DPFQQFO33SNRSCC===\n"; + let input = "JBSWY3DPFQQFO33SNRSCC===\n"; // spell-checker:disable-line new_ucmd!() .arg(decode_param) .pipe_in(input) @@ -46,7 +46,7 @@ fn test_decode() { #[test] fn test_garbage() { - let input = "aGVsbG8sIHdvcmxkIQ==\0"; + let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line new_ucmd!() .arg("-d") .pipe_in(input) @@ -57,7 +57,7 @@ fn test_garbage() { #[test] fn test_ignore_garbage() { for ignore_garbage_param in &["-i", "--ignore-garbage"] { - let input = "JBSWY\x013DPFQ\x02QFO33SNRSCC===\n"; + let input = "JBSWY\x013DPFQ\x02QFO33SNRSCC===\n"; // spell-checker:disable-line new_ucmd!() .arg("-d") .arg(ignore_garbage_param) @@ -77,7 +77,7 @@ fn test_wrap() { .pipe_in(input) .succeeds() .stdout_only( - "KRUGKIDROVUWG2ZAMJZG\n653OEBTG66BANJ2W24DT\nEBXXMZLSEB2GQZJANRQX\nU6JAMRXWOLQ=\n", + "KRUGKIDROVUWG2ZAMJZG\n653OEBTG66BANJ2W24DT\nEBXXMZLSEB2GQZJANRQX\nU6JAMRXWOLQ=\n", // spell-checker:disable-line ); } } diff --git a/tests/by-util/test_base64.rs b/tests/by-util/test_base64.rs index 75445c933..459845ccf 100644 --- a/tests/by-util/test_base64.rs +++ b/tests/by-util/test_base64.rs @@ -6,14 +6,14 @@ fn test_encode() { new_ucmd!() .pipe_in(input) .succeeds() - .stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); + .stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); // spell-checker:disable-line // Using '-' as our file new_ucmd!() .arg("-") .pipe_in(input) .succeeds() - .stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); + .stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); // spell-checker:disable-line } #[test] @@ -21,13 +21,13 @@ fn test_base64_encode_file() { new_ucmd!() .arg("input-simple.txt") .succeeds() - .stdout_only("SGVsbG8sIFdvcmxkIQo=\n"); + .stdout_only("SGVsbG8sIFdvcmxkIQo=\n"); // spell-checker:disable-line } #[test] fn test_decode() { for decode_param in &["-d", "--decode"] { - let input = "aGVsbG8sIHdvcmxkIQ=="; + let input = "aGVsbG8sIHdvcmxkIQ=="; // spell-checker:disable-line new_ucmd!() .arg(decode_param) .pipe_in(input) @@ -38,7 +38,7 @@ fn test_decode() { #[test] fn test_garbage() { - let input = "aGVsbG8sIHdvcmxkIQ==\0"; + let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line new_ucmd!() .arg("-d") .pipe_in(input) @@ -49,7 +49,7 @@ fn test_garbage() { #[test] fn test_ignore_garbage() { for ignore_garbage_param in &["-i", "--ignore-garbage"] { - let input = "aGVsbG8sIHdvcmxkIQ==\0"; + let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line new_ucmd!() .arg("-d") .arg(ignore_garbage_param) @@ -68,6 +68,7 @@ fn test_wrap() { .arg("20") .pipe_in(input) .succeeds() + // spell-checker:disable-next-line .stdout_only("VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n"); } } diff --git a/tests/by-util/test_basename.rs b/tests/by-util/test_basename.rs index 50d22b2eb..d9632106e 100644 --- a/tests/by-util/test_basename.rs +++ b/tests/by-util/test_basename.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) reallylongexecutable + use crate::common::util::*; #[cfg(any(unix, target_os = "redox"))] use std::ffi::OsStr; @@ -50,7 +52,7 @@ fn test_remove_suffix() { } #[test] -fn test_dont_remove_suffix() { +fn test_do_not_remove_suffix() { new_ucmd!() .args(&["/foo/bar/baz", "baz"]) .succeeds() @@ -64,7 +66,7 @@ fn test_multiple_param() { new_ucmd!() .args(&[multiple_param, path, path]) .succeeds() - .stdout_only("baz\nbaz\n"); + .stdout_only("baz\nbaz\n"); // spell-checker:disable-line } } @@ -75,7 +77,7 @@ fn test_suffix_param() { new_ucmd!() .args(&[suffix_param, ".exe", path, path]) .succeeds() - .stdout_only("baz\nbaz\n"); + .stdout_only("baz\nbaz\n"); // spell-checker:disable-line } } diff --git a/tests/by-util/test_cat.rs b/tests/by-util/test_cat.rs index 8ea5bbaae..b00c58dc1 100644 --- a/tests/by-util/test_cat.rs +++ b/tests/by-util/test_cat.rs @@ -9,11 +9,12 @@ fn test_output_simple() { new_ucmd!() .args(&["alpha.txt"]) .succeeds() - .stdout_only("abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); + .stdout_only("abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line } #[test] fn test_no_options() { + // spell-checker:disable-next-line for fixture in &["empty.txt", "alpha.txt", "nonewline.txt"] { // Give fixture through command line file argument new_ucmd!() @@ -66,8 +67,8 @@ fn test_fifo_symlink() { assert!(s.fixtures.is_fifo("dir/pipe")); // Make cat read the pipe through a symlink - s.fixtures.symlink_file("dir/pipe", "sympipe"); - let proc = s.ucmd().args(&["sympipe"]).run_no_wait(); + s.fixtures.symlink_file("dir/pipe", "sympipe"); // spell-checker:disable-line + let proc = s.ucmd().args(&["sympipe"]).run_no_wait(); // spell-checker:disable-line let data = vec_of_size(128 * 1024); let data2 = data.clone(); @@ -110,7 +111,7 @@ fn test_piped_to_regular_file() { .succeeds(); } let contents = read_to_string(&file_path).unwrap(); - assert_eq!(contents, "abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); + assert_eq!(contents, "abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line } } @@ -169,6 +170,7 @@ fn test_directory() { fn test_directory_and_file() { let s = TestScenario::new(util_name!()); s.fixtures.mkdir("test_directory2"); + // spell-checker:disable-next-line for fixture in &["empty.txt", "alpha.txt", "nonewline.txt"] { s.ucmd() .args(&["test_directory2", fixture]) @@ -190,8 +192,8 @@ fn test_three_directories_and_file_and_stdin() { "test_directory3/test_directory4", "alpha.txt", "-", - "filewhichdoesnotexist.txt", - "nonewline.txt", + "file_which_does_not_exist.txt", + "nonewline.txt", // spell-checker:disable-line "test_directory3/test_directory5", "test_directory3/../test_directory3/test_directory5", "test_directory3", @@ -200,12 +202,13 @@ fn test_three_directories_and_file_and_stdin() { .fails() .stderr_is_fixture("three_directories_and_file_and_stdin.stderr.expected") .stdout_is( - "abcde\nfghij\nklmno\npqrst\nuvwxyz\nstdout bytestext without a trailing newline", + "abcde\nfghij\nklmno\npqrst\nuvwxyz\nstdout bytestext without a trailing newline", // spell-checker:disable-line ); } #[test] fn test_output_multi_files_print_all_chars() { + // spell-checker:disable new_ucmd!() .args(&["alpha.txt", "256.txt", "-A", "-n"]) .succeeds() @@ -222,10 +225,12 @@ fn test_output_multi_files_print_all_chars() { M-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-\ pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?", ); + // spell-checker:enable } #[test] fn test_numbered_lines_no_trailing_newline() { + // spell-checker:disable new_ucmd!() .args(&["nonewline.txt", "alpha.txt", "-n"]) .succeeds() @@ -233,6 +238,7 @@ fn test_numbered_lines_no_trailing_newline() { " 1\ttext without a trailing newlineabcde\n 2\tfghij\n \ 3\tklmno\n 4\tpqrst\n 5\tuvwxyz\n", ); + // spell-checker:enable } #[test] @@ -310,6 +316,7 @@ fn test_stdin_squeeze_blank() { #[test] fn test_stdin_number_non_blank() { + // spell-checker:disable-next-line for same_param in &["-b", "--number-nonblank"] { new_ucmd!() .arg(same_param) @@ -322,6 +329,7 @@ fn test_stdin_number_non_blank() { #[test] fn test_non_blank_overrides_number() { + // spell-checker:disable-next-line for &same_param in &["-b", "--number-nonblank"] { new_ucmd!() .args(&[same_param, "-"]) diff --git a/tests/by-util/test_chgrp.rs b/tests/by-util/test_chgrp.rs index c0fc503ae..45380b80b 100644 --- a/tests/by-util/test_chgrp.rs +++ b/tests/by-util/test_chgrp.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) nosuchgroup + use crate::common::util::*; use rust_users::*; diff --git a/tests/by-util/test_chmod.rs b/tests/by-util/test_chmod.rs index 4611d1b96..186c645e5 100644 --- a/tests/by-util/test_chmod.rs +++ b/tests/by-util/test_chmod.rs @@ -21,7 +21,7 @@ struct TestCase { after: u32, } -fn mkfile(file: &str, mode: u32) { +fn make_file(file: &str, mode: u32) { OpenOptions::new() .mode(mode) .create(true) @@ -34,7 +34,7 @@ fn mkfile(file: &str, mode: u32) { } fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) { - mkfile(&at.plus_as_string(TEST_FILE), test.before); + make_file(&at.plus_as_string(TEST_FILE), test.before); let perms = at.metadata(TEST_FILE).permissions().mode(); if perms != test.before { panic!( @@ -123,6 +123,7 @@ fn test_chmod_octal() { #[test] #[allow(clippy::unreadable_literal)] +// spell-checker:disable-next-line fn test_chmod_ugoa() { let _guard = UMASK_MUTEX.lock(); @@ -283,7 +284,7 @@ fn test_chmod_reference_file() { }, ]; let (at, ucmd) = at_and_ucmd!(); - mkfile(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS); + make_file(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS); run_single_test(&tests[0], at, ucmd); } @@ -318,10 +319,10 @@ fn test_chmod_recursive() { at.mkdir("a/b"); at.mkdir("a/b/c"); at.mkdir("z"); - mkfile(&at.plus_as_string("a/a"), 0o100444); - mkfile(&at.plus_as_string("a/b/b"), 0o100444); - mkfile(&at.plus_as_string("a/b/c/c"), 0o100444); - mkfile(&at.plus_as_string("z/y"), 0o100444); + make_file(&at.plus_as_string("a/a"), 0o100444); + make_file(&at.plus_as_string("a/b/b"), 0o100444); + make_file(&at.plus_as_string("a/b/c/c"), 0o100444); + make_file(&at.plus_as_string("z/y"), 0o100444); ucmd.arg("-R") .arg("--verbose") @@ -351,9 +352,9 @@ fn test_chmod_non_existing_file() { .arg("-R") .arg("--verbose") .arg("-r,a+w") - .arg("dont-exist") + .arg("does-not-exist") .fails() - .stderr_contains(&"cannot access 'dont-exist': No such file or directory"); + .stderr_contains(&"cannot access 'does-not-exist': No such file or directory"); } #[test] @@ -432,6 +433,7 @@ fn test_chmod_symlink_non_existing_file_recursive() { .no_stdout(); let expected_stdout = &format!( + // spell-checker:disable-next-line "mode of '{}' retained as 0755 (rwxr-xr-x)\nneither symbolic link '{}/{}' nor referent has been changed", test_directory, test_directory, test_symlink ); @@ -473,8 +475,8 @@ fn test_chmod_strip_minus_from_mode() { ("chmod -c -R +w FILE ", "chmod -c -R +w FILE "), ("chmod a=r,=xX FILE", "chmod a=r,=xX FILE"), ( - "chmod -v --reference RFILE -R FILE", - "chmod -v --reference RFILE -R FILE", + "chmod -v --reference REF_FILE -R FILE", + "chmod -v --reference REF_FILE -R FILE", ), ("chmod -Rvc -w-x FILE", "chmod -Rvc w-x FILE"), ("chmod 755 -v FILE", "chmod 755 -v FILE"), diff --git a/tests/by-util/test_chown.rs b/tests/by-util/test_chown.rs index a531fc7f3..c8a8ea538 100644 --- a/tests/by-util/test_chown.rs +++ b/tests/by-util/test_chown.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist groupname notexisting passgrp + use crate::common::util::*; #[cfg(target_os = "linux")] use rust_users::get_effective_uid; diff --git a/tests/by-util/test_chroot.rs b/tests/by-util/test_chroot.rs index 0479e7c3a..3bac07d44 100644 --- a/tests/by-util/test_chroot.rs +++ b/tests/by-util/test_chroot.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) araba newroot userspec + use crate::common::util::*; #[test] diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs index 0fd028781..9590c1ac5 100644 --- a/tests/by-util/test_cksum.rs +++ b/tests/by-util/test_cksum.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) asdf + use crate::common::util::*; #[test] @@ -40,7 +42,7 @@ fn test_empty() { #[test] fn test_arg_overrides_stdin() { let (at, mut ucmd) = at_and_ucmd!(); - let input = "foobarfoobar"; + let input = "foobarfoobar"; // spell-checker:disable-line at.touch("a"); @@ -78,17 +80,17 @@ fn test_invalid_file() { } // Make sure crc is correct for files larger than 32 bytes -// but <128 bytes (1 fold pclmul) +// but <128 bytes (1 fold pclmul) // spell-checker:disable-line #[test] fn test_crc_for_bigger_than_32_bytes() { let (_, mut ucmd) = at_and_ucmd!(); let result = ucmd.arg("chars.txt").succeeds(); - let mut stdout_splitted = result.stdout_str().split(' '); + let mut stdout_split = result.stdout_str().split(' '); - let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap(); - let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap(); + let cksum: i64 = stdout_split.next().unwrap().parse().unwrap(); + let bytes_cnt: i64 = stdout_split.next().unwrap().parse().unwrap(); assert_eq!(cksum, 586_047_089); assert_eq!(bytes_cnt, 16); @@ -100,10 +102,10 @@ fn test_stdin_larger_than_128_bytes() { let result = ucmd.arg("larger_than_2056_bytes.txt").succeeds(); - let mut stdout_splitted = result.stdout_str().split(' '); + let mut stdout_split = result.stdout_str().split(' '); - let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap(); - let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap(); + let cksum: i64 = stdout_split.next().unwrap().parse().unwrap(); + let bytes_cnt: i64 = stdout_split.next().unwrap().parse().unwrap(); assert_eq!(cksum, 945_881_979); assert_eq!(bytes_cnt, 2058); diff --git a/tests/by-util/test_comm.rs b/tests/by-util/test_comm.rs index fa8c8beca..ba26f6819 100644 --- a/tests/by-util/test_comm.rs +++ b/tests/by-util/test_comm.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) defaultcheck nocheck + use crate::common::util::*; #[test] @@ -33,19 +35,19 @@ fn ab_dash_three() { } #[test] -fn aempty() { +fn a_empty() { new_ucmd!() .args(&["a", "empty"]) .succeeds() - .stdout_only_fixture("aempty.expected"); + .stdout_only_fixture("aempty.expected"); // spell-checker:disable-line } #[test] -fn emptyempty() { +fn empty_empty() { new_ucmd!() .args(&["empty", "empty"]) .succeeds() - .stdout_only_fixture("emptyempty.expected"); + .stdout_only_fixture("emptyempty.expected"); // spell-checker:disable-line } #[cfg_attr(not(feature = "test_unimplemented"), ignore)] @@ -68,8 +70,8 @@ fn output_delimiter_require_arg() { // even though (info) documentation suggests this is an option // in latest GNU Coreutils comm, it actually is not. -// this test is essentially an alarm in case someone well-intendingly -// implements it. +// this test is essentially an alarm in case some well-intending +// developer implements it. //marked as unimplemented as error message not set yet. #[cfg_attr(not(feature = "test_unimplemented"), ignore)] #[test] diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index e4d7fdea7..e995cc56c 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (flags) reflink (fs) tmpfs + use crate::common::util::*; #[cfg(not(windows))] use std::fs::set_permissions; @@ -926,7 +928,7 @@ fn test_cp_archive() { let (at, mut ucmd) = at_and_ucmd!(); let ts = time::now().to_timespec(); let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32); - // set the file creation/modif an hour ago + // set the file creation/modification an hour ago filetime::set_file_times( at.plus_as_string(TEST_HELLO_WORLD_SOURCE), previous, @@ -1055,7 +1057,7 @@ fn test_cp_preserve_timestamps() { let (at, mut ucmd) = at_and_ucmd!(); let ts = time::now().to_timespec(); let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32); - // set the file creation/modif an hour ago + // set the file creation/modification an hour ago filetime::set_file_times( at.plus_as_string(TEST_HELLO_WORLD_SOURCE), previous, @@ -1084,11 +1086,11 @@ fn test_cp_preserve_timestamps() { #[test] #[cfg(target_os = "linux")] -fn test_cp_dont_preserve_timestamps() { +fn test_cp_no_preserve_timestamps() { let (at, mut ucmd) = at_and_ucmd!(); let ts = time::now().to_timespec(); let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32); - // set the file creation/modif an hour ago + // set the file creation/modification an hour ago filetime::set_file_times( at.plus_as_string(TEST_HELLO_WORLD_SOURCE), previous, @@ -1181,7 +1183,7 @@ fn test_cp_one_file_system() { scene.cmd("umount").arg(mountpoint_path).succeeds(); assert!(!at_dst.file_exists(TEST_MOUNT_OTHER_FILESYSTEM_FILE)); - // Check if the other files were copied from the source folder hirerarchy + // Check if the other files were copied from the source folder hierarchy for entry in WalkDir::new(at_src.as_string()) { let entry = entry.unwrap(); let relative_src = entry diff --git a/tests/by-util/test_csplit.rs b/tests/by-util/test_csplit.rs index ae0885ff8..7eeb584eb 100644 --- a/tests/by-util/test_csplit.rs +++ b/tests/by-util/test_csplit.rs @@ -904,7 +904,7 @@ fn test_no_match() { } #[test] -fn test_too_small_linenum() { +fn test_too_small_line_num() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/", "10", "/40/"]) .succeeds() @@ -921,7 +921,7 @@ fn test_too_small_linenum() { } #[test] -fn test_too_small_linenum_equal() { +fn test_too_small_line_num_equal() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/", "20"]) .succeeds() @@ -937,7 +937,7 @@ fn test_too_small_linenum_equal() { } #[test] -fn test_too_small_linenum_elided() { +fn test_too_small_line_num_elided() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "-z", "/20/", "10", "/40/"]) .succeeds() @@ -953,7 +953,7 @@ fn test_too_small_linenum_elided() { } #[test] -fn test_too_small_linenum_negative_offset() { +fn test_too_small_line_num_negative_offset() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/-5", "10", "/40/"]) .succeeds() @@ -970,7 +970,7 @@ fn test_too_small_linenum_negative_offset() { } #[test] -fn test_too_small_linenum_twice() { +fn test_too_small_line_num_twice() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/", "10", "15", "/40/"]) .succeeds() @@ -988,7 +988,7 @@ fn test_too_small_linenum_twice() { } #[test] -fn test_too_small_linenum_repeat() { +fn test_too_small_line_num_repeat() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/", "10", "{*}"]) .fails() @@ -1020,7 +1020,7 @@ fn test_too_small_linenum_repeat() { } #[test] -fn test_linenum_out_of_range1() { +fn test_line_num_out_of_range1() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "100"]) .fails() @@ -1046,7 +1046,7 @@ fn test_linenum_out_of_range1() { } #[test] -fn test_linenum_out_of_range2() { +fn test_line_num_out_of_range2() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "10", "100"]) .fails() @@ -1073,7 +1073,7 @@ fn test_linenum_out_of_range2() { } #[test] -fn test_linenum_out_of_range3() { +fn test_line_num_out_of_range3() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "40", "{2}"]) .fails() @@ -1100,7 +1100,7 @@ fn test_linenum_out_of_range3() { } #[test] -fn test_linenum_out_of_range4() { +fn test_line_num_out_of_range4() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "40", "{*}"]) .fails() @@ -1141,7 +1141,7 @@ fn test_skip_to_match_negative_offset_before_a_match() { } #[test] -fn test_skip_to_match_negative_offset_before_a_linenum() { +fn test_skip_to_match_negative_offset_before_a_line_num() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/-10", "15"]) .succeeds() @@ -1247,7 +1247,7 @@ fn test_up_to_match_context_underflow() { // the offset is out of range because of the first pattern // NOTE: output different than gnu's: the empty split is written but the rest of the input file is not #[test] -fn test_linenum_range_with_up_to_match1() { +fn test_line_num_range_with_up_to_match1() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "10", "/12/-5"]) .fails() @@ -1277,7 +1277,7 @@ fn test_linenum_range_with_up_to_match1() { // the offset is out of range because more lines are needed than physically available // NOTE: output different than gnu's: the empty split is not written but the rest of the input file is #[test] -fn test_linenum_range_with_up_to_match2() { +fn test_line_num_range_with_up_to_match2() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "10", "/12/-15"]) .fails() @@ -1306,7 +1306,7 @@ fn test_linenum_range_with_up_to_match2() { // NOTE: output different than gnu's: the pattern /10/ is matched but should not #[test] -fn test_linenum_range_with_up_to_match3() { +fn test_line_num_range_with_up_to_match3() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "10", "/10/", "-k"]) .fails() diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index f4990566a..9689ff49e 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -181,7 +181,7 @@ fn test_date_set_valid_2() { if get_effective_uid() == 0 { let result = new_ucmd!() .arg("--set") - .arg("Sat 20 Mar 2021 14:53:01 AWST") + .arg("Sat 20 Mar 2021 14:53:01 AWST") // spell-checker:disable-line .fails(); result.no_stdout(); assert!(result.stderr_str().starts_with("date: invalid date ")); diff --git a/tests/by-util/test_dircolors.rs b/tests/by-util/test_dircolors.rs index f28074075..86b72d23b 100644 --- a/tests/by-util/test_dircolors.rs +++ b/tests/by-util/test_dircolors.rs @@ -30,14 +30,14 @@ fn test_shell_syntax() { } #[test] -fn test_strutils() { +fn test_str_utils() { let s = " asd#zcv #hk\t\n "; assert_eq!("asd#zcv", s.purify()); let s = "con256asd"; - assert!(s.fnmatch("*[2][3-6][5-9]?sd")); + assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line - let s = "zxc \t\nqwe jlk hjl"; + let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line let (k, v) = s.split_two(); assert_eq!("zxc", k); assert_eq!("qwe jlk hjl", v); diff --git a/tests/by-util/test_du.rs b/tests/by-util/test_du.rs index e4dca7a61..9e585b03e 100644 --- a/tests/by-util/test_du.rs +++ b/tests/by-util/test_du.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (paths) sublink subwords + use crate::common::util::*; const SUB_DIR: &str = "subdir/deeper"; diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index 5d1b68e6c..483ad99f5 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) araba merci + use crate::common::util::*; #[test] @@ -185,9 +187,9 @@ fn test_multiple_hyphen_values() { #[test] fn test_hyphen_values_inside_string() { new_ucmd!() - .arg("'\"\n'CXXFLAGS=-g -O2'\n\"'") + .arg("'\"\n'CXXFLAGS=-g -O2'\n\"'") // spell-checker:disable-line .succeeds() - .stdout_contains("CXXFLAGS"); + .stdout_contains("CXXFLAGS"); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_env.rs b/tests/by-util/test_env.rs index 23bba57a9..4db3b59bd 100644 --- a/tests/by-util/test_env.rs +++ b/tests/by-util/test_env.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) bamf chdir + #[cfg(not(windows))] use std::fs; diff --git a/tests/by-util/test_factor.rs b/tests/by-util/test_factor.rs index 917d19a49..063cf0e4f 100644 --- a/tests/by-util/test_factor.rs +++ b/tests/by-util/test_factor.rs @@ -6,6 +6,8 @@ // that was distributed with this source code. #![allow(clippy::unreadable_literal)] +// spell-checker:ignore (methods) hexdigest + use crate::common::util::*; use std::time::SystemTime; @@ -27,13 +29,13 @@ fn test_first_100000_integers() { extern crate sha1; let n_integers = 100_000; - let mut instring = String::new(); + let mut input_string = String::new(); for i in 0..=n_integers { - instring.push_str(&(format!("{} ", i))[..]); + input_string.push_str(&(format!("{} ", i))[..]); } - println!("STDIN='{}'", instring); - let result = new_ucmd!().pipe_in(instring.as_bytes()).succeeds(); + println!("STDIN='{}'", input_string); + let result = new_ucmd!().pipe_in(input_string.as_bytes()).succeeds(); // `seq 0 100000 | factor | sha1sum` => "4ed2d8403934fa1c76fe4b84c5d4b8850299c359" let hash_check = sha1::Sha1::from(result.stdout()).hexdigest(); @@ -95,20 +97,20 @@ fn test_random() { }; // build an input and expected output string from factor - let mut instring = String::new(); - let mut outstring = String::new(); + let mut input_string = String::new(); + let mut output_string = String::new(); for _ in 0..NUM_TESTS { let (product, factors) = rand_gt(1 << 63); - instring.push_str(&(format!("{} ", product))[..]); + input_string.push_str(&(format!("{} ", product))[..]); - outstring.push_str(&(format!("{}:", product))[..]); + output_string.push_str(&(format!("{}:", product))[..]); for factor in factors { - outstring.push_str(&(format!(" {}", factor))[..]); + output_string.push_str(&(format!(" {}", factor))[..]); } - outstring.push('\n'); + output_string.push('\n'); } - run(instring.as_bytes(), outstring.as_bytes()); + run(input_string.as_bytes(), output_string.as_bytes()); } #[test] @@ -120,30 +122,30 @@ fn test_random_big() { println!("rng_seed={:?}", rng_seed); let mut rng = SmallRng::seed_from_u64(rng_seed); - let bitrange_1 = Uniform::new(14_usize, 51); + let bit_range_1 = Uniform::new(14_usize, 51); let mut rand_64 = move || { // first, choose a random number of bits for the first factor - let f_bit_1 = bitrange_1.sample(&mut rng); + let f_bit_1 = bit_range_1.sample(&mut rng); // how many more bits do we need? let rem = 64 - f_bit_1; - // we will have a number of additional factors equal to nfacts + 1 - // where nfacts is in [0, floor(rem/14) ) NOTE half-open interval + // we will have a number of additional factors equal to n_facts + 1 + // where n_facts is in [0, floor(rem/14) ) NOTE half-open interval // Each prime factor is at least 14 bits, hence floor(rem/14) - let nfacts = Uniform::new(0_usize, rem / 14).sample(&mut rng); - // we have to distribute extrabits among the (nfacts + 1) values - let extrabits = rem - (nfacts + 1) * 14; + let n_factors = Uniform::new(0_usize, rem / 14).sample(&mut rng); + // we have to distribute extra_bits among the (n_facts + 1) values + let extra_bits = rem - (n_factors + 1) * 14; // (remember, a Range is a half-open interval) - let extrarange = Uniform::new(0_usize, extrabits + 1); + let extra_range = Uniform::new(0_usize, extra_bits + 1); // to generate an even split of this range, generate n-1 random elements // in the range, add the desired total value to the end, sort this list, // and then compute the sequential differences. let mut f_bits = Vec::new(); - for _ in 0..nfacts { - f_bits.push(extrarange.sample(&mut rng)); + for _ in 0..n_factors { + f_bits.push(extra_range.sample(&mut rng)); } - f_bits.push(extrabits); + f_bits.push(extra_bits); f_bits.sort_unstable(); // compute sequential differences here. We leave off the +14 bits @@ -160,59 +162,59 @@ fn test_random_big() { f_bits.push(f_bit_1 - 14); // index of f_bit_1 in PRIMES_BY_BITS let f_bits = f_bits; - let mut nbits = 0; + let mut n_bits = 0; let mut product = 1_u64; let mut factors = Vec::new(); for bit in f_bits { assert!(bit < 37); - nbits += 14 + bit; + n_bits += 14 + bit; let elm = Uniform::new(0, PRIMES_BY_BITS[bit].len()).sample(&mut rng); let factor = PRIMES_BY_BITS[bit][elm]; factors.push(factor); product *= factor; } - assert_eq!(nbits, 64); + assert_eq!(n_bits, 64); factors.sort_unstable(); (product, factors) }; - let mut instring = String::new(); - let mut outstring = String::new(); + let mut input_string = String::new(); + let mut output_string = String::new(); for _ in 0..NUM_TESTS { let (product, factors) = rand_64(); - instring.push_str(&(format!("{} ", product))[..]); + input_string.push_str(&(format!("{} ", product))[..]); - outstring.push_str(&(format!("{}:", product))[..]); + output_string.push_str(&(format!("{}:", product))[..]); for factor in factors { - outstring.push_str(&(format!(" {}", factor))[..]); + output_string.push_str(&(format!(" {}", factor))[..]); } - outstring.push('\n'); + output_string.push('\n'); } - run(instring.as_bytes(), outstring.as_bytes()); + run(input_string.as_bytes(), output_string.as_bytes()); } #[test] fn test_big_primes() { - let mut instring = String::new(); - let mut outstring = String::new(); + let mut input_string = String::new(); + let mut output_string = String::new(); for prime in PRIMES64 { - instring.push_str(&(format!("{} ", prime))[..]); - outstring.push_str(&(format!("{0}: {0}\n", prime))[..]); + input_string.push_str(&(format!("{} ", prime))[..]); + output_string.push_str(&(format!("{0}: {0}\n", prime))[..]); } - run(instring.as_bytes(), outstring.as_bytes()); + run(input_string.as_bytes(), output_string.as_bytes()); } -fn run(instring: &[u8], outstring: &[u8]) { - println!("STDIN='{}'", String::from_utf8_lossy(instring)); - println!("STDOUT(expected)='{}'", String::from_utf8_lossy(outstring)); +fn run(input_string: &[u8], output_string: &[u8]) { + println!("STDIN='{}'", String::from_utf8_lossy(input_string)); + println!("STDOUT(expected)='{}'", String::from_utf8_lossy(output_string)); // now run factor new_ucmd!() - .pipe_in(instring) + .pipe_in(input_string) .run() - .stdout_is(String::from_utf8(outstring.to_owned()).unwrap()); + .stdout_is(String::from_utf8(output_string.to_owned()).unwrap()); } const PRIMES_BY_BITS: &[&[u64]] = &[ diff --git a/tests/by-util/test_fold.rs b/tests/by-util/test_fold.rs index 5224a50dc..62a2bddf3 100644 --- a/tests/by-util/test_fold.rs +++ b/tests/by-util/test_fold.rs @@ -282,7 +282,7 @@ fn test_backspace_is_not_word_boundary() { .args(&["-w10", "-s"]) .pipe_in("foobar\x086789abcdef") .succeeds() - .stdout_is("foobar\x086789a\nbcdef"); + .stdout_is("foobar\x086789a\nbcdef"); // spell-checker:disable-line } #[test] @@ -291,7 +291,7 @@ fn test_carriage_return_should_be_preserved() { } #[test] -fn test_carriage_return_overwrriten_char_should_be_preserved() { +fn test_carriage_return_overwritten_char_should_be_preserved() { new_ucmd!().pipe_in("x\ry").succeeds().stdout_is("x\ry"); } @@ -308,9 +308,9 @@ fn test_carriage_return_should_reset_column_count() { fn test_carriage_return_is_not_word_boundary() { new_ucmd!() .args(&["-w6", "-s"]) - .pipe_in("fizz\rbuzz\rfizzbuzz") + .pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line .succeeds() - .stdout_is("fizz\rbuzz\rfizzbu\nzz"); + .stdout_is("fizz\rbuzz\rfizzbu\nzz"); // spell-checker:disable-line } // @@ -496,7 +496,7 @@ fn test_bytewise_backspace_is_not_word_boundary() { .args(&["-w10", "-s", "-b"]) .pipe_in("foobar\x0889abcdef") .succeeds() - .stdout_is("foobar\x0889a\nbcdef"); + .stdout_is("foobar\x0889a\nbcdef"); // spell-checker:disable-line } #[test] @@ -509,7 +509,7 @@ fn test_bytewise_carriage_return_should_be_preserved() { } #[test] -fn test_bytewise_carriage_return_overwrriten_char_should_be_preserved() { +fn test_bytewise_carriage_return_overwritten_char_should_be_preserved() { new_ucmd!() .arg("-b") .pipe_in("x\ry") @@ -530,9 +530,9 @@ fn test_bytewise_carriage_return_should_not_reset_column_count() { fn test_bytewise_carriage_return_is_not_word_boundary() { new_ucmd!() .args(&["-w6", "-s", "-b"]) - .pipe_in("fizz\rbuzz\rfizzbuzz") + .pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line .succeeds() - .stdout_is("fizz\rb\nuzz\rfi\nzzbuzz"); + .stdout_is("fizz\rb\nuzz\rfi\nzzbuzz"); // spell-checker:disable-line } #[test] fn test_obsolete_syntax() { diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index cf7c9c2ee..7daa80e3a 100755 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) bogusfile emptyfile + use crate::common::util::*; static INPUT: &str = "lorem_ipsum.txt"; diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index 6da357170..3ab5cbdfb 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) helloworld objdump + use crate::common::util::*; use filetime::FileTime; use rust_users::*; diff --git a/tests/by-util/test_join.rs b/tests/by-util/test_join.rs index a8f046851..8dbdadba7 100644 --- a/tests/by-util/test_join.rs +++ b/tests/by-util/test_join.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) autoformat + use crate::common::util::*; #[test] @@ -141,7 +143,7 @@ fn new_line_separated() { } #[test] -fn multitab_character() { +fn tab_multi_character() { new_ucmd!() .arg("semicolon_fields_1.txt") .arg("semicolon_fields_2.txt") diff --git a/tests/by-util/test_kill.rs b/tests/by-util/test_kill.rs index 637aea9a2..886445109 100644 --- a/tests/by-util/test_kill.rs +++ b/tests/by-util/test_kill.rs @@ -79,9 +79,10 @@ fn test_kill_list_one_signal_from_name() { #[test] fn test_kill_set_bad_signal_name() { + // spell-checker:disable-line new_ucmd!() .arg("-s") - .arg("IAMNOTASIGNAL") + .arg("IAMNOTASIGNAL") // spell-checker:disable-line .fails() .stderr_contains("unknown signal"); } diff --git a/tests/by-util/test_ln.rs b/tests/by-util/test_ln.rs index f2508ecbf..4dc50566b 100644 --- a/tests/by-util/test_ln.rs +++ b/tests/by-util/test_ln.rs @@ -65,10 +65,10 @@ fn test_symlink_circular() { } #[test] -fn test_symlink_dont_overwrite() { +fn test_symlink_do_not_overwrite() { let (at, mut ucmd) = at_and_ucmd!(); - let file = "test_symlink_dont_overwrite"; - let link = "test_symlink_dont_overwrite_link"; + let file = "test_symlink_do_not_overwrite"; + let link = "test_symlink_do_not_overwrite_link"; at.touch(file); at.touch(link); @@ -120,7 +120,7 @@ fn test_symlink_interactive() { scene .ucmd() .args(&["-i", "-s", file, link]) - .pipe_in("Yesh") + .pipe_in("Yesh") // spell-checker:disable-line .succeeds() .no_stderr(); diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 9614f561e..dd6e4a85d 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup somefile somegroup somehiddenbackup somehiddenfile + #[cfg(unix)] extern crate unix_socket; use crate::common::util::*; @@ -939,7 +941,7 @@ fn test_ls_color() { let a_with_colors = "\x1b[1;34ma\x1b[0m"; let z_with_colors = "\x1b[1;34mz\x1b[0m"; - let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m"; + let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m"; // spell-checker:disable-line // Color is disabled by default let result = scene.ucmd().succeeds(); diff --git a/tests/by-util/test_mktemp.rs b/tests/by-util/test_mktemp.rs index d0737764f..e61d45428 100644 --- a/tests/by-util/test_mktemp.rs +++ b/tests/by-util/test_mktemp.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) gpghome + use crate::common::util::*; use std::path::PathBuf; @@ -8,8 +10,8 @@ static TEST_TEMPLATE2: &str = "temp"; static TEST_TEMPLATE3: &str = "tempX"; static TEST_TEMPLATE4: &str = "tempXX"; static TEST_TEMPLATE5: &str = "tempXXX"; -static TEST_TEMPLATE6: &str = "tempXXXlate"; -static TEST_TEMPLATE7: &str = "XXXtemplate"; +static TEST_TEMPLATE6: &str = "tempXXXlate"; // spell-checker:disable-line +static TEST_TEMPLATE7: &str = "XXXtemplate"; // spell-checker:disable-line #[cfg(unix)] static TEST_TEMPLATE8: &str = "tempXXXl/ate"; #[cfg(windows)] diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index cc778f0b4..69499ccfe 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -10,7 +10,7 @@ fn test_more_no_arg() { #[test] fn test_more_dir_arg() { - // Run the test only if there's a valud terminal, else do nothing + // Run the test only if there's a valid terminal, else do nothing // Maybe we could capture the error, i.e. "Device not found" in that case // but I am leaving this for later if atty::is(atty::Stream::Stdout) { diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index beb8f61b9..2782ac246 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -171,7 +171,7 @@ fn test_mv_interactive() { .arg("-i") .arg(file_a) .arg(file_b) - .pipe_in("Yesh") + .pipe_in("Yesh") // spell-checker:disable-line .succeeds() .no_stderr(); diff --git a/tests/by-util/test_nice.rs b/tests/by-util/test_nice.rs index 9e004b98b..005651c52 100644 --- a/tests/by-util/test_nice.rs +++ b/tests/by-util/test_nice.rs @@ -17,7 +17,7 @@ fn test_negative_adjustment() { let res = new_ucmd!().args(&["-n", "-1", "true"]).run(); assert!(res .stderr_str() - .starts_with("nice: warning: setpriority: Permission denied")); + .starts_with("nice: warning: setpriority: Permission denied")); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index 3ca039d19..ce3014311 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -1,7 +1,7 @@ use crate::common::util::*; #[test] -fn test_stdin_nonewline() { +fn test_stdin_no_newline() { new_ucmd!() .pipe_in("No Newline") .run() @@ -41,6 +41,7 @@ fn test_padding_with_overflow() { #[test] fn test_sections_and_styles() { + // spell-checker:disable for &(fixture, output) in &[ ( "section.txt", @@ -63,4 +64,5 @@ fn test_sections_and_styles() { .run() .stdout_is(output); } + // spell-checker:enable } diff --git a/tests/by-util/test_numfmt.rs b/tests/by-util/test_numfmt.rs index b52dbc359..bb29d431e 100644 --- a/tests/by-util/test_numfmt.rs +++ b/tests/by-util/test_numfmt.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (paths) gnutest + use crate::common::util::*; #[test] @@ -231,7 +233,7 @@ fn test_should_skip_leading_space_from_stdin() { .run() .stdout_is("2048\n"); - // multiline + // multi-line new_ucmd!() .args(&["--from=auto"]) .pipe_in("\t1Ki\n 2K") diff --git a/tests/by-util/test_od.rs b/tests/by-util/test_od.rs index fa947aa6e..6b1c39d63 100644 --- a/tests/by-util/test_od.rs +++ b/tests/by-util/test_od.rs @@ -8,7 +8,7 @@ use std::fs::File; use std::io::Write; use std::path::Path; -// octal dump of 'abcdefghijklmnopqrstuvwxyz\n' +// octal dump of 'abcdefghijklmnopqrstuvwxyz\n' // spell-checker:disable-line static ALPHA_OUT: &str = " 0000000 061141 062143 063145 064147 065151 066153 067155 070157 0000020 071161 072163 073165 074167 075171 000012 @@ -16,7 +16,7 @@ static ALPHA_OUT: &str = " "; // XXX We could do a better job of ensuring that we have a fresh temp dir to ourselves, -// not a general one full of other proc's leftovers. +// not a general one full of other process leftovers. // Test that od can read one file and dump with default format #[test] @@ -29,6 +29,7 @@ fn test_file() { { let mut f = File::create(&file).unwrap(); + // spell-checker:disable-next-line if f.write_all(b"abcdefghijklmnopqrstuvwxyz\n").is_err() { panic!("Test setup failed - could not write file"); } @@ -55,6 +56,7 @@ fn test_2files() { println!("number: {} letter:{}", n, a); } + // spell-checker:disable-next-line for &(path, data) in &[(&file1, "abcdefghijklmnop"), (&file2, "qrstuvwxyz\n")] { let mut f = File::create(&path).unwrap(); if f.write_all(data.as_bytes()).is_err() { @@ -79,7 +81,7 @@ fn test_2files() { fn test_no_file() { let temp = env::temp_dir(); let tmpdir = Path::new(&temp); - let file = tmpdir.join("}surely'none'would'thus'a'file'name"); + let file = tmpdir.join("}surely'none'would'thus'a'file'name"); // spell-checker:disable-line new_ucmd!().arg(file.as_os_str()).fails(); } @@ -87,7 +89,7 @@ fn test_no_file() { // Test that od reads from stdin instead of a file #[test] fn test_from_stdin() { - let input = "abcdefghijklmnopqrstuvwxyz\n"; + let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line new_ucmd!() .arg("--endian=little") .run_piped_stdin(input.as_bytes()) @@ -104,6 +106,7 @@ fn test_from_mixed() { let file1 = tmpdir.join("test-1"); let file3 = tmpdir.join("test-3"); + // spell-checker:disable-next-line let (data1, data2, data3) = ("abcdefg", "hijklmnop", "qrstuvwxyz\n"); for &(path, data) in &[(&file1, data1), (&file3, data3)] { let mut f = File::create(&path).unwrap(); @@ -125,7 +128,7 @@ fn test_from_mixed() { #[test] fn test_multiple_formats() { - let input = "abcdefghijklmnopqrstuvwxyz\n"; + let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("-b") @@ -145,6 +148,7 @@ fn test_multiple_formats() { #[test] fn test_dec() { + // spell-checker:ignore (words) 0xffu8 xffu let input = [ 0u8, 0u8, 1u8, 0u8, 2u8, 0u8, 3u8, 0u8, 0xffu8, 0x7fu8, 0x00u8, 0x80u8, 0x01u8, 0x80u8, ]; @@ -166,12 +170,14 @@ fn test_dec() { #[test] fn test_hex16() { let input: [u8; 9] = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xff]; + // spell-checker:disable let expected_output = unindent( " 0000000 2301 6745 ab89 efcd 00ff 0000011 ", ); + // spell-checker:enable new_ucmd!() .arg("--endian=little") .arg("-x") @@ -288,7 +294,7 @@ fn test_multibyte() { new_ucmd!() .arg("-c") .arg("-w12") - .run_piped_stdin("Universität Tübingen \u{1B000}".as_bytes()) + .run_piped_stdin("Universität Tübingen \u{1B000}".as_bytes()) // spell-checker:disable-line .success() .no_stderr() .stdout_is(unindent( @@ -487,7 +493,7 @@ fn test_alignment_Fx() { } #[test] -fn test_maxuint() { +fn test_max_uint() { let input = [0xFFu8; 8]; let expected_output = unindent( " @@ -505,7 +511,7 @@ fn test_maxuint() { new_ucmd!() .arg("--format=o8") - .arg("-Oobtu8") + .arg("-Oobtu8") // spell-checker:disable-line .arg("-Dd") .arg("--format=u1") .run_piped_stdin(&input[..]) @@ -583,7 +589,7 @@ fn test_invalid_offset() { #[test] fn test_skip_bytes() { - let input = "abcdefghijklmnopq"; + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("--skip-bytes=5") @@ -609,7 +615,7 @@ fn test_skip_bytes_error() { #[test] fn test_read_bytes() { - let input = "abcdefghijklmnopqrstuvwxyz\n12345678"; + let input = "abcdefghijklmnopqrstuvwxyz\n12345678"; // spell-checker:disable-line new_ucmd!() .arg("--endian=little") .arg("--read-bytes=27") @@ -626,7 +632,7 @@ fn test_ascii_dump() { 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff, ]; new_ucmd!() - .arg("-tx1zacz") + .arg("-tx1zacz") // spell-checker:disable-line .run_piped_stdin(&input[..]) .no_stderr() .success() @@ -645,7 +651,7 @@ fn test_ascii_dump() { #[test] fn test_filename_parsing() { - // files "a" and "x" both exists, but are no filenames in the commandline below + // files "a" and "x" both exists, but are no filenames in the command line below // "-f" must be treated as a filename, it contains the text: minus lowercase f // so "-f" should not be interpreted as a formatting option. new_ucmd!() @@ -668,7 +674,7 @@ fn test_filename_parsing() { #[test] fn test_stdin_offset() { - let input = "abcdefghijklmnopq"; + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("+5") @@ -703,7 +709,7 @@ fn test_file_offset() { #[test] fn test_traditional() { // note gnu od does not align both lines - let input = "abcdefghijklmnopq"; + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("-a") @@ -726,7 +732,7 @@ fn test_traditional() { #[test] fn test_traditional_with_skip_bytes_override() { // --skip-bytes is ignored in this case - let input = "abcdefghijklmnop"; + let input = "abcdefghijklmnop"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("--skip-bytes=10") @@ -746,7 +752,7 @@ fn test_traditional_with_skip_bytes_override() { #[test] fn test_traditional_with_skip_bytes_non_override() { // no offset specified in the traditional way, so --skip-bytes is used - let input = "abcdefghijklmnop"; + let input = "abcdefghijklmnop"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("--skip-bytes=10") @@ -776,7 +782,7 @@ fn test_traditional_error() { #[test] fn test_traditional_only_label() { - let input = "abcdefghijklmnopqrstuvwxyz"; + let input = "abcdefghijklmnopqrstuvwxyz"; // spell-checker:disable-line new_ucmd!() .arg("-An") .arg("--traditional") diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index ccabb7345..c3c9ea2e4 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -9,24 +9,24 @@ pub use self::pinky::*; #[test] fn test_capitalize() { - assert_eq!("Zbnmasd", "zbnmasd".capitalize()); - assert_eq!("Abnmasd", "Abnmasd".capitalize()); - assert_eq!("1masd", "1masd".capitalize()); + assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line + assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line + assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line assert_eq!("", "".capitalize()); } #[test] fn test_long_format() { - let ulogin = "root"; - let pw: Passwd = Passwd::locate(ulogin).unwrap(); + let login = "root"; + let pw: Passwd = Passwd::locate(login).unwrap(); let real_name = pw.user_info().replace("&", &pw.name().capitalize()); new_ucmd!() .arg("-l") - .arg(ulogin) + .arg(login) .succeeds() .stdout_is(format!( "Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n\n", - ulogin, + login, real_name, pw.user_dir(), pw.user_shell() @@ -34,11 +34,11 @@ fn test_long_format() { new_ucmd!() .arg("-lb") - .arg(ulogin) + .arg(login) .succeeds() .stdout_is(format!( "Login name: {:<28}In real life: {1}\n\n", - ulogin, real_name + login, real_name )); } diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 1e3e21d0c..40e91ef4f 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -43,12 +43,12 @@ fn escaped_octal() { } #[test] -fn escaped_unicode_fourdigit() { +fn escaped_unicode_four_digit() { new_ucmd!().args(&["\\u0125"]).succeeds().stdout_only("ĥ"); } #[test] -fn escaped_unicode_eightdigit() { +fn escaped_unicode_eight_digit() { new_ucmd!() .args(&["\\U00000125"]) .succeeds() @@ -77,7 +77,7 @@ fn sub_string() { } #[test] -fn sub_multifield() { +fn sub_multi_field() { new_ucmd!() .args(&["%s %s", "hello", "world"]) .succeeds() @@ -85,7 +85,7 @@ fn sub_multifield() { } #[test] -fn sub_repeat_formatstr() { +fn sub_repeat_format_str() { new_ucmd!() .args(&["%s.", "hello", "world"]) .succeeds() @@ -101,7 +101,7 @@ fn sub_string_ignore_escapes() { } #[test] -fn sub_bstring_handle_escapes() { +fn sub_b_string_handle_escapes() { new_ucmd!() .args(&["hello %b", "\\tworld"]) .succeeds() @@ -109,7 +109,7 @@ fn sub_bstring_handle_escapes() { } #[test] -fn sub_bstring_ignore_subs() { +fn sub_b_string_ignore_subs() { new_ucmd!() .args(&["hello %b", "world %% %i"]) .succeeds() @@ -133,7 +133,7 @@ fn sub_num_int() { } #[test] -fn sub_num_int_minwidth() { +fn sub_num_int_min_width() { new_ucmd!() .args(&["twenty is %1i", "20"]) .succeeds() @@ -181,11 +181,11 @@ fn sub_num_int_hex_in_neg() { } #[test] -fn sub_num_int_charconst_in() { +fn sub_num_int_char_const_in() { new_ucmd!() - .args(&["ninetyseven is %i", "'a"]) + .args(&["ninety seven is %i", "'a"]) .succeeds() - .stdout_only("ninetyseven is 97"); + .stdout_only("ninety seven is 97"); } #[test] @@ -287,7 +287,7 @@ fn sub_num_hex_float_upper() { } #[test] -fn sub_minwidth() { +fn sub_min_width() { new_ucmd!() .args(&["hello %7s", "world"]) .succeeds() @@ -295,7 +295,7 @@ fn sub_minwidth() { } #[test] -fn sub_minwidth_negative() { +fn sub_min_width_negative() { new_ucmd!() .args(&["hello %-7s", "world"]) .succeeds() @@ -327,7 +327,7 @@ fn sub_int_leading_zeroes() { } #[test] -fn sub_int_leading_zeroes_prio() { +fn sub_int_leading_zeroes_padded() { new_ucmd!() .args(&["%5.4i", "11"]) .succeeds() @@ -359,7 +359,7 @@ fn sub_float_no_octal_in() { } #[test] -fn sub_any_asterisk_firstparam() { +fn sub_any_asterisk_first_param() { new_ucmd!() .args(&["%*i", "3", "11", "4", "12"]) .succeeds() @@ -401,7 +401,7 @@ fn sub_any_asterisk_hex_arg() { #[test] fn sub_any_specifiers_no_params() { new_ucmd!() - .args(&["%ztlhLji", "3"]) + .args(&["%ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -409,7 +409,7 @@ fn sub_any_specifiers_no_params() { #[test] fn sub_any_specifiers_after_first_param() { new_ucmd!() - .args(&["%0ztlhLji", "3"]) + .args(&["%0ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -417,7 +417,7 @@ fn sub_any_specifiers_after_first_param() { #[test] fn sub_any_specifiers_after_period() { new_ucmd!() - .args(&["%0.ztlhLji", "3"]) + .args(&["%0.ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -425,7 +425,7 @@ fn sub_any_specifiers_after_period() { #[test] fn sub_any_specifiers_after_second_param() { new_ucmd!() - .args(&["%0.0ztlhLji", "3"]) + .args(&["%0.0ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } diff --git a/tests/by-util/test_ptx.rs b/tests/by-util/test_ptx.rs index e44943bfa..c17d473f5 100644 --- a/tests/by-util/test_ptx.rs +++ b/tests/by-util/test_ptx.rs @@ -1,43 +1,43 @@ use crate::common::util::*; #[test] -fn gnu_ext_disabled_roff_no_ref() { +fn gnu_ext_disabled_rightward_no_ref() { new_ucmd!() .args(&["-G", "-R", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_no_ref.expected"); } #[test] -fn gnu_ext_disabled_roff_no_ref_empty_word_regexp() { +fn gnu_ext_disabled_rightward_no_ref_empty_word_regexp() { new_ucmd!() .args(&["-G", "-R", "-W", "", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_no_ref.expected"); } #[test] -fn gnu_ext_disabled_roff_no_ref_word_regexp_exc_space() { +fn gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space() { new_ucmd!() .args(&["-G", "-R", "-W", "[^\t\n]+", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space.expected"); } #[test] -fn gnu_ext_disabled_roff_input_ref() { +fn gnu_ext_disabled_rightward_input_ref() { new_ucmd!() .args(&["-G", "-r", "-R", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_input_ref.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_input_ref.expected"); } #[test] -fn gnu_ext_disabled_roff_auto_ref() { +fn gnu_ext_disabled_rightward_auto_ref() { new_ucmd!() .args(&["-G", "-A", "-R", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_auto_ref.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_auto_ref.expected"); } #[test] diff --git a/tests/by-util/test_pwd.rs b/tests/by-util/test_pwd.rs index b6a6c87a4..2779b9e62 100644 --- a/tests/by-util/test_pwd.rs +++ b/tests/by-util/test_pwd.rs @@ -9,5 +9,5 @@ fn test_default() { #[test] fn test_failed() { let (_at, mut ucmd) = at_and_ucmd!(); - ucmd.arg("willfail").fails(); + ucmd.arg("will-fail").fails(); } diff --git a/tests/by-util/test_relpath.rs b/tests/by-util/test_relpath.rs index b9c07fb12..051f46084 100644 --- a/tests/by-util/test_relpath.rs +++ b/tests/by-util/test_relpath.rs @@ -115,12 +115,12 @@ fn test_relpath_with_from_with_d() { #[cfg(not(windows))] assert!(Path::new(&_result_stdout).is_relative()); - // d is not part of subpath -> expect absolut path + // d is not part of subpath -> expect absolute path _result_stdout = scene .ucmd() .arg(to) .arg(from) - .arg("-dnon_existing") + .arg("-dnon_existing") // spell-checker:disable-line .succeeds() .stdout_move_str(); assert!(Path::new(&_result_stdout).is_absolute()); @@ -166,11 +166,11 @@ fn test_relpath_no_from_with_d() { #[cfg(not(windows))] assert!(Path::new(&_result_stdout).is_relative()); - // d is not part of subpath -> expect absolut path + // d is not part of subpath -> expect absolute path let result_stdout = scene .ucmd() .arg(to) - .arg("-dnon_existing") + .arg("-dnon_existing") // spell-checker:disable-line .succeeds() .stdout_move_str(); assert!(Path::new(&result_stdout).is_absolute()); diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index 2a87038d5..64259d02c 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -65,7 +65,7 @@ fn test_rm_interactive() { .arg("-i") .arg(file_a) .arg(file_b) - .pipe_in("Yesh") + .pipe_in("Yesh") // spell-checker:disable-line .succeeds(); assert!(!at.file_exists(file_a)); diff --git a/tests/by-util/test_shuf.rs b/tests/by-util/test_shuf.rs index 106d80a39..cbc01f8cd 100644 --- a/tests/by-util/test_shuf.rs +++ b/tests/by-util/test_shuf.rs @@ -19,7 +19,7 @@ fn test_output_is_random_permutation() { .map(|x| x.parse().unwrap()) .collect(); result_seq.sort_unstable(); - assert_ne!(result.stdout_str(), input, "Output is not randomised"); + assert_ne!(result.stdout_str(), input, "Output is not randomized"); assert_eq!(result_seq, input_seq, "Output is not a permutation"); } diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 588ce86bd..c31d44110 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) ints + use crate::common::util::*; fn test_helper(file_name: &str, possible_args: &[&str]) { @@ -61,7 +63,7 @@ fn test_ext_sort_stable() { } #[test] -fn test_extsort_zero_terminated() { +fn test_ext_sort_zero_terminated() { new_ucmd!() .arg("-z") .arg("-S") @@ -96,7 +98,7 @@ fn test_human_numeric_whitespace() { // This tests where serde often fails when reading back JSON // if it finds a null value #[test] -fn test_extsort_as64_bailout() { +fn test_ext_sort_as64_bailout() { new_ucmd!() .arg("-g") .arg("-S 5K") @@ -290,10 +292,10 @@ fn test_dictionary_order() { fn test_dictionary_order2() { for non_dictionary_order2_param in &["-d"] { new_ucmd!() - .pipe_in("a👦🏻aa b\naaaa b") - .arg(non_dictionary_order2_param) + .pipe_in("a👦🏻aa b\naaaa b") // spell-checker:disable-line + .arg(non_dictionary_order2_param) // spell-checker:disable-line .succeeds() - .stdout_only("a👦🏻aa b\naaaa b\n"); + .stdout_only("a👦🏻aa b\naaaa b\n"); // spell-checker:disable-line } } @@ -301,10 +303,10 @@ fn test_dictionary_order2() { fn test_non_printing_chars() { for non_printing_chars_param in &["-i"] { new_ucmd!() - .pipe_in("a👦🏻aa\naaaa") - .arg(non_printing_chars_param) + .pipe_in("a👦🏻aa\naaaa") // spell-checker:disable-line + .arg(non_printing_chars_param) // spell-checker:disable-line .succeeds() - .stdout_only("a👦🏻aa\naaaa\n"); + .stdout_only("a👦🏻aa\naaaa\n"); // spell-checker:disable-line } } @@ -592,7 +594,7 @@ fn test_keys_ignore_flag() { } #[test] -fn test_doesnt_inherit_key_settings() { +fn test_does_not_inherit_key_settings() { let input = " 1 2 10 diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 1ff8bd8f2..85b28326b 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -242,7 +242,7 @@ fn test_filter() { .succeeds(); // assert all characters are 'i' / no character is not 'i' - // (assert that command succeded) + // (assert that command succeeded) let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); assert!( glob.collate().iter().find(|&&c| { @@ -265,7 +265,7 @@ fn test_filter_with_env_var_set() { let n_lines = 3; RandomFile::new(&at, name).add_lines(n_lines); - let env_var_value = "somevalue"; + let env_var_value = "some-value"; env::set_var("FILE", &env_var_value); ucmd.args(&[format!("--filter={}", "cat > $FILE").as_str(), name]) .succeeds(); diff --git a/tests/by-util/test_stat.rs b/tests/by-util/test_stat.rs index 6935cc7f9..5c8d9d185 100644 --- a/tests/by-util/test_stat.rs +++ b/tests/by-util/test_stat.rs @@ -6,20 +6,20 @@ extern crate stat; pub use self::stat::*; #[test] -fn test_scanutil() { +fn test_scanners() { assert_eq!(Some((-5, 2)), "-5zxc".scan_num::()); assert_eq!(Some((51, 2)), "51zxc".scan_num::()); assert_eq!(Some((192, 4)), "+192zxc".scan_num::()); assert_eq!(None, "z192zxc".scan_num::()); assert_eq!(Some(('a', 3)), "141zxc".scan_char(8)); - assert_eq!(Some(('\n', 2)), "12qzxc".scan_char(8)); - assert_eq!(Some(('\r', 1)), "dqzxc".scan_char(16)); - assert_eq!(None, "z2qzxc".scan_char(8)); + assert_eq!(Some(('\n', 2)), "12qzxc".scan_char(8)); // spell-checker:disable-line + assert_eq!(Some(('\r', 1)), "dqzxc".scan_char(16)); // spell-checker:disable-line + assert_eq!(None, "z2qzxc".scan_char(8)); // spell-checker:disable-line } #[test] -fn test_groupnum() { +fn test_group_num() { assert_eq!("12,379,821,234", group_num("12379821234")); assert_eq!("21,234", group_num("21234")); assert_eq!("821,234", group_num("821234")); @@ -97,13 +97,13 @@ fn test_invalid_option() { } #[cfg(any(target_os = "linux", target_vendor = "apple"))] -const NORMAL_FMTSTR: &str = +const NORMAL_FORMAT_STR: &str = "%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s %u %U %x %X %y %Y %z %Z"; // avoid "%w %W" (birth/creation) due to `stat` limitations and linux kernel & rust version capability variations #[cfg(any(target_os = "linux"))] -const DEV_FMTSTR: &str = +const DEV_FORMAT_STR: &str = "%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s (%t/%T) %u %U %w %W %x %X %y %Y %z %Z"; #[cfg(target_os = "linux")] -const FS_FMTSTR: &str = "%b %c %i %l %n %s %S %t %T"; // avoid "%a %d %f" which can cause test failure due to race conditions +const FS_FORMAT_STR: &str = "%b %c %i %l %n %s %S %t %T"; // avoid "%a %d %f" which can cause test failure due to race conditions #[test] #[cfg(target_os = "linux")] @@ -118,7 +118,7 @@ fn test_terse_fs_format() { #[test] #[cfg(target_os = "linux")] fn test_fs_format() { - let args = ["-f", "-c", FS_FMTSTR, "/dev/shm"]; + let args = ["-f", "-c", FS_FORMAT_STR, "/dev/shm"]; new_ucmd!() .args(&args) .run() @@ -207,7 +207,7 @@ fn test_format_created_seconds() { #[cfg(any(target_os = "linux", target_vendor = "apple"))] #[test] fn test_normal_format() { - let args = ["-c", NORMAL_FMTSTR, "/bin"]; + let args = ["-c", NORMAL_FORMAT_STR, "/bin"]; new_ucmd!() .args(&args) .succeeds() @@ -231,14 +231,14 @@ fn test_symlinks() { ] { if at.file_exists(file) && at.is_symlink(file) { tested = true; - let args = ["-c", NORMAL_FMTSTR, file]; + let args = ["-c", NORMAL_FORMAT_STR, file]; scene .ucmd() .args(&args) .succeeds() .stdout_is(expected_result(&args)); // -L, --dereference follow links - let args = ["-L", "-c", NORMAL_FMTSTR, file]; + let args = ["-L", "-c", NORMAL_FORMAT_STR, file]; scene .ucmd() .args(&args) @@ -261,7 +261,7 @@ fn test_char() { let args = [ "-c", #[cfg(target_os = "linux")] - DEV_FMTSTR, + DEV_FORMAT_STR, #[cfg(target_os = "linux")] "/dev/pts/ptmx", #[cfg(any(target_vendor = "apple"))] @@ -280,7 +280,7 @@ fn test_char() { fn test_multi_files() { let args = [ "-c", - NORMAL_FMTSTR, + NORMAL_FORMAT_STR, "/dev", "/usr/lib", #[cfg(target_os = "linux")] diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index 737d0cabf..0e3092562 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -78,7 +78,7 @@ fn test_follow_multiple() { at.append(FOOBAR_2_TXT, first_append); assert_eq!(read_size(&mut child, first_append.len()), first_append); - let second_append = "doce\ntrece\n"; + let second_append = "twenty\nthirty\n"; let expected = at.read("foobar_follow_multiple_appended.expected"); at.append(FOOBAR_TXT, second_append); assert_eq!(read_size(&mut child, expected.len()), expected); @@ -95,7 +95,7 @@ fn test_follow_stdin() { .stdout_is_fixture("follow_stdin.expected"); } -// FixME: test PASSES for usual windows builds, but fails for coverage testing builds (likely related to the specific RUSTFLAGS '-Zpanic_abort_tests -Cpanic=abort') This test also breaks tty settings under bash requiring a 'stty sane' or reset. +// FixME: test PASSES for usual windows builds, but fails for coverage testing builds (likely related to the specific RUSTFLAGS '-Zpanic_abort_tests -Cpanic=abort') This test also breaks tty settings under bash requiring a 'stty sane' or reset. // spell-checker:disable-line #[cfg(disable_until_fixed)] #[test] fn test_follow_with_pid() { @@ -130,7 +130,7 @@ fn test_follow_with_pid() { at.append(FOOBAR_2_TXT, first_append); assert_eq!(read_size(&mut child, first_append.len()), first_append); - let second_append = "doce\ntrece\n"; + let second_append = "twenty\nthirty\n"; let expected = at.read("foobar_follow_multiple_appended.expected"); at.append(FOOBAR_TXT, second_append); assert_eq!(read_size(&mut child, expected.len()), expected); @@ -268,7 +268,7 @@ fn test_parse_size() { assert!(parse_size("1Y").is_err()); // Bad number - assert!(parse_size("328hdsf3290").is_err()); + assert!(parse_size("328hdsf3290").is_err()); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_test.rs b/tests/by-util/test_test.rs index 3a55f772a..a29c4f6c6 100644 --- a/tests/by-util/test_test.rs +++ b/tests/by-util/test_test.rs @@ -8,6 +8,8 @@ // file that was distributed with this source code. // +// spell-checker:ignore (words) pseudofloat + use crate::common::util::*; #[test] @@ -73,13 +75,13 @@ fn test_negated_or() { } #[test] -fn test_strlen_of_nothing() { +fn test_string_length_of_nothing() { // odd but matches GNU, which must interpret -n as a literal here new_ucmd!().arg("-n").succeeds(); } #[test] -fn test_strlen_of_empty() { +fn test_string_length_of_empty() { new_ucmd!().args(&["-n", ""]).run().status_code(1); // STRING equivalent to -n STRING @@ -98,7 +100,7 @@ fn test_zero_len_of_empty() { } #[test] -fn test_solo_paren_is_literal() { +fn test_solo_parenthesis_is_literal() { let scenario = TestScenario::new(util_name!()); let tests = [["("], [")"]]; @@ -167,7 +169,7 @@ fn test_dangling_string_comparison_is_error() { } #[test] -fn test_stringop_is_literal_after_bang() { +fn test_string_operator_is_literal_after_bang() { let scenario = TestScenario::new(util_name!()); let tests = [ ["!", "="], @@ -208,7 +210,7 @@ fn test_pseudofloat_not_equal() { #[test] fn test_negative_arg_is_a_string() { new_ucmd!().arg("-12345").succeeds(); - new_ucmd!().arg("--qwert").succeeds(); + new_ucmd!().arg("--qwert").succeeds(); // spell-checker:disable-line } #[test] @@ -475,12 +477,12 @@ fn test_nonexistent_file_is_not_symlink() { } #[test] -fn test_op_prec_and_or_1() { +fn test_op_precedence_and_or_1() { new_ucmd!().args(&[" ", "-o", "", "-a", ""]).succeeds(); } #[test] -fn test_op_prec_and_or_1_overridden_by_parentheses() { +fn test_op_precedence_and_or_1_overridden_by_parentheses() { new_ucmd!() .args(&["(", " ", "-o", "", ")", "-a", ""]) .run() @@ -488,14 +490,14 @@ fn test_op_prec_and_or_1_overridden_by_parentheses() { } #[test] -fn test_op_prec_and_or_2() { +fn test_op_precedence_and_or_2() { new_ucmd!() .args(&["", "-a", "", "-o", " ", "-a", " "]) .succeeds(); } #[test] -fn test_op_prec_and_or_2_overridden_by_parentheses() { +fn test_op_precedence_and_or_2_overridden_by_parentheses() { new_ucmd!() .args(&["", "-a", "(", "", "-o", " ", ")", "-a", " "]) .run() @@ -529,7 +531,7 @@ fn test_negated_boolean_precedence() { } #[test] -fn test_bang_boolop_precedence() { +fn test_bang_bool_op_precedence() { // For a Boolean combination of two literals, bang inverts the entire expression new_ucmd!().args(&["!", "", "-a", ""]).succeeds(); new_ucmd!().args(&["!", "", "-o", ""]).succeeds(); @@ -564,7 +566,7 @@ fn test_bang_boolop_precedence() { } #[test] -fn test_inverted_parenthetical_boolop_precedence() { +fn test_inverted_parenthetical_bool_op_precedence() { // For a Boolean combination of two literals, bang inverts the entire expression new_ucmd!() .args(&["!", "a value", "-o", "another value"]) @@ -618,6 +620,6 @@ fn test_or_as_filename() { #[test] #[ignore = "GNU considers this an error"] -fn test_strlen_and_nothing() { +fn test_string_length_and_nothing() { new_ucmd!().args(&["-n", "a", "-a"]).run().status_code(2); } diff --git a/tests/by-util/test_timeout.rs b/tests/by-util/test_timeout.rs index 592516cca..28273e00f 100644 --- a/tests/by-util/test_timeout.rs +++ b/tests/by-util/test_timeout.rs @@ -4,7 +4,7 @@ use crate::common::util::*; // the best solution is probably to generate some test binaries that we can call for any // utility that requires executing another program (kill, for instance) #[test] -fn test_subcommand_retcode() { +fn test_subcommand_return_code() { new_ucmd!().arg("1").arg("true").succeeds(); new_ucmd!().arg("1").arg("false").run().status_code(1); diff --git a/tests/by-util/test_touch.rs b/tests/by-util/test_touch.rs index d4d2c058e..14718fc0a 100644 --- a/tests/by-util/test_touch.rs +++ b/tests/by-util/test_touch.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms + extern crate touch; use self::touch::filetime::{self, FileTime}; @@ -383,13 +385,13 @@ fn is_dst_switch_hour(ts: time::Timespec) -> bool { tm_after.tm_hour == tm.tm_hour + 2 } -// get_dstswitch_hour returns date string for which touch -m -t fails. +// get_dst_switch_hour returns date string for which touch -m -t fails. // For example, in EST (UTC-5), that will be "202003080200" so -// touch -m -t 202003080200 somefile +// touch -m -t 202003080200 file // fails (that date/time does not exist). // In other locales it will be a different date/time, and in some locales // it doesn't exist at all, in which case this function will return None. -fn get_dstswitch_hour() -> Option { +fn get_dst_switch_hour() -> Option { let now = time::now(); // Start from January 1, 2020, 00:00. let mut tm = time::strptime("20200101-0000", "%Y%m%d-%H%M").unwrap(); @@ -415,7 +417,7 @@ fn test_touch_mtime_dst_fails() { let (_at, mut ucmd) = at_and_ucmd!(); let file = "test_touch_set_mtime_dst_fails"; - if let Some(s) = get_dstswitch_hour() { + if let Some(s) = get_dst_switch_hour() { ucmd.args(&["-m", "-t", &s, file]).fails(); } } diff --git a/tests/by-util/test_tr.rs b/tests/by-util/test_tr.rs index 29712b44a..4ddaff573 100644 --- a/tests/by-util/test_tr.rs +++ b/tests/by-util/test_tr.rs @@ -1,7 +1,7 @@ use crate::common::util::*; #[test] -fn test_toupper() { +fn test_to_upper() { new_ucmd!() .args(&["a-z", "A-Z"]) .pipe_in("!abcd!") @@ -80,10 +80,10 @@ fn test_complement2() { #[test] fn test_complement3() { new_ucmd!() - .args(&["-c", "abcdefgh", "123"]) + .args(&["-c", "abcdefgh", "123"]) // spell-checker:disable-line .pipe_in("the cat and the bat") .run() - .stdout_is("3he3ca33a3d33he3ba3"); + .stdout_is("3he3ca33a3d33he3ba3"); // spell-checker:disable-line } #[test] @@ -140,9 +140,9 @@ fn test_translate_and_squeeze() { fn test_translate_and_squeeze_multiple_lines() { new_ucmd!() .args(&["-s", "x", "y"]) - .pipe_in("xxaax\nxaaxx") + .pipe_in("xxaax\nxaaxx") // spell-checker:disable-line .run() - .stdout_is("yaay\nyaay"); + .stdout_is("yaay\nyaay"); // spell-checker:disable-line } #[test] @@ -169,7 +169,7 @@ fn test_set1_longer_than_set2() { .args(&["abc", "xy"]) .pipe_in("abcde") .run() - .stdout_is("xyyde"); + .stdout_is("xyyde"); // spell-checker:disable-line } #[test] @@ -178,7 +178,7 @@ fn test_set1_shorter_than_set2() { .args(&["ab", "xyz"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -187,7 +187,7 @@ fn test_truncate() { .args(&["-t", "abc", "xy"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -196,7 +196,7 @@ fn test_truncate_with_set1_shorter_than_set2() { .args(&["-t", "ab", "xyz"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -216,8 +216,8 @@ fn missing_required_second_arg_fails() { #[test] fn test_interpret_backslash_escapes() { new_ucmd!() - .args(&["abfnrtv", r"\a\b\f\n\r\t\v"]) - .pipe_in("abfnrtv") + .args(&["abfnrtv", r"\a\b\f\n\r\t\v"]) // spell-checker:disable-line + .pipe_in("abfnrtv") // spell-checker:disable-line .succeeds() .stdout_is("\u{7}\u{8}\u{c}\n\r\t\u{b}"); } diff --git a/tests/by-util/test_truncate.rs b/tests/by-util/test_truncate.rs index a28ce9451..f98027127 100644 --- a/tests/by-util/test_truncate.rs +++ b/tests/by-util/test_truncate.rs @@ -1,15 +1,15 @@ use crate::common::util::*; use std::io::{Seek, SeekFrom, Write}; -static TFILE1: &str = "truncate_test_1"; -static TFILE2: &str = "truncate_test_2"; +static FILE1: &str = "truncate_test_1"; +static FILE2: &str = "truncate_test_2"; #[test] fn test_increase_file_size() { let expected = 5 * 1024; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE1); - ucmd.args(&["-s", "+5K", TFILE1]).succeeds(); + let mut file = at.make_file(FILE1); + ucmd.args(&["-s", "+5K", FILE1]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); @@ -25,8 +25,8 @@ fn test_increase_file_size() { fn test_increase_file_size_kb() { let expected = 5 * 1000; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE1); - ucmd.args(&["-s", "+5KB", TFILE1]).succeeds(); + let mut file = at.make_file(FILE1); + ucmd.args(&["-s", "+5KB", FILE1]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); @@ -43,15 +43,15 @@ fn test_reference() { let expected = 5 * 1000; let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); - scene.ucmd().arg("-s").arg("+5KB").arg(TFILE1).run(); + scene.ucmd().arg("-s").arg("+5KB").arg(FILE1).run(); scene .ucmd() .arg("--reference") - .arg(TFILE1) - .arg(TFILE2) + .arg(FILE1) + .arg(FILE2) .run(); file.seek(SeekFrom::End(0)).unwrap(); @@ -68,9 +68,9 @@ fn test_reference() { fn test_decrease_file_size() { let expected = 6; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size=-4", TFILE2]).succeeds(); + ucmd.args(&["--size=-4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -85,9 +85,9 @@ fn test_decrease_file_size() { fn test_space_in_size() { let expected = 4; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", " 4", TFILE2]).succeeds(); + ucmd.args(&["--size", " 4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -106,22 +106,22 @@ fn test_failed() { #[test] fn test_failed_2() { let (_at, mut ucmd) = at_and_ucmd!(); - ucmd.args(&[TFILE1]).fails(); + ucmd.args(&[FILE1]).fails(); } #[test] fn test_failed_incorrect_arg() { let (_at, mut ucmd) = at_and_ucmd!(); - ucmd.args(&["-s", "+5A", TFILE1]).fails(); + ucmd.args(&["-s", "+5A", FILE1]).fails(); } #[test] fn test_at_most_shrinks() { let expected = 4; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", "<4", TFILE2]).succeeds(); + ucmd.args(&["--size", "<4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -136,9 +136,9 @@ fn test_at_most_shrinks() { fn test_at_most_no_change() { let expected = 10; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", "<40", TFILE2]).succeeds(); + ucmd.args(&["--size", "<40", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -153,9 +153,9 @@ fn test_at_most_no_change() { fn test_at_least_grows() { let expected = 15; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", ">15", TFILE2]).succeeds(); + ucmd.args(&["--size", ">15", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -170,9 +170,9 @@ fn test_at_least_grows() { fn test_at_least_no_change() { let expected = 10; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", ">4", TFILE2]).succeeds(); + ucmd.args(&["--size", ">4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -187,9 +187,9 @@ fn test_at_least_no_change() { fn test_round_down() { let expected = 8; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", "/4", TFILE2]).succeeds(); + ucmd.args(&["--size", "/4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -204,9 +204,9 @@ fn test_round_down() { fn test_round_up() { let expected = 12; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", "%4", TFILE2]).succeeds(); + ucmd.args(&["--size", "%4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -221,10 +221,10 @@ fn test_round_up() { fn test_size_and_reference() { let expected = 15; let (at, mut ucmd) = at_and_ucmd!(); - let mut file1 = at.make_file(TFILE1); - let mut file2 = at.make_file(TFILE2); + let mut file1 = at.make_file(FILE1); + let mut file2 = at.make_file(FILE2); file1.write_all(b"1234567890").unwrap(); - ucmd.args(&["--reference", TFILE1, "--size", "+5", TFILE2]) + ucmd.args(&["--reference", FILE1, "--size", "+5", FILE2]) .succeeds(); file2.seek(SeekFrom::End(0)).unwrap(); let actual = file2.seek(SeekFrom::Current(0)).unwrap(); diff --git a/tests/by-util/test_uname.rs b/tests/by-util/test_uname.rs index d878ed7ac..de3f42a6b 100644 --- a/tests/by-util/test_uname.rs +++ b/tests/by-util/test_uname.rs @@ -17,7 +17,7 @@ fn test_uname_processor() { } #[test] -fn test_uname_hwplatform() { +fn test_uname_hardware_platform() { let result = new_ucmd!().arg("-i").succeeds(); assert_eq!(result.stdout_str().trim_end(), "unknown"); } diff --git a/tests/by-util/test_unexpand.rs b/tests/by-util/test_unexpand.rs index e8b880287..692599361 100644 --- a/tests/by-util/test_unexpand.rs +++ b/tests/by-util/test_unexpand.rs @@ -38,7 +38,7 @@ fn unexpand_init_list_1() { } #[test] -fn unexpand_aflag_0() { +fn unexpand_flag_a_0() { new_ucmd!() .args(&["--"]) .pipe_in("e E\nf F\ng G\nh H\n") @@ -47,7 +47,7 @@ fn unexpand_aflag_0() { } #[test] -fn unexpand_aflag_1() { +fn unexpand_flag_a_1() { new_ucmd!() .args(&["-a"]) .pipe_in("e E\nf F\ng G\nh H\n") @@ -56,7 +56,7 @@ fn unexpand_aflag_1() { } #[test] -fn unexpand_aflag_2() { +fn unexpand_flag_a_2() { new_ucmd!() .args(&["-t8"]) .pipe_in("e E\nf F\ng G\nh H\n") diff --git a/tests/by-util/test_uptime.rs b/tests/by-util/test_uptime.rs index d20ad90c9..4dc90eb31 100644 --- a/tests/by-util/test_uptime.rs +++ b/tests/by-util/test_uptime.rs @@ -22,5 +22,5 @@ fn test_uptime_since() { #[test] fn test_failed() { - new_ucmd!().arg("willfail").fails(); + new_ucmd!().arg("will-fail").fails(); } diff --git a/tests/by-util/test_users.rs b/tests/by-util/test_users.rs index 89c3fdd0f..8ceb0eeb8 100644 --- a/tests/by-util/test_users.rs +++ b/tests/by-util/test_users.rs @@ -1,7 +1,7 @@ use crate::common::util::*; #[test] -fn test_users_noarg() { +fn test_users_no_arg() { new_ucmd!().succeeds(); } diff --git a/tests/by-util/test_wc.rs b/tests/by-util/test_wc.rs index 1203c0b1d..88c65c997 100644 --- a/tests/by-util/test_wc.rs +++ b/tests/by-util/test_wc.rs @@ -1,5 +1,7 @@ use crate::common::util::*; +// spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword + #[test] fn test_count_bytes_large_stdin() { for &n in &[ diff --git a/tests/by-util/test_who.rs b/tests/by-util/test_who.rs index 333b03f5b..16444b0cb 100644 --- a/tests/by-util/test_who.rs +++ b/tests/by-util/test_who.rs @@ -1,5 +1,7 @@ use crate::common::util::*; +// spell-checker:ignore (flags) runlevel mesg + #[cfg(any(target_vendor = "apple", target_os = "linux"))] #[test] fn test_count() { diff --git a/tests/common/util.rs b/tests/common/util.rs index 9ce7f0537..cd2633f0d 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -632,7 +632,7 @@ impl TestScenario { let tmpd = Rc::new(TempDir::new().unwrap()); let ts = TestScenario { bin_path: { - // Instead of hardcoding the path relative to the current + // Instead of hard coding the path relative to the current // directory, use Cargo's OUT_DIR to find path to executable. // This allows tests to be run using profiles other than debug. let target_dir = path_concat!(env!("OUT_DIR"), "..", "..", "..", PROGNAME); @@ -722,9 +722,10 @@ impl UCommand { cmd.current_dir(curdir.as_ref()); if env_clear { if cfg!(windows) { + // spell-checker:ignore (dll) rsaenh // %SYSTEMROOT% is required on Windows to initialize crypto provider // ... and crypto provider is required for std::rand - // From procmon: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path + // From `procmon`: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path // SUCCESS Type: REG_SZ, Length: 66, Data: %SystemRoot%\system32\rsaenh.dll" for (key, _) in env::vars_os() { if key.as_os_str() != "SYSTEMROOT" { @@ -802,7 +803,7 @@ impl UCommand { self } - /// provides stdinput to feed in to the command when spawned + /// provides standard input to feed in to the command when spawned pub fn pipe_in>>(&mut self, input: T) -> &mut UCommand { if self.bytes_into_stdin.is_some() { panic!("{}", MULTIPLE_STDIN_MEANINGLESS); @@ -934,6 +935,7 @@ pub fn vec_of_size(n: usize) -> Vec { /// Sanity checks for test utils #[cfg(test)] mod tests { + // spell-checker:ignore (tests) asdfsadfa use super::*; #[test] @@ -1012,7 +1014,7 @@ mod tests { } #[test] - fn test_no_std_errout() { + fn test_no_stderr_output() { let res = CmdResult { tmpd: None, code: None, diff --git a/tests/fixtures/cat/three_directories_and_file_and_stdin.stderr.expected b/tests/fixtures/cat/three_directories_and_file_and_stdin.stderr.expected index 1a8a33d77..04a2d4be8 100644 --- a/tests/fixtures/cat/three_directories_and_file_and_stdin.stderr.expected +++ b/tests/fixtures/cat/three_directories_and_file_and_stdin.stderr.expected @@ -1,5 +1,5 @@ cat: test_directory3/test_directory4: Is a directory -cat: filewhichdoesnotexist.txt: No such file or directory (os error 2) +cat: file_which_does_not_exist.txt: No such file or directory (os error 2) cat: test_directory3/test_directory5: Is a directory cat: test_directory3/../test_directory3/test_directory5: Is a directory cat: test_directory3: Is a directory diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected b/tests/fixtures/ptx/gnu_ext_disabled_rightward_auto_ref.expected similarity index 100% rename from tests/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected rename to tests/fixtures/ptx/gnu_ext_disabled_rightward_auto_ref.expected diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected b/tests/fixtures/ptx/gnu_ext_disabled_rightward_input_ref.expected similarity index 100% rename from tests/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected rename to tests/fixtures/ptx/gnu_ext_disabled_rightward_input_ref.expected diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected b/tests/fixtures/ptx/gnu_ext_disabled_rightward_no_ref.expected similarity index 100% rename from tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected rename to tests/fixtures/ptx/gnu_ext_disabled_rightward_no_ref.expected diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected b/tests/fixtures/ptx/gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space.expected similarity index 100% rename from tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected rename to tests/fixtures/ptx/gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space.expected diff --git a/tests/fixtures/tail/foobar_follow_multiple_appended.expected b/tests/fixtures/tail/foobar_follow_multiple_appended.expected index 0896d3743..891eb6920 100644 --- a/tests/fixtures/tail/foobar_follow_multiple_appended.expected +++ b/tests/fixtures/tail/foobar_follow_multiple_appended.expected @@ -1,4 +1,4 @@ ==> foobar.txt <== -doce -trece +twenty +thirty From 3fb8a37aceddd6805b4e14571a5f7e46630c9dcd Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:43:59 -0500 Subject: [PATCH 101/126] refactor ~ (bin/coreutils) polish spelling (comments, names, and exceptions) --- src/bin/coreutils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index 7fc494020..2e703b682 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -58,7 +58,7 @@ fn main() { // binary name equals prefixed util name? // * prefix/stem may be any string ending in a non-alphanumeric character - let utilname = if let Some(util) = utils.keys().find(|util| { + let util_name = if let Some(util) = utils.keys().find(|util| { binary_as_util.ends_with(*util) && !(&binary_as_util[..binary_as_util.len() - (*util).len()]) .ends_with(char::is_alphanumeric) @@ -71,7 +71,7 @@ fn main() { }; // 0th argument equals util name? - if let Some(util_os) = utilname { + if let Some(util_os) = util_name { let util = util_os.as_os_str().to_string_lossy(); match utils.get(&util[..]) { From b418f19c2dbb1ab194ae225c1fd6d5b374940db8 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:28:33 -0500 Subject: [PATCH 102/126] docs/date ~ convert usage text document to a markdown text segment --- src/uu/date/{usage.txt => date-usage.mkd} | 6 ++++++ 1 file changed, 6 insertions(+) rename src/uu/date/{usage.txt => date-usage.mkd} (97%) diff --git a/src/uu/date/usage.txt b/src/uu/date/date-usage.mkd similarity index 97% rename from src/uu/date/usage.txt rename to src/uu/date/date-usage.mkd index 12df1a03c..829001095 100644 --- a/src/uu/date/usage.txt +++ b/src/uu/date/date-usage.mkd @@ -1,3 +1,8 @@ +# `date` usage + + + +``` text FORMAT controls the output. Interpreted sequences are: %% a literal % @@ -70,3 +75,4 @@ Show the time on the west coast of the US (use tzselect(1) to find TZ) Show the local time for 9AM next Friday on the west coast of the US $ date --date='TZ="America/Los_Angeles" 09:00 next Fri' +``` From 1ca44fbbc3c6ac792df635ca3fae967215dbbbc0 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 00:23:12 -0500 Subject: [PATCH 103/126] docs/factor ~ fix markdownlint complaints --- src/uu/factor/BENCHMARKING.md | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/uu/factor/BENCHMARKING.md b/src/uu/factor/BENCHMARKING.md index 7b611db4b..6bf9cbf90 100644 --- a/src/uu/factor/BENCHMARKING.md +++ b/src/uu/factor/BENCHMARKING.md @@ -9,7 +9,6 @@ They are located outside the `uu_factor` crate, as they do not comply with the project's minimum supported Rust version, *i.e.* may require a newer version of `rustc`. - ## Microbenchmarking deterministic functions We currently use [`criterion`] to benchmark deterministic functions, @@ -20,8 +19,9 @@ the hardware, operating system version, etc., but they are noisy and affected by other tasks on the system (browser, compile jobs, etc.), which can cause `criterion` to report spurious performance improvements and regressions. -This can be mitigated by getting as close to [idealised conditions][lemire] +This can be mitigated by getting as close to [idealized conditions][lemire] as possible: + - minimize the amount of computation and I/O running concurrently to the benchmark, *i.e.* close your browser and IM clients, don't compile at the same time, etc. ; @@ -29,15 +29,13 @@ as possible: - [isolate a **physical** core], set it to `nohz_full`, and pin the benchmark to it, so it won't be preempted in the middle of a measurement ; - disable ASLR by running `setarch -R cargo bench`, so we can compare results - across multiple executions. - + across multiple executions. [`criterion`]: https://bheisler.github.io/criterion.rs/book/index.html [lemire]: https://lemire.me/blog/2018/01/16/microbenchmarking-calls-for-idealized-conditions/ [isolate a **physical** core]: https://pyperf.readthedocs.io/en/latest/system.html#isolate-cpus-on-linux [frequency stays constant]: ... - ### Guidance for designing microbenchmarks *Note:* this guidance is specific to `factor` and takes its application domain @@ -45,30 +43,29 @@ into account; do not expect it to generalize to other projects. It is based on Daniel Lemire's [*Microbenchmarking calls for idealized conditions*][lemire], which I recommend reading if you want to add benchmarks to `factor`. -1. Select a small, self-contained, deterministic component +1. Select a small, self-contained, deterministic component `gcd` and `table::factor` are good example of such: - no I/O or access to external data structures ; - no call into other components ; - - behaviour is deterministic: no RNG, no concurrency, ... ; + - behavior is deterministic: no RNG, no concurrency, ... ; - the test's body is *fast* (~100ns for `gcd`, ~10µs for `factor::table`), so each sample takes a very short time, minimizing variability and maximizing the numbers of samples we can take in a given time. -2. Benchmarks are immutable (once merged in `uutils`) +2. Benchmarks are immutable (once merged in `uutils`) Modifying a benchmark means previously-collected values cannot meaningfully be compared, silently giving nonsensical results. If you must modify an existing benchmark, rename it. -3. Test common cases +3. Test common cases We are interested in overall performance, rather than specific edge-cases; - use **reproducibly-randomised inputs**, sampling from either all possible + use **reproducibly-randomized inputs**, sampling from either all possible input values or some subset of interest. -4. Use [`criterion`], `criterion::black_box`, ... +4. Use [`criterion`], `criterion::black_box`, ... `criterion` isn't perfect, but it is also much better than ad-hoc solutions in each benchmark. - ## Wishlist ### Configurable statistical estimators @@ -77,7 +74,6 @@ which I recommend reading if you want to add benchmarks to `factor`. where the code under test is fully deterministic and the measurements are subject to additive, positive noise, [the minimum is more appropriate][lemire]. - ### CI & reproducible performance testing Measuring performance on real hardware is important, as it relates directly @@ -95,19 +91,17 @@ performance improvements and regressions. [`cachegrind`]: https://www.valgrind.org/docs/manual/cg-manual.html [`iai`]: https://bheisler.github.io/criterion.rs/book/iai/iai.html - -### Comparing randomised implementations across multiple inputs +### Comparing randomized implementations across multiple inputs `factor` is a challenging target for system benchmarks as it combines two characteristics: -1. integer factoring algorithms are randomised, with large variance in +1. integer factoring algorithms are randomized, with large variance in execution time ; 2. various inputs also have large differences in factoring time, that corresponds to no natural, linear ordering of the inputs. - If (1) was untrue (i.e. if execution time wasn't random), we could faithfully compare 2 implementations (2 successive versions, or `uutils` and GNU) using a scatter plot, where each axis corresponds to the perf. of one implementation. From ceda51dd5c82e0336b1b3ce8d8ca875ba20440d3 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 20:42:43 -0500 Subject: [PATCH 104/126] docs/ls ~ fix spelling + whitespace --- src/uu/ls/BENCHMARKING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uu/ls/BENCHMARKING.md b/src/uu/ls/BENCHMARKING.md index b009b703a..6bc157805 100644 --- a/src/uu/ls/BENCHMARKING.md +++ b/src/uu/ls/BENCHMARKING.md @@ -1,7 +1,7 @@ # Benchmarking ls ls majorly involves fetching a lot of details (depending upon what details are requested, eg. time/date, inode details, etc) for each path using system calls. Ideally, any system call should be done only once for each of the paths - not adhering to this principle leads to a lot of system call overhead multiplying and bubbling up, especially for recursive ls, therefore it is important to always benchmark multiple scenarios. -This is an overwiew over what was benchmarked, and if you make changes to `ls`, you are encouraged to check +This is an overview over what was benchmarked, and if you make changes to `ls`, you are encouraged to check how performance was affected for the workloads listed below. Feel free to add other workloads to the list that we should improve / make sure not to regress. @@ -55,5 +55,5 @@ However, if the `-R` option is given, the output becomes pretty much useless due #!/bin/bash cargo build --release --no-default-features --features ls perf record target/release/coreutils ls "$@" -perf script | uniq | inferno-collapse-perf | inferno-flamegraph > flamegraph.svg -``` \ No newline at end of file +perf script | uniq | inferno-collapse-perf | inferno-flamegraph > flamegraph.svg +``` From 98aff50d4b1405193fbbd8168f9f560527d9278b Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:37:28 -0500 Subject: [PATCH 105/126] docs/tail ~ fix markdownlint complaints --- src/uu/tail/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uu/tail/README.md b/src/uu/tail/README.md index 53936a609..b7f92f8e4 100644 --- a/src/uu/tail/README.md +++ b/src/uu/tail/README.md @@ -2,17 +2,17 @@ - Rudimentary tail implementation. -## Missing features: +## Missing features ### Flags with features -* [ ] `--max-unchanged-stats` : with `--follow=name`, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files). With inotify, this option is rarely useful. -* [ ] `--retry` : keep trying to open a file even when it is or becomes inaccessible; useful when follow‐ing by name, i.e., with `--follow=name` +- [ ] `--max-unchanged-stats` : with `--follow=name`, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files). With `inotify`, this option is rarely useful. +- [ ] `--retry` : keep trying to open a file even when it is or becomes inaccessible; useful when follow‐ing by name, i.e., with `--follow=name` ### Others - [ ] The current implementation does not handle `-` as an alias for stdin. -## Possible optimizations: +## Possible optimizations -* [ ] Don't read the whole file if not using `-f` and input is regular file. Read in chunks from the end going backwards, reading each individual chunk forward. +- [ ] Don't read the whole file if not using `-f` and input is regular file. Read in chunks from the end going backwards, reading each individual chunk forward. From 5182365f8f9d533e4ef122053a632f9ff1acc11b Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 13:40:59 -0500 Subject: [PATCH 106/126] docs/polish ~ (GH/stale) add spell-checker exceptions --- .github/stale.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/stale.yml b/.github/stale.yml index e0988d0bd..b614226dc 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,4 +1,5 @@ -# Number of days of inactivity before an issue/PR becomes stale +# spell-checker:ignore (labels) wontfix + # Number of days of inactivity before an issue/PR becomes stale daysUntilStale: 365 # Number of days of inactivity before a stale issue/PR is closed daysUntilClose: 365 From 6232c76451d6db2aaece8cad170a184a634a8487 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 13:42:55 -0500 Subject: [PATCH 107/126] docs/README ~ fix spelling + add spell-checker exceptions --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1365bf7ce..0455e86d1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ----------------------------------------------- - + uutils is an attempt at writing universal (as in cross-platform) CLI utilities in [Rust](http://www.rust-lang.org). This repository is intended to @@ -300,13 +300,13 @@ $ make UTILS='UTILITY_1 UTILITY_2' SPEC=y test This testing functionality is only available on *nix operating systems and requires `make`. -To run busybox's tests for all utilities for which busybox has tests +To run busybox tests for all utilities for which busybox has tests ```bash $ make busytest ``` -To run busybox's tests for a few of the available utilities +To run busybox tests for a few of the available utilities ```bash $ make UTILS='UTILITY_1 UTILITY_2' busytest From d65eecc034b8147b7366d908210356b5b4a186e3 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 13:43:21 -0500 Subject: [PATCH 108/126] docs/README ~ fix markdownlint complaints --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0455e86d1..e6aaa71a6 100644 --- a/README.md +++ b/README.md @@ -323,6 +323,7 @@ $ make UTILS='UTILITY_1 UTILITY_2' RUNTEST_ARGS='-v' busytest ![Evolution over time](https://github.com/uutils/coreutils-tracking/blob/main/gnu-results.png?raw=true) To run locally: + ```bash $ bash util/build-gnu.sh $ bash util/run-gnu-test.sh From 3140be7c1b58dba05daf75d1bb4bd5655732db0f Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 21:54:51 -0500 Subject: [PATCH 109/126] docs/CICD ~ add spell-checker exceptions --- .github/workflows/CICD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 5ac9295d4..4092d28d0 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -5,7 +5,7 @@ name: CICD # spell-checker:ignore (jargon) SHAs deps softprops toolchain # spell-checker:ignore (names) CodeCOV MacOS MinGW Peltoche rivy # spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs -# spell-checker:ignore (misc) aarch alnum armhf coreutils gnueabihf issuecomment maint nullglob onexitbegin onexitend tempfile uutils +# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils gnueabihf issuecomment maint nullglob onexitbegin onexitend tempfile testsuite uutils env: PROJECT_NAME: coreutils From 23ed32afe9f88cebde811b0b1aad12c105152946 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 21:55:48 -0500 Subject: [PATCH 110/126] docs/meta ~ fix spelling + add spell-checker exceptions --- CODE_OF_CONDUCT.md | 2 +- DEVELOPER_INSTRUCTIONS.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 6c50b811d..d196c6e95 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -5,7 +5,7 @@ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, +identity and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. diff --git a/DEVELOPER_INSTRUCTIONS.md b/DEVELOPER_INSTRUCTIONS.md index 3aa8b5b12..e0a5cf001 100644 --- a/DEVELOPER_INSTRUCTIONS.md +++ b/DEVELOPER_INSTRUCTIONS.md @@ -1,6 +1,8 @@ Code Coverage Report Generation --------------------------------- + + Code coverage report can be generated using [grcov](https://github.com/mozilla/grcov). ### Using Nightly Rust @@ -17,7 +19,7 @@ $ grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-exist $ # open target/debug/coverage/index.html in browser ``` -if changes are not reflected in the report then run `cargo clean` and run the above commands. +if changes are not reflected in the report then run `cargo clean` and run the above commands. ### Using Stable Rust From 06c53d97fc83bbfed4c3ab4cfdde203428d3ff3f Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 21:57:20 -0500 Subject: [PATCH 111/126] refactor ~ (utils) fix spelling + add spell-checker exceptions --- util/build-gnu.sh | 4 +++- util/rewrite_rules.rs | 2 +- util/run-gnu-test.sh | 1 + util/update-version.sh | 4 +--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 9d73450f6..64329bd0c 100644 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -1,4 +1,7 @@ #!/bin/bash + +# spell-checker:ignore (paths) abmon deref discrim getlimits getopt ginstall gnulib inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW ; (vars/env) BUILDDIR SRCDIR + set -e if test ! -d ../gnu; then echo "Could not find ../gnu" @@ -96,4 +99,3 @@ sed -i 's|seq \$|/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests sed -i 's|cat |/usr/bin/timeout 0.1 cat |' tests/misc/cat-self.sh test -f "${BUILDDIR}/getlimits" || cp src/getlimits "${BUILDDIR}" - diff --git a/util/rewrite_rules.rs b/util/rewrite_rules.rs index 8b29bbe92..3d680e24c 100644 --- a/util/rewrite_rules.rs +++ b/util/rewrite_rules.rs @@ -1,4 +1,4 @@ -//! Rules to update the codebase using Rerast +//! Rules to update the codebase using `rerast` /// Converts try!() to ? fn try_to_question_mark>(r: Result) -> Result { diff --git a/util/run-gnu-test.sh b/util/run-gnu-test.sh index b9948ccd3..61034e015 100644 --- a/util/run-gnu-test.sh +++ b/util/run-gnu-test.sh @@ -1,4 +1,5 @@ #!/bin/bash +# spell-checker:ignore (env/vars) BUILDDIR GNULIB SUBDIRS set -e BUILDDIR="${PWD}/uutils/target/release" GNULIB_DIR="${PWD}/gnulib" diff --git a/util/update-version.sh b/util/update-version.sh index 042d43b71..c71467fc4 100644 --- a/util/update-version.sh +++ b/util/update-version.sh @@ -14,7 +14,7 @@ PROGS=$(ls -1d src/uu/*/Cargo.toml src/uu/stdbuf/src/libstdbuf/Cargo.toml Cargo. # update the version of all programs sed -i -e "s|version = \"$FROM\"|version = \"$TO\"|" $PROGS -# Update the stbuff stuff +# Update the stdbuf stuff sed -i -e "s|libstdbuf = { version=\"$FROM\"|libstdbuf = { version=\"$TO\"|" src/uu/stdbuf/Cargo.toml sed -i -e "s|= { optional=true, version=\"$FROM\", package=\"uu_|= { optional=true, version=\"$TO\", package=\"uu_|g" Cargo.toml @@ -22,5 +22,3 @@ sed -i -e "s|= { optional=true, version=\"$FROM\", package=\"uu_|= { optional=tr #sed -i -e "s|version = \"$UUCORE_FROM\"|version = \"$UUCORE_TO\"|" src/uucore/Cargo.toml # Update crates using uucore #sed -i -e "s|uucore = { version=\">=$UUCORE_FROM\",|uucore = { version=\">=$UUCORE_TO\",|" $PROGS - - From 0b20997d10f069299e73912b50d0425aa5d9b5f1 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 21:58:57 -0500 Subject: [PATCH 112/126] refactor ~ (docs) fix spelling + add spell-checker exceptions --- docs/GNUmakefile | 3 ++- docs/Makefile | 6 +++--- docs/compiles_table.py | 4 +++- docs/conf.py | 4 +++- docs/index.rst | 7 +++++-- docs/make.bat | 5 ++++- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/GNUmakefile b/docs/GNUmakefile index 894a53be0..49d827da8 100644 --- a/docs/GNUmakefile +++ b/docs/GNUmakefile @@ -1,5 +1,6 @@ +# spell-checker:ignore (vars/env) SPHINXOPTS SPHINXBUILD SPHINXPROJ SOURCEDIR BUILDDIR + # Minimal makefile for Sphinx documentation -# # You can set these variables from the command line. SPHINXOPTS = diff --git a/docs/Makefile b/docs/Makefile index 044aaa770..f56df90fb 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,5 +1,5 @@ -USEGNU=gmake $* +UseGNU=gmake $* all: - @$(USEGNU) + @$(UseGNU) .DEFAULT: - @$(USEGNU) + @$(UseGNU) diff --git a/docs/compiles_table.py b/docs/compiles_table.py index a051287c9..aa1b8703c 100644 --- a/docs/compiles_table.py +++ b/docs/compiles_table.py @@ -10,6 +10,8 @@ from pathlib import Path # third party dependencies from tqdm import tqdm +# spell-checker:ignore (libs) tqdm imap ; (shell/mac) xcrun ; (vars) nargs + BINS_PATH=Path("../src/uu") CACHE_PATH=Path("compiles_table.csv") TARGETS = [ @@ -50,7 +52,7 @@ TARGETS = [ class Target(str): def __new__(cls, content): obj = super().__new__(cls, content) - obj.arch, obj.platfrom, obj.os = Target.parse(content) + obj.arch, obj.platform, obj.os = Target.parse(content) return obj @staticmethod diff --git a/docs/conf.py b/docs/conf.py index 74e5e1fb8..5a1213627 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,6 +21,8 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) +# spell-checker:ignore (words) howto htbp imgmath toctree todos uutilsdoc + import glob import os import re @@ -180,6 +182,6 @@ for name in glob.glob('*.rst'): # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'uutils', 'uutils Documentation', - author, 'uutils', 'A cross-platform reimplementation of GNU coreutils in Rust.', + author, 'uutils', 'A cross-platform implementation of GNU coreutils, written in Rust.', 'Miscellaneous'), ] diff --git a/docs/index.rst b/docs/index.rst index 4d70d4368..7f782b12a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,8 +3,11 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to uutils's documentation! -================================== +.. + spell-checker:ignore (directives) genindex maxdepth modindex toctree ; (misc) quickstart + +Welcome to uutils' documentation! +================================= .. toctree:: :maxdepth: 2 diff --git a/docs/make.bat b/docs/make.bat index 1e8ea10a0..6e63e3baa 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -1,5 +1,8 @@ +@setLocal @ECHO OFF +rem spell-checker:ignore (vars/env) BUILDDIR SOURCEDIR SPHINXBUILD SPHINXOPTS SPHINXPROJ + pushd %~dp0 REM Command file for Sphinx documentation @@ -14,7 +17,7 @@ set SPHINXPROJ=uutils if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( +if ErrorLevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point From ec982bb695686b1391b241142003b4c95fac0d63 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 21:59:38 -0500 Subject: [PATCH 113/126] refactor ~ (makefiles) fix spelling + add spell-checker exceptions --- GNUmakefile | 4 +++- Makefile | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 409a527cd..b6a4e5c56 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,3 +1,5 @@ +# spell-checker:ignore (misc) testsuite runtest (targets) busytest distclean manpages pkgs ; (vars/env) BINDIR BUILDDIR CARGOFLAGS DESTDIR DOCSDIR INSTALLDIR INSTALLEES MANDIR MULTICALL + # Config options PROFILE ?= debug MULTICALL ?= n @@ -274,7 +276,7 @@ busybox-src: $(BUILDDIR)/.config: $(BASEDIR)/.busybox-config cp $< $@ -# Test under the busybox testsuite +# Test under the busybox test suite $(BUILDDIR)/busybox: busybox-src build-coreutils $(BUILDDIR)/.config cp $(BUILDDIR)/coreutils $(BUILDDIR)/busybox; \ chmod +x $@; diff --git a/Makefile b/Makefile index 044aaa770..f56df90fb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -USEGNU=gmake $* +UseGNU=gmake $* all: - @$(USEGNU) + @$(UseGNU) .DEFAULT: - @$(USEGNU) + @$(UseGNU) From c392cd1cb452fb1dc7521b35f3fed3d8117b6fae Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 22:19:03 -0500 Subject: [PATCH 114/126] maint/CICD ~ `cspell`-check all repository files --- .github/workflows/CICD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 4092d28d0..78048adff 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -630,4 +630,4 @@ jobs: - name: Run `cspell` shell: bash run: | - cspell --config .vscode/cSpell.json --no-summary --no-progress $( git ls-files | grep "\.\(rs\|md\)" ) | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true + cspell --config .vscode/cSpell.json --no-summary --no-progress **/* | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true From 3f35e0a4218521c37f21f49007befc175c402767 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 22:55:28 -0500 Subject: [PATCH 115/126] refactor ~ `cargo make format` --- src/uu/od/src/prn_int.rs | 5 +++- .../src/tokenize/num_format/formatter.rs | 1 - .../formatters/cninetyninehexfloatf.rs | 15 +++++++++--- .../tokenize/num_format/formatters/decf.rs | 12 ++++++---- .../num_format/formatters/float_common.rs | 4 +++- .../tokenize/num_format/formatters/floatf.rs | 9 +++++-- .../tokenize/num_format/formatters/intf.rs | 7 +++++- src/uu/stat/src/stat.rs | 22 ++++++++++------- src/uucore/src/lib/features/fsext.rs | 4 ++-- tests/benches/factor/benches/table.rs | 2 +- tests/by-util/test_base64.rs | 4 ++-- tests/by-util/test_cat.rs | 12 +++++----- tests/by-util/test_comm.rs | 2 +- tests/by-util/test_date.rs | 2 +- tests/by-util/test_dircolors.rs | 4 ++-- tests/by-util/test_echo.rs | 2 +- tests/by-util/test_factor.rs | 5 +++- tests/by-util/test_fold.rs | 8 +++---- tests/by-util/test_kill.rs | 2 +- tests/by-util/test_ln.rs | 2 +- tests/by-util/test_ls.rs | 2 +- tests/by-util/test_mktemp.rs | 4 ++-- tests/by-util/test_more.rs | 6 +++-- tests/by-util/test_mv.rs | 2 +- tests/by-util/test_nice.rs | 2 +- tests/by-util/test_od.rs | 24 +++++++++---------- tests/by-util/test_pinky.rs | 6 ++--- tests/by-util/test_printf.rs | 8 +++---- tests/by-util/test_relpath.rs | 4 ++-- tests/by-util/test_rm.rs | 2 +- tests/by-util/test_sort.rs | 12 +++++----- tests/by-util/test_stat.rs | 6 ++--- tests/by-util/test_tail.rs | 2 +- tests/by-util/test_test.rs | 2 +- tests/by-util/test_tr.rs | 16 ++++++------- tests/by-util/test_truncate.rs | 7 +----- 36 files changed, 129 insertions(+), 100 deletions(-) diff --git a/src/uu/od/src/prn_int.rs b/src/uu/od/src/prn_int.rs index 5e31da9dd..0946824c1 100644 --- a/src/uu/od/src/prn_int.rs +++ b/src/uu/od/src/prn_int.rs @@ -153,7 +153,10 @@ fn test_format_item_hex() { assert_eq!(" 00000000", format_item_hex32(0)); assert_eq!(" ffffffff", format_item_hex32(0xffff_ffff)); assert_eq!(" 0000000000000000", format_item_hex64(0)); - assert_eq!(" ffffffffffffffff", format_item_hex64(0xffff_ffff_ffff_ffff)); + assert_eq!( + " ffffffffffffffff", + format_item_hex64(0xffff_ffff_ffff_ffff) + ); } #[test] diff --git a/src/uu/printf/src/tokenize/num_format/formatter.rs b/src/uu/printf/src/tokenize/num_format/formatter.rs index 9fd5954ed..f5f5d71b1 100644 --- a/src/uu/printf/src/tokenize/num_format/formatter.rs +++ b/src/uu/printf/src/tokenize/num_format/formatter.rs @@ -1,4 +1,3 @@ - //! Primitives used by num_format and sub_modules. //! never dealt with above (e.g. Sub Tokenizer never uses these) diff --git a/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs b/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs index 104e55ef3..f96a991b5 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs @@ -25,8 +25,13 @@ impl Formatter for CninetyNineHexFloatf { str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; - let analysis = - FloatAnalysis::analyze(&str_in, initial_prefix, Some(second_field as usize), None, true); + let analysis = FloatAnalysis::analyze( + &str_in, + initial_prefix, + Some(second_field as usize), + None, + true, + ); let f = get_primitive_hex( initial_prefix, &str_in[initial_prefix.offset..], @@ -51,7 +56,11 @@ fn get_primitive_hex( _last_dec_place: usize, capitalized: bool, ) -> FormatPrimitive { - let prefix = Some(String::from(if initial_prefix.sign == -1 { "-0x" } else { "0x" })); + let prefix = Some(String::from(if initial_prefix.sign == -1 { + "-0x" + } else { + "0x" + })); // TODO actual conversion, make sure to get back mantissa. // for hex to hex, it's really just a matter of moving the diff --git a/src/uu/printf/src/tokenize/num_format/formatters/decf.rs b/src/uu/printf/src/tokenize/num_format/formatters/decf.rs index 4d729f0ce..5798eadcb 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/decf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/decf.rs @@ -76,11 +76,13 @@ impl Formatter for Decf { second_field as usize, None, ); - Some(if get_len_fmt_primitive(&f_fl) >= get_len_fmt_primitive(&f_sci) { - f_sci - } else { - f_fl - }) + Some( + if get_len_fmt_primitive(&f_fl) >= get_len_fmt_primitive(&f_sci) { + f_sci + } else { + f_fl + }, + ) } fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String { primitive_to_str_common(prim, &field) diff --git a/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs b/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs index 4cbb496e4..dd8259233 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs @@ -2,7 +2,9 @@ // spell-checker:ignore (ToDO) arrnum use super::super::format_field::FormatField; -use super::super::formatter::{get_it_at, warn_incomplete_conv, Base, FormatPrimitive, InitialPrefix}; +use super::super::formatter::{ + get_it_at, warn_incomplete_conv, Base, FormatPrimitive, InitialPrefix, +}; use super::base_conv; use super::base_conv::RadixDef; diff --git a/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs b/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs index 79bb51fb8..aed50f18e 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs @@ -20,8 +20,13 @@ impl Formatter for Floatf { str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; - let analysis = - FloatAnalysis::analyze(&str_in, initial_prefix, None, Some(second_field as usize), false); + let analysis = FloatAnalysis::analyze( + &str_in, + initial_prefix, + None, + Some(second_field as usize), + false, + ); let f = get_primitive_dec( initial_prefix, &str_in[initial_prefix.offset..], diff --git a/src/uu/printf/src/tokenize/num_format/formatters/intf.rs b/src/uu/printf/src/tokenize/num_format/formatters/intf.rs index 1e9e25560..02c59211b 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/intf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/intf.rs @@ -150,7 +150,12 @@ impl Intf { // - if the string falls outside bounds: // for i64 output, the int minimum or int max (depending on sign) // for u64 output, the u64 max in the output radix - fn conv_from_segment(segment: &str, radix_in: Base, field_char: char, sign: i8) -> FormatPrimitive { + fn conv_from_segment( + segment: &str, + radix_in: Base, + field_char: char, + sign: i8, + ) -> FormatPrimitive { match field_char { 'i' | 'd' => match i64::from_str_radix(segment, radix_in as u32) { Ok(i) => { diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 83567e447..403134b4b 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -475,12 +475,14 @@ impl Stater { let show_fs = matches.is_present(options::FILE_SYSTEM); let default_tokens = if format_str.is_empty() { - Stater::generate_tokens(&Stater::default_format(show_fs, terse, false), use_printf).unwrap() + Stater::generate_tokens(&Stater::default_format(show_fs, terse, false), use_printf) + .unwrap() } else { Stater::generate_tokens(&format_str, use_printf)? }; let default_dev_tokens = - Stater::generate_tokens(&Stater::default_format(show_fs, terse, true), use_printf).unwrap(); + Stater::generate_tokens(&Stater::default_format(show_fs, terse, true), use_printf) + .unwrap(); let mount_list = if show_fs { // mount points aren't displayed when showing filesystem information @@ -540,12 +542,13 @@ impl Stater { match result { Ok(meta) => { let file_type = meta.file_type(); - let tokens = - if self.from_user || !(file_type.is_char_device() || file_type.is_block_device()) { - &self.default_tokens - } else { - &self.default_dev_tokens - }; + let tokens = if self.from_user + || !(file_type.is_char_device() || file_type.is_block_device()) + { + &self.default_tokens + } else { + &self.default_dev_tokens + }; for t in tokens.iter() { match *t { @@ -867,7 +870,8 @@ impl Stater { } else { format_str.push_str(" File: %N\n Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"); if show_dev_type { - format_str.push_str("Device: %Dh/%dd\tInode: %-10i Links: %-5h Device type: %t,%T\n"); + format_str + .push_str("Device: %Dh/%dd\tInode: %-10i Links: %-5h Device type: %t,%T\n"); } else { format_str.push_str("Device: %Dh/%dd\tInode: %-10i Links: %h\n"); } diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index e1cb67097..d3eec468a 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -612,12 +612,12 @@ impl FsMeta for StatFs { } #[cfg(target_os = "freebsd")] fn namelen(&self) -> u64 { - self.f_namemax as u64 // spell-checker:disable-line + self.f_namemax as u64 // spell-checker:disable-line } // XXX: should everything just use statvfs? #[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))] fn namelen(&self) -> u64 { - self.f_namemax as u64 // spell-checker:disable-line + self.f_namemax as u64 // spell-checker:disable-line } } diff --git a/tests/benches/factor/benches/table.rs b/tests/benches/factor/benches/table.rs index d8859d940..9090c7d51 100644 --- a/tests/benches/factor/benches/table.rs +++ b/tests/benches/factor/benches/table.rs @@ -18,7 +18,7 @@ fn table(c: &mut Criterion) { // Deterministic RNG; use an explicitly-named RNG to guarantee stability use rand::{RngCore, SeedableRng}; use rand_chacha::ChaCha8Rng; - const SEED: u64 = 0xdead_bebe_ea75_cafe; // spell-checker:disable-line + const SEED: u64 = 0xdead_bebe_ea75_cafe; // spell-checker:disable-line let mut rng = ChaCha8Rng::seed_from_u64(SEED); std::iter::repeat_with(move || array_init::<_, _, INPUT_SIZE>(|_| rng.next_u64())) diff --git a/tests/by-util/test_base64.rs b/tests/by-util/test_base64.rs index 459845ccf..236f53fb1 100644 --- a/tests/by-util/test_base64.rs +++ b/tests/by-util/test_base64.rs @@ -38,7 +38,7 @@ fn test_decode() { #[test] fn test_garbage() { - let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line + let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line new_ucmd!() .arg("-d") .pipe_in(input) @@ -49,7 +49,7 @@ fn test_garbage() { #[test] fn test_ignore_garbage() { for ignore_garbage_param in &["-i", "--ignore-garbage"] { - let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line + let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line new_ucmd!() .arg("-d") .arg(ignore_garbage_param) diff --git a/tests/by-util/test_cat.rs b/tests/by-util/test_cat.rs index b00c58dc1..fadf378ab 100644 --- a/tests/by-util/test_cat.rs +++ b/tests/by-util/test_cat.rs @@ -9,7 +9,7 @@ fn test_output_simple() { new_ucmd!() .args(&["alpha.txt"]) .succeeds() - .stdout_only("abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line + .stdout_only("abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line } #[test] @@ -67,8 +67,8 @@ fn test_fifo_symlink() { assert!(s.fixtures.is_fifo("dir/pipe")); // Make cat read the pipe through a symlink - s.fixtures.symlink_file("dir/pipe", "sympipe"); // spell-checker:disable-line - let proc = s.ucmd().args(&["sympipe"]).run_no_wait(); // spell-checker:disable-line + s.fixtures.symlink_file("dir/pipe", "sympipe"); // spell-checker:disable-line + let proc = s.ucmd().args(&["sympipe"]).run_no_wait(); // spell-checker:disable-line let data = vec_of_size(128 * 1024); let data2 = data.clone(); @@ -111,7 +111,7 @@ fn test_piped_to_regular_file() { .succeeds(); } let contents = read_to_string(&file_path).unwrap(); - assert_eq!(contents, "abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line + assert_eq!(contents, "abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line } } @@ -193,7 +193,7 @@ fn test_three_directories_and_file_and_stdin() { "alpha.txt", "-", "file_which_does_not_exist.txt", - "nonewline.txt", // spell-checker:disable-line + "nonewline.txt", // spell-checker:disable-line "test_directory3/test_directory5", "test_directory3/../test_directory3/test_directory5", "test_directory3", @@ -202,7 +202,7 @@ fn test_three_directories_and_file_and_stdin() { .fails() .stderr_is_fixture("three_directories_and_file_and_stdin.stderr.expected") .stdout_is( - "abcde\nfghij\nklmno\npqrst\nuvwxyz\nstdout bytestext without a trailing newline", // spell-checker:disable-line + "abcde\nfghij\nklmno\npqrst\nuvwxyz\nstdout bytestext without a trailing newline", // spell-checker:disable-line ); } diff --git a/tests/by-util/test_comm.rs b/tests/by-util/test_comm.rs index ba26f6819..01cdcc985 100644 --- a/tests/by-util/test_comm.rs +++ b/tests/by-util/test_comm.rs @@ -39,7 +39,7 @@ fn a_empty() { new_ucmd!() .args(&["a", "empty"]) .succeeds() - .stdout_only_fixture("aempty.expected"); // spell-checker:disable-line + .stdout_only_fixture("aempty.expected"); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index 9689ff49e..72747fa66 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -181,7 +181,7 @@ fn test_date_set_valid_2() { if get_effective_uid() == 0 { let result = new_ucmd!() .arg("--set") - .arg("Sat 20 Mar 2021 14:53:01 AWST") // spell-checker:disable-line + .arg("Sat 20 Mar 2021 14:53:01 AWST") // spell-checker:disable-line .fails(); result.no_stdout(); assert!(result.stderr_str().starts_with("date: invalid date ")); diff --git a/tests/by-util/test_dircolors.rs b/tests/by-util/test_dircolors.rs index 86b72d23b..fac4161f3 100644 --- a/tests/by-util/test_dircolors.rs +++ b/tests/by-util/test_dircolors.rs @@ -35,9 +35,9 @@ fn test_str_utils() { assert_eq!("asd#zcv", s.purify()); let s = "con256asd"; - assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line + assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line - let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line + let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line let (k, v) = s.split_two(); assert_eq!("zxc", k); assert_eq!("qwe jlk hjl", v); diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index 483ad99f5..09ed9658f 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -189,7 +189,7 @@ fn test_hyphen_values_inside_string() { new_ucmd!() .arg("'\"\n'CXXFLAGS=-g -O2'\n\"'") // spell-checker:disable-line .succeeds() - .stdout_contains("CXXFLAGS"); // spell-checker:disable-line + .stdout_contains("CXXFLAGS"); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_factor.rs b/tests/by-util/test_factor.rs index 063cf0e4f..a3f06ea8a 100644 --- a/tests/by-util/test_factor.rs +++ b/tests/by-util/test_factor.rs @@ -209,7 +209,10 @@ fn test_big_primes() { fn run(input_string: &[u8], output_string: &[u8]) { println!("STDIN='{}'", String::from_utf8_lossy(input_string)); - println!("STDOUT(expected)='{}'", String::from_utf8_lossy(output_string)); + println!( + "STDOUT(expected)='{}'", + String::from_utf8_lossy(output_string) + ); // now run factor new_ucmd!() .pipe_in(input_string) diff --git a/tests/by-util/test_fold.rs b/tests/by-util/test_fold.rs index 62a2bddf3..1acdadac1 100644 --- a/tests/by-util/test_fold.rs +++ b/tests/by-util/test_fold.rs @@ -282,7 +282,7 @@ fn test_backspace_is_not_word_boundary() { .args(&["-w10", "-s"]) .pipe_in("foobar\x086789abcdef") .succeeds() - .stdout_is("foobar\x086789a\nbcdef"); // spell-checker:disable-line + .stdout_is("foobar\x086789a\nbcdef"); // spell-checker:disable-line } #[test] @@ -308,9 +308,9 @@ fn test_carriage_return_should_reset_column_count() { fn test_carriage_return_is_not_word_boundary() { new_ucmd!() .args(&["-w6", "-s"]) - .pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line + .pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line .succeeds() - .stdout_is("fizz\rbuzz\rfizzbu\nzz"); // spell-checker:disable-line + .stdout_is("fizz\rbuzz\rfizzbu\nzz"); // spell-checker:disable-line } // @@ -530,7 +530,7 @@ fn test_bytewise_carriage_return_should_not_reset_column_count() { fn test_bytewise_carriage_return_is_not_word_boundary() { new_ucmd!() .args(&["-w6", "-s", "-b"]) - .pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line + .pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line .succeeds() .stdout_is("fizz\rb\nuzz\rfi\nzzbuzz"); // spell-checker:disable-line } diff --git a/tests/by-util/test_kill.rs b/tests/by-util/test_kill.rs index 886445109..fe5d4557a 100644 --- a/tests/by-util/test_kill.rs +++ b/tests/by-util/test_kill.rs @@ -82,7 +82,7 @@ fn test_kill_set_bad_signal_name() { // spell-checker:disable-line new_ucmd!() .arg("-s") - .arg("IAMNOTASIGNAL") // spell-checker:disable-line + .arg("IAMNOTASIGNAL") // spell-checker:disable-line .fails() .stderr_contains("unknown signal"); } diff --git a/tests/by-util/test_ln.rs b/tests/by-util/test_ln.rs index 4dc50566b..e475e3608 100644 --- a/tests/by-util/test_ln.rs +++ b/tests/by-util/test_ln.rs @@ -120,7 +120,7 @@ fn test_symlink_interactive() { scene .ucmd() .args(&["-i", "-s", file, link]) - .pipe_in("Yesh") // spell-checker:disable-line + .pipe_in("Yesh") // spell-checker:disable-line .succeeds() .no_stderr(); diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index dd6e4a85d..20c6b913d 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -941,7 +941,7 @@ fn test_ls_color() { let a_with_colors = "\x1b[1;34ma\x1b[0m"; let z_with_colors = "\x1b[1;34mz\x1b[0m"; - let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m"; // spell-checker:disable-line + let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m"; // spell-checker:disable-line // Color is disabled by default let result = scene.ucmd().succeeds(); diff --git a/tests/by-util/test_mktemp.rs b/tests/by-util/test_mktemp.rs index e61d45428..d601bad5b 100644 --- a/tests/by-util/test_mktemp.rs +++ b/tests/by-util/test_mktemp.rs @@ -10,8 +10,8 @@ static TEST_TEMPLATE2: &str = "temp"; static TEST_TEMPLATE3: &str = "tempX"; static TEST_TEMPLATE4: &str = "tempXX"; static TEST_TEMPLATE5: &str = "tempXXX"; -static TEST_TEMPLATE6: &str = "tempXXXlate"; // spell-checker:disable-line -static TEST_TEMPLATE7: &str = "XXXtemplate"; // spell-checker:disable-line +static TEST_TEMPLATE6: &str = "tempXXXlate"; // spell-checker:disable-line +static TEST_TEMPLATE7: &str = "XXXtemplate"; // spell-checker:disable-line #[cfg(unix)] static TEST_TEMPLATE8: &str = "tempXXXl/ate"; #[cfg(windows)] diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index 69499ccfe..9b28ee24e 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -5,7 +5,8 @@ fn test_more_no_arg() { // Reading from stdin is now supported, so this must succeed if atty::is(atty::Stream::Stdout) { new_ucmd!().succeeds(); - } else {} + } else { + } } #[test] @@ -19,5 +20,6 @@ fn test_more_dir_arg() { const EXPECTED_ERROR_MESSAGE: &str = "more: '.' is a directory.\nTry 'more --help' for more information."; assert_eq!(result.stderr_str().trim(), EXPECTED_ERROR_MESSAGE); - } else {} + } else { + } } diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index 2782ac246..2f35bf5eb 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -171,7 +171,7 @@ fn test_mv_interactive() { .arg("-i") .arg(file_a) .arg(file_b) - .pipe_in("Yesh") // spell-checker:disable-line + .pipe_in("Yesh") // spell-checker:disable-line .succeeds() .no_stderr(); diff --git a/tests/by-util/test_nice.rs b/tests/by-util/test_nice.rs index 005651c52..25886de78 100644 --- a/tests/by-util/test_nice.rs +++ b/tests/by-util/test_nice.rs @@ -17,7 +17,7 @@ fn test_negative_adjustment() { let res = new_ucmd!().args(&["-n", "-1", "true"]).run(); assert!(res .stderr_str() - .starts_with("nice: warning: setpriority: Permission denied")); // spell-checker:disable-line + .starts_with("nice: warning: setpriority: Permission denied")); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_od.rs b/tests/by-util/test_od.rs index 6b1c39d63..c21c683dc 100644 --- a/tests/by-util/test_od.rs +++ b/tests/by-util/test_od.rs @@ -81,7 +81,7 @@ fn test_2files() { fn test_no_file() { let temp = env::temp_dir(); let tmpdir = Path::new(&temp); - let file = tmpdir.join("}surely'none'would'thus'a'file'name"); // spell-checker:disable-line + let file = tmpdir.join("}surely'none'would'thus'a'file'name"); // spell-checker:disable-line new_ucmd!().arg(file.as_os_str()).fails(); } @@ -89,7 +89,7 @@ fn test_no_file() { // Test that od reads from stdin instead of a file #[test] fn test_from_stdin() { - let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line + let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line new_ucmd!() .arg("--endian=little") .run_piped_stdin(input.as_bytes()) @@ -128,7 +128,7 @@ fn test_from_mixed() { #[test] fn test_multiple_formats() { - let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line + let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("-b") @@ -294,7 +294,7 @@ fn test_multibyte() { new_ucmd!() .arg("-c") .arg("-w12") - .run_piped_stdin("Universität Tübingen \u{1B000}".as_bytes()) // spell-checker:disable-line + .run_piped_stdin("Universität Tübingen \u{1B000}".as_bytes()) // spell-checker:disable-line .success() .no_stderr() .stdout_is(unindent( @@ -511,7 +511,7 @@ fn test_max_uint() { new_ucmd!() .arg("--format=o8") - .arg("-Oobtu8") // spell-checker:disable-line + .arg("-Oobtu8") // spell-checker:disable-line .arg("-Dd") .arg("--format=u1") .run_piped_stdin(&input[..]) @@ -589,7 +589,7 @@ fn test_invalid_offset() { #[test] fn test_skip_bytes() { - let input = "abcdefghijklmnopq"; // spell-checker:disable-line + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("--skip-bytes=5") @@ -615,7 +615,7 @@ fn test_skip_bytes_error() { #[test] fn test_read_bytes() { - let input = "abcdefghijklmnopqrstuvwxyz\n12345678"; // spell-checker:disable-line + let input = "abcdefghijklmnopqrstuvwxyz\n12345678"; // spell-checker:disable-line new_ucmd!() .arg("--endian=little") .arg("--read-bytes=27") @@ -674,7 +674,7 @@ fn test_filename_parsing() { #[test] fn test_stdin_offset() { - let input = "abcdefghijklmnopq"; // spell-checker:disable-line + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("+5") @@ -709,7 +709,7 @@ fn test_file_offset() { #[test] fn test_traditional() { // note gnu od does not align both lines - let input = "abcdefghijklmnopq"; // spell-checker:disable-line + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("-a") @@ -732,7 +732,7 @@ fn test_traditional() { #[test] fn test_traditional_with_skip_bytes_override() { // --skip-bytes is ignored in this case - let input = "abcdefghijklmnop"; // spell-checker:disable-line + let input = "abcdefghijklmnop"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("--skip-bytes=10") @@ -752,7 +752,7 @@ fn test_traditional_with_skip_bytes_override() { #[test] fn test_traditional_with_skip_bytes_non_override() { // no offset specified in the traditional way, so --skip-bytes is used - let input = "abcdefghijklmnop"; // spell-checker:disable-line + let input = "abcdefghijklmnop"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("--skip-bytes=10") @@ -782,7 +782,7 @@ fn test_traditional_error() { #[test] fn test_traditional_only_label() { - let input = "abcdefghijklmnopqrstuvwxyz"; // spell-checker:disable-line + let input = "abcdefghijklmnopqrstuvwxyz"; // spell-checker:disable-line new_ucmd!() .arg("-An") .arg("--traditional") diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index c3c9ea2e4..0813e5e1b 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -9,9 +9,9 @@ pub use self::pinky::*; #[test] fn test_capitalize() { - assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line - assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line - assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line + assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line + assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line + assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line assert_eq!("", "".capitalize()); } diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 40e91ef4f..b5c9dc3ed 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -401,7 +401,7 @@ fn sub_any_asterisk_hex_arg() { #[test] fn sub_any_specifiers_no_params() { new_ucmd!() - .args(&["%ztlhLji", "3"]) //spell-checker:disable-line + .args(&["%ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -409,7 +409,7 @@ fn sub_any_specifiers_no_params() { #[test] fn sub_any_specifiers_after_first_param() { new_ucmd!() - .args(&["%0ztlhLji", "3"]) //spell-checker:disable-line + .args(&["%0ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -417,7 +417,7 @@ fn sub_any_specifiers_after_first_param() { #[test] fn sub_any_specifiers_after_period() { new_ucmd!() - .args(&["%0.ztlhLji", "3"]) //spell-checker:disable-line + .args(&["%0.ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -425,7 +425,7 @@ fn sub_any_specifiers_after_period() { #[test] fn sub_any_specifiers_after_second_param() { new_ucmd!() - .args(&["%0.0ztlhLji", "3"]) //spell-checker:disable-line + .args(&["%0.0ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } diff --git a/tests/by-util/test_relpath.rs b/tests/by-util/test_relpath.rs index 051f46084..44a685c90 100644 --- a/tests/by-util/test_relpath.rs +++ b/tests/by-util/test_relpath.rs @@ -120,7 +120,7 @@ fn test_relpath_with_from_with_d() { .ucmd() .arg(to) .arg(from) - .arg("-dnon_existing") // spell-checker:disable-line + .arg("-dnon_existing") // spell-checker:disable-line .succeeds() .stdout_move_str(); assert!(Path::new(&_result_stdout).is_absolute()); @@ -170,7 +170,7 @@ fn test_relpath_no_from_with_d() { let result_stdout = scene .ucmd() .arg(to) - .arg("-dnon_existing") // spell-checker:disable-line + .arg("-dnon_existing") // spell-checker:disable-line .succeeds() .stdout_move_str(); assert!(Path::new(&result_stdout).is_absolute()); diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index 64259d02c..0592be244 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -65,7 +65,7 @@ fn test_rm_interactive() { .arg("-i") .arg(file_a) .arg(file_b) - .pipe_in("Yesh") // spell-checker:disable-line + .pipe_in("Yesh") // spell-checker:disable-line .succeeds(); assert!(!at.file_exists(file_a)); diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index c31d44110..d2b447925 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -292,10 +292,10 @@ fn test_dictionary_order() { fn test_dictionary_order2() { for non_dictionary_order2_param in &["-d"] { new_ucmd!() - .pipe_in("a👦🏻aa b\naaaa b") // spell-checker:disable-line - .arg(non_dictionary_order2_param) // spell-checker:disable-line + .pipe_in("a👦🏻aa b\naaaa b") // spell-checker:disable-line + .arg(non_dictionary_order2_param) // spell-checker:disable-line .succeeds() - .stdout_only("a👦🏻aa b\naaaa b\n"); // spell-checker:disable-line + .stdout_only("a👦🏻aa b\naaaa b\n"); // spell-checker:disable-line } } @@ -303,10 +303,10 @@ fn test_dictionary_order2() { fn test_non_printing_chars() { for non_printing_chars_param in &["-i"] { new_ucmd!() - .pipe_in("a👦🏻aa\naaaa") // spell-checker:disable-line - .arg(non_printing_chars_param) // spell-checker:disable-line + .pipe_in("a👦🏻aa\naaaa") // spell-checker:disable-line + .arg(non_printing_chars_param) // spell-checker:disable-line .succeeds() - .stdout_only("a👦🏻aa\naaaa\n"); // spell-checker:disable-line + .stdout_only("a👦🏻aa\naaaa\n"); // spell-checker:disable-line } } diff --git a/tests/by-util/test_stat.rs b/tests/by-util/test_stat.rs index 5c8d9d185..89dd96752 100644 --- a/tests/by-util/test_stat.rs +++ b/tests/by-util/test_stat.rs @@ -13,9 +13,9 @@ fn test_scanners() { assert_eq!(None, "z192zxc".scan_num::()); assert_eq!(Some(('a', 3)), "141zxc".scan_char(8)); - assert_eq!(Some(('\n', 2)), "12qzxc".scan_char(8)); // spell-checker:disable-line - assert_eq!(Some(('\r', 1)), "dqzxc".scan_char(16)); // spell-checker:disable-line - assert_eq!(None, "z2qzxc".scan_char(8)); // spell-checker:disable-line + assert_eq!(Some(('\n', 2)), "12qzxc".scan_char(8)); // spell-checker:disable-line + assert_eq!(Some(('\r', 1)), "dqzxc".scan_char(16)); // spell-checker:disable-line + assert_eq!(None, "z2qzxc".scan_char(8)); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index 0e3092562..b31344c34 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -268,7 +268,7 @@ fn test_parse_size() { assert!(parse_size("1Y").is_err()); // Bad number - assert!(parse_size("328hdsf3290").is_err()); // spell-checker:disable-line + assert!(parse_size("328hdsf3290").is_err()); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_test.rs b/tests/by-util/test_test.rs index a29c4f6c6..aaf09d657 100644 --- a/tests/by-util/test_test.rs +++ b/tests/by-util/test_test.rs @@ -210,7 +210,7 @@ fn test_pseudofloat_not_equal() { #[test] fn test_negative_arg_is_a_string() { new_ucmd!().arg("-12345").succeeds(); - new_ucmd!().arg("--qwert").succeeds(); // spell-checker:disable-line + new_ucmd!().arg("--qwert").succeeds(); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_tr.rs b/tests/by-util/test_tr.rs index 4ddaff573..936af2ca8 100644 --- a/tests/by-util/test_tr.rs +++ b/tests/by-util/test_tr.rs @@ -140,9 +140,9 @@ fn test_translate_and_squeeze() { fn test_translate_and_squeeze_multiple_lines() { new_ucmd!() .args(&["-s", "x", "y"]) - .pipe_in("xxaax\nxaaxx") // spell-checker:disable-line + .pipe_in("xxaax\nxaaxx") // spell-checker:disable-line .run() - .stdout_is("yaay\nyaay"); // spell-checker:disable-line + .stdout_is("yaay\nyaay"); // spell-checker:disable-line } #[test] @@ -169,7 +169,7 @@ fn test_set1_longer_than_set2() { .args(&["abc", "xy"]) .pipe_in("abcde") .run() - .stdout_is("xyyde"); // spell-checker:disable-line + .stdout_is("xyyde"); // spell-checker:disable-line } #[test] @@ -178,7 +178,7 @@ fn test_set1_shorter_than_set2() { .args(&["ab", "xyz"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); // spell-checker:disable-line + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -187,7 +187,7 @@ fn test_truncate() { .args(&["-t", "abc", "xy"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); // spell-checker:disable-line + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -196,7 +196,7 @@ fn test_truncate_with_set1_shorter_than_set2() { .args(&["-t", "ab", "xyz"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); // spell-checker:disable-line + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -216,8 +216,8 @@ fn missing_required_second_arg_fails() { #[test] fn test_interpret_backslash_escapes() { new_ucmd!() - .args(&["abfnrtv", r"\a\b\f\n\r\t\v"]) // spell-checker:disable-line - .pipe_in("abfnrtv") // spell-checker:disable-line + .args(&["abfnrtv", r"\a\b\f\n\r\t\v"]) // spell-checker:disable-line + .pipe_in("abfnrtv") // spell-checker:disable-line .succeeds() .stdout_is("\u{7}\u{8}\u{c}\n\r\t\u{b}"); } diff --git a/tests/by-util/test_truncate.rs b/tests/by-util/test_truncate.rs index f98027127..bb0f4a596 100644 --- a/tests/by-util/test_truncate.rs +++ b/tests/by-util/test_truncate.rs @@ -47,12 +47,7 @@ fn test_reference() { scene.ucmd().arg("-s").arg("+5KB").arg(FILE1).run(); - scene - .ucmd() - .arg("--reference") - .arg(FILE1) - .arg(FILE2) - .run(); + scene.ucmd().arg("--reference").arg(FILE1).arg(FILE2).run(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); From 691f03b9aed62ae980f284e4aea153e34614a810 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 23:18:46 -0500 Subject: [PATCH 116/126] maint/CICD ~ improve visibility of spell check during testing --- .github/workflows/CICD.yml | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 78048adff..4ce9e556d 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -58,6 +58,24 @@ jobs: # * convert any warnings to GHA UI annotations; ref: S=$(find tests -name "*.rs" -print0 | xargs -0 cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; } + code_spellcheck: + name: Style/spelling + runs-on: ${{ matrix.job.os }} + strategy: + matrix: + job: + - { os: ubuntu-latest } + steps: + - uses: actions/checkout@v1 + - name: Install/setup prerequisites + shell: bash + run: | + sudo apt-get -y update ; sudo apt-get -y install npm ; sudo npm install cspell -g; + - name: Run `cspell` + shell: bash + run: | + cspell --config .vscode/cSpell.json --no-summary --no-progress **/* | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true + code_warnings: name: Style/warnings runs-on: ${{ matrix.job.os }} @@ -614,20 +632,3 @@ jobs: flags: ${{ steps.vars.outputs.CODECOV_FLAGS }} name: codecov-umbrella fail_ci_if_error: false - spellcheck: - name: Spell Check - runs-on: ${{ matrix.job.os }} - strategy: - matrix: - job: - - { os: ubuntu-latest } - steps: - - uses: actions/checkout@v1 - - name: Install/setup prerequisites - shell: bash - run: | - sudo apt-get -y update ; sudo apt-get -y install npm ; sudo npm install cspell -g; - - name: Run `cspell` - shell: bash - run: | - cspell --config .vscode/cSpell.json --no-summary --no-progress **/* | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true From 9d8e7b9acbb0b0a41fc6488687a0293b6f696aef Mon Sep 17 00:00:00 2001 From: Dean Li Date: Mon, 31 May 2021 20:13:58 +0800 Subject: [PATCH 117/126] Fix touch parse date error Now it can parse `touch -d 2000-01-23 file` and add test for parse date error. Related to #2311 --- Cargo.lock | 24 +----------------------- src/uu/touch/src/touch.rs | 10 +++++++--- tests/by-util/test_touch.rs | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1365049a9..21bd5950b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -513,28 +513,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "csv" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" -dependencies = [ - "bstr", - "csv-core", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "csv-core" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" -dependencies = [ - "memchr 2.4.0", -] - [[package]] name = "ctor" version = "0.1.20" @@ -954,7 +932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" dependencies = [ "winapi 0.3.9", - ] +] [[package]] name = "num-bigint" diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 00b936e55..b76e04b7a 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -238,10 +238,14 @@ fn parse_date(str: &str) -> FileTime { // be any simple specification for what format this parameter allows and I'm // not about to implement GNU parse_datetime. // http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=lib/parse-datetime.y - match time::strptime(str, "%c") { - Ok(tm) => local_tm_to_filetime(to_local(tm)), - Err(e) => panic!("Unable to parse date\n{}", e), + let formats = vec!["%c", "%F"]; + for f in formats { + if let Ok(tm) = time::strptime(str, f) { + return local_tm_to_filetime(to_local(tm)); + } } + show_error!("Unable to parse date: {}\n", str); + process::exit(1); } fn parse_timestamp(s: &str) -> FileTime { diff --git a/tests/by-util/test_touch.rs b/tests/by-util/test_touch.rs index d4d2c058e..ecd56ab71 100644 --- a/tests/by-util/test_touch.rs +++ b/tests/by-util/test_touch.rs @@ -354,6 +354,34 @@ fn test_touch_set_date() { assert_eq!(mtime, start_of_year); } +#[test] +fn test_touch_set_date2() { + let (at, mut ucmd) = at_and_ucmd!(); + let file = "test_touch_set_date"; + + ucmd.args(&["-d", "2000-01-23", file]) + .succeeds() + .no_stderr(); + + assert!(at.file_exists(file)); + + let start_of_year = str_to_filetime("%Y%m%d%H%M", "200001230000"); + let (atime, mtime) = get_file_times(&at, file); + assert_eq!(atime, mtime); + assert_eq!(atime, start_of_year); + assert_eq!(mtime, start_of_year); +} + +#[test] +fn test_touch_set_date_wrong_format() { + let (_at, mut ucmd) = at_and_ucmd!(); + let file = "test_touch_set_date_wrong_format"; + + ucmd.args(&["-d", "2005-43-21", file]) + .fails() + .stderr_contains("Unable to parse date: 2005-43-21"); +} + #[test] fn test_touch_mtime_dst_succeeds() { let (at, mut ucmd) = at_and_ucmd!(); From 6ccc3055136d9347e16db5b8d7ec5854cca611df Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Mon, 31 May 2021 20:49:02 +0200 Subject: [PATCH 118/126] seq: implement integer sequences If we notice that we can represent all arguments as BigInts, take a different code path. Just like GNU seq this means we can print an infinite amount of numbers in this case. --- Cargo.lock | 2 + src/uu/seq/Cargo.toml | 2 + src/uu/seq/src/seq.rs | 137 ++++++++++++++++++++++++++++++-------- tests/by-util/test_seq.rs | 61 +++++++++++++++++ 4 files changed, 173 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21bd5950b..ca963674a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2402,6 +2402,8 @@ name = "uu_seq" version = "0.0.6" dependencies = [ "clap", + "num-bigint", + "num-traits", "uucore", "uucore_procs", ] diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index 96c629c68..32f2bbac8 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -16,6 +16,8 @@ path = "src/seq.rs" [dependencies] clap = "2.33" +num-bigint = "0.4.0" +num-traits = "0.2.14" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index c3bba1c78..fc72efc5a 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -7,8 +7,13 @@ extern crate uucore; use clap::{App, AppSettings, Arg}; +use num_bigint::BigInt; +use num_traits::One; +use num_traits::Zero; +use num_traits::{Num, ToPrimitive}; use std::cmp; use std::io::{stdout, Write}; +use std::str::FromStr; static VERSION: &str = env!("CARGO_PKG_VERSION"); static ABOUT: &str = "Display numbers from FIRST to LAST, in steps of INCREMENT."; @@ -33,16 +38,46 @@ struct SeqOptions { widths: bool, } -fn parse_float(mut s: &str) -> Result { - if s.starts_with('+') { - s = &s[1..]; +enum Number { + BigInt(BigInt), + F64(f64), +} + +impl Number { + fn is_zero(&self) -> bool { + match self { + Number::BigInt(n) => n.is_zero(), + Number::F64(n) => n.is_zero(), + } } - match s.parse() { - Ok(n) => Ok(n), - Err(e) => Err(format!( - "seq: invalid floating point argument `{}`: {}", - s, e - )), + + fn into_f64(self) -> f64 { + match self { + // BigInt::to_f64() can not return None. + Number::BigInt(n) => n.to_f64().unwrap(), + Number::F64(n) => n, + } + } +} + +impl FromStr for Number { + type Err = String; + /// Tries to parse this string as a BigInt, or if that fails as an f64. + fn from_str(mut s: &str) -> Result { + if s.starts_with('+') { + s = &s[1..]; + } + + match s.parse::() { + Ok(n) => Ok(Number::BigInt(n)), + Err(_) => match s.parse::() { + Ok(n) => Ok(Number::F64(n)), + Err(e) => Err(format!( + "seq: invalid floating point argument `{}`: {}", + s, e + )), + }, + } } } @@ -107,7 +142,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let dec = slice.find('.').unwrap_or(len); largest_dec = len - dec; padding = dec; - match parse_float(slice) { + match slice.parse() { Ok(n) => n, Err(s) => { show_error!("{}", s); @@ -115,7 +150,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } } } else { - 1.0 + Number::BigInt(BigInt::one()) }; let increment = if numbers.len() > 2 { let slice = numbers[1]; @@ -123,7 +158,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let dec = slice.find('.').unwrap_or(len); largest_dec = cmp::max(largest_dec, len - dec); padding = cmp::max(padding, dec); - match parse_float(slice) { + match slice.parse() { Ok(n) => n, Err(s) => { show_error!("{}", s); @@ -131,16 +166,16 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } } } else { - 1.0 + Number::BigInt(BigInt::one()) }; - if increment == 0.0 { + if increment.is_zero() { show_error!("increment value: '{}'", numbers[1]); return 1; } let last = { let slice = numbers[numbers.len() - 1]; padding = cmp::max(padding, slice.find('.').unwrap_or_else(|| slice.len())); - match parse_float(slice) { + match slice.parse::() { Ok(n) => n, Err(s) => { show_error!("{}", s); @@ -156,28 +191,42 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Some(term) => escape_sequences(&term[..]), None => separator.clone(), }; - print_seq( - first, - increment, - last, - largest_dec, - separator, - terminator, - options.widths, - padding, - ); + match (first, last, increment) { + (Number::BigInt(first), Number::BigInt(last), Number::BigInt(increment)) => { + print_seq_integers( + first, + increment, + last, + separator, + terminator, + options.widths, + padding, + ) + } + (first, last, increment) => print_seq( + first.into_f64(), + increment.into_f64(), + last.into_f64(), + largest_dec, + separator, + terminator, + options.widths, + padding, + ), + } 0 } -fn done_printing(next: f64, increment: f64, last: f64) -> bool { - if increment >= 0f64 { +fn done_printing(next: &T, increment: &T, last: &T) -> bool { + if increment >= &T::zero() { next > last } else { next < last } } +/// Floating point based code path #[allow(clippy::too_many_arguments)] fn print_seq( first: f64, @@ -191,7 +240,7 @@ fn print_seq( ) { let mut i = 0isize; let mut value = first + i as f64 * increment; - while !done_printing(value, increment, last) { + while !done_printing(&value, &increment, &last) { let istr = format!("{:.*}", largest_dec, value); let ilen = istr.len(); let before_dec = istr.find('.').unwrap_or(ilen); @@ -203,7 +252,7 @@ fn print_seq( print!("{}", istr); i += 1; value = first + i as f64 * increment; - if !done_printing(value, increment, last) { + if !done_printing(&value, &increment, &last) { print!("{}", separator); } } @@ -212,3 +261,33 @@ fn print_seq( } crash_if_err!(1, stdout().flush()); } + +/// BigInt based code path +fn print_seq_integers( + first: BigInt, + increment: BigInt, + last: BigInt, + separator: String, + terminator: String, + pad: bool, + padding: usize, +) { + let mut value = first; + let mut is_first_iteration = true; + while !done_printing(&value, &increment, &last) { + if !is_first_iteration { + print!("{}", separator); + } + is_first_iteration = false; + if pad { + print!("{number:>0width$}", number = value, width = padding); + } else { + print!("{}", value); + } + value += &increment; + } + + if !is_first_iteration { + print!("{}", terminator); + } +} diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index a74938377..3da1a84ca 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -1,5 +1,7 @@ use crate::common::util::*; +// ---- Tests for the big integer based path ---- + #[test] fn test_count_up() { new_ucmd!() @@ -45,3 +47,62 @@ fn test_seq_wrong_arg() { fn test_zero_step() { new_ucmd!().args(&["10", "0", "32"]).fails(); } + +#[test] +fn test_big_numbers() { + new_ucmd!() + .args(&[ + "1000000000000000000000000000", + "1000000000000000000000000001", + ]) + .succeeds() + .stdout_only("1000000000000000000000000000\n1000000000000000000000000001\n"); +} + +// ---- Tests for the floating point based path ---- + +#[test] +fn test_count_up_floats() { + new_ucmd!() + .args(&["10.0"]) + .run() + .stdout_is("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"); +} + +#[test] +fn test_count_down_floats() { + new_ucmd!() + .args(&["--", "5", "-1.0", "1"]) + .run() + .stdout_is("5.0\n4.0\n3.0\n2.0\n1.0\n"); + new_ucmd!() + .args(&["5", "-1", "1.0"]) + .run() + .stdout_is("5\n4\n3\n2\n1\n"); +} + +#[test] +fn test_separator_and_terminator_floats() { + new_ucmd!() + .args(&["-s", ",", "-t", "!", "2.0", "6"]) + .run() + .stdout_is("2.0,3.0,4.0,5.0,6.0!"); +} + +#[test] +fn test_equalize_widths_floats() { + new_ucmd!() + .args(&["-w", "5", "10.0"]) + .run() + .stdout_is("05\n06\n07\n08\n09\n10\n"); +} + +#[test] +fn test_seq_wrong_arg_floats() { + new_ucmd!().args(&["-w", "5", "10.0", "33", "32"]).fails(); +} + +#[test] +fn test_zero_step_floats() { + new_ucmd!().args(&["10.0", "0", "32"]).fails(); +} From c78cc65421eb8089dab043079046cfffa6f2820c Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Mon, 31 May 2021 20:53:25 +0200 Subject: [PATCH 119/126] seq: make arguments required Right now seq panics when invoked without args. --- src/uu/seq/src/seq.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index fc72efc5a..4737fe872 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -119,7 +119,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .multiple(true) .takes_value(true) .allow_hyphen_values(true) - .max_values(3), + .max_values(3) + .required(true), ) .get_matches_from(args); From 4cf18e96f3113c07d179fee2bf966bc933e3ab80 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Mon, 31 May 2021 21:19:19 +0200 Subject: [PATCH 120/126] seq: change default value for -t and remove dubious escape sequences GNU seq does not support -t, but always outputs a newline at the end. Therefore, our default for -t should be \n. Also removes support for escape sequences (interpreting a literal "\n" as a newline). This is not what GNU seq is doing, and unexpected. --- src/uu/seq/src/seq.rs | 32 ++++++++++---------------------- tests/by-util/test_seq.rs | 12 ++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 4737fe872..bdab044c5 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -34,7 +34,7 @@ fn get_usage() -> String { #[derive(Clone)] struct SeqOptions { separator: String, - terminator: Option, + terminator: String, widths: bool, } @@ -81,10 +81,6 @@ impl FromStr for Number { } } -fn escape_sequences(s: &str) -> String { - s.replace("\\n", "\n").replace("\\t", "\t") -} - pub fn uumain(args: impl uucore::Args) -> i32 { let usage = get_usage(); let matches = App::new(executable!()) @@ -104,7 +100,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Arg::with_name(OPT_TERMINATOR) .short("t") .long("terminator") - .help("Terminator character (defaults to separator)") + .help("Terminator character (defaults to \\n)") .takes_value(true) .number_of_values(1), ) @@ -126,14 +122,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let numbers = matches.values_of(ARG_NUMBERS).unwrap().collect::>(); - let mut options = SeqOptions { - separator: "\n".to_owned(), - terminator: None, - widths: false, + let options = SeqOptions { + separator: matches.value_of(OPT_SEPARATOR).unwrap_or("\n").to_string(), + terminator: matches.value_of(OPT_TERMINATOR).unwrap_or("\n").to_string(), + widths: matches.is_present(OPT_WIDTHS), }; - options.separator = matches.value_of(OPT_SEPARATOR).unwrap_or("\n").to_string(); - options.terminator = matches.value_of(OPT_TERMINATOR).map(String::from); - options.widths = matches.is_present(OPT_WIDTHS); let mut largest_dec = 0; let mut padding = 0; @@ -187,11 +180,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 { if largest_dec > 0 { largest_dec -= 1; } - let separator = escape_sequences(&options.separator[..]); - let terminator = match options.terminator { - Some(term) => escape_sequences(&term[..]), - None => separator.clone(), - }; match (first, last, increment) { (Number::BigInt(first), Number::BigInt(last), Number::BigInt(increment)) => { @@ -199,8 +187,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { first, increment, last, - separator, - terminator, + options.separator, + options.terminator, options.widths, padding, ) @@ -210,8 +198,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { increment.into_f64(), last.into_f64(), largest_dec, - separator, - terminator, + options.separator, + options.terminator, options.widths, padding, ), diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index 3da1a84ca..98eb23598 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -28,6 +28,18 @@ fn test_separator_and_terminator() { .args(&["-s", ",", "-t", "!", "2", "6"]) .run() .stdout_is("2,3,4,5,6!"); + new_ucmd!() + .args(&["-s", ",", "2", "6"]) + .run() + .stdout_is("2,3,4,5,6\n"); + new_ucmd!() + .args(&["-s", "\n", "2", "6"]) + .run() + .stdout_is("2\n3\n4\n5\n6\n"); + new_ucmd!() + .args(&["-s", "\\n", "2", "6"]) + .run() + .stdout_is("2\\n3\\n4\\n5\\n6\n"); } #[test] From 7b7185f91673a2c649bbc61cba34d0e4e47d331b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 31 May 2021 21:20:55 +0200 Subject: [PATCH 121/126] Fix clippy warnings in the pr tests --- tests/by-util/test_pr.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/by-util/test_pr.rs b/tests/by-util/test_pr.rs index aae0cc058..584b15108 100644 --- a/tests/by-util/test_pr.rs +++ b/tests/by-util/test_pr.rs @@ -6,17 +6,16 @@ use std::fs::metadata; fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { let tmp_dir_path = ucmd.get_full_fixture_path(path); let file_metadata = metadata(tmp_dir_path); - return file_metadata + file_metadata .map(|i| { - return i - .modified() + i.modified() .map(|x| { let datetime: DateTime = x.into(); datetime.format("%b %d %H:%M %Y").to_string() }) - .unwrap_or(String::new()); + .unwrap_or_default() }) - .unwrap_or(String::new()); + .unwrap_or_default() } fn now_time() -> String { From 8de42ed18e1b14c8d8686e9b3a2519e1e1fa0f98 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Mon, 31 May 2021 22:23:40 +0200 Subject: [PATCH 122/126] maint: actually run spellcheck on all files **/* must be quoted, otherwise it is expanded by the shell and not literally passed to cspell. --- .github/workflows/CICD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 4ce9e556d..32c3537c2 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -74,7 +74,7 @@ jobs: - name: Run `cspell` shell: bash run: | - cspell --config .vscode/cSpell.json --no-summary --no-progress **/* | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true + cspell --config .vscode/cSpell.json --no-summary --no-progress "**/*" | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true code_warnings: name: Style/warnings From 41878f1bf4340644b0198b745c8420c3274de986 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Mon, 31 May 2021 22:38:53 +0200 Subject: [PATCH 123/126] refactor/pr: polish spelling --- src/uu/pr/src/pr.rs | 42 +++++++++++++++++++++------------------- tests/by-util/test_pr.rs | 6 ++++-- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 266f605c5..486cedc00 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -6,6 +6,8 @@ // that was distributed with this source code. // +// spell-checker:ignore (ToDO) adFfmprt, kmerge + #[macro_use] extern crate quick_error; @@ -204,7 +206,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { options::NUMBERING_MODE_OPTION, "number-lines", "Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies - the first width column positions of each text column or each line of -m output. If char (any nondigit + the first width column positions of each text column or each line of -m output. If char (any non-digit character) is given, it is appended to the line number to separate it from whatever follows. The default for char is a . Line numbers longer than width columns are truncated.", "[char][width]", @@ -274,8 +276,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { options::COLUMN_OPTION, "Produce multi-column output that is arranged in column columns (the default shall be 1) and is written down each column in the order in which the text is received from the input file. This option should not be used with -m. - The options -e and -i shall be assumed for multiple text-column output. Whether or not text columns are pro‐ - duced with identical vertical lengths is unspecified, but a text column shall never exceed the length of the + The options -e and -i shall be assumed for multiple text-column output. Whether or not text columns are produced + with identical vertical lengths is unspecified, but a text column shall never exceed the length of the page (see the -l option). When used with -t, use the minimum number of lines to write the output.", "[column]", HasArg::Yes, @@ -285,9 +287,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 { opts.opt( options::COLUMN_WIDTH_OPTION, "width", - "Set the width of the line to width column positions for multiple text-column output only. If the -w option is - not specified and the -s option is not specified, the default width shall be 72. If the -w option is not speci‐ - fied and the -s option is specified, the default width shall be 512.", + "Set the width of the line to width column positions for multiple text-column output only. If the -w option is + not specified and the -s option is not specified, the default width shall be 72. If the -w option is not specified + and the -s option is specified, the default width shall be 512.", "[width]", HasArg::Yes, Occur::Optional, @@ -472,9 +474,9 @@ fn print_usage(opts: &mut getopts::Options, matches: &Matches) -> i32 { ); println!(); let usage: &str = "The pr utility is a printing and pagination filter - for text files. When multiple input files are spec- - ified, each is read, formatted, and written to stan- - dard output. By default, the input is separated + for text files. When multiple input files are specified, + each is read, formatted, and written to standard + output. By default, the input is separated into 66-line pages, each with o A 5-line header with the page number, date, @@ -486,8 +488,8 @@ fn print_usage(opts: &mut getopts::Options, matches: &Matches) -> i32 { diagnostic messages are suppressed until the pr utility has completed processing. - When multiple column output is specified, text col- - umns are of equal width. By default text columns + When multiple column output is specified, text columns + are of equal width. By default text columns are separated by at least one . Input lines that do not fit into a text column are truncated. Lines are not truncated under single column output."; @@ -599,8 +601,8 @@ fn build_options( let line_separator = "\n".to_string(); let last_modified_time = if is_merge_mode || paths[0].eq(FILE_STDIN) { - let datetime = Local::now(); - datetime.format("%b %d %H:%M %Y").to_string() + let date_time = Local::now(); + date_time.format("%b %d %H:%M %Y").to_string() } else { file_last_modified_time(paths.get(0).unwrap()) }; @@ -951,7 +953,7 @@ fn read_stream_and_create_pages( } fn mpr(paths: &[String], options: &OutputOptions) -> Result { - let nfiles = paths.len(); + let n_files = paths.len(); // Check if files exists for path in paths { @@ -972,7 +974,7 @@ fn mpr(paths: &[String], options: &OutputOptions) -> Result { .into_iter() .map(|fl| FileLine { page_number, - group_key: page_number * nfiles + fl.file_id, + group_key: page_number * n_files + fl.file_id, ..fl }) .collect::>() @@ -1147,11 +1149,11 @@ fn get_line_for_printing( indexes: usize, ) -> String { let blank_line = String::new(); - let fmtd_line_number = get_fmtd_line_number(&options, file_line.line_number, index); + let formatted_line_number = get_formatted_line_number(&options, file_line.line_number, index); let mut complete_line = format!( "{}{}", - fmtd_line_number, + formatted_line_number, file_line.line_content.as_ref().unwrap() ); @@ -1186,7 +1188,7 @@ fn get_line_for_printing( ) } -fn get_fmtd_line_number(opts: &OutputOptions, line_number: usize, index: usize) -> String { +fn get_formatted_line_number(opts: &OutputOptions, line_number: usize, index: usize) -> String { let should_show_line_number = opts.number.is_some() && (opts.merge_files_print.is_none() || index == 0); if should_show_line_number && line_number != 0 { @@ -1234,8 +1236,8 @@ fn file_last_modified_time(path: &str) -> String { .map(|i| { i.modified() .map(|x| { - let datetime: DateTime = x.into(); - datetime.format("%b %d %H:%M %Y").to_string() + let date_time: DateTime = x.into(); + date_time.format("%b %d %H:%M %Y").to_string() }) .unwrap_or_default() }) diff --git a/tests/by-util/test_pr.rs b/tests/by-util/test_pr.rs index aae0cc058..d4d21a6f4 100644 --- a/tests/by-util/test_pr.rs +++ b/tests/by-util/test_pr.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (ToDO) Sdivide + use crate::common::util::*; use chrono::offset::Local; use chrono::DateTime; @@ -11,8 +13,8 @@ fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String { return i .modified() .map(|x| { - let datetime: DateTime = x.into(); - datetime.format("%b %d %H:%M %Y").to_string() + let date_time: DateTime = x.into(); + date_time.format("%b %d %H:%M %Y").to_string() }) .unwrap_or(String::new()); }) From 46470fc60750c5a144a2500e87ed5a61b1de7baf Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Mon, 31 May 2021 22:39:03 +0200 Subject: [PATCH 124/126] refactor/rmdir: polish spelling --- src/uu/rmdir/src/rmdir.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index bebb2844b..d39c33f77 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -5,6 +5,8 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. +// spell-checker:ignore (ToDO) ENOTDIR + #[macro_use] extern crate uucore; From c1f2d41a273d08ecf36345070d0967f83c262207 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 1 Jun 2021 09:54:49 +0200 Subject: [PATCH 125/126] sum: fix help text for system v argument --- src/uu/sum/src/sum.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/sum/src/sum.rs b/src/uu/sum/src/sum.rs index ea833c0d2..95de707fa 100644 --- a/src/uu/sum/src/sum.rs +++ b/src/uu/sum/src/sum.rs @@ -108,13 +108,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .arg( Arg::with_name(options::BSD_COMPATIBLE) .short(options::BSD_COMPATIBLE) - .help("use the BSD compatible algorithm (default)"), + .help("use the BSD sum algorithm, use 1K blocks (default)"), ) .arg( Arg::with_name(options::SYSTEM_V_COMPATIBLE) .short("s") .long(options::SYSTEM_V_COMPATIBLE) - .help("use the BSD compatible algorithm (default)"), + .help("use System V sum algorithm, use 512 bytes blocks"), ) .get_matches_from(args); From 1dc4ab92d90dd30dd1562f1c6bb496583571d5d0 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 1 Jun 2021 10:27:50 +0200 Subject: [PATCH 126/126] ls: add help text and value name for --hide and --ignore --- src/uu/ls/src/ls.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 5846cb0aa..a74a045c5 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -785,6 +785,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .long(options::HIDE) .takes_value(true) .multiple(true) + .value_name("PATTERN") + .help("do not list implied entries matching shell PATTERN (overridden by -a or -A)") ) .arg( Arg::with_name(options::IGNORE) @@ -792,6 +794,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .long(options::IGNORE) .takes_value(true) .multiple(true) + .value_name("PATTERN") + .help("do not list implied entries matching shell PATTERN") ) .arg( Arg::with_name(options::IGNORE_BACKUPS)