[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2565-g21f459
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2565-g21f4591 |
Date: |
Tue, 23 May 2017 15:11:43 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, master has been updated
via 21f45911879abbaf5933c65df1beac8399b30038 (commit)
from 6d75aa092bf1e04201c8bfa1c2ce88ca22422a00 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=21f45911879abbaf5933c65df1beac8399b30038
commit 21f45911879abbaf5933c65df1beac8399b30038
Author: Arnold D. Robbins <address@hidden>
Date: Tue May 23 22:11:15 2017 +0300
Additional robustness in FIELDWIDTHS parsing.
diff --git a/ChangeLog b/ChangeLog
index b03e05b..2072972 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-23 Andrew J. Schorr <address@hidden>
+
+ * field.c (set_FIELDWIDTHS): Simplify the logic and consistentify
+ use of UINT_MAX. Make sure that negative value after : is caught.
+
2017-05-23 Arnold D. Robbins <address@hidden>
* field.c (fw_parse_field): Stop upon hitting the end of the
diff --git a/field.c b/field.c
index de1bae5..54055ad 100644
--- a/field.c
+++ b/field.c
@@ -1175,39 +1175,39 @@ set_FIELDWIDTHS()
/*
* Detect an invalid base-10 integer, a valid value that
* is followed by something other than a blank or '\0',
- * or a value that is not in the range [1..INT_MAX].
+ * or a value that is not in the range [1..UINT_MAX].
*/
errno = 0;
tmp = strtoul(scan, &end, 10);
if (errno == 0 && *end == ':' && (0 < tmp && tmp <= UINT_MAX)) {
FIELDWIDTHS->fields[i].skip = tmp;
scan = end + 1;
- if (*scan == '*')
- goto got_star;
+ if (*scan == '-') {
+ fatal_error = true;
+ break;
+ }
// try scanning for field width
tmp = strtoul(scan, &end, 10);
}
else
FIELDWIDTHS->fields[i].skip = 0;
- if (*scan == '*') {
- got_star:
- for (scan++; is_blank(*scan); scan++)
- continue;
-
- if (*scan != '\0')
- fatal(_("`*' must be the last designator in
FIELDWIDTHS"));
-
- FIELDWIDTHS->fields[i].len = UINT_MAX;
- FIELDWIDTHS->nf = i+1;
- break;
- }
-
if (errno != 0
|| (*end != '\0' && ! is_blank(*end))
- || !(0 < tmp && tmp <= INT_MAX)
+ || !(0 < tmp && tmp <= UINT_MAX)
) {
- fatal_error = true;
+ if (*scan == '*') {
+ for (scan++; is_blank(*scan); scan++)
+ continue;
+
+ if (*scan != '\0')
+ fatal(_("`*' must be the last
designator in FIELDWIDTHS"));
+
+ FIELDWIDTHS->fields[i].len = UINT_MAX;
+ FIELDWIDTHS->nf = i+1;
+ }
+ else
+ fatal_error = true;
break;
}
FIELDWIDTHS->fields[i].len = tmp;
diff --git a/test/ChangeLog b/test/ChangeLog
index 4b929c6..aef9822 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,8 +1,9 @@
2017-05-23 Arnold D. Robbins <address@hidden>
- * Makefile.am (fwtest5, fwtest6): New tests.
+ * Makefile.am (fwtest5, fwtest6, fwtest7, fwtest8): New tests.
* fwtest5.awk, fwtest5.in, fwtest5.ok, fwtest6.awk, fwtest6.in,
- fwtest6.ok, fwtest7.awk, fwtest7.in, fwtest7.ok: New files.
+ fwtest6.ok, fwtest7.awk, fwtest7.in, fwtest7.ok, fwtest8.awk,
+ fwtest8.in, fwtest8.ok: New files.
2017-05-20 Arnold D. Robbins <address@hidden>
diff --git a/test/Makefile.am b/test/Makefile.am
index dd5f236..443580b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -402,6 +402,9 @@ EXTRA_DIST = \
fwtest7.awk \
fwtest7.in \
fwtest7.ok \
+ fwtest8.awk \
+ fwtest8.in \
+ fwtest8.ok \
genpot.awk \
genpot.ok \
gensub.awk \
@@ -1242,7 +1245,7 @@ GAWK_EXT_TESTS = \
devfd devfd1 devfd2 dumpvars errno exit \
fieldwdth forcenum fpat1 fpat2 fpat3 fpat4 fpat5 fpat6 fpatnull \
fsfwfs funlen functab1 functab2 functab3 \
- fwtest fwtest2 fwtest3 fwtest4 fwtest5 fwtest6 fwtest7 \
+ fwtest fwtest2 fwtest3 fwtest4 fwtest5 fwtest6 fwtest7 fwtest8 \
genpot gensub gensub2 gensub3 getlndir gnuops2 gnuops3 gnureops gsubind
\
icasefs icasers id igncdym igncfs ignrcas2 ignrcas4 ignrcase \
incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 9d27170..e3fe9cb 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -660,6 +660,9 @@ EXTRA_DIST = \
fwtest7.awk \
fwtest7.in \
fwtest7.ok \
+ fwtest8.awk \
+ fwtest8.in \
+ fwtest8.ok \
genpot.awk \
genpot.ok \
gensub.awk \
@@ -1499,7 +1502,7 @@ GAWK_EXT_TESTS = \
devfd devfd1 devfd2 dumpvars errno exit \
fieldwdth forcenum fpat1 fpat2 fpat3 fpat4 fpat5 fpat6 fpatnull \
fsfwfs funlen functab1 functab2 functab3 \
- fwtest fwtest2 fwtest3 fwtest4 fwtest5 fwtest6 fwtest7 \
+ fwtest fwtest2 fwtest3 fwtest4 fwtest5 fwtest6 fwtest7 fwtest8 \
genpot gensub gensub2 gensub3 getlndir gnuops2 gnuops3 gnureops gsubind
\
icasefs icasers id igncdym igncfs ignrcas2 ignrcas4 ignrcase \
incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \
@@ -4050,6 +4053,11 @@ fwtest7:
@AWKPATH="$(srcdir)" $(AWK) -f address@hidden <
"$(srcdir)"/address@hidden >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+fwtest8:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f address@hidden <
"$(srcdir)"/address@hidden >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+
gensub:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f address@hidden <
"$(srcdir)"/address@hidden >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 20b659e..f8c54f9 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1207,6 +1207,11 @@ fwtest7:
@AWKPATH="$(srcdir)" $(AWK) -f address@hidden <
"$(srcdir)"/address@hidden >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+fwtest8:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f address@hidden <
"$(srcdir)"/address@hidden >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+
gensub:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f address@hidden <
"$(srcdir)"/address@hidden >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/fwtest8.awk b/test/fwtest8.awk
new file mode 100644
index 0000000..27cbff4
--- /dev/null
+++ b/test/fwtest8.awk
@@ -0,0 +1,2 @@
+BEGIN { FIELDWIDTHS = "2:1 3:-1 4" }
+{ print $2 }
diff --git a/test/fwtest8.in b/test/fwtest8.in
new file mode 100644
index 0000000..b378a01
--- /dev/null
+++ b/test/fwtest8.in
@@ -0,0 +1 @@
+ssAsssBCCCC
diff --git a/test/fwtest8.ok b/test/fwtest8.ok
new file mode 100644
index 0000000..8a685a8
--- /dev/null
+++ b/test/fwtest8.ok
@@ -0,0 +1,2 @@
+gawk: fwtest8.awk:1: fatal: invalid FIELDWIDTHS value, for field 1, near `-1 4'
+EXIT CODE: 2
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 5 +++++
field.c | 36 ++++++++++++++++++------------------
test/ChangeLog | 5 +++--
test/Makefile.am | 5 ++++-
test/Makefile.in | 10 +++++++++-
test/Maketests | 5 +++++
test/fwtest8.awk | 2 ++
test/fwtest8.in | 1 +
test/fwtest8.ok | 2 ++
9 files changed, 49 insertions(+), 22 deletions(-)
create mode 100644 test/fwtest8.awk
create mode 100644 test/fwtest8.in
create mode 100644 test/fwtest8.ok
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2565-g21f4591,
Arnold Robbins <=