Mercurial > emacs
annotate lib-src/hexl.c @ 18344:dca9b4a8155e
(untabify): Handle consecutive tabs all at once.
(tabify-regexp): New var.
(tabify): Use it.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 21 Jun 1997 00:35:11 +0000 |
parents | 0a93a0afdd74 |
children | 653a7898590b |
rev | line source |
---|---|
15903
0a93a0afdd74
Include <config.h>, so DOS_NT is defined on MSDOS.
Richard M. Stallman <rms@gnu.org>
parents:
15100
diff
changeset
|
1 #ifdef HAVE_CONFIG_H |
0a93a0afdd74
Include <config.h>, so DOS_NT is defined on MSDOS.
Richard M. Stallman <rms@gnu.org>
parents:
15100
diff
changeset
|
2 #include <config.h> |
0a93a0afdd74
Include <config.h>, so DOS_NT is defined on MSDOS.
Richard M. Stallman <rms@gnu.org>
parents:
15100
diff
changeset
|
3 #endif |
0a93a0afdd74
Include <config.h>, so DOS_NT is defined on MSDOS.
Richard M. Stallman <rms@gnu.org>
parents:
15100
diff
changeset
|
4 |
26 | 5 #include <stdio.h> |
6 #include <ctype.h> | |
15100
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
7 #ifdef DOS_NT |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
8 #include <fcntl.h> |
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
9 #if __DJGPP__ >= 2 |
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
10 #include <io.h> |
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
11 #endif |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
12 #endif |
15100
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
13 #ifdef WINDOWSNT |
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
14 #include <io.h> |
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
15 #endif |
26 | 16 |
17 #define DEFAULT_GROUPING 0x01 | |
18 #define DEFAULT_BASE 16 | |
19 | |
20 #undef TRUE | |
21 #undef FALSE | |
22 #define TRUE (1) | |
23 #define FALSE (0) | |
24 | |
25 int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1; | |
26 int group_by = DEFAULT_GROUPING; | |
27 char *progname; | |
28 | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8026
diff
changeset
|
29 void usage(); |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8026
diff
changeset
|
30 |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8026
diff
changeset
|
31 int |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
32 main (argc, argv) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
33 int argc; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
34 char *argv[]; |
26 | 35 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
36 register long address; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
37 char string[18]; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
38 FILE *fp; |
26 | 39 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
40 progname = *argv++; --argc; |
26 | 41 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
42 /* |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
43 ** -hex hex dump |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
44 ** -oct Octal dump |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
45 ** -group-by-8-bits |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
46 ** -group-by-16-bits |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
47 ** -group-by-32-bits |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
48 ** -group-by-64-bits |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
49 ** -iso iso character set. |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
50 ** -big-endian Big Endian |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
51 ** -little-endian Little Endian |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
52 ** -un || -de from hexl format to binary. |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
53 ** -- End switch list. |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
54 ** <filename> dump filename |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
55 ** - (as filename == stdin) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
56 */ |
26 | 57 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
58 while (*argv && *argv[0] == '-' && (*argv)[1]) |
26 | 59 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
60 /* A switch! */ |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
61 if (!strcmp (*argv, "--")) |
26 | 62 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
63 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
64 break; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
65 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
66 else if (!strcmp (*argv, "-un") || !strcmp (*argv, "-de")) |
26 | 67 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
68 un_flag = TRUE; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
69 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
70 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
71 else if (!strcmp (*argv, "-hex")) |
26 | 72 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
73 base = 16; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
74 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
75 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
76 else if (!strcmp (*argv, "-iso")) |
26 | 77 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
78 iso_flag = TRUE; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
79 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
80 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
81 else if (!strcmp (*argv, "-oct")) |
26 | 82 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
83 base = 8; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
84 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
85 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
86 else if (!strcmp (*argv, "-big-endian")) |
26 | 87 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
88 endian = 1; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
89 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
90 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
91 else if (!strcmp (*argv, "-little-endian")) |
26 | 92 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
93 endian = 0; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
94 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
95 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
96 else if (!strcmp (*argv, "-group-by-8-bits")) |
26 | 97 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
98 group_by = 0x00; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
99 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
100 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
101 else if (!strcmp (*argv, "-group-by-16-bits")) |
26 | 102 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
103 group_by = 0x01; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
104 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
105 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
106 else if (!strcmp (*argv, "-group-by-32-bits")) |
26 | 107 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
108 group_by = 0x03; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
109 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
110 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
111 else if (!strcmp (*argv, "-group-by-64-bits")) |
26 | 112 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
113 group_by = 0x07; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
114 endian = 0; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
115 --argc; argv++; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
116 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
117 else |
26 | 118 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
119 fprintf (stderr, "%s: invalid switch: \"%s\".\n", progname, |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
120 *argv); |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
121 usage (); |
26 | 122 } |
123 } | |
124 | |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
125 do |
26 | 126 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
127 if (*argv == NULL) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
128 fp = stdin; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
129 else |
26 | 130 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
131 char *filename = *argv++; |
26 | 132 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
133 if (!strcmp (filename, "-")) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
134 fp = stdin; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
135 else if ((fp = fopen (filename, "r")) == NULL) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
136 { |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
137 perror (filename); |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
138 continue; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
139 } |
26 | 140 } |
141 | |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
142 if (un_flag) |
26 | 143 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
144 char buf[18]; |
26 | 145 |
15100
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
146 #ifdef DOS_NT |
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
147 #if (__DJGPP__ >= 2) || (defined WINDOWSNT) |
15018
2a4f0129d30d
(main) [DJGPP v2]: Don't change to binary for a tty.
Richard M. Stallman <rms@gnu.org>
parents:
15008
diff
changeset
|
148 if (!isatty (fileno (stdout))) |
2a4f0129d30d
(main) [DJGPP v2]: Don't change to binary for a tty.
Richard M. Stallman <rms@gnu.org>
parents:
15008
diff
changeset
|
149 setmode (fileno (stdout), O_BINARY); |
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
150 #else |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
151 (stdout)->_flag &= ~_IOTEXT; /* print binary */ |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
152 _setmode (fileno (stdout), O_BINARY); |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
153 #endif |
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
154 #endif |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
155 for (;;) |
26 | 156 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
157 register int i, c, d; |
26 | 158 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
159 #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) |
26 | 160 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
161 fread (buf, 1, 10, fp); /* skip 10 bytes */ |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
162 |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
163 for (i=0; i < 16; ++i) |
26 | 164 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
165 if ((c = getc (fp)) == ' ' || c == EOF) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
166 break; |
26 | 167 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
168 d = getc (fp); |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
169 c = hexchar (c) * 0x10 + hexchar (d); |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
170 putchar (c); |
26 | 171 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
172 if ((i&group_by) == group_by) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
173 getc (fp); |
26 | 174 } |
175 | |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
176 if (c == ' ') |
26 | 177 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
178 while ((c = getc (fp)) != '\n' && c != EOF) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
179 ; |
26 | 180 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
181 if (c == EOF) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
182 break; |
26 | 183 } |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
184 else |
26 | 185 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
186 if (i < 16) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
187 break; |
26 | 188 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
189 fread (buf, 1, 18, fp); /* skip 18 bytes */ |
26 | 190 } |
191 } | |
192 } | |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
193 else |
26 | 194 { |
15100
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
195 #ifdef DOS_NT |
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
196 #if (__DJGPP__ >= 2) || (defined WINDOWSNT) |
15019
30bc23af98e3
(main) [DJGPP v2]: Don't change to binary for a tty.
Richard M. Stallman <rms@gnu.org>
parents:
15018
diff
changeset
|
197 if (!isatty (fileno (fp))) |
30bc23af98e3
(main) [DJGPP v2]: Don't change to binary for a tty.
Richard M. Stallman <rms@gnu.org>
parents:
15018
diff
changeset
|
198 setmode (fileno (fp), O_BINARY); |
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
199 #else |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
200 (fp)->_flag &= ~_IOTEXT; /* read binary */ |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
201 _setmode (fileno (fp), O_BINARY); |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
202 #endif |
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
203 #endif |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
204 address = 0; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
205 string[0] = ' '; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
206 string[17] = '\0'; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
207 for (;;) |
26 | 208 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
209 register int i, c; |
26 | 210 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
211 for (i=0; i < 16; ++i) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
212 { |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
213 if ((c = getc (fp)) == EOF) |
26 | 214 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
215 if (!i) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
216 break; |
26 | 217 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
218 fputs (" ", stdout); |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
219 string[i+1] = '\0'; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
220 } |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
221 else |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
222 { |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
223 if (!i) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
224 printf ("%08x: ", address); |
26 | 225 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
226 if (iso_flag) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
227 string[i+1] = |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
228 (c < 0x20 || (c >= 0x7F && c < 0xa0)) ? '.' :c; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
229 else |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
230 string[i+1] = (c < 0x20 || c >= 0x7F) ? '.' : c; |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
231 |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
232 printf ("%02x", c); |
26 | 233 } |
234 | |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
235 if ((i&group_by) == group_by) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
236 putchar (' '); |
26 | 237 } |
238 | |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
239 if (i) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
240 puts (string); |
26 | 241 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
242 if (c == EOF) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
243 break; |
26 | 244 |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
245 address += 0x10; |
26 | 246 |
247 } | |
248 } | |
249 | |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
250 if (fp != stdin) |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
251 fclose (fp); |
26 | 252 |
253 } while (*argv != NULL); | |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
254 return 0; |
26 | 255 } |
256 | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8026
diff
changeset
|
257 void |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
258 usage () |
26 | 259 { |
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
260 fprintf (stderr, "usage: %s [-de] [-iso]\n", progname); |
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
261 exit (1); |
26 | 262 } |