diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-08-12 11:55:37 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-08-12 11:55:37 +0300 |
commit | 06d8f4cf720f5399ae32828de8182b34459df664 (patch) | |
tree | 330da19c46a732601ea93ca0689ca67c330d2459 | |
parent | c4dee818eaee376cd19cb56d69d066e29c6eee2b (diff) | |
parent | 5ce09ba3867f5c9d3c3dc0c00c155c0ba0c224f6 (diff) | |
download | egawk-06d8f4cf720f5399ae32828de8182b34459df664.tar.gz egawk-06d8f4cf720f5399ae32828de8182b34459df664.tar.bz2 egawk-06d8f4cf720f5399ae32828de8182b34459df664.zip |
Merge branch 'master' into feature/nocopy
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | Checklist | 4 | ||||
-rw-r--r-- | awk.h | 8 | ||||
-rw-r--r-- | dfa.c | 1 | ||||
-rw-r--r-- | int_array.c | 70 | ||||
-rw-r--r-- | vms/ChangeLog | 7 | ||||
-rw-r--r-- | vms/vmstest.com | 78 |
7 files changed, 177 insertions, 11 deletions
@@ -1,3 +1,23 @@ +2016-08-12 Arnold D. Robbins <arnold@skeeve.com> + + * dfa.c: Sync with GNU grep. + + Unrelated: + + * int_array.c: Minor text and formatting edits. + +2016-08-09 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * 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", <value>). + (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-03 Arnold D. Robbins <arnold@skeeve.com> Remove typed regexes until they can be done properly. @@ -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 @@ -422,6 +422,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", <numeric value>). 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 MALLOC 0x0001 /* stptr can be free'd, i.e. not a field node pointing into a shared buffer */ @@ -3392,6 +3392,7 @@ dfaoptimize (struct dfa *d) free_mbdata (d); d->multibyte = false; d->dfaexec = dfaexec_sb; + d->fast = true; } static void diff --git a/int_array.c b/int_array.c index 9981fafe..e52bb40e 100644 --- a/int_array.c +++ b/int_array.c @@ -78,14 +78,50 @@ int_array_init(NODE *symbol, NODE *subs ATTRIBUTE_UNUSED) return & success_node; } +/* + * standard_integer_string -- check whether the string matches what + * sprintf("%ld", <value>) 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; @@ -111,13 +147,40 @@ is_integer(NODE *symbol, NODE *subs) if ((subs->flags & NUMINT) != 0) return & success_node; - if ((subs->flags & NUMBER) != 0) { +#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); + + /* 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", <subscript>). 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 @@ -174,6 +237,7 @@ is_integer(NODE *symbol, NODE *subs) } return NULL; +#endif /* CHECK_INTEGER_USING_FORCE_NUMBER */ } diff --git a/vms/ChangeLog b/vms/ChangeLog index 510f61cd..73b30a9a 100644 --- a/vms/ChangeLog +++ b/vms/ChangeLog @@ -1,8 +1,13 @@ +2016-08-08 John E. Malmberg <wb8tyw@qsl.net> + + * vmstest.com: New test (basic) ofmtstrnum + New test (extra) ignrcas3 - skipped. + Updated test (shlib) filefuncs, backsmalls1 + 2016-06-16 John E. Malmberg <wb8tyw@qsl.net> * vmstest.com: New tests (basic) hex2, mixed1, subback - 2016-05-30 John E. Malmberg <wb8tyw@qsl.net> * 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" |