diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2011-08-10 22:36:00 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2011-08-10 22:36:00 +0300 |
commit | b8c993f5a867f38fa9edd343d7d90b4b36800be2 (patch) | |
tree | 75d48551001252a7b78469634d5f5dc11b2a6754 /io.c | |
parent | 0d1a4f152fa45eda08b5877e4989c3250beb280e (diff) | |
download | egawk-b8c993f5a867f38fa9edd343d7d90b4b36800be2.tar.gz egawk-b8c993f5a867f38fa9edd343d7d90b4b36800be2.tar.bz2 egawk-b8c993f5a867f38fa9edd343d7d90b4b36800be2.zip |
BEGINFILE/ENDFILE code redone.
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 25 |
1 files changed, 9 insertions, 16 deletions
@@ -214,7 +214,6 @@ static Regexp *RS_re_no_case; static Regexp *RS_regexp; int RS_is_null; -int has_endfile = FALSE; extern int output_is_tty; extern NODE *ARGC_node; @@ -262,10 +261,6 @@ after_beginfile(IOBUF **curfile) iop = *curfile; assert(iop != NULL); -#if 0 - if (iop == NULL) - return; -#endif if (iop->fd == INVALID_HANDLE) { const char *fname; @@ -309,10 +304,13 @@ nextfile(IOBUF **curfile, int skipping) IOBUF *iop = *curfile; if (skipping) { /* for 'nextfile' call */ - if (iop != NULL) + errcode = 0; + if (iop != NULL) { + errcode = iop->errcode; (void) iop_close(iop); + } *curfile = NULL; - return 0; /* return value not used */ + return (errcode == 0); } if (iop != NULL) { @@ -409,28 +407,23 @@ set_NR() /* inrec --- This reads in a record from the input file */ int -inrec(IOBUF *iop) +inrec(IOBUF *iop, int *errcode) { char *begin; int cnt; int retval = 0; - int errcode = 0; if (at_eof(iop) && no_data_left(iop)) cnt = EOF; else if ((iop->flag & IOP_CLOSED) != 0) cnt = EOF; else - cnt = get_a_record(&begin, iop, & errcode); + cnt = get_a_record(&begin, iop, errcode); if (cnt == EOF) { retval = 1; - if (errcode > 0) { - update_ERRNO_saved(errcode); - if (do_traditional || ! has_endfile) - fatal(_("error reading input file `%s': %s"), - iop->name, strerror(errcode)); - } + if (*errcode > 0) + update_ERRNO_saved(*errcode); } else { NR += 1; FNR += 1; |