=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/lib.c,v retrieving revision 1.23 retrieving revision 1.24 diff -c -r1.23 -r1.24 *** src/usr.bin/awk/lib.c 2017/09/25 17:36:35 1.23 --- src/usr.bin/awk/lib.c 2017/10/09 14:51:31 1.24 *************** *** 1,4 **** ! /* $OpenBSD: lib.c,v 1.23 2017/09/25 17:36:35 krw Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved --- 1,4 ---- ! /* $OpenBSD: lib.c,v 1.24 2017/10/09 14:51:31 deraadt Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved *************** *** 120,126 **** firsttime = 0; initgetrec(); } ! dprintf( ("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n", *RS, *FS, *ARGC, *FILENAME) ); if (isrecord) { donefld = 0; --- 120,126 ---- firsttime = 0; initgetrec(); } ! DPRINTF( ("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n", *RS, *FS, *ARGC, *FILENAME) ); if (isrecord) { donefld = 0; *************** *** 129,135 **** saveb0 = buf[0]; buf[0] = 0; while (argno < *ARGC || infile == stdin) { ! dprintf( ("argno=%d, file=|%s|\n", argno, file) ); if (infile == NULL) { /* have to open a new file */ file = getargv(argno); if (file == NULL || *file == '\0') { /* deleted or zapped */ --- 129,135 ---- saveb0 = buf[0]; buf[0] = 0; while (argno < *ARGC || infile == stdin) { ! DPRINTF( ("argno=%d, file=|%s|\n", argno, file) ); if (infile == NULL) { /* have to open a new file */ file = getargv(argno); if (file == NULL || *file == '\0') { /* deleted or zapped */ *************** *** 142,148 **** continue; } *FILENAME = file; ! dprintf( ("opening file %s\n", file) ); if (*file == '-' && *(file+1) == '\0') infile = stdin; else if ((infile = fopen(file, "r")) == NULL) --- 142,148 ---- continue; } *FILENAME = file; ! DPRINTF( ("opening file %s\n", file) ); if (*file == '-' && *(file+1) == '\0') infile = stdin; else if ((infile = fopen(file, "r")) == NULL) *************** *** 223,229 **** if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3")) FATAL("input record `%.30s...' too long", buf); *rr = 0; ! dprintf( ("readrec saw <%s>, returns %d\n", buf, c == EOF && rr == buf ? 0 : 1) ); *pbuf = buf; *pbufsize = bufsize; return c == EOF && rr == buf ? 0 : 1; --- 223,229 ---- if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3")) FATAL("input record `%.30s...' too long", buf); *rr = 0; ! DPRINTF( ("readrec saw <%s>, returns %d\n", buf, c == EOF && rr == buf ? 0 : 1) ); *pbuf = buf; *pbufsize = bufsize; return c == EOF && rr == buf ? 0 : 1; *************** *** 240,246 **** return NULL; x = setsymtab(temp, "", 0.0, STR, ARGVtab); s = getsval(x); ! dprintf( ("getargv(%d) returns |%s|\n", n, s) ); return s; } --- 240,246 ---- return NULL; x = setsymtab(temp, "", 0.0, STR, ARGVtab); s = getsval(x); ! DPRINTF( ("getargv(%d) returns |%s|\n", n, s) ); return s; } *************** *** 259,265 **** q->fval = atof(q->sval); q->tval |= NUM; } ! dprintf( ("command line set %s to |%s|\n", s, p) ); } --- 259,265 ---- q->fval = atof(q->sval); q->tval |= NUM; } ! DPRINTF( ("command line set %s to |%s|\n", s, p) ); } *************** *** 437,443 **** if (*rec == '\0') return 0; pfa = makedfa(fs, 1); ! dprintf( ("into refldbld, rec = <%s>, pat = <%s>\n", rec, fs) ); tempstat = pfa->initstat; for (i = 1; ; i++) { if (i > nfields) --- 437,443 ---- if (*rec == '\0') return 0; pfa = makedfa(fs, 1); ! DPRINTF( ("into refldbld, rec = <%s>, pat = <%s>\n", rec, fs) ); tempstat = pfa->initstat; for (i = 1; ; i++) { if (i > nfields) *************** *** 446,461 **** xfree(fldtab[i]->sval); fldtab[i]->tval = FLD | STR | DONTFREE; fldtab[i]->sval = fr; ! dprintf( ("refldbld: i=%d\n", i) ); if (nematch(pfa, rec)) { pfa->initstat = 2; /* horrible coupling to b.c */ ! dprintf( ("match %s (%d chars)\n", patbeg, patlen) ); strncpy(fr, rec, patbeg-rec); fr += patbeg - rec + 1; *(fr-1) = '\0'; rec = patbeg + patlen; } else { ! dprintf( ("no match %s\n", rec) ); strlcpy(fr, rec, fields + fieldssize - fr); pfa->initstat = tempstat; break; --- 446,461 ---- xfree(fldtab[i]->sval); fldtab[i]->tval = FLD | STR | DONTFREE; fldtab[i]->sval = fr; ! DPRINTF( ("refldbld: i=%d\n", i) ); if (nematch(pfa, rec)) { pfa->initstat = 2; /* horrible coupling to b.c */ ! DPRINTF( ("match %s (%d chars)\n", patbeg, patlen) ); strncpy(fr, rec, patbeg-rec); fr += patbeg - rec + 1; *(fr-1) = '\0'; rec = patbeg + patlen; } else { ! DPRINTF( ("no match %s\n", rec) ); strlcpy(fr, rec, fields + fieldssize - fr); pfa->initstat = tempstat; break; *************** *** 488,502 **** if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3")) FATAL("built giant record `%.30s...'", record); *r = '\0'; ! dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); if (freeable(fldtab[0])) xfree(fldtab[0]->sval); fldtab[0]->tval = REC | STR | DONTFREE; fldtab[0]->sval = record; ! dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); ! dprintf( ("recbld = |%s|\n", record) ); donerec = 1; } --- 488,502 ---- if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3")) FATAL("built giant record `%.30s...'", record); *r = '\0'; ! DPRINTF( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); if (freeable(fldtab[0])) xfree(fldtab[0]->sval); fldtab[0]->tval = REC | STR | DONTFREE; fldtab[0]->sval = record; ! DPRINTF( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); ! DPRINTF( ("recbld = |%s|\n", record) ); donerec = 1; }