gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, gawk-4.2-stable, updated. gawk-4.1.0-305


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.2-stable, updated. gawk-4.1.0-3054-gc25c88f
Date: Wed, 26 Sep 2018 09:26:44 -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, gawk-4.2-stable has been updated
       via  c25c88f583c984112055fa091d357c1b8538d5d8 (commit)
      from  26b1a15e75cc1d134e8b52b0df9a5d1365e66d8f (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=c25c88f583c984112055fa091d357c1b8538d5d8

commit c25c88f583c984112055fa091d357c1b8538d5d8
Author: Arnold D. Robbins <address@hidden>
Date:   Wed Sep 26 16:26:25 2018 +0300

    Add more lint warnings.

diff --git a/ChangeLog b/ChangeLog
index b614358..358962d 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2018-09-26         Arnold D. Robbins     <address@hidden>
+
+       Add more lint checks.
+
+       * awk.h (POP_ARRAY): Add boolean parameter to check for untyped
+       value and include lint warning.
+       * interpret.h (r_interpret): Adjust all calls to POP_ARRAY.
+       * field.c (do_split): Improve lint warning text for empty
+       third argument.
+       * re.c (make_regexp): Add lint check for '\0' in contents of
+       regexp to be matched (dynamic or otherwise).
+
 2018-09-23         Steven Packard        <address@hidden>
 
        * awk.h: Add `#if !defined(__SUNPRO_C)' around check for non-ANSI
diff --git a/awk.h b/awk.h
index 4de6cfc..e3f458b 100644
--- a/awk.h
+++ b/awk.h
@@ -1771,9 +1771,15 @@ extern uintmax_t adjust_uint(uintmax_t n);
 /* POP_ARRAY --- get the array at the top of the stack */
 
 static inline NODE *
-POP_ARRAY()
+POP_ARRAY(bool check_for_untyped)
 {
        NODE *t = POP();
+       static bool warned = false;
+
+       if (do_lint && ! warned && check_for_untyped && t->type == 
Node_var_new) {
+               warned = true;
+               lintwarn(_("behavior of `for' loop on untyped variable is not 
defined by POSIX"));
+       }
 
        return (t->type == Node_var_array) ? t : force_array(t, true);
 }
diff --git a/field.c b/field.c
index 2f6eff7..ccf47df 100644
--- a/field.c
+++ b/field.c
@@ -1038,7 +1038,7 @@ do_split(int nargs)
 
                        if (do_lint && ! warned) {
                                warned = true;
-                               lintwarn(_("split: null string for third arg is 
a gawk extension"));
+                               lintwarn(_("split: null string for third arg is 
a non-standard extension"));
                        }
                } else if (fs->stlen == 1 && (sep->re_flags & CONSTANT) == 0) {
                        if (fs->stptr[0] == ' ') {
diff --git a/interpret.h b/interpret.h
index fed0078..4381a92 100644
--- a/interpret.h
+++ b/interpret.h
@@ -248,7 +248,7 @@ uninitialized_scalar:
 
                case Op_subscript:
                        t2 = mk_sub(pc->sub_count);
-                       t1 = POP_ARRAY();
+                       t1 = POP_ARRAY(false);
 
                        if (do_lint && in_array(t1, t2) == NULL) {
                                t2 = force_string(t2);
@@ -295,7 +295,7 @@ uninitialized_scalar:
 
                case Op_sub_array:
                        t2 = mk_sub(pc->sub_count);
-                       t1 = POP_ARRAY();
+                       t1 = POP_ARRAY(false);
                        r = in_array(t1, t2);
                        if (r == NULL) {
                                r = make_array();
@@ -321,7 +321,7 @@ uninitialized_scalar:
 
                case Op_subscript_lhs:
                        t2 = mk_sub(pc->sub_count);
-                       t1 = POP_ARRAY();
+                       t1 = POP_ARRAY(false);
                        if (do_lint && in_array(t1, t2) == NULL) {
                                t2 = force_string(t2);
                                if (pc->do_reference)
@@ -884,19 +884,19 @@ mod:
                        break;
 
                case Op_K_delete:
-                       t1 = POP_ARRAY();
+                       t1 = POP_ARRAY(false);
                        do_delete(t1, pc->expr_count);
                        stack_adj(-pc->expr_count);
                        break;
 
                case Op_K_delete_loop:
-                       t1 = POP_ARRAY();
+                       t1 = POP_ARRAY(false);
                        lhs = POP_ADDRESS();    /* item */
                        do_delete_loop(t1, lhs);
                        break;
 
                case Op_in_array:
-                       t1 = POP_ARRAY();
+                       t1 = POP_ARRAY(false);
                        t2 = mk_sub(pc->expr_count);
                        r = node_Boolean[(in_array(t1, t2) != NULL)];
                        DEREF(t2);
@@ -915,7 +915,7 @@ mod:
                        bool saved_end = false;
 
                        /* get the array */
-                       array = POP_ARRAY();
+                       array = POP_ARRAY(true);
 
                        /* sanity: check if empty */
                        num_elems = assoc_length(array);
diff --git a/re.c b/re.c
index a693a9a..d772400 100644
--- a/re.c
+++ b/re.c
@@ -51,6 +51,12 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool 
dfa, bool canfatal)
        static bool no_dfa = false;
        int i;
        static struct dfa* dfaregs[2] = { NULL, NULL };
+       static bool nul_warned = false;
+
+       if (do_lint && ! nul_warned && memchr(s, '\0', len) != NULL) {
+               nul_warned = true;
+               lintwarn(_("behavior of matching a regexp containing NUL 
characters is not defined by POSIX"));
+       }
 
        /*
         * The number of bytes in the current multibyte character.
@@ -148,6 +154,12 @@ make_regexp(const char *s, size_t len, bool ignorecase, 
bool dfa, bool canfatal)
                                    && strchr("()|*+?.^$\\[]", c2) != NULL)
                                        *dest++ = '\\';
                                *dest++ = (char) c2;
+                               if (do_lint
+                                   && ! nul_warned
+                                   && c2 == '\0') {
+                                       nul_warned = true;
+                                       lintwarn(_("behavior of matching a 
regexp containing NUL characters is not defined by POSIX"));
+                               }
                                break;
                        case '8':
                        case '9':       /* a\9b not valid */

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog   | 12 ++++++++++++
 awk.h       |  8 +++++++-
 field.c     |  2 +-
 interpret.h | 14 +++++++-------
 re.c        | 12 ++++++++++++
 5 files changed, 39 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]