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. dab3a678b3f65ae4cde21c


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. dab3a678b3f65ae4cde21ca4b1d4fd24e8a71918
Date: Wed, 06 Jun 2012 17:09:21 +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  dab3a678b3f65ae4cde21ca4b1d4fd24e8a71918 (commit)
       via  fcc37ab5b658388a6fa14bcd9c0254454418c96a (commit)
      from  a9c75046c071c9a67455ef27be44cac0b64be3c4 (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=dab3a678b3f65ae4cde21ca4b1d4fd24e8a71918

commit dab3a678b3f65ae4cde21ca4b1d4fd24e8a71918
Author: Arnold D. Robbins <address@hidden>
Date:   Wed Jun 6 20:08:02 2012 +0300

    Changes to LINT reflect to extn API. Add API tests.

diff --git a/ChangeLog b/ChangeLog
index 928b628..f7e9ac9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,11 @@
        * cint_array.c (tree_print, leaf_print): Add additional casts
        for printf warnings.
 
+       * awk.h (update_ext_api): Add declaration.
+       * gawkapi.c (update_ext_api): New function.
+       * eval.c (set_LINT): Call update_ext_api() at the end.
+       * gawkapi.h: Document that do_XXX could change on the fly.
+
 2012-06-05         Arnold D. Robbins     <address@hidden>
 
        * ext.c (load_ext): Remove use of RTLD_GLOBAL. Not needed in new
diff --git a/awk.h b/awk.h
index ea4819e..280563c 100644
--- a/awk.h
+++ b/awk.h
@@ -709,6 +709,7 @@ struct break_point;
 #include "gawkapi.h"
 extern gawk_api_t api_impl;
 extern void init_ext_api(void);
+extern void update_ext_api(void);
 extern NODE *awk_value_to_node(const awk_value_t *);
 #endif
 
diff --git a/eval.c b/eval.c
index 9044565..9b3e8e0 100644
--- a/eval.c
+++ b/eval.c
@@ -967,6 +967,9 @@ set_LINT()
        /* explicitly use warning() here, in case lintfunc == r_fatal */
        if (old_lint != do_lint && old_lint && ! do_lint)
                warning(_("turning off `--lint' due to assignment to `LINT'"));
+
+       /* inform plug-in api of change */
+       update_ext_api();
 #endif /* ! NO_LINT */
 }
 
