| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: display.c,v 1.22 2013/10/18 20:19:03 christos Exp $ */ | | 1 | /* $NetBSD: display.c,v 1.23 2016/03/04 02:46:19 dholland Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1989, 1993 | | 4 | * Copyright (c) 1989, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -28,50 +28,51 @@ | | | @@ -28,50 +28,51 @@ |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #if HAVE_NBTOOL_CONFIG_H | | 32 | #if HAVE_NBTOOL_CONFIG_H |
33 | #include "nbtool_config.h" | | 33 | #include "nbtool_config.h" |
34 | #endif | | 34 | #endif |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | #if !defined(lint) | | 37 | #if !defined(lint) |
38 | #if 0 | | 38 | #if 0 |
39 | static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93"; | | 39 | static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93"; |
40 | #else | | 40 | #else |
41 | __RCSID("$NetBSD: display.c,v 1.22 2013/10/18 20:19:03 christos Exp $"); | | 41 | __RCSID("$NetBSD: display.c,v 1.23 2016/03/04 02:46:19 dholland Exp $"); |
42 | #endif | | 42 | #endif |
43 | #endif /* not lint */ | | 43 | #endif /* not lint */ |
44 | | | 44 | |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | #include <sys/stat.h> | | 46 | #include <sys/stat.h> |
47 | | | 47 | |
48 | #include <ctype.h> | | 48 | #include <ctype.h> |
49 | #include <err.h> | | 49 | #include <err.h> |
50 | #include <errno.h> | | 50 | #include <errno.h> |
51 | #include <inttypes.h> | | 51 | #include <inttypes.h> |
52 | #include <stdio.h> | | 52 | #include <stdio.h> |
53 | #include <stdlib.h> | | 53 | #include <stdlib.h> |
54 | #include <string.h> | | 54 | #include <string.h> |
55 | #include <unistd.h> | | 55 | #include <unistd.h> |
56 | #include <util.h> | | 56 | #include <util.h> |
57 | | | 57 | |
58 | #include "hexdump.h" | | 58 | #include "hexdump.h" |
59 | | | 59 | |
60 | enum _vflag vflag = FIRST; | | 60 | enum _vflag vflag = FIRST; |
61 | | | 61 | |
62 | static off_t address; /* address/offset in stream */ | | 62 | static off_t address; /* address/offset in stream */ |
63 | static off_t eaddress; /* end address */ | | 63 | static off_t eaddress; /* end address */ |
64 | | | 64 | |
| | | 65 | static u_char *get(void); |
65 | static inline void print(PR *, u_char *); | | 66 | static inline void print(PR *, u_char *); |
66 | | | 67 | |
67 | void | | 68 | void |
68 | display(void) | | 69 | display(void) |
69 | { | | 70 | { |
70 | FS *fs; | | 71 | FS *fs; |
71 | FU *fu; | | 72 | FU *fu; |
72 | PR *pr; | | 73 | PR *pr; |
73 | int cnt; | | 74 | int cnt; |
74 | u_char *bp; | | 75 | u_char *bp; |
75 | off_t saveaddress; | | 76 | off_t saveaddress; |
76 | u_char savech, *savebp; | | 77 | u_char savech, *savebp; |
77 | | | 78 | |
| @@ -219,27 +220,27 @@ bpad(PR *pr) | | | @@ -219,27 +220,27 @@ bpad(PR *pr) |
219 | * Remove all conversion flags; '-' is the only one valid | | 220 | * Remove all conversion flags; '-' is the only one valid |
220 | * with %s, and it's not useful here. | | 221 | * with %s, and it's not useful here. |
221 | */ | | 222 | */ |
222 | pr->flags = F_BPAD; | | 223 | pr->flags = F_BPAD; |
223 | pr->cchar[0] = 's'; | | 224 | pr->cchar[0] = 's'; |
224 | pr->cchar[1] = '\0'; | | 225 | pr->cchar[1] = '\0'; |
225 | for (p1 = pr->fmt; *p1 != '%'; ++p1); | | 226 | for (p1 = pr->fmt; *p1 != '%'; ++p1); |
226 | for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1); | | 227 | for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1); |
227 | while ((*p2++ = *p1++) != '\0'); | | 228 | while ((*p2++ = *p1++) != '\0'); |
228 | } | | 229 | } |
229 | | | 230 | |
230 | static char **_argv; | | 231 | static char **_argv; |
231 | | | 232 | |
232 | u_char * | | 233 | static u_char * |
233 | get(void) | | 234 | get(void) |
234 | { | | 235 | { |
235 | static int ateof = 1; | | 236 | static int ateof = 1; |
236 | static u_char *curp, *savp; | | 237 | static u_char *curp, *savp; |
237 | int n; | | 238 | int n; |
238 | int need, nread; | | 239 | int need, nread; |
239 | u_char *tmpp; | | 240 | u_char *tmpp; |
240 | | | 241 | |
241 | if (!curp) { | | 242 | if (!curp) { |
242 | curp = ecalloc(blocksize, 1); | | 243 | curp = ecalloc(blocksize, 1); |
243 | savp = ecalloc(blocksize, 1); | | 244 | savp = ecalloc(blocksize, 1); |
244 | } else { | | 245 | } else { |
245 | tmpp = curp; | | 246 | tmpp = curp; |