Mercurial > emacs
annotate lib-src/hexl.c @ 83537:c19f348befac
Fix F10 behaviour. (Reported by Bernard Adrian.)
* src/xmenu.c (Fx_menu_bar_open) [USE_X_TOOLKIT, USE_GTK]:
Rename from Fmenu_bar_open.
(syms_of_xmenu): Update defsubr.
* lisp/menu-bar.el (menu-bar-open): New function.
Bind it to f10.
* lisp/term/x-win.el: Don't bind f10.
* lisp/tmm.el: Remove autoload binding for f10.
* lisp/ldefs-boot.el: Regenerate.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-577
| author | Karoly Lorentey <lorentey@elte.hu> |
|---|---|
| date | Sat, 29 Jul 2006 20:57:26 +0000 |
| parents | 3661e9b3c48f |
| children | 6d19c76d81c5 c5406394f567 |
| rev | line source |
|---|---|
|
19339
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
1 /* Convert files for Emacs Hexl mode. |
|
68647
3661e9b3c48f
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64769
diff
changeset
|
2 Copyright (C) 1989, 2002, 2003, 2004, 2005, |
|
3661e9b3c48f
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64769
diff
changeset
|
3 2006 Free Software Foundation, Inc. |
|
19339
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
4 |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
5 This file is not considered part of GNU Emacs. |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
6 |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
7 This program is free software; you can redistribute it and/or modify |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
8 it under the terms of the GNU General Public License as published by |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
9 the Free Software Foundation; either version 2 of the License, or |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
10 (at your option) any later version. |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
11 |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
12 This program is distributed in the hope that it will be useful, |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
15 GNU General Public License for more details. |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
16 |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
|
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
18 along with this program; if not, write to the Free Software Foundation, |
| 64083 | 19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
|
19339
4a529ce5a52e
Add copyright and permission notices.
Richard M. Stallman <rms@gnu.org>
parents:
19338
diff
changeset
|
20 |
|
15903
0a93a0afdd74
Include <config.h>, so DOS_NT is defined on MSDOS.
Richard M. Stallman <rms@gnu.org>
parents:
15100
diff
changeset
|
21 #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
|
22 #include <config.h> |
|
0a93a0afdd74
Include <config.h>, so DOS_NT is defined on MSDOS.
Richard M. Stallman <rms@gnu.org>
parents:
15100
diff
changeset
|
23 #endif |
|
0a93a0afdd74
Include <config.h>, so DOS_NT is defined on MSDOS.
Richard M. Stallman <rms@gnu.org>
parents:
15100
diff
changeset
|
24 |
| 26 | 25 #include <stdio.h> |
| 26 #include <ctype.h> | |
|
15100
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
27 #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
|
28 #include <fcntl.h> |
|
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
29 #if __DJGPP__ >= 2 |
|
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
30 #include <io.h> |
|
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
31 #endif |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
32 #endif |
|
15100
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
33 #ifdef WINDOWSNT |
|
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
34 #include <io.h> |
|
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
35 #endif |
| 26 | 36 |
| 37 #define DEFAULT_GROUPING 0x01 | |
| 38 #define DEFAULT_BASE 16 | |
| 39 | |
| 40 #undef TRUE | |
| 41 #undef FALSE | |
| 42 #define TRUE (1) | |
| 43 #define FALSE (0) | |
| 44 | |
| 45 int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1; | |
| 46 int group_by = DEFAULT_GROUPING; | |
| 47 char *progname; | |
| 48 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8026
diff
changeset
|
49 void usage(); |
|
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8026
diff
changeset
|
50 |
|
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8026
diff
changeset
|
51 int |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
52 main (argc, argv) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
53 int argc; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
54 char *argv[]; |
| 26 | 55 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
56 register long address; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
57 char string[18]; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
58 FILE *fp; |
| 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 progname = *argv++; --argc; |
| 26 | 61 |
|
5445
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 ** -hex hex dump |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
64 ** -oct Octal dump |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
65 ** -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
|
66 ** -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
|
67 ** -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
|
68 ** -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
|
69 ** -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
|
70 ** -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
|
71 ** -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
|
72 ** -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
|
73 ** -- End switch list. |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
74 ** <filename> dump filename |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
75 ** - (as filename == stdin) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
76 */ |
|
42439
d8a417105504
Remove unnecessary whitespaces.
Pavel Jan?k <Pavel@Janik.cz>
parents:
19339
diff
changeset
|
77 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
78 while (*argv && *argv[0] == '-' && (*argv)[1]) |
| 26 | 79 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
80 /* A switch! */ |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
81 if (!strcmp (*argv, "--")) |
| 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 --argc; argv++; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
84 break; |
|
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, "-un") || !strcmp (*argv, "-de")) |
| 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 un_flag = TRUE; |
|
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, "-hex")) |
| 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 base = 16; |
|
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, "-iso")) |
| 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 iso_flag = TRUE; |
|
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, "-oct")) |
| 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 base = 8; |
|
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, "-big-endian")) |
| 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 endian = 1; |
|
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, "-little-endian")) |
| 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 endian = 0; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
114 --argc; argv++; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
115 } |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
116 else if (!strcmp (*argv, "-group-by-8-bits")) |
| 26 | 117 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
118 group_by = 0x00; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
119 --argc; argv++; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
120 } |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
121 else if (!strcmp (*argv, "-group-by-16-bits")) |
| 26 | 122 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
123 group_by = 0x01; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
124 --argc; argv++; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
125 } |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
126 else if (!strcmp (*argv, "-group-by-32-bits")) |
| 26 | 127 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
128 group_by = 0x03; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
129 --argc; argv++; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
130 } |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
131 else if (!strcmp (*argv, "-group-by-64-bits")) |
| 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 group_by = 0x07; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
134 endian = 0; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
135 --argc; argv++; |
|
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 else |
| 26 | 138 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
139 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
|
140 *argv); |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
141 usage (); |
| 26 | 142 } |
| 143 } | |
| 144 | |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
145 do |
| 26 | 146 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
147 if (*argv == NULL) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
148 fp = stdin; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
149 else |
| 26 | 150 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
151 char *filename = *argv++; |
| 26 | 152 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
153 if (!strcmp (filename, "-")) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
154 fp = stdin; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
155 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
|
156 { |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
157 perror (filename); |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
158 continue; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
159 } |
| 26 | 160 } |
| 161 | |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
162 if (un_flag) |
| 26 | 163 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
164 char buf[18]; |
| 26 | 165 |
|
15100
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
166 #ifdef DOS_NT |
|
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
167 #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
|
168 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
|
169 setmode (fileno (stdout), O_BINARY); |
|
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
170 #else |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
171 (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
|
172 _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
|
173 #endif |
|
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
174 #endif |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
175 for (;;) |
| 26 | 176 { |
|
58078
5d803fae362c
(main): Init local var c to silence compiler.
Kim F. Storm <storm@cua.dk>
parents:
55442
diff
changeset
|
177 register int i, c = 0, d; |
| 26 | 178 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
179 #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) |
| 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 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
|
182 |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
183 for (i=0; i < 16; ++i) |
| 26 | 184 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
185 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
|
186 break; |
| 26 | 187 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
188 d = getc (fp); |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
189 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
|
190 putchar (c); |
| 26 | 191 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
192 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
|
193 getc (fp); |
| 26 | 194 } |
| 195 | |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
196 if (c == ' ') |
| 26 | 197 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
198 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
|
199 ; |
| 26 | 200 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
201 if (c == EOF) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
202 break; |
| 26 | 203 } |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
204 else |
| 26 | 205 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
206 if (i < 16) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
207 break; |
| 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 fread (buf, 1, 18, fp); /* skip 18 bytes */ |
| 26 | 210 } |
| 211 } | |
| 212 } | |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
213 else |
| 26 | 214 { |
|
15100
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
215 #ifdef DOS_NT |
|
85edb1a5281a
[DOSNT]: Include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
15019
diff
changeset
|
216 #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
|
217 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
|
218 setmode (fileno (fp), O_BINARY); |
|
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
219 #else |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
220 (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
|
221 _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
|
222 #endif |
|
15008
aca392dc5b0f
[DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
223 #endif |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
224 address = 0; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
225 string[0] = ' '; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
226 string[17] = '\0'; |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
227 for (;;) |
| 26 | 228 { |
|
58078
5d803fae362c
(main): Init local var c to silence compiler.
Kim F. Storm <storm@cua.dk>
parents:
55442
diff
changeset
|
229 register int i, c = 0; |
| 26 | 230 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
231 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
|
232 { |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
233 if ((c = getc (fp)) == EOF) |
| 26 | 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) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
236 break; |
| 26 | 237 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
238 fputs (" ", stdout); |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
239 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
|
240 } |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
241 else |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
242 { |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
243 if (!i) |
|
19338
653a7898590b
(main): Use %08lx instead of %08x in printf because the
Richard M. Stallman <rms@gnu.org>
parents:
15903
diff
changeset
|
244 printf ("%08lx: ", address); |
| 26 | 245 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
246 if (iso_flag) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
247 string[i+1] = |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
248 (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
|
249 else |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
250 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
|
251 |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
252 printf ("%02x", c); |
| 26 | 253 } |
| 254 | |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
255 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
|
256 putchar (' '); |
| 26 | 257 } |
| 258 | |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
259 if (i) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
260 puts (string); |
| 26 | 261 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
262 if (c == EOF) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
263 break; |
| 26 | 264 |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
265 address += 0x10; |
| 26 | 266 |
| 267 } | |
| 268 } | |
| 269 | |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
270 if (fp != stdin) |
|
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
271 fclose (fp); |
| 26 | 272 |
| 273 } while (*argv != NULL); | |
|
55442
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
274 return EXIT_SUCCESS; |
| 26 | 275 } |
| 276 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8026
diff
changeset
|
277 void |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
278 usage () |
| 26 | 279 { |
|
5445
44e193cc8f49
Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents:
26
diff
changeset
|
280 fprintf (stderr, "usage: %s [-de] [-iso]\n", progname); |
|
55442
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
281 exit (EXIT_FAILURE); |
| 26 | 282 } |
| 52401 | 283 |
| 284 /* arch-tag: 20e04fb7-926e-4e48-be86-64fe869ecdaa | |
| 285 (do not change this comment) */ | |
|
55442
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
286 |
|
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
287 /* hexl.c ends here */ |
