mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 21:17:46 +00:00
regex::Captures::{at,name} returns Option
This commit is contained in:
parent
5cfde0dcb9
commit
872bb0010a
2 changed files with 9 additions and 5 deletions
|
@ -205,9 +205,9 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool
|
|||
};
|
||||
for mode in cmode.unwrap().as_slice().split(',') { // cmode is guaranteed to be Some in this case
|
||||
let cap = REGEXP.captures(mode).unwrap(); // mode was verified earlier, so this is safe
|
||||
if cap.at(1) != "" {
|
||||
if cap.at(1).unwrap() != "" {
|
||||
// symbolic
|
||||
let mut levels = cap.at(2);
|
||||
let mut levels = cap.at(2).unwrap();
|
||||
if levels.len() == 0 {
|
||||
levels = "a";
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool
|
|||
}
|
||||
} else {
|
||||
// numeric
|
||||
let change = cap.at(4);
|
||||
let change = cap.at(4).unwrap();
|
||||
let ch = change.char_at(0);
|
||||
let (action, slice) = match ch {
|
||||
'+' | '-' | '=' => (ch, change.slice_from(1)),
|
||||
|
|
|
@ -213,9 +213,13 @@ fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary:
|
|||
for (i, line) in buffer.lines().enumerate() {
|
||||
let line = safe_unwrap!(line);
|
||||
let (ck_filename, sum, binary_check): (_, Vec<Ascii>, _) = match gnu_re.captures(line.as_slice()) {
|
||||
Some(caps) => (caps.name("fileName"), caps.name("digest").to_ascii().iter().map(|ch| ch.to_lowercase()).collect(), caps.name("binary") == "*"),
|
||||
Some(caps) => (caps.name("fileName").unwrap(),
|
||||
caps.name("digest").unwrap().to_ascii().iter().map(|ch| ch.to_lowercase()).collect(),
|
||||
caps.name("binary").unwrap() == "*"),
|
||||
None => match bsd_re.captures(line.as_slice()) {
|
||||
Some(caps) => (caps.name("fileName"), caps.name("digest").to_ascii().iter().map(|ch| ch.to_lowercase()).collect(), true),
|
||||
Some(caps) => (caps.name("fileName").unwrap(),
|
||||
caps.name("digest").unwrap().to_ascii().iter().map(|ch| ch.to_lowercase()).collect(),
|
||||
true),
|
||||
None => {
|
||||
bad_format += 1;
|
||||
if strict {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue