swab(1): untested move to new getopt bindings
This commit is contained in:
parent
2f87ad948f
commit
d07bb7da41
12
src/swab.rs
12
src/swab.rs
@ -49,13 +49,10 @@ fn main() -> ExitCode {
|
||||
let mut force = false;
|
||||
let mut wordsize: usize = 2;
|
||||
|
||||
loop {
|
||||
match opts.next() {
|
||||
None => break,
|
||||
Some(opt) =>
|
||||
match opt {
|
||||
Ok(Opt('f', None)) => force = true,
|
||||
Ok(Opt('w', Some(arg))) => {
|
||||
while let Some(opt) = argv.getopt("fw:") {
|
||||
match opt.opt() {
|
||||
Ok("f") => force = true,
|
||||
Ok("w") => {
|
||||
match arg.parse::<usize>() {
|
||||
Ok(w) if w % 2 == 0 => { wordsize = w; () },
|
||||
_ => { return usage(&argv[0]); },
|
||||
@ -64,7 +61,6 @@ fn main() -> ExitCode {
|
||||
_ => { return usage(&argv[0]); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buf.resize(wordsize, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user