From afabebe4324f327a72bbf89b5c0df63b3e1628ca Mon Sep 17 00:00:00 2001 From: Arcterus Date: Sat, 27 Sep 2014 15:24:10 -0700 Subject: [PATCH 1/2] Fix wc output for bytes --- src/wc/wc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wc/wc.rs b/src/wc/wc.rs index d1e83d50a..d5f616cff 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -203,7 +203,7 @@ fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: u print!("{:1$}", word_count, max_str_len); } if matches.opt_present("bytes") { - print!("{:1$}", byte_count, max_str_len + 1); + print!("{:1$}", byte_count, max_str_len); } if matches.opt_present("chars") { print!("{:1$}", char_count, max_str_len); From ba0177c82456f73993a611fc1042d2a78a5e89e2 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Sat, 27 Sep 2014 20:17:34 -0700 Subject: [PATCH 2/2] Allow test to be checked by the Busybox test suite --- src/test/test.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/test/test.rs b/src/test/test.rs index 5bedf0534..9a3f76d77 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -16,16 +16,24 @@ use std::os::{args_as_bytes}; use std::str::{from_utf8}; use num::bigint::{BigInt}; +static NAME: &'static str = "test"; + +// TODO: decide how to handle non-UTF8 input for all the utils pub fn uumain(_: Vec) -> int { let args = args_as_bytes(); let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect(); - let args = args.as_slice(); if args.len() == 0 { return 2; } + let args = + if !args[0].ends_with(NAME.as_bytes()) { + args.slice_from(1) + } else { + args.as_slice() + }; let args = match args[0] { - b"[" => match args[args.len()-1] { - b"]" => args.slice(1, args.len()-1), + b"[" => match args[args.len() - 1] { + b"]" => args.slice(1, args.len() - 1), _ => return 2, }, _ => args.slice(1, args.len()), @@ -228,7 +236,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool { FIFO => stat.kind == TypeNamedPipe, Readable => false, // TODO Socket => false, // TODO? - NonEmpty => stat.size > 0, + NonEmpty => stat.size > 0, UserIDFlag => false, Writable => false, // TODO Executable => false, // TODO