char *input = NULL;
char *output = NULL;
char *commands = NULL;
- int printlen = -1;
+ int length = -1;
sequence_t seq = {0};
unsigned long int addr = 0;
+ char c;
/* get basename */
char *pt = progname = argv[0];
} else {
VERBOSE (DEBUG, printf ("commands: %s\n", commands));
while ((*commands != '\0') && (rc == 0)) {
- switch (*commands++) {
+ switch (c = *commands++) {
case ' ':
case '\t':
break;
break;
case 'd': /* delete mode */
- break;
+ /* fall through */
case 'p': /* print mode */
- printlen = -1;
+ length = -1;
while (*commands != '\0') {
if ((*commands == ' ') || (*commands == '\t')) {
commands++;
} else if ((*commands >= '0') && (*commands <= '9')) {
- printlen = strtol (commands, &commands, 10);
+ length = strtol (commands, &commands, 10);
break;
} else if (*commands == '-') {
- printlen = -1;
+ length = -1;
commands++;
break;
} else {
- VERBOSE (ERROR, fprintf (stderr, "unknown print length (%s)\n", commands));
+ VERBOSE (ERROR, fprintf (stderr, "unknown length (%s)\n", commands));
rc = 1;
break;
}
}
if (rc == 0) {
- hexdump (printlen);
+ switch (c) {
+ case 'd':
+ fseek (fin, length, SEEK_CUR);
+ break;
+ case 'p':
+ hexdump (length);
+ break;
+ }
}
break;
// test: cmp hexdump.c test.c; x=$?; rm test.c; test x$x = x0
// test: hexdump.exe -i hexdump.c -v 3 -e " /\'/" -e ' /\"/' -e ' /\\/' -e ' /\x2a/' -e ' s/\x3A/' | grep l: | wc -l | xargs test 5 =
// test: hexdump.exe -i hexdump.c -e ' /\n\/* vim:/ p -' | grep -q ': 74 3a 20 2a 2f 0a *t: \*\/\.'
-// test: hexdump.exe -i hexdump.c -e 'p go_to_end' 2>&1 | grep -q 'unknown print length'
+// test: hexdump.exe -i hexdump.c -e 'p go_to_end' 2>&1 | grep -q 'unknown length'
// 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 -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'
+// test: hexdump.exe -i hexdump.c -o test.c -e ' /lags/ d 2'
+// test: grep -q cfgs test.c; x=$?; rm test.c; test x$x = x0
/* vim: set ts=4 sw=4 et: */