1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge branch 'master' of github.com:uutils/coreutils into feature/preserve_timestamps_#1758

This commit is contained in:
Hari 2021-03-12 17:47:02 -05:00
commit 8471088d6d
No known key found for this signature in database
GPG key ID: 3C13EE62349616E4
4 changed files with 38 additions and 5 deletions

View file

@ -95,12 +95,21 @@ impl WordFilter {
if matches.opt_present("b") {
crash!(1, "-b not implemented yet");
}
let reg = if matches.opt_present("W") {
matches.opt_str("W").expect("parsing options failed!")
} else if config.gnu_ext {
"\\w+".to_owned()
// Ignore empty string regex from cmd-line-args
let arg_reg: Option<String> = if matches.opt_present("W") {
matches.opt_str("W").filter(|reg| !reg.is_empty())
} else {
"[^ \t\n]+".to_owned()
None
};
let reg = match arg_reg {
Some(arg_reg) => arg_reg,
None => {
if config.gnu_ext {
"\\w+".to_owned()
} else {
"[^ \t\n]+".to_owned()
}
}
};
WordFilter {
only_specified: o,

View file

@ -8,6 +8,22 @@ fn gnu_ext_disabled_roff_no_ref() {
.stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected");
}
#[test]
fn gnu_ext_disabled_roff_no_ref_empty_word_regexp() {
new_ucmd!()
.args(&["-G", "-R", "-W", "", "input"])
.succeeds()
.stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected");
}
#[test]
fn gnu_ext_disabled_roff_no_ref_word_regexp_exc_space() {
new_ucmd!()
.args(&["-G", "-R", "-W", "[^\t\n]+", "input"])
.succeeds()
.stdout_only_fixture("gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected");
}
#[test]
fn gnu_ext_disabled_roff_input_ref() {
new_ucmd!()

View file

@ -261,6 +261,7 @@ impl AtPath {
}
pub fn write(&self, name: &str, contents: &str) {
log_info("open(write)", self.plus_as_string(name));
let _ = std::fs::write(self.plus(name), contents);
}

View file

@ -0,0 +1,7 @@
.xx "" "" """quotes"", for roff" ""
.xx "" "" "and some other like %a, b#, c$c" ""
.xx "" "" "hello world!" ""
.xx "" "" "let's check special characters:" ""
.xx "" "" "maybe also~or^" ""
.xx "" "" "oh, and back\slash" ""
.xx "" "" "{brackets} for tex" ""