display.c (82766) | display.c (87203) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] = | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/usr.bin/hexdump/display.c 82766 2001-09-01 22:42:47Z ache $"; | 39 "$FreeBSD: head/usr.bin/hexdump/display.c 87203 2001-12-02 12:09:41Z markm $"; |
40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/stat.h> 44 45#include <ctype.h> 46#include <err.h> 47#include <stdio.h> --- 16 unchanged lines hidden (view full) --- 64 register FS *fs; 65 register FU *fu; 66 register PR *pr; 67 register int cnt; 68 register u_char *bp; 69 off_t saveaddress; 70 u_char savech, *savebp; 71 | 40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/stat.h> 44 45#include <ctype.h> 46#include <err.h> 47#include <stdio.h> --- 16 unchanged lines hidden (view full) --- 64 register FS *fs; 65 register FU *fu; 66 register PR *pr; 67 register int cnt; 68 register u_char *bp; 69 off_t saveaddress; 70 u_char savech, *savebp; 71 |
72 while (bp = get()) | 72 while ((bp = get())) |
73 for (fs = fshead, savebp = bp, saveaddress = address; fs; 74 fs = fs->nextfs, bp = savebp, address = saveaddress) 75 for (fu = fs->nextfu; fu; fu = fu->nextfu) { 76 if (fu->flags&F_IGNORE) 77 break; 78 for (cnt = fu->reps; cnt; --cnt) 79 for (pr = fu->nextpr; pr; address += pr->bcnt, 80 bp += pr->bcnt, pr = pr->nextpr) { --- 122 unchanged lines hidden (view full) --- 203 break; 204 } 205} 206 207void 208bpad(pr) 209 PR *pr; 210{ | 73 for (fs = fshead, savebp = bp, saveaddress = address; fs; 74 fs = fs->nextfs, bp = savebp, address = saveaddress) 75 for (fu = fs->nextfu; fu; fu = fu->nextfu) { 76 if (fu->flags&F_IGNORE) 77 break; 78 for (cnt = fu->reps; cnt; --cnt) 79 for (pr = fu->nextpr; pr; address += pr->bcnt, 80 bp += pr->bcnt, pr = pr->nextpr) { --- 122 unchanged lines hidden (view full) --- 203 break; 204 } 205} 206 207void 208bpad(pr) 209 PR *pr; 210{ |
211 static char *spec = " -0+#"; | 211 static char spec[] = " -0+#"; |
212 register char *p1, *p2; 213 214 /* 215 * Remove all conversion flags; '-' is the only one valid 216 * with %s, and it's not useful here. 217 */ 218 pr->flags = F_BPAD; 219 pr->cchar[0] = 's'; 220 pr->cchar[1] = '\0'; 221 for (p1 = pr->fmt; *p1 != '%'; ++p1); 222 for (p2 = ++p1; *p1 && index(spec, *p1); ++p1); | 212 register char *p1, *p2; 213 214 /* 215 * Remove all conversion flags; '-' is the only one valid 216 * with %s, and it's not useful here. 217 */ 218 pr->flags = F_BPAD; 219 pr->cchar[0] = 's'; 220 pr->cchar[1] = '\0'; 221 for (p1 = pr->fmt; *p1 != '%'; ++p1); 222 for (p2 = ++p1; *p1 && index(spec, *p1); ++p1); |
223 while (*p2++ = *p1++); | 223 while ((*p2++ = *p1++)); |
224} 225 226static char **_argv; 227 228u_char * 229get() 230{ | 224} 225 226static char **_argv; 227 228u_char * 229get() 230{ |
231 extern enum _vflag vflag; | |
232 extern int length; 233 static int ateof = 1; 234 static u_char *curp, *savp; 235 register int n; 236 int need, nread; 237 int valid_save = 0; 238 u_char *tmpp; 239 --- 10 unchanged lines hidden (view full) --- 250 valid_save = 1; 251 } 252 for (need = blocksize, nread = 0;;) { 253 /* 254 * if read the right number of bytes, or at EOF for one file, 255 * and no other files are available, zero-pad the rest of the 256 * block and set the end flag. 257 */ | 231 extern int length; 232 static int ateof = 1; 233 static u_char *curp, *savp; 234 register int n; 235 int need, nread; 236 int valid_save = 0; 237 u_char *tmpp; 238 --- 10 unchanged lines hidden (view full) --- 249 valid_save = 1; 250 } 251 for (need = blocksize, nread = 0;;) { 252 /* 253 * if read the right number of bytes, or at EOF for one file, 254 * and no other files are available, zero-pad the rest of the 255 * block and set the end flag. 256 */ |
258 if (!length || ateof && !next((char **)NULL)) { | 257 if (!length || (ateof && !next((char **)NULL))) { |
259 if (need == blocksize) 260 return((u_char *)NULL); 261 if (vflag != ALL && 262 valid_save && 263 bcmp(curp, savp, nread) == 0) { 264 if (vflag != DUP) 265 (void)printf("*\n"); 266 return((u_char *)NULL); --- 68 unchanged lines hidden (view full) --- 335 if (!skip) 336 return(1); 337 } 338 /* NOTREACHED */ 339} 340 341void 342doskip(fname, statok) | 258 if (need == blocksize) 259 return((u_char *)NULL); 260 if (vflag != ALL && 261 valid_save && 262 bcmp(curp, savp, nread) == 0) { 263 if (vflag != DUP) 264 (void)printf("*\n"); 265 return((u_char *)NULL); --- 68 unchanged lines hidden (view full) --- 334 if (!skip) 335 return(1); 336 } 337 /* NOTREACHED */ 338} 339 340void 341doskip(fname, statok) |
343 char *fname; | 342 const char *fname; |
344 int statok; 345{ 346 register int cnt; 347 struct stat sb; 348 349 if (statok) { 350 if (fstat(fileno(stdin), &sb)) 351 err(1, "%s", fname); --- 19 unchanged lines hidden --- | 343 int statok; 344{ 345 register int cnt; 346 struct stat sb; 347 348 if (statok) { 349 if (fstat(fileno(stdin), &sb)) 350 err(1, "%s", fname); --- 19 unchanged lines hidden --- |