From 2d58ea5f8bf3232a2339d130ad43364f1cd79329 Mon Sep 17 00:00:00 2001 From: tilakpatidar Date: Sat, 8 Dec 2018 21:57:53 +0530 Subject: [PATCH 01/61] 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 02/61] 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 03/61] 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 04/61] 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 05/61] 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 06/61] 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 07/61] 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 08/61] 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 09/61] 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 10/61] 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 11/61] 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 12/61] 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 13/61] 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 14/61] 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 15/61] 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 16/61] 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 17/61] 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 18/61] 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 19/61] 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 20/61] 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 21/61] 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 22/61] 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 23/61] 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 24/61] 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 25/61] 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 26/61] 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 27/61] 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 28/61] 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 29/61] 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 30/61] 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 31/61] 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 32/61] 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 33/61] 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 34/61] 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 35/61] 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 36/61] 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 37/61] 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 38/61] 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 39/61] 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 40/61] 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 41/61] 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 42/61] 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 43/61] 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 44/61] 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 45/61] 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 46/61] 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 47/61] 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 48/61] 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 49/61] 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 50/61] 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 51/61] 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 52/61] 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 53/61] 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 54/61] 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 55/61] 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 56/61] 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 57/61] 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 58/61] 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 59/61] 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 60/61] 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 61/61] 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) {