gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, master, updated. 3bb52bc2b515aa00bcd7238


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. 3bb52bc2b515aa00bcd72382a786a45a65538e1d
Date: Sat, 10 Nov 2012 19:59:57 +0000

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  3bb52bc2b515aa00bcd72382a786a45a65538e1d (commit)
       via  1d607c0112f20a1f3a46668bc61fdc7e38c492eb (commit)
       via  080a0a51372998be6d995208697c0537b975c1bc (commit)
       via  2fe4775356a1042a90f0236d69df1d0379b1a9bc (commit)
       via  a92d9e310f119d61752b38bcb232e0cbe867c34f (commit)
      from  b1f42bdc87249e1869d13df2cacaa3aceea6fc1e (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=3bb52bc2b515aa00bcd72382a786a45a65538e1d

commit 3bb52bc2b515aa00bcd72382a786a45a65538e1d
Author: Arnold D. Robbins <address@hidden>
Date:   Sat Nov 10 21:48:13 2012 +0200

    Add symtab6.ok file.

diff --git a/test/symtab6.ok b/test/symtab6.ok
new file mode 100644
index 0000000..ac5484d
--- /dev/null
+++ b/test/symtab6.ok
@@ -0,0 +1,27 @@
+ARGC: 1
+ARGIND: 0
+ARGV: array, 1 elements
+BINMODE: 0
+CONVFMT: "%.6g"
+ERRNO: ""
+FIELDWIDTHS: ""
+FILENAME: ""
+FNR: 0
+FPAT: "[^[:space:]]+"
+FS: " "
+IGNORECASE: 0
+LINT: 0
+NF: 0
+NR: 0
+OFMT: "%.6g"
+OFS: " "
+ORS: "\n"
+PREC: 53
+PROCINFO: array, 23 elements
+RLENGTH: 0
+ROUNDMODE: "N"
+RS: "\n"
+RSTART: 0
+RT: ""
+SUBSEP: "\034"
+TEXTDOMAIN: "messages"

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=1d607c0112f20a1f3a46668bc61fdc7e38c492eb

commit 1d607c0112f20a1f3a46668bc61fdc7e38c492eb
Author: Arnold D. Robbins <address@hidden>
Date:   Sat Nov 10 21:47:32 2012 +0200

    Array bug fixes.

diff --git a/ChangeLog b/ChangeLog
index 58bf10e..80a0c64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-11-10         John Haque      <address@hidden>
+
+       * int_array.c (int_copy): Initialize next pointer of newchain to null.
+       * eval.c (eval_condition): Force string context for an integer used
+       as array index.
+
 2012-11-10         Arnold D. Robbins     <address@hidden>
 
        * gawkapi.c (api_add_ext_func, api_awk_atexit, api_clear_array,
diff --git a/eval.c b/eval.c
index 4c3e6ab..36a8149 100644
--- a/eval.c
+++ b/eval.c
@@ -1498,6 +1498,8 @@ eval_condition(NODE *t)
 
        if ((t->flags & MAYBE_NUM) != 0)
                force_number(t);
+       else if ((t->flags & INTIND) != 0)
+               force_string(t);
 
        if ((t->flags & NUMBER) != 0)
                return ! iszero(t);
diff --git a/int_array.c b/int_array.c
index 4e1ff2b..a2c9e41 100644
--- a/int_array.c
+++ b/int_array.c
@@ -398,6 +398,7 @@ int_copy(NODE *symbol, NODE *newsymb)
                ) {
                        getbucket(newchain);
                        newchain->aicount = chain->aicount;
+                       newchain->ainext = NULL;
                        for (j = 0; j < chain->aicount; j++) {
                                NODE *oldval;
 

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=080a0a51372998be6d995208697c0537b975c1bc

commit 080a0a51372998be6d995208697c0537b975c1bc
Author: Arnold D. Robbins <address@hidden>
Date:   Sat Nov 10 21:46:31 2012 +0200

    Bug fix in symtab6 test.

diff --git a/test/Makefile.am b/test/Makefile.am
index 6530f3d..55244ee 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1701,7 +1701,7 @@ symtab6:
        @echo $@
        @$(AWK) -d__$@ -f $(srcdir)/address@hidden
        @grep -v '^ENVIRON' __$@ > _$@ ; rm __$@
-       @-$(CMP) address@hidden _$@ && rm -f address@hidden _$@
+       @-$(CMP) address@hidden _$@ && rm -f _$@
 
 # Targets generated for other tests:
 include Maketests
diff --git a/test/Makefile.in b/test/Makefile.in
index 22b5cf8..d371138 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -2082,7 +2082,7 @@ symtab6:
        @echo $@
        @$(AWK) -d__$@ -f $(srcdir)/address@hidden
        @grep -v '^ENVIRON' __$@ > _$@ ; rm __$@
-       @-$(CMP) address@hidden _$@ && rm -f address@hidden _$@
+       @-$(CMP) address@hidden _$@ && rm -f _$@
 Gt-dummy:
 # file Maketests, generated from Makefile.am by the Gentests program
 addcomma:

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=2fe4775356a1042a90f0236d69df1d0379b1a9bc

commit 2fe4775356a1042a90f0236d69df1d0379b1a9bc
Author: Arnold D. Robbins <address@hidden>
Date:   Sat Nov 10 21:42:18 2012 +0200

    Bug fixes for SYMTAB.

diff --git a/ChangeLog b/ChangeLog
index af8c2b8..58bf10e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,10 @@
        remove_element, run_ext_exit_handlers): Add null pointer checks.
        Everywhere: Add / fixup leading comments.
 
+       * interpret.h (Op_store_sub): If assigning to an unitialized variable
+       through SYMTAB, change it to Node_var. Add explanatory comments.
+       * symbol.c (get_symbol): Rationalized. Skip non-variables in SYMTAB.
+
 2012-11-04         Arnold D. Robbins     <address@hidden>
 
        * gawkapi.h: Minor documentation edit.
diff --git a/interpret.h b/interpret.h
index 0a30684..26725a2 100644
--- a/interpret.h
+++ b/interpret.h
@@ -557,10 +557,26 @@ mod:
                        }
                        DEREF(t2);
 
+                       /*
+                        * Changing something in FUNCTAB is not allowed.
+                        *
+                        * SYMTAB is a little more messy.  Three kinds of 
values may
+                        * 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)
+                        * 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 just us the value we got from 
assoc_lookup(), above.
+                        */
                        if (t1 == func_table)
                                fatal(_("cannot assign to elements of 
FUNCTAB"));
-                       else if (t1 == symbol_table && (*lhs)->type == Node_var)
-                               lhs = & ((*lhs)->var_value);
+                       else if (   t1 == symbol_table
+                                && (   (*lhs)->type == Node_var
+                                    || (*lhs)->type == Node_var_new)) {
+                               (*lhs)->type = Node_var;        /* in case was 
Node_var_new */
+                               lhs = & ((*lhs)->var_value);    /* extra level 
of indirection */
+                       }
 
                        unref(*lhs);
                        *lhs = POP_SCALAR();
diff --git a/symbol.c b/symbol.c
index 1e0e474..e698298 100644
--- a/symbol.c
+++ b/symbol.c
@@ -379,23 +379,36 @@ get_symbols(SYMBOL_TYPE what, int sort)
        if (what == FUNCTION) {
                count = func_count;
                the_table = func_table;
+
+               max = the_table->table_size * 2;
+               list = assoc_list(the_table, "@unsorted", ASORTI);
+               emalloc(table, NODE **, (count + 1) * sizeof(NODE *), 
"symbol_list");
+
+               for (i = j = 0; i < max; i += 2) {
+                       r = list[i+1];
+                       if (r->type == Node_ext_func)
+                               continue;
+                       assert(r->type == Node_func);
+                       table[j++] = r;
+               }
        } else {        /* what == VARIABLE */
-               count = var_count;
                the_table = symbol_table;
+               count = var_count;
+
                update_global_values();
-       }
 
-       emalloc(table, NODE **, (count + 1) * sizeof(NODE *), "symbol_list");
+               max = the_table->table_size * 2;
+               list = assoc_list(the_table, "@unsorted", ASORTI);
+               emalloc(table, NODE **, (count + 1) * sizeof(NODE *), 
"symbol_list");
 
-       max = the_table->table_size * 2;
-       list = assoc_list(the_table, "@unsorted", ASORTI);
-       for (i = j = 0; i < max; i += 2) {
-               r = list[i+1];
-               if (r->type == Node_ext_func)
-                       continue;
-               if (what == VARIABLE || r->type == Node_func)
+               for (i = j = 0; i < max; i += 2) {
+                       r = list[i+1];
+                       if (r->vname == NULL)   /* non-variable in SYMTAB */
+                               continue;
                        table[j++] = r;
+               }
        }
+
        efree(list);
 
        if (sort && count > 1)
diff --git a/test/ChangeLog b/test/ChangeLog
index feedd95..55c6494 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,11 @@
+2012-11-10         Arnold D. Robbins     <address@hidden>
+
+       * symtab4.awk, symtab4.in, symtab4.ok, symtab5.awk, symtab5.in,
+       symtab5.ok, symtab6.awk: New files.
+       * Makefile.am (EXTRA_DIST): Add new files.
+       (symtab4, symtab5, symtab6): New tests.
+       Thanks to Assaf Gordon <address@hidden>.
+
 2012-10-28         Andrew J. Schorr     <address@hidden>
 
        * messages.awk, fts.awk: Adjusted so make diffout will work.
diff --git a/test/Makefile.am b/test/Makefile.am
index d3c1b14..6530f3d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -799,6 +799,14 @@ EXTRA_DIST = \
        symtab2.ok \
        symtab3.awk \
        symtab3.ok \
+       symtab4.awk \
+       symtab4.in \
+       symtab4.ok \
+       symtab5.awk \
+       symtab5.in \
+       symtab5.ok \
+       symtab6.awk \
+       symtab6.ok \
        synerr1.awk \
        synerr1.ok \
        synerr2.awk \
@@ -919,7 +927,7 @@ GAWK_EXT_TESTS = \
        rebuf regx8bit reint reint2 rsstart1 \
        rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
        strtonum switch2 \
-       symtab1 symtab2 symtab3 \
+       symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
        include include2 incdupe incdupe2 incdupe3 \
        incdupe4 incdupe5 incdupe6 incdupe7
 
@@ -1689,6 +1697,12 @@ charasbytes:
        od -c -t x1 | sed -e 's/  */ /g' -e 's/ *$$//' >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 
+symtab6:
+       @echo $@
+       @$(AWK) -d__$@ -f $(srcdir)/address@hidden
+       @grep -v '^ENVIRON' __$@ > _$@ ; rm __$@
+       @-$(CMP) address@hidden _$@ && rm -f address@hidden _$@
+
 # Targets generated for other tests:
 include Maketests
 
diff --git a/test/Makefile.in b/test/Makefile.in
index c148886..22b5cf8 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1011,6 +1011,14 @@ EXTRA_DIST = \
        symtab2.ok \
        symtab3.awk \
        symtab3.ok \
+       symtab4.awk \
+       symtab4.in \
+       symtab4.ok \
+       symtab5.awk \
+       symtab5.in \
+       symtab5.ok \
+       symtab6.awk \
+       symtab6.ok \
        synerr1.awk \
        synerr1.ok \
        synerr2.awk \
@@ -1130,7 +1138,7 @@ GAWK_EXT_TESTS = \
        rebuf regx8bit reint reint2 rsstart1 \
        rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
        strtonum switch2 \
-       symtab1 symtab2 symtab3 \
+       symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
        include include2 incdupe incdupe2 incdupe3 \
        incdupe4 incdupe5 incdupe6 incdupe7
 
@@ -2069,6 +2077,12 @@ charasbytes:
        AWKPATH=$(srcdir) $(AWK) -b -f address@hidden $(srcdir)/address@hidden 
| \
        od -c -t x1 | sed -e 's/  */ /g' -e 's/ *$$//' >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+symtab6:
+       @echo $@
+       @$(AWK) -d__$@ -f $(srcdir)/address@hidden
+       @grep -v '^ENVIRON' __$@ > _$@ ; rm __$@
+       @-$(CMP) address@hidden _$@ && rm -f address@hidden _$@
 Gt-dummy:
 # file Maketests, generated from Makefile.am by the Gentests program
 addcomma:
@@ -3261,6 +3275,16 @@ symtab3:
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 
+symtab4:
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) -f address@hidden  < $(srcdir)/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+symtab5:
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) -f address@hidden  < $(srcdir)/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
 include:
        @echo $@
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 6490410..1accc80 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1190,6 +1190,16 @@ symtab3:
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 
+symtab4:
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) -f address@hidden  < $(srcdir)/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+symtab5:
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) -f address@hidden  < $(srcdir)/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
 include:
        @echo $@
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
diff --git a/test/symtab4.awk b/test/symtab4.awk
new file mode 100644
index 0000000..4eed7e9
--- /dev/null
+++ b/test/symtab4.awk
@@ -0,0 +1 @@
+{SYMTAB["POS"]=1 ; print $POS }
diff --git a/test/symtab4.in b/test/symtab4.in
new file mode 100644
index 0000000..d35e192
--- /dev/null
+++ b/test/symtab4.in
@@ -0,0 +1,2 @@
+1 a
+2 b
diff --git a/test/symtab4.ok b/test/symtab4.ok
new file mode 100644
index 0000000..1191247
--- /dev/null
+++ b/test/symtab4.ok
@@ -0,0 +1,2 @@
+1
+2
diff --git a/test/symtab5.awk b/test/symtab5.awk
new file mode 100644
index 0000000..e4fbc85
--- /dev/null
+++ b/test/symtab5.awk
@@ -0,0 +1 @@
+BEGIN {SYMTAB["POS"]=1} {print $POS}
diff --git a/test/symtab5.in b/test/symtab5.in
new file mode 100644
index 0000000..d35e192
--- /dev/null
+++ b/test/symtab5.in
@@ -0,0 +1,2 @@
+1 a
+2 b
diff --git a/test/symtab5.ok b/test/symtab5.ok
new file mode 100644
index 0000000..1191247
--- /dev/null
+++ b/test/symtab5.ok
@@ -0,0 +1,2 @@
+1
+2
diff --git a/test/symtab6.awk b/test/symtab6.awk
new file mode 100644
index 0000000..d8f4cb1
--- /dev/null
+++ b/test/symtab6.awk
@@ -0,0 +1 @@
+BEGIN {SYMTAB["POS"]=1}

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

