version 1.23, 2017/09/25 17:36:35 |
version 1.24, 2017/10/09 14:51:31 |
|
|
firsttime = 0; |
firsttime = 0; |
initgetrec(); |
initgetrec(); |
} |
} |
dprintf( ("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n", |
DPRINTF( ("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n", |
*RS, *FS, *ARGC, *FILENAME) ); |
*RS, *FS, *ARGC, *FILENAME) ); |
if (isrecord) { |
if (isrecord) { |
donefld = 0; |
donefld = 0; |
|
|
saveb0 = buf[0]; |
saveb0 = buf[0]; |
buf[0] = 0; |
buf[0] = 0; |
while (argno < *ARGC || infile == stdin) { |
while (argno < *ARGC || infile == stdin) { |
dprintf( ("argno=%d, file=|%s|\n", argno, file) ); |
DPRINTF( ("argno=%d, file=|%s|\n", argno, file) ); |
if (infile == NULL) { /* have to open a new file */ |
if (infile == NULL) { /* have to open a new file */ |
file = getargv(argno); |
file = getargv(argno); |
if (file == NULL || *file == '\0') { /* deleted or zapped */ |
if (file == NULL || *file == '\0') { /* deleted or zapped */ |
|
|
continue; |
continue; |
} |
} |
*FILENAME = file; |
*FILENAME = file; |
dprintf( ("opening file %s\n", file) ); |
DPRINTF( ("opening file %s\n", file) ); |
if (*file == '-' && *(file+1) == '\0') |
if (*file == '-' && *(file+1) == '\0') |
infile = stdin; |
infile = stdin; |
else if ((infile = fopen(file, "r")) == NULL) |
else if ((infile = fopen(file, "r")) == NULL) |
|
|
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3")) |
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3")) |
FATAL("input record `%.30s...' too long", buf); |
FATAL("input record `%.30s...' too long", buf); |
*rr = 0; |
*rr = 0; |
dprintf( ("readrec saw <%s>, returns %d\n", buf, c == EOF && rr == buf ? 0 : 1) ); |
DPRINTF( ("readrec saw <%s>, returns %d\n", buf, c == EOF && rr == buf ? 0 : 1) ); |
*pbuf = buf; |
*pbuf = buf; |
*pbufsize = bufsize; |
*pbufsize = bufsize; |
return c == EOF && rr == buf ? 0 : 1; |
return c == EOF && rr == buf ? 0 : 1; |
|
|
return NULL; |
return NULL; |
x = setsymtab(temp, "", 0.0, STR, ARGVtab); |
x = setsymtab(temp, "", 0.0, STR, ARGVtab); |
s = getsval(x); |
s = getsval(x); |
dprintf( ("getargv(%d) returns |%s|\n", n, s) ); |
DPRINTF( ("getargv(%d) returns |%s|\n", n, s) ); |
return s; |
return s; |
} |
} |
|
|
|
|
q->fval = atof(q->sval); |
q->fval = atof(q->sval); |
q->tval |= NUM; |
q->tval |= NUM; |
} |
} |
dprintf( ("command line set %s to |%s|\n", s, p) ); |
DPRINTF( ("command line set %s to |%s|\n", s, p) ); |
} |
} |
|
|
|
|
|
|
if (*rec == '\0') |
if (*rec == '\0') |
return 0; |
return 0; |
pfa = makedfa(fs, 1); |
pfa = makedfa(fs, 1); |
dprintf( ("into refldbld, rec = <%s>, pat = <%s>\n", rec, fs) ); |
DPRINTF( ("into refldbld, rec = <%s>, pat = <%s>\n", rec, fs) ); |
tempstat = pfa->initstat; |
tempstat = pfa->initstat; |
for (i = 1; ; i++) { |
for (i = 1; ; i++) { |
if (i > nfields) |
if (i > nfields) |
|
|
xfree(fldtab[i]->sval); |
xfree(fldtab[i]->sval); |
fldtab[i]->tval = FLD | STR | DONTFREE; |
fldtab[i]->tval = FLD | STR | DONTFREE; |
fldtab[i]->sval = fr; |
fldtab[i]->sval = fr; |
dprintf( ("refldbld: i=%d\n", i) ); |
DPRINTF( ("refldbld: i=%d\n", i) ); |
if (nematch(pfa, rec)) { |
if (nematch(pfa, rec)) { |
pfa->initstat = 2; /* horrible coupling to b.c */ |
pfa->initstat = 2; /* horrible coupling to b.c */ |
dprintf( ("match %s (%d chars)\n", patbeg, patlen) ); |
DPRINTF( ("match %s (%d chars)\n", patbeg, patlen) ); |
strncpy(fr, rec, patbeg-rec); |
strncpy(fr, rec, patbeg-rec); |
fr += patbeg - rec + 1; |
fr += patbeg - rec + 1; |
*(fr-1) = '\0'; |
*(fr-1) = '\0'; |
rec = patbeg + patlen; |
rec = patbeg + patlen; |
} else { |
} else { |
dprintf( ("no match %s\n", rec) ); |
DPRINTF( ("no match %s\n", rec) ); |
strlcpy(fr, rec, fields + fieldssize - fr); |
strlcpy(fr, rec, fields + fieldssize - fr); |
pfa->initstat = tempstat; |
pfa->initstat = tempstat; |
break; |
break; |
|
|
if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3")) |
if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3")) |
FATAL("built giant record `%.30s...'", record); |
FATAL("built giant record `%.30s...'", record); |
*r = '\0'; |
*r = '\0'; |
dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); |
DPRINTF( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); |
|
|
if (freeable(fldtab[0])) |
if (freeable(fldtab[0])) |
xfree(fldtab[0]->sval); |
xfree(fldtab[0]->sval); |
fldtab[0]->tval = REC | STR | DONTFREE; |
fldtab[0]->tval = REC | STR | DONTFREE; |
fldtab[0]->sval = record; |
fldtab[0]->sval = record; |
|
|
dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); |
DPRINTF( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); |
dprintf( ("recbld = |%s|\n", record) ); |
DPRINTF( ("recbld = |%s|\n", record) ); |
donerec = 1; |
donerec = 1; |
} |
} |
|
|