Skip to content
Myr

Implement smart-case, closes #7

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent fba5e02 · Browse files · 2 files+9 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−3 removed

  • other:+9 added−3 removed

2 files+9 added−3 removed

modified:src/main.rs+7 added-3 removed
80 unmodified lines
81 print!("{}", opts.usage(&brief));82 process::exit(1);83 }8485 let case_insensitive = !matches.opt_present("s");8685 let empty = String::new();86 let pattern = matches.free.get(0).unwrap_or(&empty);8788 let current_dir_buf = match env::current_dir() {
1 unmodified line
90 Err(_) => error("Could not get current directory!")91 };92 let current_dir = current_dir_buf.as_path();9394 // The search will be case-sensitive if the command line flag is set or if95 // the pattern has an uppercase character (smart case).96 let case_sensitive =97 matches.opt_present("s") ||98 pattern.chars().any(char::is_uppercase);99100 match RegexBuilder::new(pattern)97 .case_insensitive(case_insensitive)101 .case_insensitive(!case_sensitive)102 .build() {103 Ok(re) => scan(current_dir, &re),104 Err(err) => error(err.description())105 }
1 unmodified line
modified:README.md+2 added