commit a92d9e310f119d61752b38bcb232e0cbe867c34f
Author: Arnold D. Robbins <address@hidden>
Date:   Sat Nov 10 21:09:32 2012 +0200

    Add null pointer checks in gawkapi.c.

diff --git a/ChangeLog b/ChangeLog
index f7551cf..af8c2b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-11-10         Arnold D. Robbins     <address@hidden>
+
+       * gawkapi.c (api_add_ext_func, api_awk_atexit, api_clear_array,
+       api_create_array, api_create_value, api_register_ext_version,
+       api_release_value, api_update_ERRNO_string, node_to_awk_value,
+       remove_element, run_ext_exit_handlers): Add null pointer checks.
+       Everywhere: Add / fixup leading comments.
+
 2012-11-04         Arnold D. Robbins     <address@hidden>
 
        * gawkapi.h: Minor documentation edit.
diff --git a/gawkapi.c b/gawkapi.c
index 9f4c4f5..c9b2ace 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -29,11 +29,13 @@ static awk_bool_t node_to_awk_value(NODE *node, awk_value_t 
*result, awk_valtype
 static void set_constant();
 
 /*
- * Get the count'th paramater, zero-based.
+ * api_get_argument --- get the count'th paramater, zero-based.
+ *
  * Returns false if count is out of range, or if actual paramater
  * does not match what is specified in wanted. In the latter
  * case, fills in result->val_type with the actual type.
  */
+
 static awk_bool_t
 api_get_argument(awk_ext_id_t id, size_t count,
                        awk_valtype_t wanted, awk_value_t *result)
@@ -99,6 +101,8 @@ scalar:
 #endif
 }
 
