diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | TODO.xgawk | 14 | ||||
-rw-r--r-- | awk.h | 2 | ||||
-rw-r--r-- | awkgram.c | 4 | ||||
-rw-r--r-- | awkgram.y | 4 | ||||
-rw-r--r-- | extension/ChangeLog | 5 | ||||
-rw-r--r-- | extension/testext.c | 68 | ||||
-rw-r--r-- | gawkapi.c | 3 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/testext.ok | 6 |
10 files changed, 68 insertions, 51 deletions
@@ -1,3 +1,12 @@ +2012-06-21 Arnold D. Robbins <arnold@skeeve.com> + + * awk.h (stopme): Make signature match other built-ins. + * awkgram.y (stopme): Make signature match other built-ins. + (regexp): Minor edit. + * gawkapi.c (api_set_argument): Remove unused variable. + Set parent_array field of array value. + * TODO.xgawk: Update some. + 2012-06-20 Arnold D. Robbins <arnold@skeeve.com> Restore lost debugging function: @@ -1,12 +1,5 @@ To-do list for xgawk enhancements: -- Finish implementing new interface using gawkapi.h - - api_get_curfunc_param not honoring requested type in node_to_awk_value - - should api_sym_lookup also accept a type request? - - must update the API do_lint value when changed by set_LINT - - what is the proper return value for load_ext? It does not matter - unless called by the "extension" function that nobody uses. - - Attempting to load the same file with -f and -i (or @include) should be a fatal error. @@ -160,3 +153,10 @@ Done: - Add time extension to the gawk distro. This defines sleep and gettimeofday. Renamed existing gettimeofday to getlocaltime. + +- Finish implementing new interface using gawkapi.h + - api_get_curfunc_param not honoring requested type in node_to_awk_value + - should api_sym_lookup also accept a type request? + - must update the API do_lint value when changed by set_LINT + - what is the proper return value for load_ext? It does not matter + unless called by the "extension" function that nobody uses. @@ -1416,7 +1416,7 @@ extern int parse_program(INSTRUCTION **pcode); extern void dump_funcs(void); extern void dump_vars(const char *fname); extern const char *getfname(NODE *(*)(int)); -extern NODE *stopme(NODE *tree); +extern NODE *stopme(int nargs); extern void shadow_funcs(void); extern int check_special(const char *name); extern SRCFILE *add_srcfile(int stype, char *src, SRCFILE *curr, bool *already_included, int *errcode); @@ -2368,7 +2368,7 @@ yyreduce: if (len == 0) lintwarn_ln((yyvsp[(3) - (3)])->source_line, _("regexp constant `//' looks like a C++ comment, but is not")); - else if ((re)[0] == '*' && (re)[len-1] == '*') + else if (re[0] == '*' && re[len-1] == '*') /* possible C comment */ lintwarn_ln((yyvsp[(3) - (3)])->source_line, _("regexp constant `/%s/' looks like a C comment, but is not"), re); @@ -7216,7 +7216,7 @@ make_assignable(INSTRUCTION *ip) /* stopme --- for debugging */ NODE * -stopme(NODE *tree ATTRIBUTE_UNUSED) +stopme(int nargs ATTRIBUTE_UNUSED) { return make_number(0.0); } @@ -407,7 +407,7 @@ regexp if (len == 0) lintwarn_ln($3->source_line, _("regexp constant `//' looks like a C++ comment, but is not")); - else if ((re)[0] == '*' && (re)[len-1] == '*') + else if (re[0] == '*' && re[len-1] == '*') /* possible C comment */ lintwarn_ln($3->source_line, _("regexp constant `/%s/' looks like a C comment, but is not"), re); @@ -4496,7 +4496,7 @@ make_assignable(INSTRUCTION *ip) /* stopme --- for debugging */ NODE * -stopme(NODE *tree ATTRIBUTE_UNUSED) +stopme(int nargs ATTRIBUTE_UNUSED) { return make_number(0.0); } diff --git a/extension/ChangeLog b/extension/ChangeLog index a134e00c..b482d6f1 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,8 @@ +2012-06-21 Arnold D. Robbins <arnold@skeeve.com> + + * testext.c (test_array_elem): Add a subarray. + (test_array_flatten): Removed: Tests done elsewhere. + 2012-06-20 Arnold D. Robbins <arnold@skeeve.com> * testext.c (fill_in_array): New function. diff --git a/extension/testext.c b/extension/testext.c index 963a5638..e3975b27 100644 --- a/extension/testext.c +++ b/extension/testext.c @@ -312,13 +312,22 @@ BEGIN { ret = test_array_elem(test_array2, "3") printf "test_array_elem() returned %d, test_array2[3] = %g\n", ret, test_array2[3] if ("5" in test_array2) - printf "error: test_array_elem did not remove element \"5\"\n" + printf "error: test_array_elem() did not remove element \"5\"\n" else - printf "test_array_elem did remove element \"5\"\n" + printf "test_array_elem() did remove element \"5\"\n" if ("7" in test_array2) - printf "test_array_elem added element \"7\" --> %s\n", test_array2[7] + printf "test_array_elem() added element \"7\" --> %s\n", test_array2[7] else - printf "test_array_elem did not add element \"7\"\n" + printf "test_array_elem() did not add element \"7\"\n" + if ("subarray" in test_array2) { + if (isarray(test_array2["subarray"])) { + for (i in test_array2["subarray"]) + printf("test_array2[\"subarray\"][\"%s\"] = %s\n", + i, test_array2["subarray"][i]) + } else + printf "test_array_elem() added element \"subarray\" as scalar\n" + } else + printf "test_array_elem() did not add element \"subarray\"\n" print "" } */ @@ -380,6 +389,15 @@ test_array_elem(int nargs, awk_value_t *result) goto out; } + /* add a subarray */ + (void) make_string("subarray", 8, & index); + element.index = index; + fill_in_array(& element.value); + if (! set_array_element(array.array_cookie, & element)) { + printf("test_array_elem: set_array_element (subarray) failed\n"); + goto out; + } + /* change and deletion should be reflected in awk script */ make_number(1.0, result); out: @@ -465,37 +483,7 @@ out: return result; } -/* -#BEGIN { -# n = split("one two three four five six", test_array3) -# ret = test_array_flatten(test_array3) -# printf "test_array_flatten() returned %d\n", ret -# if ("3" in test_array3) -# printf "error: test_array_flatten() did not remove element \"3\"\n" -# else -# printf "test_array_flatten() did remove element \"3\"\n" -# print "" -#} -*/ - -static awk_value_t * -test_array_flatten(int nargs, awk_value_t *result) -{ - assert(result != NULL); - make_number(0.0, result); - - if (nargs != 1) { - printf("test_array_flatten: nargs not right (%d should be 1)\n", nargs); - goto out; - } - - /* FIXME: CODE HERE */ - - make_number(1.0, result); - -out: - return result; -} +/* fill_in_array --- fill in a new array */ static void fill_in_array(awk_value_t *value) @@ -527,6 +515,8 @@ fill_in_array(awk_value_t *value) } +/* create_new_array --- create a named array */ + static void create_new_array() { @@ -537,6 +527,8 @@ create_new_array() printf("create_new_array: sym_update(\"new_array\") failed!\n"); } +/* at_exit0 --- first at_exit program, runs last */ + static void at_exit0(void *data, int exit_status) { printf("at_exit0 called (should be third):"); @@ -547,6 +539,7 @@ static void at_exit0(void *data, int exit_status) printf(" exit_status = %d\n", exit_status); } +/* at_exit1 --- second at_exit program, runs second */ static int data_for_1 = 0xDeadBeef; static void at_exit1(void *data, int exit_status) @@ -565,6 +558,8 @@ static void at_exit1(void *data, int exit_status) printf(" exit_status = %d\n", exit_status); } +/* at_exit2 --- third at_exit program, runs first */ + static void at_exit2(void *data, int exit_status) { printf("at_exit2 called (should be first):"); @@ -582,10 +577,11 @@ static awk_ext_func_t func_table[] = { { "test_array_size", test_array_size, 1 }, { "test_array_elem", test_array_elem, 2 }, { "test_array_param", test_array_param, 1 }, - { "test_array_flatten", test_array_flatten, 1 }, { "print_do_lint", print_do_lint, 0 }, }; +/* dl_load --- extension load routine, called from gawk */ + int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id) { size_t i, j; @@ -101,7 +101,6 @@ api_set_argument(awk_ext_id_t id, { NODE *arg; NODE *array = (NODE *) new_array; - awk_valtype_t valtype; (void) id; @@ -544,6 +543,8 @@ api_set_array_element(awk_ext_id_t id, awk_array_t a_cookie, unref(tmp); unref(*aptr); *aptr = awk_value_to_node(& element->value); + if ((*aptr)->type == Node_var_array) + (*aptr)->parent_array = array; return true; } diff --git a/test/ChangeLog b/test/ChangeLog index 71edf199..6d363108 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2012-06-21 Arnold D. Robbins <arnold@skeeve.com> + + * testext.ok: Update contents. + 2012-06-20 Arnold D. Robbins <arnold@skeeve.com> * testext.ok: Update contents. diff --git a/test/testext.ok b/test/testext.ok index 08e272d0..619d97ba 100644 --- a/test/testext.ok +++ b/test/testext.ok @@ -22,8 +22,10 @@ test_array_size() returned 1, length is now 0 test_array_elem: a["3"] = "three" test_array_elem() returned 1, test_array2[3] = 42 -test_array_elem did remove element "5" -test_array_elem added element "7" --> seven +test_array_elem() did remove element "5" +test_array_elem() added element "7" --> seven +test_array2["subarray"]["hello"] = world +test_array2["subarray"]["answer"] = 42 test_array_param() returned 1 isarray(a_new_array) = 1 |