wok diff busybox/stuff/busybox-1.7.3-hexdump.u @ rev 2213

openssh*: --libexecdir=/usr/sbin (no /usr/libexec)
author Christophe Lincoln <pankso@slitaz.org>
date Wed Feb 11 17:41:17 2009 +0100 (2009-02-11)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.7.3-hexdump.u	Wed Feb 11 17:41:17 2009 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +--- busybox-1.7.3/util-linux/hexdump.c
     1.5 ++++ busybox-1.7.3/util-linux/hexdump.c
     1.6 +@@ -45,7 +45,7 @@
     1.7 + 
     1.8 + static const char add_first[] ALIGN1 = "\"%07.7_Ax\n\"";
     1.9 + 
    1.10 +-static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:v";
    1.11 ++static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:vR";
    1.12 + 
    1.13 + static const struct suffix_mult suffixes[] = {
    1.14 + 	{ "b", 512 },
    1.15 +@@ -59,6 +59,8 @@
    1.16 + {
    1.17 + 	const char *p;
    1.18 + 	int ch;
    1.19 ++	FILE *fp;
    1.20 ++	smallint rdump = 0;
    1.21 + 
    1.22 + 	bb_dump_vflag = FIRST;
    1.23 + 	bb_dump_length = -1;
    1.24 +@@ -70,7 +72,7 @@
    1.25 + 		if ((p - hexdump_opts) < 5) {
    1.26 + 			bb_dump_add(add_first);
    1.27 + 			bb_dump_add(add_strings[(int)(p - hexdump_opts)]);
    1.28 +-		} else if (ch == 'C') {
    1.29 ++		} if (ch == 'C') {
    1.30 + 			bb_dump_add("\"%08.8_Ax\n\"");
    1.31 + 			bb_dump_add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
    1.32 + 			bb_dump_add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
    1.33 +@@ -90,6 +92,9 @@
    1.34 + 			} /* else */
    1.35 + 			if (ch == 'v') {
    1.36 + 				bb_dump_vflag = ALL;
    1.37 ++			} /* else */
    1.38 ++			if (ch == 'R') {
    1.39 ++				rdump = 1;
    1.40 + 			}
    1.41 + 		}
    1.42 + 	}
    1.43 +@@ -101,5 +106,36 @@
    1.44 + 
    1.45 + 	argv += optind;
    1.46 + 
    1.47 +-	return bb_dump_dump(argv);
    1.48 ++	if (!rdump) {
    1.49 ++		return bb_dump_dump(argv);
    1.50 ++	}
    1.51 ++
    1.52 ++	/* -R: reverse of 'hexdump -Cv' */
    1.53 ++	fp = stdin;
    1.54 ++	if (!*argv) {
    1.55 ++		argv--;
    1.56 ++		goto jump_in;
    1.57 ++	}
    1.58 ++
    1.59 ++	do {
    1.60 ++		char *buf;
    1.61 ++		fp = xfopen(*argv, "r");
    1.62 ++ jump_in:
    1.63 ++		while ((buf = xmalloc_getline(fp)) != NULL) {
    1.64 ++			p = buf;
    1.65 ++			while (1) {
    1.66 ++				/* skip address or previous byte */
    1.67 ++				while (isxdigit(*p)) p++;
    1.68 ++				while (*p == ' ') p++;
    1.69 ++				/* '|' char will break the line */
    1.70 ++				if (!isxdigit(*p) || sscanf(p, "%x ", &ch) != 1)
    1.71 ++					break;
    1.72 ++				putchar(ch);
    1.73 ++			}
    1.74 ++			free(buf);
    1.75 ++		}
    1.76 ++		fclose(fp);
    1.77 ++	} while (*++argv);
    1.78 ++
    1.79 ++	fflush_stdout_and_exit(EXIT_SUCCESS);
    1.80 + }