+/* api_set_argument --- convert an argument to an array */
+
 static awk_bool_t
 api_set_argument(awk_ext_id_t id,
                size_t count,
@@ -283,6 +287,9 @@ api_update_ERRNO_string(awk_ext_id_t id,
 {
        (void) id;
 
+       if (string == NULL)
+               return;
+
        update_ERRNO_string(string);
 }
 
@@ -307,6 +314,9 @@ api_add_ext_func(awk_ext_id_t id,
        (void) id;
        (void) namespace;
 
+       if (func == NULL)
+               return false;
+
 #ifdef DYNAMIC
        return make_builtin(func);
 #else
@@ -338,7 +348,7 @@ run_ext_exit_handlers(int exitval)
        list_head = NULL;
 }
 
-/* api_awk_atexit --- add an exit call back, returns true upon success */
+/* api_awk_atexit --- add an exit call back */
 
 static void
 api_awk_atexit(awk_ext_id_t id,
@@ -349,6 +359,9 @@ api_awk_atexit(awk_ext_id_t id,
 
        (void) id;
 
+       if (funcp == NULL)
+               return;
+
        /* allocate memory */
        emalloc(p, struct ext_exit_handler *, sizeof(struct ext_exit_handler), 
"api_awk_atexit");
 
@@ -368,6 +381,12 @@ node_to_awk_value(NODE *node, awk_value_t *val, 
awk_valtype_t wanted)
 {
        awk_bool_t ret = false;
 
+       if (node == NULL)
+               fatal(_("node_to_awk_value: received null node"));
+
+       if (val == NULL)
+               fatal(_("node_to_awk_value: received null val"));
+
        switch (node->type) {
        case Node_var_new:      /* undefined variable */
                val->val_type = AWK_UNDEFINED;
@@ -695,9 +714,11 @@ api_sym_update_scalar(awk_ext_id_t id,
 }
 
 /*
- * Test if a type is allowed for an array subscript.
+ * valid_subscript_type --- test if a type is allowed for an array subscript.
+ *
  * Any scalar value is fine, so only AWK_ARRAY (or an invalid type) is illegal.
  */
+
 static inline int
 valid_subscript_type(awk_valtype_t valtype)
 {
@@ -715,9 +736,11 @@ valid_subscript_type(awk_valtype_t valtype)
 
 /* Array management */
 /*
- * Return the value of an element - read only!
+ * api_get_array_element --- teturn the value of an element - read only!
+ *
  * Use set_array_element to change it.
  */
+
 static awk_bool_t
 api_get_array_element(awk_ext_id_t id,
                awk_array_t a_cookie,
@@ -758,9 +781,10 @@ api_get_array_element(awk_ext_id_t id,
 }
 
 /*
- * Change (or create) element in existing array with
- * element->index and element->value.
+ * api_set_array_element --- change (or create) element in existing array
+ *     with element->index and element->value.
  */
+
 static awk_bool_t
 api_set_array_element(awk_ext_id_t id, awk_array_t a_cookie,
                                        const awk_value_t *const index,
@@ -805,6 +829,12 @@ remove_element(NODE *array, NODE *subscript)
 {
        NODE *val;
 
+       if (array == NULL)
+               fatal(_("remove_element: received null array"));
+
+       if (subscript == NULL)
+               fatal(_("remove_element: received null subscript"));
+
        val = in_array(array, subscript);
 
        if (val == NULL)
@@ -822,9 +852,10 @@ remove_element(NODE *array, NODE *subscript)
 }
 
 /*
- * Remove the element with the given index.
- * Returns success if removed or if element did not exist.
+ * api_del_array_element --- remove the element with the given index.
+ *     Return success if removed or if element did not exist.
  */
+
 static awk_bool_t
 api_del_array_element(awk_ext_id_t id,
                awk_array_t a_cookie, const awk_value_t* const index)
@@ -847,9 +878,10 @@ api_del_array_element(awk_ext_id_t id,
 }
 
 /*
- * Retrieve total number of elements in array.
- * Returns false if some kind of error.
+ * api_get_element_count --- retrieve total number of elements in array.
+ *     Return false if some kind of error.
  */
+
 static awk_bool_t
 api_get_element_count(awk_ext_id_t id,
                awk_array_t a_cookie, size_t *count)
@@ -863,7 +895,8 @@ api_get_element_count(awk_ext_id_t id,
        return true;
 }
 
-/* Create a new array cookie to which elements may be added */
+/* api_create_array --- create a new array cookie to which elements may be 
added */
+
 static awk_array_t
 api_create_array(awk_ext_id_t id)
 {
@@ -876,13 +909,16 @@ api_create_array(awk_ext_id_t id)
        return (awk_array_t) n;
 }
 
-/* Clear out an array */
+/* api_clear_array --- clear out an array */
+
 static awk_bool_t
 api_clear_array(awk_ext_id_t id, awk_array_t a_cookie)
 {
        NODE *node = (NODE *) a_cookie;
 
-       if (node == NULL || node->type != Node_var_array)
+       if (   node == NULL
+           || node->type != Node_var_array
+           || (node->flags & NO_EXT_SET) != 0)
                return false;
 
        assoc_clear(node);
@@ -942,9 +978,11 @@ api_flatten_array(awk_ext_id_t id,
 }
 
 /*
- * When done, release the memory, delete any marked elements
- * Count must match what gawk thinks the size is.
+ * api_release_flattened_array --- release array memory,
+ *     delete any marked elements. Count must match what
+ *     gawk thinks the size is.
  */
+
 static awk_bool_t
 api_release_flattened_array(awk_ext_id_t id,
                awk_array_t a_cookie,
@@ -980,10 +1018,15 @@ api_release_flattened_array(awk_ext_id_t id,
        return true;
 }
 
+/* api_create_value --- create a cached value */
+
 static awk_bool_t
 api_create_value(awk_ext_id_t id, awk_value_t *value,
                awk_value_cookie_t *result)
 {
+       if (value == NULL || result == NULL)
+               return false;
+
        switch (value->val_type) {
        case AWK_NUMBER:
        case AWK_STRING:
@@ -996,10 +1039,17 @@ api_create_value(awk_ext_id_t id, awk_value_t *value,
        return (*result = awk_value_to_node(value)) != NULL;
 }
 
+/* api_release_value --- release a cached value */
+
 static awk_bool_t
 api_release_value(awk_ext_id_t id, awk_value_cookie_t value)
 {
-       unref((NODE *) value);
+       NODE *val = (NODE *) value;
+
+       if (val == NULL)
+               return false;
+
+       unref(val);
        return true;
 }
 
@@ -1021,6 +1071,9 @@ api_register_ext_version(awk_ext_id_t id, const char 
*version)
 {
        struct version_info *info;
 
+       if (version == NULL)
+               return;
+
        (void) id;
 
        emalloc(info, struct version_info *, sizeof(struct version_info), 
"register_ext_version");
@@ -1029,6 +1082,7 @@ api_register_ext_version(awk_ext_id_t id, const char 
*version)
        vi_head = info;
 }
 
+/* the struct api */
 gawk_api_t api_impl = {
        /* data */
        GAWK_API_MAJOR_VERSION, /* major and minor versions */

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

Summary of changes:
 ChangeLog                        |   18 ++++++++
 eval.c                           |    2 +
 gawkapi.c                        |   86 +++++++++++++++++++++++++++++++-------
 int_array.c                      |    1 +
 interpret.h                      |   20 ++++++++-
 symbol.c                         |   33 ++++++++++----
 test/ChangeLog                   |    8 ++++
 test/Makefile.am                 |   16 +++++++-
 test/Makefile.in                 |   26 +++++++++++-
 test/Maketests                   |   10 ++++
 test/symtab4.awk                 |    1 +
 test/symtab4.in                  |    2 +
 test/{nulrsend.ok => symtab4.ok} |    0
 test/symtab5.awk                 |    1 +
 test/symtab5.in                  |    2 +
 test/{nulrsend.ok => symtab5.ok} |    0
 test/symtab6.awk                 |    1 +
 test/{dumpvars.ok => symtab6.ok} |   11 +++--
 18 files changed, 203 insertions(+), 35 deletions(-)
 create mode 100644 test/symtab4.awk
 create mode 100644 test/symtab4.in
 copy test/{nulrsend.ok => symtab4.ok} (100%)
 create mode 100644 test/symtab5.awk
 create mode 100644 test/symtab5.in
 copy test/{nulrsend.ok => symtab5.ok} (100%)
 create mode 100644 test/symtab6.awk
 copy test/{dumpvars.ok => symtab6.ok} (79%)


hooks/post-receive
-- 
gawk



reply via email to

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