version 1.17, 2007/09/02 15:19:31 |
version 1.18, 2008/10/06 20:38:33 |
|
|
Cell **fldtab; /* pointers to Cells */ |
Cell **fldtab; /* pointers to Cells */ |
char inputFS[100] = " "; |
char inputFS[100] = " "; |
|
|
#define MAXFLD 200 |
#define MAXFLD 2 |
int nfields = MAXFLD; /* last allocated slot for $i */ |
int nfields = MAXFLD; /* last allocated slot for $i */ |
|
|
int donefld; /* 1 = implies rec broken into fields */ |
int donefld; /* 1 = implies rec broken into fields */ |
|
|
|
|
void recinit(unsigned int n) |
void recinit(unsigned int n) |
{ |
{ |
record = (char *) malloc(n); |
if ( (record = (char *) malloc(n)) == NULL |
fields = (char *) malloc(n); |
|| (fields = (char *) malloc(n+1)) == NULL |
fldtab = (Cell **) calloc((nfields+1), sizeof(Cell *)); |
|| (fldtab = (Cell **) calloc(nfields+1, sizeof(Cell *))) == NULL |
if (record == NULL || fields == NULL || fldtab == NULL) |
|| (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL ) |
FATAL("out of space for $0 and fields"); |
FATAL("out of space for $0 and fields"); |
|
|
fldtab[0] = (Cell *) malloc(sizeof (Cell)); |
|
if (fldtab[0] == NULL) |
|
FATAL("out of space for fields"); |
|
*fldtab[0] = dollar0; |
*fldtab[0] = dollar0; |
fldtab[0]->sval = record; |
fldtab[0]->sval = record; |
fldtab[0]->nval = tostring("0"); |
fldtab[0]->nval = tostring("0"); |
|
|
{ /* note: cares whether buf == record */ |
{ /* note: cares whether buf == record */ |
int c; |
int c; |
char *buf = *pbuf; |
char *buf = *pbuf; |
int bufsize = *pbufsize; |
uschar saveb0; |
|
int bufsize = *pbufsize, savebufsize = bufsize; |
|
|
if (firsttime) { |
if (firsttime) { |
firsttime = 0; |
firsttime = 0; |
|
|
donefld = 0; |
donefld = 0; |
donerec = 1; |
donerec = 1; |
} |
} |
|
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) ); |
|
|
infile = NULL; |
infile = NULL; |
argno++; |
argno++; |
} |
} |
|
buf[0] = saveb0; |
*pbuf = buf; |
*pbuf = buf; |
*pbufsize = bufsize; |
*pbufsize = savebufsize; |
return 0; /* true end of file */ |
return 0; /* true end of file */ |
} |
} |
|
|
void nextfile(void) |
void nextfile(void) |
{ |
{ |
if (infile != stdin && infile != NULL) |
if (infile != NULL && infile != stdin) |
fclose(infile); |
fclose(infile); |
infile = NULL; |
infile = NULL; |
argno++; |
argno++; |