summaryrefslogtreecommitdiff
path: root/tests/hd.c
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2002-07-22 23:35:31 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:47 +0200
commit673f690a37f6673a3262e933709c79de8a66f48c (patch)
tree3acd007863bf23ce8549f9edb5e51d23a3bc6078 /tests/hd.c
parent352e3b3230dfc6746be6d53325ffe1e33efc5289 (diff)
downloaddev86-673f690a37f6673a3262e933709c79de8a66f48c.tar.gz
Import Dev86src-0.16.4.tar.gzv0.16.4
Diffstat (limited to 'tests/hd.c')
-rw-r--r--tests/hd.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/tests/hd.c b/tests/hd.c
index 3df7761..2be4425 100644
--- a/tests/hd.c
+++ b/tests/hd.c
@@ -1,7 +1,27 @@
+/*
+ * This is a Xenix style hex dump command.
+ *
+ * The 'reverse hex dump' option is an addition that allows a simple
+ * method of editing binary files.
+ *
+ * The overkill Linux 'hexdump' command can be configured to generate
+ * the same format as this command by this shell macro:
+ *
+ * hd() { hexdump -e '"%06.6_ax:" 8/1 " %02x" " " 8/1 " %02x" " " ' \
+ * -e '16/1 "%_p" "\n"' \
+ * "$@"
+ * }
+ *
+ */
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
+#ifndef MSDOS
+#ifndef __BCC__
+#include <locale.h>
+#endif
+#endif
int lastnum[16] = {-1};
long lastaddr = -1;
@@ -9,7 +29,7 @@ long offset = 0;
FILE *fd;
-FILE * ofd = stdout;
+FILE * ofd;
char * outfile = 0;
int reverse = 0;
@@ -21,6 +41,14 @@ char **argv;
int ar;
int aflag = 1;
+#ifndef MSDOS
+#ifndef __BCC__
+ setlocale(LC_CTYPE, "");
+#endif
+#endif
+
+ ofd = stdout;
+
for (ar = 1; ar < argc; ar++)
if (aflag && argv[ar][0] == '-')
switch (argv[ar][1])
@@ -119,7 +147,7 @@ do_fd()
break;
num[j] = ch;
- if (isascii(ch) && isprint(ch))
+ if (isprint(ch))
buf[j] = ch;
else
buf[j] = '.';
@@ -195,8 +223,12 @@ do_rev_fd()
ptr = str;
if( *ptr == '*' ) zap_last = 0;
- if( !isxdigit(*ptr) ) continue;
- addr = strtol(ptr, &ptr, 16);
+ if( *ptr != ':' ) {
+ if( !isxdigit(*ptr) ) continue;
+ addr = strtol(ptr, &ptr, 16);
+ }
+ else
+ addr = nxtaddr;
if( *ptr == ':' ) ptr++;
if (nxtaddr == 0)