gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, feature/mdim-restart, updated. gawk-4.1.0-4696-g3ef91


From: Arnold Robbins
Subject: [SCM] gawk branch, feature/mdim-restart, updated. gawk-4.1.0-4696-g3ef91f55
Date: Fri, 1 Apr 2022 07:20:34 -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, feature/mdim-restart has been updated
       via  3ef91f5586feb1fa9e20cb3c2f1359a465ec8db9 (commit)
       via  56242fa8c66f43ae23b9f47b1e225a6692515f1b (commit)
      from  8b41863cd58085a86acf31e131e60233e9b3a4f2 (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=3ef91f5586feb1fa9e20cb3c2f1359a465ec8db9

commit 3ef91f5586feb1fa9e20cb3c2f1359a465ec8db9
Merge: 56242fa8 8b41863c
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Fri Apr 1 14:20:09 2022 +0300

    Merge branch 'feature/mdim-restart' of ssh://git.sv.gnu.org/srv/git/gawk 
into feature/mdim-restart


http://git.sv.gnu.org/cgit/gawk.git/commit/?id=56242fa8c66f43ae23b9f47b1e225a6692515f1b

commit 56242fa8c66f43ae23b9f47b1e225a6692515f1b
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Fri Apr 1 14:18:53 2022 +0300

    Additional cleanups.

diff --git a/ChangeLog b/ChangeLog
index 71134b54..5232ce5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2022-03-31         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * array.c (new_array_element): Make a full null string instead of
+       an empty node; it can be more easily converted to scalar that way.
+       * awk.h (force_string_fmt): Change the node type, remove NUMBER flag,
+       set STFMT_UNUSED.
+       * cint_array.c (lear_clear): Remove check for not equal Node_elem_new.
+       * int_array.c (int_clear): Ditto.
+       * str_array.c (str_clear): Ditto.
+       * eval.c (elem_new_to_scalar): Now only needs to change the node type.
+       * interpret.h (r_interpret): Treat Node_elem_new like Node_val, and
+       UPREF it when pushed. Remove test before DEREFing when popping.
+       * mpfr.c (mpg_force_number): Simplify converting Node_elem_new to
+       Node_val. Fix the string value.
+       * node.c (r_force_number): Ditto.
+
 2022-03-28         Arnold D. Robbins     <arnold@skeeve.com>
 
        Allow unreferenced array elements to turn into subarrays.
diff --git a/array.c b/array.c
index 38000471..59948877 100644
--- a/array.c
+++ b/array.c
@@ -1437,10 +1437,16 @@ assoc_list(NODE *symbol, const char *sort_str, 
sort_context_t sort_ctxt)
 NODE *
 new_array_element(void)
 {
-       NODE *n;
+       NODE *n = make_number(0.0);
+       char *sp;
 
-       getnode(n);
-       memset(n, 0, sizeof(NODE));
+       emalloc(sp, char *, 2, "new_array_element");
+       sp[0] = sp[1] = '\0';
+
+       n->stptr = sp;
+       n->stlen = 0;
+
+       n->flags |= (MALLOC|STRING|STRCUR);
 
        n->type = Node_elem_new;
        n->valref = 1;
diff --git a/awk.h b/awk.h
index dc0202a4..cb91cb01 100644
--- a/awk.h
+++ b/awk.h
@@ -1945,18 +1945,10 @@ static inline NODE *
 force_string_fmt(NODE *s, const char *fmtstr, int fmtidx)
 {
        if (s->type == Node_elem_new) {
-               NODE *p = make_string("", 0);
-               *s = *p;
-               // This is interesting. A Node_elem_new gets converted to
-               // a string on number only by an operation working on it
-               // where it's on the stack. The Node_elem_new itself does
-               // get UPREF'ed when pushed on the stack. So converting it
-               // needs to make it look like a Node_val that _was_ UPREF'ed.
-               // Thus we increase the valref so that later on when it's
-               // unref'ed the valref doesn't go to zero too early.
-               // The same thing is done in the two versions of str2number.
-               s->valref++;
-               freenode(p);
+               s->type = Node_val;
+               s->flags &= ~NUMBER;
+               s->stfmt = STFMT_UNUSED;
+
                return s;
        }
 
diff --git a/cint_array.c b/cint_array.c
index 5088adde..3e0393c9 100644
--- a/cint_array.c
+++ b/cint_array.c
@@ -1101,7 +1101,7 @@ leaf_clear(NODE *array)
                        assoc_clear(r);         /* recursively clear all 
sub-arrays */
                        efree(r->vname);
                        freenode(r);
-               } else if (r->type != Node_elem_new)
+               } else
                        unref(r);
        }
        efree(array->nodes);
