summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2022-07-08 10:00:17 +0300
committerArnold D. Robbins <arnold@skeeve.com>2022-07-08 10:00:17 +0300
commitd2e694ad66a379fa128137d19c10b77b942972f2 (patch)
tree4a85a454f2bb1ed8768a5ef2290cc3994abe9767 /array.c
parentff1f652ddb88dcd84edaffa9d2e5fe331aefabc9 (diff)
downloadgawk-d2e694ad66a379fa128137d19c10b77b942972f2.tar.gz
Squashed commit of the following:
commit 50fbb5b087ad2d3522be24276df77bd2f20e5733 Merge: f8246bcd ff1f652d Author: Arnold D. Robbins <arnold@skeeve.com> Date: Thu Jul 7 20:32:20 2022 +0300 Merge branch 'master' into feature/mdim-start-again commit f8246bcd2aa993f686ebedfa52b073f8aecb3d6a Merge: e9e57774 fe43a264 Author: Arnold D. Robbins <arnold@skeeve.com> Date: Thu Jul 7 10:19:59 2022 +0300 Merge branch 'master' into feature/mdim-start-again commit e9e577747cfbe1d20db47a2ab58d57d27564f75f Merge: 4585a0b3 37989990 Author: Arnold D. Robbins <arnold@skeeve.com> Date: Tue Jul 5 11:26:20 2022 +0300 Merge branch 'master' into feature/mdim-start-again commit 4585a0b3090e686493f6f74df9224a5dd36a15e8 Author: Arnold D. Robbins <arnold@skeeve.com> Date: Sun Jul 3 21:11:54 2022 +0300 Additional fix. commit 72aee849f9ea9b979118a17b7cddb6d3eff85027 Merge: 114fba55 30af96ec Author: Arnold D. Robbins <arnold@skeeve.com> Date: Fri Jul 1 11:55:14 2022 +0300 Merge branch 'master' into feature/mdim-start-again commit 114fba55758093388c60d004d3f8718290cd752b Merge: a85b4b76 5b4a2474 Author: Arnold D. Robbins <arnold@skeeve.com> Date: Fri Jul 1 11:52:54 2022 +0300 Merge branch 'master' into feature/mdim-start-again commit a85b4b76890962a2c47f15ab76e0462e5c795dd5 Author: Arnold D. Robbins <arnold@skeeve.com> Date: Thu Jun 30 21:51:45 2022 +0300 Fix TOP_SCALAR and POP_SCALAR for Node_elem_new. commit 342bd54e3e87c0b127fcdb1296f4b4ca96b863fd Author: Arnold D. Robbins <arnold@skeeve.com> Date: Wed Jun 29 08:04:10 2022 +0300 New branch to continue on mdim stuff. Sigh.
Diffstat (limited to 'array.c')
-rw-r--r--array.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/array.c b/array.c
index 3658ac72..6d2ed19b 100644
--- a/array.c
+++ b/array.c
@@ -315,7 +315,7 @@ array_vname(const NODE *symbol)
/*
* force_array --- proceed to the actual Node_var_array,
- * change Node_var_new to an array.
+ * change Node_var_new or Node_elem_new to an array.
* If canfatal and type isn't good, die fatally,
* otherwise return the final actual value.
*/
@@ -334,6 +334,11 @@ force_array(NODE *symbol, bool canfatal)
}
switch (symbol->type) {
+ case Node_elem_new:
+ efree(symbol->stptr);
+ symbol->stptr = NULL;
+ symbol->stlen = 0;
+ /* fall through */
case Node_var_new:
symbol->xarray = NULL; /* make sure union is as it should be */
null_array(symbol);
@@ -1166,6 +1171,7 @@ do_sort_up_value_type(const void *p1, const void *p2)
Node_func,
Node_ext_func,
Node_var_new,
+ Node_elem_new,
Node_var,
Node_var_array,
Node_val,
@@ -1429,3 +1435,26 @@ assoc_list(NODE *symbol, const char *sort_str, sort_context_t sort_ctxt)
return list;
}
+
+/* new_array_element --- return a new empty element node */
+
+NODE *
+new_array_element(void)
+{
+ NODE *n = make_number(0.0);
+ char *sp;
+
+ emalloc(sp, char *, 2, "new_array_element");
+ sp[0] = sp[1] = '\0';
+
+ n->stptr = sp;
+ n->stlen = 0;
+ n->stfmt = STFMT_UNUSED;
+
+ n->flags |= (MALLOC|STRING|STRCUR);
+
+ n->type = Node_elem_new;
+ n->valref = 1;
+
+ return n;
+}