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,13 +49,10 @@ 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 {
Ok(Opt('f', None)) => force = true,
Ok(Opt('w', Some(arg))) => {
match arg.parse::<usize>() { match arg.parse::<usize>() {
Ok(w) if w % 2 == 0 => { wordsize = w; () }, Ok(w) if w % 2 == 0 => { wordsize = w; () },
_ => { return usage(&argv[0]); }, _ => { return usage(&argv[0]); },
@ -64,7 +61,6 @@ fn main() -> ExitCode {
_ => { return usage(&argv[0]); } _ => { return usage(&argv[0]); }
} }
} }
}
buf.resize(wordsize, 0); buf.resize(wordsize, 0);