diff --git a/eval.c b/eval.c
index 47dcdf10..e54e925f 100644
--- a/eval.c
+++ b/eval.c
@@ -1886,17 +1886,8 @@ init_interpret()
 static void
 elem_new_to_scalar(NODE *n)
 {
-       NODE *s;
-
        if (n->type != Node_elem_new)
                return;
 
-       getnode(s);
-       *s = *Nnull_string;
-       // See the comment in awk.h:force_string_fmt as to why we
-       // increase the valref.
-       s->valref = n->valref + 1;
-       *n = *s;
-
-       freenode(s);
+       n->type = Node_val;
 }
diff --git a/int_array.c b/int_array.c
index 957f5ff7..8752413e 100644
--- a/int_array.c
+++ b/int_array.c
@@ -332,7 +332,7 @@ int_clear(NODE *symbol, NODE *subs ATTRIBUTE_UNUSED)
                                        assoc_clear(r); /* recursively clear 
all sub-arrays */
                                        efree(r->vname);
                                        freenode(r);
-                               } else if (r->type != Node_elem_new)
+                               } else
                                        unref(r);
                        }
                        freebucket(b);
diff --git a/interpret.h b/interpret.h
index 8227eccb..4177b2b9 100644
--- a/interpret.h
+++ b/interpret.h
@@ -321,7 +321,7 @@ uninitialized_scalar:
                                }
                        }
 
-                       if (r->type == Node_val)
+                       if (r->type == Node_val || r->type == Node_elem_new)
                                UPREF(r);
                        PUSH(r);
                        break;
@@ -377,7 +377,7 @@ uninitialized_scalar:
                         * be stored in SYMTAB:
                         *      1. Variables that don"t yet have a value 
(Node_var_new)
                         *      2. Variables that have a value (Node_var)
-                        *      3. Values that awk code stuck into SYMTAB not 
related to variables (Node_value)
+                        *      3. Values that awk code stuck into SYMTAB not 
related to variables (Node_val)
                         * For 1, since we are giving it a value, we have to 
change the type to Node_var.
                         * For 1 and 2, we have to step through the Node_var to 
get to the value.
                         * For 3, we fatal out. This avoids confusion on things 
like
@@ -701,7 +701,7 @@ mod:
                         * SYMTAB is a little more messy.  Three possibilities 
for SYMTAB:
                         *      1. Variables that don"t yet have a value 
(Node_var_new)
                         *      2. Variables that have a value (Node_var)
-                        *      3. Values that awk code stuck into SYMTAB not 
related to variables (Node_value)
+                        *      3. Values that awk code stuck into SYMTAB not 
related to variables (Node_val)
                         * For 1, since we are giving it a value, we have to 
change the type to Node_var.
                         * For 1 and 2, we have to step through the Node_var to 
get to the value.
                         * For 3, we fatal out. This avoids confusion on things 
like
@@ -1065,7 +1065,7 @@ arrayfor:
                        (void) POP_CODE();
                        while (arg_count-- > 0) {
                                t1 = POP();
-                               if (t1->type == Node_val)
+                               if (t1->type == Node_val || t1->type == 
Node_elem_new)
                                        DEREF(t1);
                        }
                        free_api_string_copies();
