aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--awk.h2
-rw-r--r--interpret.h2
-rw-r--r--io.c10
-rw-r--r--main.c2
-rw-r--r--test/ChangeLog4
-rw-r--r--test/badargs.ok2
7 files changed, 30 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 3fb8bb98..aaa09f3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2014-07-24 Arnold D. Robbins <arnold@skeeve.com>
+
+ * main.c (usage): Put text for `-n' *after* text for `-m'.
+ Report from Robert P. J. Day <rpjday@crashcourse.ca>.
+
+ Fix problems with I/O errors reported by Assaf Gordon
+ <assafgordon@gmail.com>:
+
+ * io.c (inrec): Change type to bool to make calling easier. Add
+ check in non-EOF case for error, and if so, return false.
+ Update ERRNO in case there is an ENDFILE block.
+ * awk.h (inrec): Change type in declaration.
+ * interpret.h (r_interpret): Change call of inrec() to boolean
+ notation.
+
2014-07-10 Arnold D. Robbins <arnold@skeeve.com>
New `div()' function to do integer division and remainder;
diff --git a/awk.h b/awk.h
index cb9f8091..dd5bbe04 100644
--- a/awk.h
+++ b/awk.h
@@ -1533,7 +1533,7 @@ extern char *find_source(const char *src, struct stat *stb, int *errcode, int is
extern NODE *do_getline_redir(int intovar, enum redirval redirtype);
extern NODE *do_getline(int intovar, IOBUF *iop);
extern struct redirect *getredirect(const char *str, int len);
-extern int inrec(IOBUF *iop, int *errcode);
+extern bool inrec(IOBUF *iop, int *errcode);
extern int nextfile(IOBUF **curfile, bool skipping);
/* main.c */
extern int arg_assign(char *arg, bool initing);
diff --git a/interpret.h b/interpret.h
index 27f194ae..ff9ba768 100644
--- a/interpret.h
+++ b/interpret.h
@@ -1191,7 +1191,7 @@ match_re:
JUMPTO(ni);
}
- if (inrec(curfile, & errcode) != 0) {
+ if (! inrec(curfile, & errcode)) {
if (errcode > 0 && (do_traditional || ! pc->has_endfile))
fatal(_("error reading input file `%s': %s"),
curfile->public.name, strerror(errcode));
diff --git a/io.c b/io.c
index 57d4af22..45b5015f 100644
--- a/io.c
+++ b/io.c
@@ -574,12 +574,12 @@ set_NR()
/* inrec --- This reads in a record from the input file */
-int
+bool
inrec(IOBUF *iop, int *errcode)
{
char *begin;
int cnt;
- int retval = 0;
+ bool retval = true;
if (at_eof(iop) && no_data_left(iop))
cnt = EOF;
@@ -589,13 +589,17 @@ inrec(IOBUF *iop, int *errcode)
cnt = get_a_record(& begin, iop, errcode);
if (cnt == EOF) {
- retval = 1;
+ retval = false;
if (*errcode > 0)
update_ERRNO_int(*errcode);
} else {
INCREMENT_REC(NR);
INCREMENT_REC(FNR);
set_record(begin, cnt);
+ if (*errcode > 0) {
+ update_ERRNO_int(*errcode);
+ retval = false;
+ }
}
return retval;
diff --git a/main.c b/main.c
index 901bfea5..a7ff5f5d 100644
--- a/main.c
+++ b/main.c
@@ -819,9 +819,9 @@ usage(int exitval, FILE *fp)
fputs(_("\t-i includefile\t\t--include=includefile\n"), fp);
fputs(_("\t-l library\t\t--load=library\n"), fp);
fputs(_("\t-L [fatal]\t\t--lint[=fatal]\n"), fp);
- fputs(_("\t-n\t\t\t--non-decimal-data\n"), fp);
fputs(_("\t-M\t\t\t--bignum\n"), fp);
fputs(_("\t-N\t\t\t--use-lc-numeric\n"), fp);
+ fputs(_("\t-n\t\t\t--non-decimal-data\n"), fp);
fputs(_("\t-o[file]\t\t--pretty-print[=file]\n"), fp);
fputs(_("\t-O\t\t\t--optimize\n"), fp);
fputs(_("\t-p[file]\t\t--profile[=file]\n"), fp);
diff --git a/test/ChangeLog b/test/ChangeLog
index cc921277..79e2d538 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2014-07-24 Arnold D. Robbins <arnold@skeeve.com>
+
+ * badargs.ok: Adjust after correctly alphabetizing options.
+
2014-07-10 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (printhuge): New test.
diff --git a/test/badargs.ok b/test/badargs.ok
index 1be81ec3..8d34be1f 100644
--- a/test/badargs.ok
+++ b/test/badargs.ok
@@ -18,9 +18,9 @@ Short options: GNU long options: (extensions)
-i includefile --include=includefile
-l library --load=library
-L [fatal] --lint[=fatal]
- -n --non-decimal-data
-M --bignum
-N --use-lc-numeric
+ -n --non-decimal-data
-o[file] --pretty-print[=file]
-O --optimize
-p[file] --profile[=file]