Deleted Added
full compact
lib.c (221381) lib.c (224731)
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

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

119 donerec = 1;
120 }
121 saveb0 = buf[0];
122 buf[0] = 0;
123 while (argno < *ARGC || infile == stdin) {
124 dprintf( ("argno=%d, file=|%s|\n", argno, file) );
125 if (infile == NULL) { /* have to open a new file */
126 file = getargv(argno);
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

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

119 donerec = 1;
120 }
121 saveb0 = buf[0];
122 buf[0] = 0;
123 while (argno < *ARGC || infile == stdin) {
124 dprintf( ("argno=%d, file=|%s|\n", argno, file) );
125 if (infile == NULL) { /* have to open a new file */
126 file = getargv(argno);
127 if (*file == '\0') { /* it's been zapped */
127 if (file == NULL || *file == '\0') { /* deleted or zapped */
128 argno++;
129 continue;
130 }
131 if (isclvar(file)) { /* a var=value arg */
132 setclvar(file);
133 argno++;
134 continue;
135 }

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

182int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf */
183{
184 int sep, c;
185 char *rr, *buf = *pbuf;
186 int bufsize = *pbufsize;
187
188 if (strlen(*FS) >= sizeof(inputFS))
189 FATAL("field separator %.10s... is too long", *FS);
128 argno++;
129 continue;
130 }
131 if (isclvar(file)) { /* a var=value arg */
132 setclvar(file);
133 argno++;
134 continue;
135 }

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

182int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf */
183{
184 int sep, c;
185 char *rr, *buf = *pbuf;
186 int bufsize = *pbufsize;
187
188 if (strlen(*FS) >= sizeof(inputFS))
189 FATAL("field separator %.10s... is too long", *FS);
190 /*fflush(stdout); avoids some buffering problem but makes it 25% slower*/
190 strcpy(inputFS, *FS); /* for subsequent field splitting */
191 if ((sep = **RS) == 0) {
192 sep = '\n';
193 while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
194 ;
195 if (c != EOF)
196 ungetc(c, inf);
197 }

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

222
223char *getargv(int n) /* get ARGV[n] */
224{
225 Cell *x;
226 char *s, temp[50];
227 extern Array *ARGVtab;
228
229 sprintf(temp, "%d", n);
191 strcpy(inputFS, *FS); /* for subsequent field splitting */
192 if ((sep = **RS) == 0) {
193 sep = '\n';
194 while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
195 ;
196 if (c != EOF)
197 ungetc(c, inf);
198 }

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

223
224char *getargv(int n) /* get ARGV[n] */
225{
226 Cell *x;
227 char *s, temp[50];
228 extern Array *ARGVtab;
229
230 sprintf(temp, "%d", n);
231 if (lookup(temp, ARGVtab) == NULL)
232 return NULL;
230 x = setsymtab(temp, "", 0.0, STR, ARGVtab);
231 s = getsval(x);
232 dprintf( ("getargv(%d) returns |%s|\n", n, s) );
233 return s;
234}
235
236void setclvar(char *s) /* set var=value from s */
237{

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

472 FATAL("created $0 `%.30s...' too long", record);
473 for (p = *OFS; (*r = *p++) != 0; )
474 r++;
475 }
476 }
477 if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3"))
478 FATAL("built giant record `%.30s...'", record);
479 *r = '\0';
233 x = setsymtab(temp, "", 0.0, STR, ARGVtab);
234 s = getsval(x);
235 dprintf( ("getargv(%d) returns |%s|\n", n, s) );
236 return s;
237}
238
239void setclvar(char *s) /* set var=value from s */
240{

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

475 FATAL("created $0 `%.30s...' too long", record);
476 for (p = *OFS; (*r = *p++) != 0; )
477 r++;
478 }
479 }
480 if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3"))
481 FATAL("built giant record `%.30s...'", record);
482 *r = '\0';
480 dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) );
483 dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) );
481
482 if (freeable(fldtab[0]))
483 xfree(fldtab[0]->sval);
484 fldtab[0]->tval = REC | STR | DONTFREE;
485 fldtab[0]->sval = record;
486
484
485 if (freeable(fldtab[0]))
486 xfree(fldtab[0]->sval);
487 fldtab[0]->tval = REC | STR | DONTFREE;
488 fldtab[0]->sval = record;
489
487 dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) );
490 dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) );
488 dprintf( ("recbld = |%s|\n", record) );
489 donerec = 1;
490}
491
492int errorflag = 0;
493
494void yyerror(const char *s)
495{

--- 203 unchanged lines hidden ---
491 dprintf( ("recbld = |%s|\n", record) );
492 donerec = 1;
493}
494
495int errorflag = 0;
496
497void yyerror(const char *s)
498{

--- 203 unchanged lines hidden ---