From 560cf6d52f978e360e9b2a10f7ddd9a0197e0b31 Mon Sep 17 00:00:00 2001 From: John Malmberg Date: Tue, 9 Aug 2016 08:28:24 -0500 Subject: Update VMS tests --- vms/ChangeLog | 7 +++++- vms/vmstest.com | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 79 insertions(+), 6 deletions(-) diff --git a/vms/ChangeLog b/vms/ChangeLog index 3a018787..d9d7a4a7 100644 --- a/vms/ChangeLog +++ b/vms/ChangeLog @@ -1,8 +1,13 @@ +2016-08-08 John E. Malmberg + + * vmstest.com: New test (basic) ofmtstrnum + New test (extra) ignrcas3 - skipped. + Updated test (shlib) filefuncs, backsmalls1 + 2016-06-16 John E. Malmberg * vmstest.com: New tests (basic) hex2, mixed1, subback - 2016-05-30 John E. Malmberg * vmstest.com: New tests (basic) fsnul1 diff --git a/vms/vmstest.com b/vms/vmstest.com index 93e5a149..aa96ceba 100644 --- a/vms/vmstest.com +++ b/vms/vmstest.com @@ -50,8 +50,11 @@ $! $! 4.1.3.g: New tests $! basic: fsnul1, hex2, mixed1, subback $! ext: fpat4, symtab10 -$ -$ +$! +$! 4.1.3.i: New tests +$! basic: ofmtstrnum +$! extra: ignrcas3 +$! $ echo = "write sys$output" $ cmp = "diff/Output=_NL:/Maximum=1" $ delsym = "delete/symbol/local/nolog" @@ -302,7 +305,7 @@ $ gosub list_of_tests $ return $ $extra: echo "extra..." -$ list = "regtest inftest inet" +$ list = "regtest inftest inet ignrcas3" $ gosub list_of_tests $ return $ @@ -563,6 +566,7 @@ $negrange: $nulinsrc: $nlstrina: $octsub: +$ofmtstrnum: $paramtyp: $paramuninitglobal: $pcntplus: @@ -1614,7 +1618,23 @@ $ gosub junit_report_fail_diff $ endif $ set On $ return -$ +$! +$ignrcas3: echo "''test'" +$ test_class = "extra" +$ if f$search("sys$i18n_locale:el_gr_iso8859-7.locale") .nes. "" +$ then +$ define/user LC_ALL "el_gr_iso8859-7" +$ define/user GAWKLOCALE "el_gr_iso8859-7" + AWKPATH_srcdir +$! goto common_without_test_in +$ skip_reason = "VMS EL_GR_ISO8859-7 locale fails test" +$ gosub junit_report_skip +$ else +$ skip_reason = "EL_GR_ISO8859-7 locale not installed" +$ gosub junit_report_skip +$ endif +$ return +$! $childin: echo "''test'" $ test_class = "basic" $ cat = "type sys$input" @@ -2712,6 +2732,10 @@ $ else $ echo "''test'" $ endif $ gawk -f 'test'.awk 'test'.in >_'test'.tmp +$ if f$search("sys$disk:[]_''test'.tmp;2") .nes. "" +$ then +$ delete sys$disk:[]_'test'.tmp;2 +$ endif $ cmp 'test'.ok sys$disk:[]_'test'.tmp $ if $status $ then @@ -3794,10 +3818,31 @@ $ endif $ return $! $filefuncs: +$ echo "''test'" +$ test_class = "shlib" +$ filefunc_file = "[-]gawkapi.o" +$ open/write gapi 'filefunc_file' +$ close gapi +$ set noOn +$ AWKLIBPATH_dir +$ gawk -v builddir="sys$disk:[-]" - + -f 'test'.awk 'test'.in >_'test'.tmp 2>&1 +$ if .not. $status then call exit_code '$status' _'test'.tmp +$ set On +$ cmp 'test'.ok sys$disk:[]_'test'.tmp +$ if $status +$ then +$ rm _'test'.tmp; +$ gosub junit_report_pass +$ else +$ gosub junit_report_fail_diff +$ endif +$ if f$search(filefunc_file) .nes. "" then rm 'filefunc_file';* +$ return +$! $fnmatch: $functab4: $ordchr: -$ordchr2: $revout: $revtwoway: $time: @@ -3822,6 +3867,29 @@ $ endif $ if f$search(filefunc_file) .nes. "" then rm 'filefunc_file';* $ return $! +$ordchr2: +$ echo "''test'" +$ test_class = "shlib" +$ filefunc_file = "[-]gawkapi.o" +$ open/write gapi 'filefunc_file' +$ close gapi +$ set noOn +$ AWKLIBPATH_dir +$ gawk --load ordchr "BEGIN {print chr(ord(""z""))}" > _'test'.tmp 2>&1 +$ if .not. $status then call exit_code '$status' _'test'.tmp +$ set On +$ cmp 'test'.ok sys$disk:[]_'test'.tmp +$ if $status +$ then +$ rm _'test'.tmp; +$ gosub junit_report_pass +$ else +$ gosub junit_report_fail_diff +$ endif +$ if f$search(filefunc_file) .nes. "" then rm 'filefunc_file';* +$ return +$ +$! $rwarray: $ echo "''test'" $ test_class = "shlib" -- cgit v1.2.3 From 3cf67f58ce8e42f9ce8d7be45936eedf79751b46 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 9 Aug 2016 11:33:27 -0400 Subject: If a strnum integer has a non-standard string representation, do not accept it as an integer array subscript. --- ChangeLog | 12 +++++++++++ awk.h | 8 +++++++ int_array.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 85 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ac5be64..c3da0195 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2016-08-09 Andrew J. Schorr + + * awk.h: Add a comment explaining the NUMINT flag in more detail. + * int_array.c (standard_integer_string): New function to test whether + a string matches what would be produced by sprintf("%ld", ). + (is_integer): Fix bug -- if NUMBER was set, then the function was + accepting strnum values with nonstandard string representations. We + now call standard_integer_string to check that the string looks OK. + Also added ifdef'ed code to simplify the function by relying upon + force_number to parse the string, but this is disabled due to possible + negative performance impact. + 2016-08-01 Arnold D. Robbins * README, NEWS: Mark DJGPP port as unsupported. diff --git a/awk.h b/awk.h index 7288e20f..ff622898 100644 --- a/awk.h +++ b/awk.h @@ -420,6 +420,14 @@ typedef struct exp_node { * and add WSTRCUR to the flags so that we don't have to do the * conversion more than once. * + * The NUMINT flag may be used with a value of any type -- NUMBER, + * STRING, or STRNUM. It indicates that the string representation + * equals the result of sprintf("%ld", ). So, for + * example, NUMINT should NOT be set if it's a strnum or string value + * where the string is " 1" or "01" or "+1" or "1.0" or "0.1E1". This + * is a hint to indicate that an integer array optimization may be + * used when this value appears as a subscript. + * * We hope that the rest of the flags are self-explanatory. :-) */ # define STRING 0x0002 /* assigned as string */ diff --git a/int_array.c b/int_array.c index a8de3d55..1fa32bd7 100644 --- a/int_array.c +++ b/int_array.c @@ -78,27 +78,86 @@ int_array_init(NODE *symbol, NODE *subs ATTRIBUTE_UNUSED) return & success_node; } +/* + * standard_integer_string -- check whether the string matches what + * sprintf("%ld", ) would produce. This is accomplished by accepting + * only strings that look like /^0$/ or /^-?[1-9][0-9]*$/. This should be + * faster than comparing vs. the results of actually calling sprintf. + */ + +static bool +standard_integer_string(const char *s, size_t len) +{ + const char *end; + + if (len == 0) + return false; + if (*s == '0' && len == 1) + return true; + end = s + len; + /* ignore leading minus sign */ + if (*s == '-' && ++s == end) + return false; + /* check first char is [1-9] */ + if (*s < '1' || *s > '9') + return false; + while (++s < end) { + if (*s < '0' || *s > '9') + return false; + } + return true; +} + /* is_integer --- check if subscript is an integer */ NODE ** is_integer(NODE *symbol, NODE *subs) { +#ifndef CHECK_INTEGER_USING_FORCE_NUMBER long l; +#endif AWKNUM d; + if ((subs->flags & NUMINT) != 0) + /* quick exit */ + return & success_node; + if (subs == Nnull_string || do_mpfr) return NULL; - if ((subs->flags & NUMINT) != 0) - return & success_node; +#ifdef CHECK_INTEGER_USING_FORCE_NUMBER + /* + * This approach is much simpler, because we remove all of the strtol + * logic below. But this may be slower in some usage cases. + */ + if ((subs->flags & NUMCUR) == 0) { + str2number(subs); - if ((subs->flags & NUMBER) != 0) { + /* check again in case force_number set NUMINT */ + if ((subs->flags & NUMINT) != 0) + return & success_node; + } +#else /* CHECK_INTEGER_USING_FORCE_NUMBER */ + if ((subs->flags & NUMCUR) != 0) { +#endif /* CHECK_INTEGER_USING_FORCE_NUMBER */ d = subs->numbr; if (d <= INT32_MAX && d >= INT32_MIN && d == (int32_t) d) { - subs->flags |= NUMINT; - return & success_node; + /* + * the numeric value is an integer, but we must + * protect against strings that cannot be generated + * from sprintf("%ld", ). This can happen + * with strnum or string values. We could skip this + * check for pure NUMBER values, but unfortunately the + * code does not currently distinguish between NUMBER + * and strnum values. + */ + if ((subs->flags & STRCUR) == 0 || standard_integer_string(subs->stptr, subs->stlen)) { + subs->flags |= NUMINT; + return & success_node; + } } return NULL; +#ifndef CHECK_INTEGER_USING_FORCE_NUMBER } /* a[3]=1; print "3" in a -- true @@ -151,6 +210,7 @@ is_integer(NODE *symbol, NODE *subs) } } return NULL; +#endif /* CHECK_INTEGER_USING_FORCE_NUMBER */ } -- cgit v1.2.3 From 1c972b5c234fb031f62356706cd8c0336312833d Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 12 Aug 2016 07:10:49 +0300 Subject: Sync dfa.c with GNU grep. --- ChangeLog | 4 ++++ dfa.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index c3da0195..efdbad2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-08-12 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + 2016-08-09 Andrew J. Schorr * awk.h: Add a comment explaining the NUMINT flag in more detail. diff --git a/dfa.c b/dfa.c index fcc0dd49..07d87dbc 100644 --- a/dfa.c +++ b/dfa.c @@ -3405,6 +3405,7 @@ dfaoptimize (struct dfa *d) free_mbdata (d); d->multibyte = false; d->dfaexec = dfaexec_sb; + d->fast = true; } static void -- cgit v1.2.3 From dcb6d54b3c272a7c8f0efadb7fad215e39248cad Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 12 Aug 2016 07:11:23 +0300 Subject: Minor text and formatting edits in int_array.c. --- ChangeLog | 4 ++++ int_array.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index efdbad2a..f218714f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ * dfa.c: Sync with GNU grep. + Unrelated: + + * int_array.c: Minor text and formatting edits. + 2016-08-09 Andrew J. Schorr * awk.h: Add a comment explaining the NUMINT flag in more detail. diff --git a/int_array.c b/int_array.c index 1fa32bd7..6cffec86 100644 --- a/int_array.c +++ b/int_array.c @@ -143,7 +143,7 @@ is_integer(NODE *symbol, NODE *subs) d = subs->numbr; if (d <= INT32_MAX && d >= INT32_MIN && d == (int32_t) d) { /* - * the numeric value is an integer, but we must + * The numeric value is an integer, but we must * protect against strings that cannot be generated * from sprintf("%ld", ). This can happen * with strnum or string values. We could skip this @@ -151,7 +151,8 @@ is_integer(NODE *symbol, NODE *subs) * code does not currently distinguish between NUMBER * and strnum values. */ - if ((subs->flags & STRCUR) == 0 || standard_integer_string(subs->stptr, subs->stlen)) { + if ( (subs->flags & STRCUR) == 0 + || standard_integer_string(subs->stptr, subs->stlen)) { subs->flags |= NUMINT; return & success_node; } -- cgit v1.2.3 From 1e83ff34fa8a4a80e486169f24519864480320f4 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 12 Aug 2016 11:46:37 +0300 Subject: Minor updates to Checklist. --- Checklist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Checklist b/Checklist index 6c26a4da..b33fac65 100644 --- a/Checklist +++ b/Checklist @@ -1,4 +1,4 @@ -Tue May 5 12:37:45 IDT 2015 +Fri Aug 12 11:39:43 IDT 2016 ============================ A checklist for making releases @@ -39,7 +39,7 @@ Testing on make maintainer-clean make release - compile with tcc + compile with pcc compile with clang compile 32 bit tests - clang and gcc -- cgit v1.2.3