annotate lib-src/hexl.c @ 7431:a0f1b8c25adf

(texinfo-environment-regexp): Split lines. Add def..., ifset, ifclear. (texinfo-show-structure): Fix typo.
author Richard M. Stallman <rms@gnu.org>
date Tue, 10 May 1994 06:39:04 +0000
parents 6d1d2e86fb37
children cd7741bac302
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 #include <stdio.h>
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 #include <ctype.h>
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
3 #ifdef MSDOS
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
4 #include <fcntl.h>
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
5 #endif
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 #define DEFAULT_GROUPING 0x01
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 #define DEFAULT_BASE 16
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 #undef TRUE
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 #undef FALSE
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 #define TRUE (1)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 #define FALSE (0)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14
7196
6d1d2e86fb37 [MSDOS]: Don't define proto type for exit.
Richard M. Stallman <rms@gnu.org>
parents: 5445
diff changeset
15 #ifndef MSDOS
6d1d2e86fb37 [MSDOS]: Don't define proto type for exit.
Richard M. Stallman <rms@gnu.org>
parents: 5445
diff changeset
16 /* Defined volatile by std.h in MsDos. */
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
17 extern void exit (), perror ();
7196
6d1d2e86fb37 [MSDOS]: Don't define proto type for exit.
Richard M. Stallman <rms@gnu.org>
parents: 5445
diff changeset
18 #endif
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 int group_by = DEFAULT_GROUPING;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 char *progname;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
24 main (argc, argv)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
25 int argc;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
26 char *argv[];
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
28 register long address;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
29 char string[18];
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
30 FILE *fp;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
32 progname = *argv++; --argc;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
34 /*
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
35 ** -hex hex dump
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
36 ** -oct Octal dump
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
37 ** -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
38 ** -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
39 ** -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
40 ** -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
41 ** -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
42 ** -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
43 ** -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
44 ** -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
45 ** -- End switch list.
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
46 ** <filename> dump filename
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
47 ** - (as filename == stdin)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
48 */
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
50 while (*argv && *argv[0] == '-' && (*argv)[1])
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
52 /* A switch! */
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
53 if (!strcmp (*argv, "--"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
55 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
56 break;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
57 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
58 else if (!strcmp (*argv, "-un") || !strcmp (*argv, "-de"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
60 un_flag = TRUE;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
61 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
62 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
63 else if (!strcmp (*argv, "-hex"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
65 base = 16;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
66 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
67 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
68 else if (!strcmp (*argv, "-iso"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
70 iso_flag = TRUE;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
71 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
72 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
73 else if (!strcmp (*argv, "-oct"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
75 base = 8;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
76 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
77 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
78 else if (!strcmp (*argv, "-big-endian"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
80 endian = 1;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
81 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
82 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
83 else if (!strcmp (*argv, "-little-endian"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
85 endian = 0;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
86 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
87 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
88 else if (!strcmp (*argv, "-group-by-8-bits"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
90 group_by = 0x00;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
91 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
92 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
93 else if (!strcmp (*argv, "-group-by-16-bits"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
95 group_by = 0x01;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
96 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
97 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
98 else if (!strcmp (*argv, "-group-by-32-bits"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
100 group_by = 0x03;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
101 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
102 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
103 else if (!strcmp (*argv, "-group-by-64-bits"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
105 group_by = 0x07;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
106 endian = 0;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
107 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
108 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
109 else
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
111 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
112 *argv);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
113 usage ();
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
117 do
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
119 if (*argv == NULL)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
120 fp = stdin;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
121 else
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
123 char *filename = *argv++;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
125 if (!strcmp (filename, "-"))
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
126 fp = stdin;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
127 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
128 {
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
129 perror (filename);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
130 continue;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
131 }
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
134 if (un_flag)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
136 char buf[18];
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
138 #ifdef MSDOS
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
139 (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
140 _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
141 #endif
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
142 for (;;)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
144 register int i, c, d;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
146 #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
148 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
149
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
150 for (i=0; i < 16; ++i)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
152 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
153 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
155 d = getc (fp);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
156 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
157 putchar (c);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
159 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
160 getc (fp);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
163 if (c == ' ')
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
165 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
166 ;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
168 if (c == EOF)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
169 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 }
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
171 else
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
173 if (i < 16)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
174 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
176 fread (buf, 1, 18, fp); /* skip 18 bytes */
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 }
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
180 else
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
182 #ifdef MSDOS
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
183 (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
184 _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
185 #endif
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
186 address = 0;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
187 string[0] = ' ';
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
188 string[17] = '\0';
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
189 for (;;)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
191 register int i, c;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
193 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
194 {
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
195 if ((c = getc (fp)) == EOF)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
197 if (!i)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
198 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
200 fputs (" ", stdout);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
201 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
202 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
203 else
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
204 {
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
205 if (!i)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
206 printf ("%08x: ", address);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
208 if (iso_flag)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
209 string[i+1] =
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
210 (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
211 else
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
212 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
213
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
214 printf ("%02x", c);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
217 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
218 putchar (' ');
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
221 if (i)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
222 puts (string);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
224 if (c == EOF)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
225 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
227 address += 0x10;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
232 if (fp != stdin)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
233 fclose (fp);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 } 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
236 return 0;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
239 usage ()
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
241 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
242 exit (1);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 }