gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, extgawk, updated. 898eb2ad1d514887993994


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. 898eb2ad1d514887993994e60fe860ac3ee1bba8
Date: Thu, 21 Jun 2012 19:21:04 +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, extgawk has been updated
       via  898eb2ad1d514887993994e60fe860ac3ee1bba8 (commit)
      from  d66f3c9922e36bb2e760e0ac36364c1a5aa11442 (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=898eb2ad1d514887993994e60fe860ac3ee1bba8

commit 898eb2ad1d514887993994e60fe860ac3ee1bba8
Author: Arnold D. Robbins <address@hidden>
Date:   Thu Jun 21 22:20:38 2012 +0300

    Further API code and test code.

diff --git a/ChangeLog b/ChangeLog
index beb8f36..57da23e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-06-21         Arnold D. Robbins     <address@hidden>
+
+       * 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     <address@hidden>
 
        Restore lost debugging function:
diff --git a/TODO.xgawk b/TODO.xgawk
index a2f78e8..7ea135a 100644
--- a/TODO.xgawk
+++ b/TODO.xgawk
@@ -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.
diff --git a/awk.h b/awk.h
index 4bfaef4..d433a6e 100644
--- a/awk.h
+++ b/awk.h
@@ -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);
diff --git a/awkgram.c b/awkgram.c
index ffdf95b..c8c7a08 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -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);
 }
diff --git a/awkgram.y b/awkgram.y
index e7f8701..3ed450d 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -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 a134e00..b482d6f 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-21         Arnold D. Robbins     <address@hidden>
+
+       * testext.c (test_array_elem): Add a subarray.
+       (test_array_flatten): Removed: Tests done elsewhere.
+
 2012-06-20         Arnold D. Robbins     <address@hidden>
 
        * testext.c (fill_in_array): New function.
diff --git a/extension/testext.c b/extension/testext.c
index 963a563..e3975b2 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;
diff --git a/gawkapi.c b/gawkapi.c
index ad7e68f..139d77b 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -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 71edf19..6d36310 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2012-06-21         Arnold D. Robbins     <address@hidden>
+
+       * testext.ok: Update contents.
+
 2012-06-20         Arnold D. Robbins     <address@hidden>
 
        * testext.ok: Update contents.
diff --git a/test/testext.ok b/test/testext.ok
index 08e272d..619d97b 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

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

Summary of changes:
 ChangeLog           |    9 ++++++
 TODO.xgawk          |   14 +++++-----
 awk.h               |    2 +-
 awkgram.c           |    4 +-
 awkgram.y           |    4 +-
 extension/ChangeLog |    5 +++
 extension/testext.c |   68 ++++++++++++++++++++++++---------------------------
 gawkapi.c           |    3 +-
 test/ChangeLog      |    4 +++
 test/testext.ok     |    6 +++-
 10 files changed, 68 insertions(+), 51 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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