Deleted Added
full compact
parse.c (27315) parse.c (30921)
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[] = "@(#)parse.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[] = "@(#)parse.c 8.1 (Berkeley) 6/6/93";
37#endif
38static const char rcsid[] =
39 "$Id$";
39 "$Id: parse.c,v 1.2 1997/07/10 06:48:24 charnier Exp $";
40#endif /* not lint */
41
42#include <sys/types.h>
43
44#include <err.h>
45#include <fcntl.h>
46#include <stdio.h>
47#include <stdlib.h>
48#include <ctype.h>
49#include <string.h>
50#include "hexdump.h"
51
52FU *endfu; /* format at end-of-data */
53
54void
55addfile(name)
56 char *name;
57{
40#endif /* not lint */
41
42#include <sys/types.h>
43
44#include <err.h>
45#include <fcntl.h>
46#include <stdio.h>
47#include <stdlib.h>
48#include <ctype.h>
49#include <string.h>
50#include "hexdump.h"
51
52FU *endfu; /* format at end-of-data */
53
54void
55addfile(name)
56 char *name;
57{
58 register char *p;
58 register unsigned char *p;
59 FILE *fp;
60 int ch;
61 char buf[2048 + 1];
62
63 if ((fp = fopen(name, "r")) == NULL)
64 err(1, "%s", name);
65 while (fgets(buf, sizeof(buf), fp)) {
66 if (!(p = index(buf, '\n'))) {

--- 9 unchanged lines hidden (view full) ---

76 }
77 (void)fclose(fp);
78}
79
80void
81add(fmt)
82 char *fmt;
83{
59 FILE *fp;
60 int ch;
61 char buf[2048 + 1];
62
63 if ((fp = fopen(name, "r")) == NULL)
64 err(1, "%s", name);
65 while (fgets(buf, sizeof(buf), fp)) {
66 if (!(p = index(buf, '\n'))) {

--- 9 unchanged lines hidden (view full) ---

76 }
77 (void)fclose(fp);
78}
79
80void
81add(fmt)
82 char *fmt;
83{
84 register char *p;
84 unsigned char *p, *savep;
85 static FS **nextfs;
86 FS *tfs;
87 FU *tfu, **nextfu;
85 static FS **nextfs;
86 FS *tfs;
87 FU *tfu, **nextfu;
88 char *savep;
89
90 /* start new linked list of format units */
91 tfs = emalloc(sizeof(FS));
92 if (!fshead)
93 fshead = tfs;
94 else
95 *nextfs = tfs;
96 nextfs = &tfs->nextfs;

--- 56 unchanged lines hidden (view full) ---

153static char *spec = ".#-+ 0123456789";
154
155int
156size(fs)
157 FS *fs;
158{
159 register FU *fu;
160 register int bcnt, cursize;
88
89 /* start new linked list of format units */
90 tfs = emalloc(sizeof(FS));
91 if (!fshead)
92 fshead = tfs;
93 else
94 *nextfs = tfs;
95 nextfs = &tfs->nextfs;

--- 56 unchanged lines hidden (view full) ---

152static char *spec = ".#-+ 0123456789";
153
154int
155size(fs)
156 FS *fs;
157{
158 register FU *fu;
159 register int bcnt, cursize;
161 register char *fmt;
160 register unsigned char *fmt;
162 int prec;
163
164 /* figure out the data block size needed for each format unit */
165 for (cursize = 0, fu = fs->nextfu; fu; fu = fu->nextfu) {
166 if (fu->bcnt) {
167 cursize += fu->bcnt * fu->reps;
168 continue;
169 }

--- 38 unchanged lines hidden (view full) ---

208
209void
210rewrite(fs)
211 FS *fs;
212{
213 enum { NOTOKAY, USEBCNT, USEPREC } sokay;
214 register PR *pr, **nextpr;
215 register FU *fu;
161 int prec;
162
163 /* figure out the data block size needed for each format unit */
164 for (cursize = 0, fu = fs->nextfu; fu; fu = fu->nextfu) {
165 if (fu->bcnt) {
166 cursize += fu->bcnt * fu->reps;
167 continue;
168 }

--- 38 unchanged lines hidden (view full) ---

207
208void
209rewrite(fs)
210 FS *fs;
211{
212 enum { NOTOKAY, USEBCNT, USEPREC } sokay;
213 register PR *pr, **nextpr;
214 register FU *fu;
216 register char *p1, *p2;
217 char savech, *fmtp, cs[3];
215 unsigned char *p1, *p2, *fmtp;
216 char savech, cs[3];
218 int nconv, prec;
219
220 for (fu = fs->nextfu; fu; fu = fu->nextfu) {
221 /*
222 * Break each format unit into print units; each conversion
223 * character gets its own.
224 */
225 for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {

--- 286 unchanged lines hidden ---
217 int nconv, prec;
218
219 for (fu = fs->nextfu; fu; fu = fu->nextfu) {
220 /*
221 * Break each format unit into print units; each conversion
222 * character gets its own.
223 */
224 for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {

--- 286 unchanged lines hidden ---