diff --git a/extension/ChangeLog b/extension/ChangeLog
index e31a107..140aea5 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -2,6 +2,9 @@
 
        * filefuncs.c (do_stat): Make `type' const char *.
 
+       * testext.c: Functions renamed, some of them filled in. Corresponding
+       awk code for each test added inline.
+
 2012-05-30         Arnold D. Robbins     <address@hidden>
 
        * testext.c: New file. Outline of tests for extension API.
diff --git a/extension/testext.c b/extension/testext.c
index 599581c..5b171e8 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -41,35 +41,92 @@ static awk_ext_id_t *ext_id;
 
 int plugin_is_GPL_compatible;
 
+/*
+ * The awk code for these tests is embedded in this file and then extracted
+ * dynamically to create the script that is run together with this extension.
+ * Extraction requires the format for awk code where test code is enclosed
+ * in a BEGIN block, with the BEGIN and close brace on lines by themselves
+ * and at the front of the lines.
+ */
+
+/*
address@hidden testext
+BEGIN {
+       dump_procinfo()
+}
+*/
 static awk_value_t *
-do_func1(int nargs, awk_value_t *result)
+dump_procinfo(int nargs, awk_value_t *result)
 {
        /* get PROCINFO as flat array and print it */
 }
 
+/*
+BEGIN {
+       testvar = "One Adam Twelve"
+       ret = var_test("testvar")
+       printf "var_test() returned %d, test_var = %s\n", ret, testvar
+}
+*/
+
 static awk_value_t *
-do_func2(int nargs, awk_value_t *result)
+var_test(int nargs, awk_value_t *result)
 {
+       awk_value_t value;
+
+       if (nargs != 1 || result == NULL)
+               return NULL;
+
        /* look up a reserved variable - should fail */
+       if (sym_lookup("ARGC", & value, AWK_NUMBER) != NULL)
+               printf("var_test: sym_lookup of ARGC failed - got a value!\n");
+       else
+               printf("var_test: sym_lookup of ARGC passed\n");
+
        /* look up variable whose name is passed in, should pass */
        /* change the value, should be reflected in awk script */
 }
 
+/*
+BEGIN {
+       ERRNO = ""
+       ret = test_errno()
+       printf "test_errno() returned %d, ERRNO = %s\n", ret, ERRNO
+}
+*/
 static awk_value_t *
-do_func3(int nargs, awk_value_t *result)
+test_errno(int nargs, awk_value_t *result)
 {
-       /* set ERRNO, should be reflected in awk script */
+       update_ERRNO_int(ECHILD);
 }
 
+/*
+BEGIN {
+       for (i = 1; i <= 10; i++)
+               test_array[i] = i + 2
+
+       printf ("length of test_array is %d, should be 10\n", length(test_array)
+       ret = test_array_size(test_array);
+       printf "test_array_size() returned %d, length is now %d\n", ret, 
length(test_array)
+}
+*/
+
 static awk_value_t *
-do_func4(int nargs, awk_value_t *result)
+test_array_size(int nargs, awk_value_t *result)
 {
        /* get element count and print it; should match length(array) from awk 
script */
        /* clear array - length(array) should then go to zero in script */
 }
 
+/*
+BEGIN {
+       n = split("one two three four five six", test_array2)
+       ret = test_array_elem(test_array2, "3")
+       printf "test_array_elem() returned %d, test_array2[3] = %g\n", ret, 
test_array2[3]
+}
+*/
 static awk_value_t *
-do_func5(int nargs, awk_value_t *result)
+test_array_elem(int nargs, awk_value_t *result)
 {
        /* look up an array element and print the value */
        /* change the element */
@@ -77,9 +134,66 @@ do_func5(int nargs, awk_value_t *result)
        /* change and deletion should be reflected in awk script */
 }
 
+/*
+BEGIN {
+       printf "Initial value of LINT is %d\n", LINT
+       ret = print_do_lint();
+       printf "print_do_lint() returned %d\n", ret
+       LINT = ! LINT
+       printf "Changed value of LINT is %d\n", LINT
+       ret = print_do_lint();
+       printf "print_do_lint() returned %d\n", ret
+}
+*/
+static awk_value_t *
+print_do_lint(int nargs, awk_value_t *result)
+{
+       printf("print_do_lint: lint = %d\n", do_lint);
+}
+
+static void at_exit0(void *data, int exit_status)
+{
+       printf("at_exit0 called (should be third):");
+       if (data)
+               printf(" data = %p,", data);
+       else
+               printf(" data = <null>,");
+       printf(" exit_status = %d\n", exit_status);
+}
+
+
+static int data_for_1 = 0xDeadBeef;
+static void at_exit1(void *data, int exit_status)
+{
+       printf("at_exit1 called (should be second):");
+       if (data) {
+               printf(" data = %p", data);
+               if (data == & data_for_1)
+                       printf(" (data is & data_for_1),");
+               else
+                       printf(" (data is NOT & data_for_1),");
+       } else
+               printf(" data = <null>,");
+       printf(" exit_status = %d\n", exit_status);
+}
+
+static void at_exit2(void *data, int exit_status)
+{
+       printf("at_exit2 called (should be first):");
+       if (data)
+               printf(" data = %p,", data);
+       else
+               printf(" data = <null>,");
+       printf(" exit_status = %d\n", exit_status);
+}
 
 static awk_ext_func_t func_table[] = {
-       { "test_func1", do_func1, 1 },
+       { "dump_procinfo", dump_procinfo, 0 },
+       { "var_test", var_test, 1 },
+       { "test_errno", test_errno, 0 },
+       { "test_array_size", test_array_size, 1 },
+       { "test_array_elem", test_array_elem, 2 },
+       { "print_do_lint", print_do_lint, 0 },
 };
 
 
@@ -88,6 +202,8 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id)
 {
        size_t i, j;
        int errors = 0;
+       awk_value_t value;
+       static const char message[] = "hello, world";   /* of course */
 
        api = api_p;
        ext_id = id;
@@ -103,7 +219,7 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id)
 
        /* load functions */
        for (i = 0, j = sizeof(func_table) / sizeof(func_table[0]); i < j; i++) 
{
-               if (! add_ext_func(& func_table[i], name_space)) {
+               if (! add_ext_func(& func_table[i], "")) {
                        warning(ext_id, "testfuncs: could not add %s\n",
                                        func_table[i].name);
                        errors++;
@@ -111,8 +227,23 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id)
        }
 
        /* add at_exit functions */
+       awk_atexit(at_exit0, NULL);
+       awk_atexit(at_exit1, & data_for_1);
+       awk_atexit(at_exit2, NULL);
+
+/*
+BEGIN {
+       printf("answer_num = %g\n", answer_num);
+       printf("message_string = %s\n", message_string);
+}
+*/
 
        /* install some variables */
+       if (! sym_update("answer_num", make_number(42, & value)))
+                       printf("textext: sym_update(\"answer_num\") failed!\n");
+
+       if (! sym_update("message_string", dup_string(message, strlen(message), 
& value)))
+                       printf("textext: sym_update(\"answer_num\") failed!\n");
 
        return (errors == 0);
 }
diff --git a/gawkapi.c b/gawkapi.c
index 3b915fc..7a79f78 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -479,3 +479,11 @@ init_ext_api()
        api_impl.do_flags[4] = do_debug;
        api_impl.do_flags[5] = do_mpfr;
 }
+
+/* update_ext_api --- update the variables in the API that can change */
+
+void
+update_ext_api()
+{
+       api_impl.do_flags[0] = do_lint;
+}
diff --git a/gawkapi.h b/gawkapi.h
index 87d2d2f..09a1ce7 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -179,6 +179,11 @@ typedef struct gawk_api {
        int major_version;
        int minor_version;
 
+       /*
+        * These can change on the fly as things happen within gawk.
+        * Currently only do_lint is prone to change, but we reserve
+        * the right to allow the others also.
+        */
        int do_flags[DO_FLAGS_SIZE];
 /* Use these as indices into do_flags[] array to check the values */
 #define gawk_do_lint           0

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

commit fcc37ab5b658388a6fa14bcd9c0254454418c96a
Author: Arnold D. Robbins <address@hidden>
Date:   Wed Jun 6 20:03:29 2012 +0300

    Minor fixes for printf compile warnings.

diff --git a/ChangeLog b/ChangeLog
index 16cd1de..928b628 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-06         Arnold D. Robbins     <address@hidden>
+
+       * cint_array.c (tree_print, leaf_print): Add additional casts
+       for printf warnings.
+
 2012-06-05         Arnold D. Robbins     <address@hidden>
 
        * ext.c (load_ext): Remove use of RTLD_GLOBAL. Not needed in new
diff --git a/cint_array.c b/cint_array.c
index 3245cdc..cafd1bb 100644
--- a/cint_array.c
+++ b/cint_array.c
@@ -996,7 +996,8 @@ tree_print(NODE *tree, size_t bi, int indent_level)
        hsize = tree->array_size;
        if ((tree->flags & HALFHAT) != 0)
                hsize /= 2;
-       fprintf(output_fp, "%4lu:%s[%4lu:%-4lu]\n", bi,
+       fprintf(output_fp, "%4lu:%s[%4lu:%-4lu]\n",
+                       (unsigned long) bi,
                        (tree->flags & HALFHAT) ? "HH" : "H",
                        (unsigned long) hsize, (unsigned long) 
tree->table_size);
 
@@ -1210,7 +1211,8 @@ static void
 leaf_print(NODE *array, size_t bi, int indent_level)
 {
        indent(indent_level);
-       fprintf(output_fp, "%4lu:L[%4lu:%-4lu]\n", bi,
+       fprintf(output_fp, "%4lu:L[%4lu:%-4lu]\n",
+                       (unsigned long) bi,
                        (unsigned long) array->array_size,
                        (unsigned long) array->table_size);
 }
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 9551de9..e31a107 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,7 @@
+2012-06-06         Arnold D. Robbins     <address@hidden>
+
+       * filefuncs.c (do_stat): Make `type' const char *.
+
 2012-05-30         Arnold D. Robbins     <address@hidden>
 
        * testext.c: New file. Outline of tests for extension API.
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 46b1596..4d38200 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -240,7 +240,7 @@ do_stat(int nargs, awk_value_t *result)
        struct stat sbuf;
        int ret, j, k;
        char *pmode;    /* printable mode */
-       char *type = "unknown";
+       const char *type = "unknown";
        awk_value_t tmp;
        static struct ftype_map {
                int mask;

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

Summary of changes:
 ChangeLog             |   10 +++
 awk.h                 |    1 +
 cint_array.c          |    6 +-
 eval.c                |    3 +
 extension/ChangeLog   |    7 ++
 extension/filefuncs.c |    2 +-
 extension/testext.c   |  147 ++++++++++++++++++++++++++++++++++++++++++++++---
 gawkapi.c             |    8 +++
 gawkapi.h             |    5 ++
 9 files changed, 178 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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