od: remove trailing spaces in output

can't find documentation confirming this behaviour
besides it does not work correctly on all formats
see also uutils/coreutils#922
This commit is contained in:
Wim Hueskes 2016-07-23 19:51:03 +02:00
parent f45169d37c
commit 1b01f02e9e
2 changed files with 6 additions and 14 deletions

View file

@ -213,7 +213,6 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
const LINEBYTES:usize = 16;
const WORDBYTES:usize = 2;
fn odfunc(input_offset_base: &Radix, fnames: &[InputSource], formats: &[OdFormat]) -> i32 {
@ -288,13 +287,6 @@ fn odfunc(input_offset_base: &Radix, fnames: &[InputSource], formats: &[OdFormat
}
b = nextb;
}
// Add extra spaces to pad out the short, presumably last, line.
if n < LINEBYTES {
// calc # of items we did not print, must be short at least WORDBYTES to be missing any.
let words_short = (LINEBYTES - n) / WORDBYTES;
// XXX this is running short for -c & -a
print!("{:>width$}", "", width = (words_short) * (6 + 2));
}
print!("\n");
}
addr += n;

View file

@ -12,7 +12,7 @@ use self::unindent::*;
// octal dump of 'abcdefghijklmnopqrstuvwxyz\n'
static ALPHA_OUT: &'static str = "
0000000 061141 062143 063145 064147 065151 066153 067155 070157
0000020 071161 072163 073165 074167 075171 000012
0000020 071161 072163 073165 074167 075171 000012
0000033
";
@ -136,8 +136,8 @@ fn test_multiple_formats() {
assert_eq!(result.stdout, unindent("
0000000 a b c d e f g h i j k l m n o p
141 142 143 144 145 146 147 150 151 152 153 154 155 156 157 160
0000020 q r s t u v w x y z \\n
161 162 163 164 165 166 167 170 171 172 012
0000020 q r s t u v w x y z \\n
161 162 163 164 165 166 167 170 171 172 012
0000033
"));
@ -155,7 +155,7 @@ fn test_dec() {
0x00u8,0x80u8,
0x01u8,0x80u8,];
let expected_output = unindent("
0000000 0 1 2 3 32767 -32768 -32767
0000000 0 1 2 3 32767 -32768 -32767
0000016
");
let result = new_ucmd!().arg("-i").run_piped_stdin(&input[..]);
@ -179,7 +179,7 @@ fn test_f32(){
0x00, 0x00, 0x7f, 0x80];// 0x807f0000 -1.1663108E-38
let expected_output = unindent("
0000000 -1.2345679 12345678 -9.8765427e37 -0
0000020 NaN 1e-40 -1.1663108e-38
0000020 NaN 1e-40 -1.1663108e-38
0000034
");
let result = new_ucmd!().arg("-f").run_piped_stdin(&input[..]);
@ -201,7 +201,7 @@ fn test_f64(){
let expected_output = unindent("
0000000 12345678912345678 0
0000020 -2.2250738585072014e-308 5e-324
0000040 -2.0000000000000000
0000040 -2.0000000000000000
0000050
");
let result = new_ucmd!().arg("-F").run_piped_stdin(&input[..]);