test complited
authorLaurent Mazet <mazet@softndesign.org>
Fri, 13 Jan 2023 22:43:49 +0000 (23:43 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Fri, 13 Jan 2023 22:43:49 +0000 (23:43 +0100)
hexdump.c

index d606a121ac3ee4b8263b4a236200e19d29fbbf81..b168c0f5ea4ba5148ff586ecd3c2265ded82c040 100644 (file)
--- a/hexdump.c
+++ b/hexdump.c
@@ -449,6 +449,7 @@ int main (int argc, char *argv[])
     }
 
     if (commands == NULL) {
+        VERBOSE (DEBUG, printf ("no command\n"));
         hexdump (-1);
     } else {
         VERBOSE (DEBUG, printf ("commands: %s\n", commands));
@@ -506,12 +507,7 @@ int main (int argc, char *argv[])
             case '9': /* read address */
                 commands--;
                 addr = strtol (commands, &commands, 10);
-                if (addr) {
-                    rc = gotoaddr (addr);
-                } else {
-                    VERBOSE (ERROR, fprintf (stderr, "erroneous address\n"));
-                    rc = 1;
-                }
+                rc = gotoaddr (addr);
                 break;
 
             case 'a': /* append mode */
@@ -546,7 +542,7 @@ int main (int argc, char *argv[])
                         }
                     }
                 }
-                if ((seq.length > 0) && (rc == 0)) {
+                if ((seq.length > 0) && (rc == 0) && (i % 2 == 0)) {
                     rc = insertseq (&seq);
                 } else {
                     VERBOSE (ERROR, fprintf (stderr, "erroneous sequence '%s'\n", seq.sequence));
@@ -632,5 +628,9 @@ int main (int argc, char *argv[])
 // test: hexdump.exe -i hexdump.c -e ' //' 2>&1 | grep -q 'incorrect sequence'
 // test: hexdump.exe -i hexdump.c -e 'foo' 2>&1 | grep -q 'unknown command'
 // test: hexdump.exe -i hexdump.c -e '0x20 p 8 64 p 8 0200 p 16' | grep -q '0x0080:'
+// test: hexdump.exe -i hexdump.c -e '0xg' 2>&1 | grep -q 'erroneous address'
+// test: hexdump.exe -i hexdump.c -o test.c -e ' /cflags/ a 414e5a /link/ i 2F333B'
+// test: grep -q ANZcflags test.c && grep -q 'link/3;er' test.c; x=$?; rm test.c; test x$x = x0
+// test: hexdump.exe -i hexdump.c -e ' /cflags/ a 414e5' 2>&1 | grep 'erroneous sequence'
 
 /* vim: set ts=4 sw=4 et: */