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

Update for changes in regex

This commit is contained in:
Alex Lyon 2017-01-11 15:45:21 -08:00 committed by Alex Lyon
parent 9abc3208d3
commit 7cfe0465ee
2 changed files with 5 additions and 5 deletions

View file

@ -238,7 +238,7 @@ fn create_word_set(config: &Config, filter: &WordFilter,
// if -r, exclude reference from word set // if -r, exclude reference from word set
let (ref_beg, ref_end) = match ref_reg.find(line) { let (ref_beg, ref_end) = match ref_reg.find(line) {
Some(x) => (x.start(), x.end()), Some(x) => (x.start(), x.end()),
None => (0,0) None => (0, 0)
}; };
// match words with given regex // match words with given regex
for mat in reg.find_iter(line) { for mat in reg.find_iter(line) {
@ -281,7 +281,7 @@ fn get_reference(config: &Config, word_ref: &WordRef, line: &str) ->
let reg = Regex::new(&config.context_regex).unwrap(); let reg = Regex::new(&config.context_regex).unwrap();
let (beg, end) = match reg.find(line) { let (beg, end) = match reg.find(line) {
Some(x) => (x.start(), x.end()), Some(x) => (x.start(), x.end()),
None => (0,0) None => (0, 0)
}; };
format!("{}", &line[beg .. end]) format!("{}", &line[beg .. end])
} else { } else {

View file

@ -93,7 +93,7 @@ impl RandomFile {
fn test_split_default() { fn test_split_default() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let name = "split_default"; let name = "split_default";
let glob = Glob::new(&at, ".", r"x[:alpha:][:alpha:]$"); let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
RandomFile::new(&at, name).add_lines(2000); RandomFile::new(&at, name).add_lines(2000);
ucmd.args(&[name]).succeeds(); ucmd.args(&[name]).succeeds();
assert_eq!(glob.count(), 2); assert_eq!(glob.count(), 2);
@ -115,7 +115,7 @@ fn test_split_num_prefixed_chunks_by_bytes() {
fn test_split_str_prefixed_chunks_by_bytes() { fn test_split_str_prefixed_chunks_by_bytes() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let name = "split_str_prefixed_chunks_by_bytes"; let name = "split_str_prefixed_chunks_by_bytes";
let glob = Glob::new(&at, ".", r"b[:alpha:][:alpha:]$"); let glob = Glob::new(&at, ".", r"b[[:alpha:]][[:alpha:]]$");
RandomFile::new(&at, name).add_bytes(10000); RandomFile::new(&at, name).add_bytes(10000);
ucmd.args(&["-b", "1000", name, "b"]).succeeds(); ucmd.args(&["-b", "1000", name, "b"]).succeeds();
assert_eq!(glob.count(), 10); assert_eq!(glob.count(), 10);
@ -137,7 +137,7 @@ fn test_split_num_prefixed_chunks_by_lines() {
fn test_split_str_prefixed_chunks_by_lines() { fn test_split_str_prefixed_chunks_by_lines() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let name = "split_str_prefixed_chunks_by_lines"; let name = "split_str_prefixed_chunks_by_lines";
let glob = Glob::new(&at, ".", r"d[:alpha:][:alpha:]$"); let glob = Glob::new(&at, ".", r"d[[:alpha:]][[:alpha:]]$");
RandomFile::new(&at, name).add_lines(10000); RandomFile::new(&at, name).add_lines(10000);
ucmd.args(&["-l", "1000", name, "d"]).succeeds(); ucmd.args(&["-l", "1000", name, "d"]).succeeds();
assert_eq!(glob.count(), 10); assert_eq!(glob.count(), 10);