Browse Source

hexdump: fix dup block comparison

function                                             old     new   delta
bb_dump_dump                                        1523    1520      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko 3 years ago
parent
commit
079487b487
2 changed files with 19 additions and 1 deletions
  1. 0 1
      libbb/dump.c
  2. 19 0
      testsuite/hexdump.tests

+ 0 - 1
libbb/dump.c

@@ -432,7 +432,6 @@ static unsigned char *get(priv_dumper_t *dumper)
 				if (dumper->pub.dump_vflag != DUP) {
 					puts("*");
 				}
-				return NULL;
 			}
 			memset(dumper->get__curp + nread, 0, need);
 			dumper->eaddress = dumper->address + nread;

+ 19 - 0
testsuite/hexdump.tests

@@ -15,4 +15,23 @@ testing 'hexdump -C with four NULs' \
 	'' \
 	'\0\0\0\0'
 
+testing "hexdump does not think last padded block matches any full block" \
+	"hexdump -e '1/1 \"%02x|\"1/1 \"%02x!\\n\"'" \
+	"\
+00|00!
+*
+00|  !
+" \
+	'' \
+	'\0\0\0\0\0\0\0\0\0\0\0'
+
+testing "hexdump thinks last full block can match" \
+	"hexdump -e '1/1 \"%02x|\"1/1 \"%02x!\\n\"'" \
+	"\
+00|00!
+*
+" \
+	'' \
+	'\0\0\0\0\0\0\0\0\0\0\0\0'
+
 exit $FAILCOUNT