diff --git a/src/fold/fold.rs b/src/fold/fold.rs index 200951676..5b8da31cd 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -156,7 +156,7 @@ fn fold_file(mut file: BufReader, bytes: bool, spaces: bool, width: let ncount = routput.chars().fold(0, |out, ch: char| { out + match ch { '\t' => 8, - '\x08' => if out > 0 { -1 } else { 0 }, + '\x08' => if out > 0 { !0 } else { 0 }, '\r' => return 0, _ => 1 } diff --git a/src/stdbuf/stdbuf.rs b/src/stdbuf/stdbuf.rs index 0be155afa..0024ef72d 100644 --- a/src/stdbuf/stdbuf.rs +++ b/src/stdbuf/stdbuf.rs @@ -231,7 +231,7 @@ pub fn uumain(args: Vec) -> i32 { for i in 1 .. args.len()+1 { match parse_options(&args[1 .. i], &mut options, &opts) { Ok(OkMsg::Buffering) => { - command_idx = i - 1; + command_idx = (i as i32) - 1; break; }, Ok(OkMsg::Help) => { @@ -249,10 +249,10 @@ pub fn uumain(args: Vec) -> i32 { if command_idx == -1 { crash!(125, "Invalid options\nTry 'stdbuf --help' for more information."); } - let ref command_name = args[command_idx]; + let ref command_name = args[command_idx as usize]; let mut command = Command::new(command_name); let (preload_env, libstdbuf) = get_preload_env(); - command.args(&args[command_idx + 1 ..]).env(preload_env, libstdbuf); + command.args(&args[(command_idx as usize)+ 1 ..]).env(preload_env, libstdbuf); set_command_env(&mut command, "_STDBUF_I", options.stdin); set_command_env(&mut command, "_STDBUF_O", options.stdout); set_command_env(&mut command, "_STDBUF_E", options.stderr);