correct output
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Mon, 16 Jan 2023 15:31:32 +0000 (16:31 +0100)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Mon, 16 Jan 2023 15:31:32 +0000 (16:31 +0100)
hexdump.c

index 9c90d21c921cdd45f4fc5e2ed563b3ba0f5aa8d9..8a085616731ce23ec2e92cb4aa4636c43c62feb5 100644 (file)
--- a/hexdump.c
+++ b/hexdump.c
@@ -87,7 +87,7 @@ void printline (char *buffer, int nb, unsigned long int addr) {
 
     printf ("0x%0*lx:", nbdigits, addr);
     for (i = 0; i < nb; i++) {
-        printf (" %02x", buffer[i]);
+        printf (" %02x", (unsigned char)buffer[i]);
     }
     for (i = nb; i < nbcols; i++) {
         printf ("   ");
@@ -755,5 +755,6 @@ int main (int argc, char *argv[])
 // test: hexdump.exe -i hexdump.c -e ' s//' 2>&1 | grep -q 'erroneous pattern'
 // test: hexdump.exe -i hexdump.c -e ' s/\x41BCD/2041/' 2>&1 | grep -q "can't find pattern"
 // test: hexdump.exe -i hexdump.c -e ' s/cflags/414e5/' 2>&1 | grep -q 'erroneous sequence'
+// test: hexdump.exe -i hexdump.exe | grep -q 'ffff'; test x$? = x1
 
 /* vim: set ts=4 sw=4 et: */