@@ -1490,8 +1490,7 @@ match_re:
 
                case Op_pop:
                        r = POP_SCALAR();
-                       if (r->type != Node_elem_new)
-                               DEREF(r);
+                       DEREF(r);
                        break;
 
                case Op_line_range:
diff --git a/mpfr.c b/mpfr.c
index 3fd21614..f954e2d9 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -350,13 +350,10 @@ mpg_force_number(NODE *n)
        char *cp, *cpend;
 
        if (n->type == Node_elem_new) {
-               NODE *r = make_number(0.0);
-
-               *n = *r;
-               // See the comment in awk.h:force_string_fmt for an explanation
-               // of why we increment valref.
-               n->valref++;
-               freenode(r);
+               n->type = Node_val;
+               n->flags &= ~STRING;
+               n->stptr[0] = '0';      // STRCUR is still set
+               n->stlen = 1;
                return n;
        }
 
diff --git a/node.c b/node.c
index f6b54d2d..9070c5a5 100644
--- a/node.c
+++ b/node.c
@@ -62,12 +62,10 @@ r_force_number(NODE *n)
        char *ptr;
 
        if (n->type == Node_elem_new) {
-               NODE *p = make_number(0.0);
-               *n = *p;
-               // See the comment in awk.h:force_string_fmt for an explanation
-               // of why we increment valref.
-               n->valref++;
-               freenode(p);
+               n->type = Node_val;
+               n->flags &= ~STRING;
+               n->stptr[0] = '0';      // STRCUR is still set
+               n->stlen = 1;
                return n;
        }
 
diff --git a/str_array.c b/str_array.c
index ad960043..101ad0b9 100644
--- a/str_array.c
+++ b/str_array.c
@@ -257,7 +257,7 @@ str_clear(NODE *symbol, NODE *subs ATTRIBUTE_UNUSED)
                                assoc_clear(r); /* recursively clear all 
sub-arrays */
                                efree(r->vname);
                                freenode(r);
-                       } else if (r->type != Node_elem_new)
+                       } else
                                unref(r);
                        unref(b->ahname);
                        freebucket(b);
diff --git a/test/ChangeLog b/test/ChangeLog
index b89aeb3b..34e5a3bb 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,11 @@
+2022-03-31         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * aadelete1.awk, aadelete1.ok: Changed to sync with code changes.
+
+2022-03-30         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * delarprm2.awk, delarprm2.ok: Changes to make test more helpful.
+
 2022-03-27         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.am (EXTRA_DIST): mdim1, mdim2: new tests.
diff --git a/test/aadelete1.awk b/test/aadelete1.awk
index 2484a057..158d2aa3 100644
--- a/test/aadelete1.awk
+++ b/test/aadelete1.awk
@@ -8,7 +8,7 @@ BEGIN {
        print length(a), length(a[1])
        delete a
        print length(a), length(a[1]), length(a)
-       a[1][1] = 11
+       a[1][1] = 11    # this used to fatal, now it no longer does.
 }
 
 function f(c, b) {
diff --git a/test/aadelete1.ok b/test/aadelete1.ok
index d4b678b5..c3e29d26 100644
--- a/test/aadelete1.ok
+++ b/test/aadelete1.ok
@@ -2,5 +2,3 @@
 1
 1 1
 0 0 1
-gawk: aadelete1.awk:11: fatal: attempt to use scalar `a["1"]' as an array
-EXIT CODE: 2

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

Summary of changes:
 ChangeLog          | 16 ++++++++++++++++
 array.c            | 12 +++++++++---
 awk.h              | 16 ++++------------
 cint_array.c       |  2 +-
 eval.c             | 11 +----------
 int_array.c        |  2 +-
 interpret.h        | 11 +++++------
 mpfr.c             | 11 ++++-------
 node.c             | 10 ++++------
 str_array.c        |  2 +-
 test/ChangeLog     |  4 ++++
 test/aadelete1.awk |  2 +-
 test/aadelete1.ok  |  2 --
 13 files changed, 51 insertions(+), 50 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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