swab(1): untested move to new getopt bindings

This commit is contained in:
dtb 2024-06-28 08:33:31 -06:00
parent 2f87ad948f
commit d07bb7da41
Signed by: trinity
GPG Key ID: 34C0543BBB6AF81B

View File

@ -49,20 +49,16 @@ fn main() -> ExitCode {
let mut force = false; let mut force = false;
let mut wordsize: usize = 2; let mut wordsize: usize = 2;
loop { while let Some(opt) = argv.getopt("fw:") {
match opts.next() { match opt.opt() {
None => break, Ok("f") => force = true,
Some(opt) => Ok("w") => {
match opt { match arg.parse::<usize>() {
Ok(Opt('f', None)) => force = true, Ok(w) if w % 2 == 0 => { wordsize = w; () },
Ok(Opt('w', Some(arg))) => { _ => { return usage(&argv[0]); },
match arg.parse::<usize>() { }
Ok(w) if w % 2 == 0 => { wordsize = w; () }, },
_ => { return usage(&argv[0]); }, _ => { return usage(&argv[0]); }
}
},
_ => { return usage(&argv[0]); }
}
} }
} }