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. 8ce87087172ee5be4ee72a


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. 8ce87087172ee5be4ee72a1513daad3821185bf7
Date: Tue, 12 Jun 2012 20:12:14 +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  8ce87087172ee5be4ee72a1513daad3821185bf7 (commit)
       via  820b6a2ccb7859e15ade36af6ac1d0d08c1da4b1 (commit)
       via  b4a2d75b7d9fd23069a55dc91a42f7fddd0c7570 (commit)
       via  21a01e3ad4e2e77dccf73e8fd069370749880757 (commit)
      from  5472c2cc2889aab121c32ed4ca6bd831ae520d89 (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=8ce87087172ee5be4ee72a1513daad3821185bf7

commit 8ce87087172ee5be4ee72a1513daad3821185bf7
Author: Arnold D. Robbins <address@hidden>
Date:   Tue Jun 12 23:11:37 2012 +0300

    More API implementations and testext improvements.

diff --git a/ChangeLog b/ChangeLog
index d6bad9e..1b071e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,12 @@
 2012-06-12         Arnold D. Robbins     <address@hidden>
 
+       API Work:
+
        * gawkapi.h (awk_value_t): Restore union.
        (get_curfunc_param): Renamed to get_argument. Return type changed
        to awk_bool_t. Semantics better thought out and documented.
        (awk_atexit, get_array_element): Return type now void.
        (sym_lookup): Return type now void. Argument order rationalized.
-
        * gawkapi.c (node_to_awk_value): Return type is now awk_bool_t.
        Semantics now match table in gawkawpi.h.
        (api_awk_atexit): Return type now void.
@@ -13,6 +14,21 @@
        order.
        (api_get_array_element): Return type is now awk_bool_t.
 
+       Further API implementations and fixes for extension/testext.c:
+
+       * awk.h (final_exit): Add declaration.
+       * ext.c (load_ext): Change `func' to install_func.
+       * gawkapi.c: Add casts to void for id param in all functions.
+       (api_sym_update): Finish implementation.
+       (api_get_array_element): Start implementation.
+       (api_set_array_element): Add error checking.
+       (api_get_element_count): Add error checking, return the right value.
+       * main.c (main): Call final_exit instead of exit.
+       (arg_assign): Ditto.
+       * msg.c (final_exit): New routine to run the exit handlers and exit.
+       (gawk_exit): Call it.
+       * profile.c (dump_and_exit): Ditto.
+
 2012-06-10         Andrew J. Schorr     <address@hidden>
 
        * TODO.xgawk: Addition of time extension moved to "done" section.
diff --git a/awk.h b/awk.h
index d8aa238..6c1e706 100644
--- a/awk.h
+++ b/awk.h
@@ -1604,6 +1604,7 @@ extern int mpg_strtoui(mpz_ptr, char *, size_t, char **, 
int);
 #endif
 /* msg.c */
 extern void gawk_exit(int status);
+extern void final_exit(int status) ATTRIBUTE_NORETURN;
 extern void err(const char *s, const char *emsg, va_list argp) 
ATTRIBUTE_PRINTF(2, 0);
 extern void msg (const char *mesg, ...) ATTRIBUTE_PRINTF_1;
 extern void error (const char *mesg, ...) ATTRIBUTE_PRINTF_1;
diff --git a/ext.c b/ext.c
index 66ea7fb..d0755cc 100644
--- a/ext.c
+++ b/ext.c
@@ -60,7 +60,7 @@ do_ext(int nargs)
 NODE *
 load_ext(const char *lib_name, const char *init_func)
 {
-       int (*func)(const gawk_api_t *const, awk_ext_id_t);
+       int (*install_func)(const gawk_api_t *const, awk_ext_id_t);
        void *dl;
        int flags = RTLD_LAZY;
        int *gpl_compat;
@@ -80,12 +80,13 @@ load_ext(const char *lib_name, const char *init_func)
        if (gpl_compat == NULL)
                fatal(_("load_ext: library `%s': does not define 
`plugin_is_GPL_compatible' (%s)\n"),
                                lib_name, dlerror());
-       func = (int (*)(const gawk_api_t *const, awk_ext_id_t)) dlsym(dl, 
init_func);
-       if (func == NULL)
+       install_func = (int (*)(const gawk_api_t *const, awk_ext_id_t))
+                               dlsym(dl, init_func);
+       if (install_func == NULL)
                fatal(_("load_ext: library `%s': cannot call function `%s' 
(%s)\n"),
                                lib_name, init_func, dlerror());
 
-       if ((*func)(& api_impl, NULL /* ext_id */) == 0) {
+       if (install_func(& api_impl, NULL /* ext_id */) == 0) {
                warning(_("load_ext: library `%s' initialization routine `%s' 
failed\n"),
                                lib_name, init_func);
                return make_number(-1);
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 6c4ea84..4d504fb 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,5 +1,7 @@
 2012-06-12         Arnold D. Robbins     <address@hidden>
 
+       Revise API:
+
        * filefuncs.c (do_chdir): Replace get_curfunc_param with get_argument.
        (format_mode): Use unsigned masks.
        (do_stat): Replace get_curfunc_param with get_argument.
@@ -10,6 +12,14 @@
        * time.c (do_sleep): Replace get_curfunc_param with get_argument.
        Replace set_ERRNO with update_ERRNO_str for no way to sleep case.
 
+       Work on testext.c:
+
+       * Makefile.am: Add stuff to make testext. Remove doit and steps
+       from EXTRA_DIST.
+       * testext.c: Fill in many of the test routines. Still more to do.
+       Fix up test scripts for each routine.
+       * time.c (do_sleep): Fix use of get_argument to be boolean.
+
 2012-06-10         Andrew J. Schorr     <address@hidden>
 
        * Makefile.am: Add time extension.
diff --git a/extension/Makefile.am b/extension/Makefile.am
index f2b30ed..bdb1bd1 100644
--- a/extension/Makefile.am
+++ b/extension/Makefile.am
@@ -36,6 +36,7 @@ pkgextension_LTLIBRARIES =    \
        fork.la         \
        ordchr.la       \
        readfile.la     \
+       testext.la      \
        time.la
 
 MY_MODULE_FLAGS = -module -avoid-version -no-undefined
@@ -50,12 +51,12 @@ readfile_la_SOURCES   = readfile.c
 readfile_la_LDFLAGS   = $(MY_MODULE_FLAGS)
 time_la_SOURCES       = time.c
 time_la_LDFLAGS       = $(MY_MODULE_FLAGS)
+testext_la_SOURCES       = testext.c
+testext_la_LDFLAGS       = $(MY_MODULE_FLAGS)
 #rwarray_la_SOURCES    = rwarray.c
 #rwarray_la_LDFLAGS    = $(MY_MODULE_FLAGS)
 
 EXTRA_DIST = \
        ChangeLog \
        ChangeLog.0 \
-       *.awk \
-       doit \
-       steps
+       *.awk
diff --git a/extension/Makefile.in b/extension/Makefile.in
index 5952891..202989a 100644
--- a/extension/Makefile.in
+++ b/extension/Makefile.in
@@ -154,6 +154,12 @@ readfile_la_OBJECTS = $(am_readfile_la_OBJECTS)
 readfile_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(readfile_la_LDFLAGS) $(LDFLAGS) -o $@
+testext_la_LIBADD =
+am_testext_la_OBJECTS = testext.lo
+testext_la_OBJECTS = $(am_testext_la_OBJECTS)
+testext_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(testext_la_LDFLAGS) $(LDFLAGS) -o $@
 time_la_LIBADD =
 am_time_la_OBJECTS = time.lo
 time_la_OBJECTS = $(am_time_la_OBJECTS)
@@ -174,9 +180,11 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) 
$(LIBTOOLFLAGS) \
        --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
        $(LDFLAGS) -o $@
 SOURCES = $(filefuncs_la_SOURCES) $(fork_la_SOURCES) \
-       $(ordchr_la_SOURCES) $(readfile_la_SOURCES) $(time_la_SOURCES)
+       $(ordchr_la_SOURCES) $(readfile_la_SOURCES) \
+       $(testext_la_SOURCES) $(time_la_SOURCES)
 DIST_SOURCES = $(filefuncs_la_SOURCES) $(fork_la_SOURCES) \
-       $(ordchr_la_SOURCES) $(readfile_la_SOURCES) $(time_la_SOURCES)
+       $(ordchr_la_SOURCES) $(readfile_la_SOURCES) \
+       $(testext_la_SOURCES) $(time_la_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -329,6 +337,7 @@ pkgextension_LTLIBRARIES = \
        fork.la         \
        ordchr.la       \
        readfile.la     \
+       testext.la      \
        time.la
 
 MY_MODULE_FLAGS = -module -avoid-version -no-undefined
@@ -342,14 +351,14 @@ readfile_la_SOURCES = readfile.c
 readfile_la_LDFLAGS = $(MY_MODULE_FLAGS)
 time_la_SOURCES = time.c
 time_la_LDFLAGS = $(MY_MODULE_FLAGS)
+testext_la_SOURCES = testext.c
+testext_la_LDFLAGS = $(MY_MODULE_FLAGS)
 #rwarray_la_SOURCES    = rwarray.c
 #rwarray_la_LDFLAGS    = $(MY_MODULE_FLAGS)
 EXTRA_DIST = \
        ChangeLog \
        ChangeLog.0 \
-       *.awk \
-       doit \
-       steps
+       *.awk
 
 all: config.h
        $(MAKE) $(AM_MAKEFLAGS) all-am
@@ -447,6 +456,8 @@ ordchr.la: $(ordchr_la_OBJECTS) $(ordchr_la_DEPENDENCIES) 
$(EXTRA_ordchr_la_DEPE
        $(ordchr_la_LINK) -rpath $(pkgextensiondir) $(ordchr_la_OBJECTS) 
$(ordchr_la_LIBADD) $(LIBS)
 readfile.la: $(readfile_la_OBJECTS) $(readfile_la_DEPENDENCIES) 
$(EXTRA_readfile_la_DEPENDENCIES) 
        $(readfile_la_LINK) -rpath $(pkgextensiondir) $(readfile_la_OBJECTS) 
$(readfile_la_LIBADD) $(LIBS)
+testext.la: $(testext_la_OBJECTS) $(testext_la_DEPENDENCIES) 
$(EXTRA_testext_la_DEPENDENCIES) 
+       $(testext_la_LINK) -rpath $(pkgextensiondir) $(testext_la_OBJECTS) 
$(testext_la_LIBADD) $(LIBS)
 time.la: $(time_la_OBJECTS) $(time_la_DEPENDENCIES) 
$(EXTRA_time_la_DEPENDENCIES) 
        $(time_la_LINK) -rpath $(pkgextensiondir) $(time_la_OBJECTS) 
$(time_la_LIBADD) $(LIBS)
 
@@ -460,6 +471,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
address@hidden@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 
 .c.o:
diff --git a/extension/testext.c b/extension/testext.c
index 5b171e8..fa8dbf6 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -50,18 +50,20 @@ int plugin_is_GPL_compatible;
  */
 
 /*
address@hidden testext
-BEGIN {
-       dump_procinfo()
-}
address@hidden "testext"
+#BEGIN {
+#      dump_procinfo()
+#}
 */
 static awk_value_t *
 dump_procinfo(int nargs, awk_value_t *result)
 {
        /* get PROCINFO as flat array and print it */
+       return result;
 }
 
 /*
address@hidden "testext"
 BEGIN {
        testvar = "One Adam Twelve"
        ret = var_test("testvar")
@@ -72,19 +74,45 @@ BEGIN {
 static awk_value_t *
 var_test(int nargs, awk_value_t *result)
 {
-       awk_value_t value;
+       awk_value_t value, value2;
+       awk_value_t *valp;
 
-       if (nargs != 1 || result == NULL)
+       if (nargs != 1 || result == NULL) {
+               printf("var_test: nargs not right (%d should be 1) or result == 
NULL\n", nargs);
                return NULL;
+       }
 
        /* look up a reserved variable - should fail */
-       if (sym_lookup("ARGC", & value, AWK_NUMBER) != NULL)
+       if (sym_lookup("ARGC", AWK_NUMBER, & value))
                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 */
+       if (get_argument(0, AWK_STRING, & value)) {
+               if (sym_lookup(value.str_value.str, AWK_STRING, & value2)) {
+                       /* change the value, should be reflected in awk script 
*/
+                       valp = make_number(42.0, & value2);
+
+                       if (sym_update(value.str_value.str, valp)) {
+                               printf("var_test: sym_update(\"%s\") 
succeeded\n", value.str_value.str);
+                       } else {
+                               printf("var_test: sym_update(\"%s\") failed\n", 
value.str_value.str);
+                               return NULL;
+                       }
+               } else {
+                       printf("var_test: sym_lookup(\"%s\") failed\n", 
value.str_value.str);
+                       return NULL;
+               }
+       } else {
+               printf("var_test: get_argument() failed\n");
+               return NULL;
+       }
+
+       result->val_type = AWK_NUMBER;
+       result->num_value = 1.0;
+
+       return result;
 }
 
 /*
@@ -97,7 +125,17 @@ BEGIN {
 static awk_value_t *
 test_errno(int nargs, awk_value_t *result)
 {
+       if (nargs != 0 || result == NULL) {
+               printf("test_errno: nargs not right (%d should be 0) or result 
== NULL\n", nargs);
+               return NULL;
+       }
+
        update_ERRNO_int(ECHILD);
+
+       result->val_type = AWK_NUMBER;
+       result->num_value = 1.0;
+
+       return result;
 }
 
 /*
@@ -105,7 +143,7 @@ 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)
+       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)
 }
@@ -114,24 +152,62 @@ BEGIN {
 static awk_value_t *
 test_array_size(int nargs, awk_value_t *result)
 {
+       awk_value_t value;
+       size_t count = 0;
+
+       if (nargs != 1 || result == NULL) {
+               printf("test_array_size: nargs not right (%d should be 0) or 
result == NULL\n", nargs);
+               return NULL;
+       }
+
        /* get element count and print it; should match length(array) from awk 
script */
+       if (! get_argument(0, AWK_ARRAY, & value)) {
+               printf("test_array_size: get_argument failed\n");
+               return NULL;
+       }
+
+       if (! get_element_count(value.array_cookie, & count)) {
+               printf("test_array_size: get_element_count failed\n");
+               return NULL;
+       }
+
+       printf("test_array_size: incoming size is %lu\n", (unsigned long) 
count);
+
        /* clear array - length(array) should then go to zero in script */
+       if (! clear_array(value.array_cookie)) {
+               printf("test_array_size: clear_array failed\n");
+               return NULL;
+       }
+
+       result->val_type = AWK_NUMBER;
+       result->num_value = 1.0;
+
+       return result;
 }
 
 /*
-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]
-}
+#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]
+#      if ("5" in test_array2)
+#              printf "error: test_array_elem did not remove element \"5\"\n"
+#      else
+#              printf "test_array_elem did remove element \"5\"\n"
+#}
 */
 static awk_value_t *
 test_array_elem(int nargs, awk_value_t *result)
 {
+       if (nargs != 2 || result == NULL) {
+               printf("test_array_elem: nargs not right (%d should be 2) or 
result == NULL\n", nargs);
+               return NULL;
+       }
        /* look up an array element and print the value */
-       /* change the element */
-       /* delete another element */
+       /* change the element - "3" */
+       /* delete another element - "5" */
        /* change and deletion should be reflected in awk script */
+       return result;
 }
 
 /*
@@ -148,7 +224,17 @@ BEGIN {
 static awk_value_t *
 print_do_lint(int nargs, awk_value_t *result)
 {
+       if (nargs != 0 || result == NULL) {
+               printf("print_do_lint: nargs not right (%d should be 0) or 
result == NULL\n", nargs);
+               return NULL;
+       }
+
        printf("print_do_lint: lint = %d\n", do_lint);
+
+       result->val_type = AWK_NUMBER;
+       result->num_value = 1.0;
+
+       return result;
 }
 
 static void at_exit0(void *data, int exit_status)
@@ -157,7 +243,7 @@ static void at_exit0(void *data, int exit_status)
        if (data)
                printf(" data = %p,", data);
        else
-               printf(" data = <null>,");
+               printf(" data = NULL,");
        printf(" exit_status = %d\n", exit_status);
 }
 
@@ -173,7 +259,7 @@ static void at_exit1(void *data, int exit_status)
                else
                        printf(" (data is NOT & data_for_1),");
        } else
-               printf(" data = <null>,");
+               printf(" data = NULL,");
        printf(" exit_status = %d\n", exit_status);
 }
 
@@ -183,7 +269,7 @@ static void at_exit2(void *data, int exit_status)
        if (data)
                printf(" data = %p,", data);
        else
-               printf(" data = <null>,");
+               printf(" data = NULL,");
        printf(" exit_status = %d\n", exit_status);
 }
 
diff --git a/extension/time.c b/extension/time.c
index 09e71d0..a12a05d 100644
--- a/extension/time.c
+++ b/extension/time.c
@@ -116,7 +116,7 @@ do_sleep(int nargs, awk_value_t *result)
        if  (do_lint && nargs > 1)
                lintwarn(ext_id, "sleep: called with too many arguments");
 
-       if (get_argument(0, AWK_NUMBER, &num) == NULL) {
+       if (! get_argument(0, AWK_NUMBER, &num)) {
                update_ERRNO_string("sleep: missing required numeric argument", 
1);
                return make_number(-1, result);
        }
diff --git a/gawkapi.c b/gawkapi.c
index 885d514..3f9159d 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -42,6 +42,8 @@ api_get_argument(awk_ext_id_t id, size_t count,
        if (result == NULL)
                return false;
 
+       (void) id;
+
        arg = (wanted == AWK_ARRAY
                        ? get_array_argument(count, false)
                        : get_scalar_argument(count, false) );
@@ -81,10 +83,16 @@ awk_value_to_node(const awk_value_t *retval)
 
 /* Functions to print messages */
 /* FIXME: Code duplicate from msg.c. Fix this. */
+
+/* api_fatal --- print a fatal message and exit */
+
 static void
 api_fatal(awk_ext_id_t id, const char *format, ...)
 {
        va_list args;
+
+       (void) id;
+
        va_start(args, format);
        err(_("fatal: "), format, args);
        va_end(args);
@@ -94,19 +102,29 @@ api_fatal(awk_ext_id_t id, const char *format, ...)
        gawk_exit(EXIT_FATAL);
 }
 
+/* api_warning --- print a warning message and exit */
+
 static void
 api_warning(awk_ext_id_t id, const char *format, ...)
 {
        va_list args;
+
+       (void) id;
+
        va_start(args, format);
        err(_("warning: "), format, args);
        va_end(args);
 }
 
+/* api_lintwarn --- print a lint warning message and exit if appropriate */
+
 static void
 api_lintwarn(awk_ext_id_t id, const char *format, ...)
 {
        va_list args;
+
+       (void) id;
+
        va_start(args, format);
        if (lintwarn == r_fatal) {
                err(_("fatal: "), format, args);
@@ -121,31 +139,47 @@ api_lintwarn(awk_ext_id_t id, const char *format, ...)
        }
 }
 
-/* Register an open hook; for opening files read-only */
+/* api_register_open_hook --- register an open hook; for opening files 
read-only */
 
 static void
 api_register_open_hook(awk_ext_id_t id, void* (*open_func)(IOBUF *))
 {
+       (void) id;
+
        register_open_hook(open_func);
 }
 
 /* Functions to update ERRNO */
+
+/* api_update_ERRNO_int --- update ERRNO with an integer value */
+
 static void
 api_update_ERRNO_int(awk_ext_id_t id, int errno_val)
 {
+       (void) id;
+
        update_ERRNO_int(errno_val);
 }
 
+/* api_update_ERRNO_string --- update ERRNO with a string value */
+
 static void
-api_update_ERRNO_string(awk_ext_id_t id, const char *string,
-               awk_bool_t translate)
+api_update_ERRNO_string(awk_ext_id_t id,
+                       const char *string,
+                       awk_bool_t translate)
 {
+       (void) id;
+
        update_ERRNO_string(string, (translate ? TRANSLATE : DONT_TRANSLATE));
 }
 
+/* api_unset_ERRNO --- unset ERRNO */
+
 static void
 api_unset_ERRNO(awk_ext_id_t id)
 {
+       (void) id;
+
        unset_ERRNO();
 }
 
@@ -157,6 +191,9 @@ api_add_ext_func(awk_ext_id_t id,
                const awk_ext_func_t *func,
                const char *namespace)
 {
+       (void) id;
+       (void) namespace;
+
        return make_builtin(func);
 }
 
@@ -193,6 +230,8 @@ api_awk_atexit(awk_ext_id_t id,
 {
        struct ext_exit_handler *p;
 
+       (void) id;
+
        /* allocate memory */
        emalloc(p, struct ext_exit_handler *, sizeof(struct ext_exit_handler), 
"api_awk_atexit");
 
@@ -300,6 +339,9 @@ node_to_awk_value(NODE *node, awk_value_t *val, 
awk_valtype_t wanted)
  * In the latter case, fills in vaule->val_type with the real type.
  * Built-in variables (except PROCINFO) may not be accessed by an extension.
  */
+
+/* api_sym_lookup --- look up a symbol */
+
 static awk_bool_t
 api_sym_lookup(awk_ext_id_t id,
                const char *name,
@@ -318,27 +360,13 @@ api_sym_lookup(awk_ext_id_t id,
        return node_to_awk_value(node, result, wanted);
 }
 
-/* api_sym_update --- update a value, see gawkapi.h for semantics */
+/* api_sym_update --- update a symbol's value, see gawkapi.h for semantics */
 
 static awk_bool_t
 api_sym_update(awk_ext_id_t id, const char *name, awk_value_t *value)
 {
        NODE *node;
 
-       if (   name == NULL
-           || *name == '\0'
-           || value == NULL
-           || is_off_limits_var(name)) /* most built-in vars not allowed */
-               return false;
-
-       node = lookup(name);
-
-       if (node == NULL) {
-               /* new value to be installed */
-       } else {
-               /* existing value to be updated */
-       }
-
        switch (value->val_type) {
        case AWK_NUMBER:
        case AWK_STRING:
@@ -349,11 +377,27 @@ api_sym_update(awk_ext_id_t id, const char *name, 
awk_value_t *value)
                return false;
 
        default:
-               fatal(_("api_sym_update: invalid value for type of new value 
(%d)"), value->val_type);
+               /* fatal(_("api_sym_update: invalid value for type of new value 
(%d)"), value->val_type); */
                return false;
        }
 
-       return true;    /* for now */
+       if (   name == NULL
+           || *name == '\0'
+           || is_off_limits_var(name)  /* most built-in vars not allowed */
+           || value == NULL)
+               return false;
+
+       node = lookup(name);
+
+       if (node == NULL) {
+               /* new value to be installed */
+               node = install_symbol((char *) name, Node_var);
+       }
+       unref(node->var_value);
+
+       node->var_value = awk_value_to_node(value);
+
+       return true;
 }
 
 /* Array management */
@@ -366,6 +410,21 @@ api_get_array_element(awk_ext_id_t id,
                awk_array_t a_cookie, const awk_value_t *const index,
                awk_valtype_t wanted, awk_value_t *result)
 {
+       NODE *array;
+       NODE *subscript;
+
+       /* don't check for index len zero, null str is ok as index */
+       if (   a_cookie == NULL
+           || result == NULL
+           || index == NULL
+           || index->val_type != AWK_STRING
+           || index->str_value.str == NULL)
+               return false;
+
+       array = (NODE *) a_cookie;
+       subscript = awk_value_to_node(index);
+       /* FIXME: write rest of code */
+
        return true;    /* for now */
 }
 
@@ -381,6 +440,12 @@ api_set_array_element(awk_ext_id_t id, awk_array_t 
a_cookie,
        NODE *tmp;
        NODE **aptr;
 
+       /* don't check for index len zero, null str is ok as index */
+       if (   a_cookie == NULL
+           || element == NULL
+           || element->index.str == NULL)
+               return false;
+
        tmp = make_string(element->index.str, element->index.len);
        aptr = assoc_lookup(array, tmp);
        unref(tmp);
@@ -410,10 +475,10 @@ api_get_element_count(awk_ext_id_t id,
 {
        NODE *node = (NODE *) a_cookie;
 
-       if (node == NULL || node->type != Node_var_array)
+       if (count == NULL || node == NULL || node->type != Node_var_array)
                return false;
 
-       *count = node->array_size;
+       *count = node->table_size;
        return true;
 }
 
diff --git a/main.c b/main.c
index 91da77d..b3f7f9e 100644
--- a/main.c
+++ b/main.c
@@ -731,7 +731,7 @@ out:
        if (extra_stack)
                efree(extra_stack);
 
-       exit(exit_val);         /* more portable */
+       final_exit(exit_val);
        return exit_val;        /* to suppress warnings */
 }
 
@@ -1318,7 +1318,7 @@ arg_assign(char *arg, bool initing)
 
                var = variable(0, cp2, Node_var);
                if (var == NULL)        /* error */
-                       exit(EXIT_FATAL);
+                       final_exit(EXIT_FATAL);
                if (var->type == Node_var && var->var_update)
                        var->var_update();
                lhs = get_lhs(var, false);
diff --git a/msg.c b/msg.c
index 22cf556..b94e840 100644
--- a/msg.c
+++ b/msg.c
@@ -159,6 +159,14 @@ gawk_exit(int status)
                longjmp(fatal_tag, 1);
        }
 
+       final_exit(status);
+}
+
+/* final_exit --- run extension exit handlers and exit */
+
+void
+final_exit(int status)
+{
        /* run any extension exit handlers */
        run_ext_exit_handlers(status);
 
diff --git a/profile.c b/profile.c
index 15c9879..16aa1cd 100644
--- a/profile.c
+++ b/profile.c
@@ -922,7 +922,7 @@ static RETSIGTYPE
 dump_and_exit(int signum)
 {
        just_dump(signum);
-       exit(EXIT_FAILURE);
+       final_exit(EXIT_FAILURE);
 }
 
 

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

commit 820b6a2ccb7859e15ade36af6ac1d0d08c1da4b1
Author: Arnold D. Robbins <address@hidden>
Date:   Tue Jun 12 22:10:31 2012 +0300

    Further cleanups and improvements in API.

diff --git a/ChangeLog b/ChangeLog
index fb7b6ae..d6bad9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2012-06-12         Arnold D. Robbins     <address@hidden>
+
+       * gawkapi.h (awk_value_t): Restore union.
+       (get_curfunc_param): Renamed to get_argument. Return type changed
+       to awk_bool_t. Semantics better thought out and documented.
+       (awk_atexit, get_array_element): Return type now void.
+       (sym_lookup): Return type now void. Argument order rationalized.
+
+       * gawkapi.c (node_to_awk_value): Return type is now awk_bool_t.
+       Semantics now match table in gawkawpi.h.
+       (api_awk_atexit): Return type now void.
+       (api_sym_lookup): Return type is now awk_bool_t. Change parameter
+       order.
+       (api_get_array_element): Return type is now awk_bool_t.
+
 2012-06-10         Andrew J. Schorr     <address@hidden>
 
        * TODO.xgawk: Addition of time extension moved to "done" section.
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 5e513f8..6c4ea84 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,15 @@
+2012-06-12         Arnold D. Robbins     <address@hidden>
+
+       * filefuncs.c (do_chdir): Replace get_curfunc_param with get_argument.
+       (format_mode): Use unsigned masks.
+       (do_stat): Replace get_curfunc_param with get_argument.
+       * fork.c (do_fork): Rearrange arg order in call to sym_lookup
+       (do_waitpid): Replace get_curfunc_param with get_argument.
+       * ordchr.c (do_ord, do_chr): Replace get_curfunc_param with 
get_argument.
+       * readfile.c (do_readfile): Replace get_curfunc_param with get_argument.
+       * time.c (do_sleep): Replace get_curfunc_param with get_argument.
+       Replace set_ERRNO with update_ERRNO_str for no way to sleep case.
+
 2012-06-10         Andrew J. Schorr     <address@hidden>
 
        * Makefile.am: Add time extension.
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 4d38200..12f3acb 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -57,7 +57,7 @@ do_chdir(int nargs, awk_value_t *result)
        if (do_lint && nargs != 1)
                lintwarn(ext_id, "chdir: called with incorrect number of 
arguments, expecting 1");
 
-       if (get_curfunc_param(0, AWK_STRING, & newdir) != NULL) {
+       if (get_argument(0, AWK_STRING, & newdir)) {
                ret = chdir(newdir.str_value.str);
                if (ret < 0)
                        update_ERRNO_int(errno);
@@ -73,7 +73,7 @@ format_mode(unsigned long fmode)
 {
        static char outbuf[12];
        static struct ftype_map {
-               int mask;
+               unsigned int mask;
                int charval;
        } ftype_map[] = {
                { S_IFREG, '-' },       /* redundant */
@@ -94,7 +94,7 @@ format_mode(unsigned long fmode)
 #endif /* S_IFDOOR */
        };
        static struct mode_map {
-               int mask;
+               unsigned int mask;
                int rep;
        } map[] = {
                { S_IRUSR, 'r' }, { S_IWUSR, 'w' }, { S_IXUSR, 'x' },
@@ -102,7 +102,7 @@ format_mode(unsigned long fmode)
                { S_IROTH, 'r' }, { S_IWOTH, 'w' }, { S_IXOTH, 'x' },
        };
        static struct setuid_map {
-               int mask;
+               unsigned int mask;
                int index;
                int small_rep;
                int big_rep;
@@ -243,7 +243,7 @@ do_stat(int nargs, awk_value_t *result)
        const char *type = "unknown";
        awk_value_t tmp;
        static struct ftype_map {
-               int mask;
+               unsigned int mask;
                const char *type;
        } ftype_map[] = {
                { S_IFREG, "file" },
@@ -270,8 +270,8 @@ do_stat(int nargs, awk_value_t *result)
        }
 
        /* file is first arg, array to hold results is second */
-       if (   get_curfunc_param(0, AWK_STRING, & file_param) == NULL
-           || get_curfunc_param(1, AWK_ARRAY, & array_param) == NULL) {
+       if (   ! get_argument(0, AWK_STRING, & file_param)
+           || ! get_argument(1, AWK_ARRAY, & array_param)) {
                warning(ext_id, "stat: bad parameters");
                return make_number(-1, result);
        }
diff --git a/extension/fork.c b/extension/fork.c
index 1d4ad82..0c2e31d 100644
--- a/extension/fork.c
+++ b/extension/fork.c
@@ -78,7 +78,7 @@ do_fork(int nargs, awk_value_t *result)
                /* update PROCINFO in the child, if the array exists */
                awk_value_t procinfo;
 
-               if (sym_lookup("PROCINFO", & procinfo, AWK_ARRAY) != NULL) {
+               if (sym_lookup("PROCINFO", AWK_ARRAY, & procinfo)) {
                        if (procinfo.val_type != AWK_ARRAY) {
                                if (do_lint)
                                        lintwarn(ext_id, "fork: PROCINFO is not 
an array!");
@@ -105,7 +105,7 @@ do_waitpid(int nargs, awk_value_t *result)
        if  (do_lint && nargs > 1)
                lintwarn(ext_id, "waitpid: called with too many arguments");
 
-       if (get_curfunc_param(0, AWK_NUMBER, &pid) != NULL) {
+       if (get_argument(0, AWK_NUMBER, &pid)) {
                options = WNOHANG|WUNTRACED;
                ret = waitpid(pid.num_value, NULL, options);
                if (ret < 0)
diff --git a/extension/ordchr.c b/extension/ordchr.c
index c5d2bb4..dc02479 100644
--- a/extension/ordchr.c
+++ b/extension/ordchr.c
@@ -56,7 +56,7 @@ do_ord(int nargs, awk_value_t *result)
        if  (do_lint && nargs > 1)
                lintwarn(ext_id, "ord: called with too many arguments");
 
-       if (get_curfunc_param(0, AWK_STRING, & str) != NULL) {
+       if (get_argument(0, AWK_STRING, & str)) {
                ret = str.str_value.str[0];
        } else if (do_lint)
                lintwarn(ext_id, "ord: called with no arguments");
@@ -80,7 +80,7 @@ do_chr(int nargs, awk_value_t *result)
        if  (do_lint && nargs > 1)
                lintwarn(ext_id, "chr: called with too many arguments");
 
-       if (get_curfunc_param(0, AWK_NUMBER, &num) != NULL) {
+       if (get_argument(0, AWK_NUMBER, & num)) {
                val = num.num_value;
                ret = val;      /* convert to int */
                ret &= 0xff;
diff --git a/extension/readfile.c b/extension/readfile.c
index ca51391..166bb8f 100644
--- a/extension/readfile.c
+++ b/extension/readfile.c
@@ -66,7 +66,7 @@ do_readfile(int nargs, awk_value_t *result)
        if  (do_lint && nargs > 1)
                lintwarn(ext_id, "readfile: called with too many arguments");
 
-       if (get_curfunc_param(0, AWK_STRING, &filename) != NULL) {
+       if (get_argument(0, AWK_STRING, &filename)) {
                ret = stat(filename.str_value.str, & sbuf);
                if (ret < 0) {
                        update_ERRNO_int(errno);
diff --git a/extension/time.c b/extension/time.c
index 4f590c8..09e71d0 100644
--- a/extension/time.c
+++ b/extension/time.c
@@ -116,8 +116,7 @@ do_sleep(int nargs, awk_value_t *result)
        if  (do_lint && nargs > 1)
                lintwarn(ext_id, "sleep: called with too many arguments");
 
-
-       if (get_curfunc_param(0, AWK_NUMBER, &num) == NULL) {
+       if (get_argument(0, AWK_NUMBER, &num) == NULL) {
                update_ERRNO_string("sleep: missing required numeric argument", 
1);
                return make_number(-1, result);
        }
@@ -151,7 +150,7 @@ do_sleep(int nargs, awk_value_t *result)
 #else
        /* no way to sleep on this platform */
        rc = -1;
-       set_ERRNO("sleep: not supported on this platform");
+       update_ERRNO_str("sleep: not supported on this platform", 0);
 #endif
 
        return make_number(rc, result);
diff --git a/gawkapi.c b/gawkapi.c
index 95bcbf1..885d514 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -25,24 +25,32 @@
 
 #include "awk.h"
 
-static awk_value_t *node_to_awk_value(NODE *node, awk_value_t *result, 
awk_valtype_t wanted);
+static awk_bool_t node_to_awk_value(NODE *node, awk_value_t *result, 
awk_valtype_t wanted);
 
 /*
  * Get the count'th paramater, zero-based.
- * Returns NULL if count is out of range, or if actual paramater
- * does not match what is specified in wanted.
+ * 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_value_t *
-api_get_curfunc_param(awk_ext_id_t id, size_t count,
+static awk_bool_t
+api_get_argument(awk_ext_id_t id, size_t count,
                        awk_valtype_t wanted, awk_value_t *result)
 {
        NODE *arg;
 
+       if (result == NULL)
+               return false;
+
        arg = (wanted == AWK_ARRAY
                        ? get_array_argument(count, false)
                        : get_scalar_argument(count, false) );
-       if (arg == NULL)
-               return NULL;
+
+       if (arg == NULL) {
+               memset(result, 0, sizeof(*result));
+               result->val_type = AWK_UNDEFINED;
+               return false;
+       }
 
        return node_to_awk_value(arg, result, wanted);
 }
@@ -142,7 +150,8 @@ api_unset_ERRNO(awk_ext_id_t id)
 }
 
 
-/* Add a function to the interpreter, returns true upon success */
+/* api_add_ext_func --- add a function to the interpreter, returns true upon 
success */
+
 static awk_bool_t
 api_add_ext_func(awk_ext_id_t id,
                const awk_ext_func_t *func,
@@ -177,7 +186,7 @@ run_ext_exit_handlers(int exitval)
 
 /* api_awk_atexit --- add an exit call back, returns true upon success */
 
-static awk_bool_t
+static void
 api_awk_atexit(awk_ext_id_t id,
                void (*funcp)(void *data, int exit_status),
                void *arg0)
@@ -194,73 +203,87 @@ api_awk_atexit(awk_ext_id_t id,
        /* add to linked list, LIFO order */
        p->next = list_head;
        list_head = p;
-       return true;    /* for now */
 }
 
 /* node_to_awk_value --- convert a node into a value for an extension */
 
-static awk_value_t *
+static awk_bool_t
 node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted)
 {
-       /* clear out the result */
-       memset(val, 0, sizeof(*val));
+       awk_bool_t ret = false;
 
-       switch (wanted) {
-       case AWK_NUMBER:
-       case AWK_STRING:
-               /* handle it below */
-               break;
-
-       case AWK_UNDEFINED:
-               /* ignore the actual value. weird but could happen */
+       switch (node->type) {
+       case Node_var_new:      /* undefined variable */
                val->val_type = AWK_UNDEFINED;
-               return val;
-
-       case AWK_ARRAY:
-               if (node->type == Node_var_array) {
-                       val->val_type = AWK_ARRAY;
-                       val->array_cookie = node;
-
-                       return val;
+               if (wanted == AWK_UNDEFINED) {
+                       ret = true;
                }
-               return NULL;
-
-       default:
-               fatal(_("node_to_awk_value: invalid value for `wanted' (%d)"), 
wanted);
                break;
-       }
 
-       /* get here only for string or number */
-
-       switch (node->type) {
        case Node_var:
                node = node->var_value;
                /* FALL THROUGH */
        case Node_val:
-               /* make sure both values are valid */
-               (void) force_number(node);
-               (void) force_string(node);
-
-               if (wanted == AWK_NUMBER) {
+               /* a scalar value */
+               switch (wanted) {
+               case AWK_NUMBER:
                        val->val_type = AWK_NUMBER;
-                       val->num_value = get_number_d(node);
-                       val->str_value.str = node->stptr;
-                       val->str_value.len = node->stlen;
-               } else if (wanted == AWK_STRING) {
+
+                       (void) force_number(node);
+                       if (node->flags & NUMCUR) {
+                               val->num_value = get_number_d(node);
+                               ret = true;
+                       }
+                       break;
+
+               case AWK_STRING:
                        val->val_type = AWK_STRING;
-                       val->str_value.str = node->stptr;
-                       val->str_value.len = node->stlen;
-                       val->num_value = get_number_d(node);
+
+                       (void) force_string(node);
+                       if (node->flags & STRCUR) {
+                               val->str_value.str = node->stptr;
+                               val->str_value.len = node->stlen;
+                               ret = true;
+                       }
+                       break;
+
+               case AWK_UNDEFINED:
+                       /* return true and actual type for request of undefined 
*/
+                       if (node->flags & NUMBER) {
+                               val->val_type = AWK_NUMBER;
+                               val->num_value = get_number_d(node);
+                               ret = true;
+                       } else if (node->flags & STRING) {
+                               val->val_type = AWK_STRING;
+                               val->str_value.str = node->stptr;
+                               val->str_value.len = node->stlen;
+                               ret = true;
+                       } else
+                               val->val_type = AWK_UNDEFINED;
+                       break;
+
+               case AWK_ARRAY:
+                       break;
                }
-               return val;
+               break;
 
-       case Node_var_new:
        case Node_var_array:
+               val->val_type = AWK_ARRAY;
+               if (wanted == AWK_ARRAY || wanted == AWK_UNDEFINED) {
+                       val->array_cookie = node;
+                       ret = true;
+               } else {
+                       ret = false;
+               }
+               break;
+
        default:
+               val->val_type = AWK_UNDEFINED;
+               ret = false;
                break;
        }
 
-       return NULL;
+       return ret;
 }
 
 /*
@@ -271,22 +294,26 @@ node_to_awk_value(NODE *node, awk_value_t *val, 
awk_valtype_t wanted)
  *       to scalar or array. 
  */
 /*
- * Lookup a variable, return its value. No messing with the value
- * returned. Return value is NULL if the variable doesn't exist.
- * Built-in variables (except PROCINFO) may not be changed by an extension.
+ * Lookup a variable, fills in value. No messing with the value
+ * returned. Returns false if the variable doesn't exist
+ * or the wrong type was requested.
+ * In the latter case, fills in vaule->val_type with the real type.
+ * Built-in variables (except PROCINFO) may not be accessed by an extension.
  */
-static awk_value_t *
+static awk_bool_t
 api_sym_lookup(awk_ext_id_t id,
-               const char *name, awk_value_t *result,
-               awk_valtype_t wanted)
+               const char *name,
+               awk_valtype_t wanted,
+               awk_value_t *result)
 {
        NODE *node;
 
        if (   name == NULL
            || *name == '\0'
+           || result == NULL
            || is_off_limits_var(name)  /* most built-in vars not allowed */
            || (node = lookup(name)) == NULL)
-               return NULL;
+               return false;
 
        return node_to_awk_value(node, result, wanted);
 }
@@ -334,12 +361,12 @@ api_sym_update(awk_ext_id_t id, const char *name, 
awk_value_t *value)
  * Return the value of an element - read only!
  * Use set_array_element to change it.
  */
-static awk_value_t *
+static awk_bool_t
 api_get_array_element(awk_ext_id_t id,
                awk_array_t a_cookie, const awk_value_t *const index,
-               awk_value_t *result, awk_valtype_t wanted)
+               awk_valtype_t wanted, awk_value_t *result)
 {
-       return NULL;    /* for now */
+       return true;    /* for now */
 }
 
 /*
@@ -438,7 +465,7 @@ gawk_api_t api_impl = {
        GAWK_API_MINOR_VERSION,
        { 0 },                  /* do_flags */
 
-       api_get_curfunc_param,
+       api_get_argument,
 
        api_fatal,
        api_warning,
diff --git a/gawkapi.h b/gawkapi.h
index 09a1ce7..7e6a66f 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -116,15 +116,18 @@ typedef void *awk_array_t;
 
 /*
  * An awk value. The val_type tag indicates what
- * is contained.  For scalars, gawk fills in both kinds
- * of values and val_type indicates the assigned type.
- * For arrays, the scalar types will be set to zero.
+ * is in the union.
  */
 typedef struct {
        awk_valtype_t   val_type;
-       awk_string_t    str_value;
-       double          num_value;
-       awk_array_t     array_cookie;
+       union {
+               awk_string_t    s;
+               double          d;
+               awk_array_t     a;
+       } u;
+#define str_value      u.s
+#define num_value      u.d
+#define array_cookie   u.a
 } awk_value_t;
 
 /*
@@ -195,10 +198,27 @@ typedef struct gawk_api {
 
        /*
         * Get the count'th paramater, zero-based.
-        * Returns NULL if count is out of range, or if actual paramater
-        * does not match what is specified in wanted.
+        * Returns false if count is out of range, or if actual paramater
+        * does not match what is specified in wanted. In that case,
+        * result->val_type will hold the actual type of what was passed.
+
+       Table entry is type returned:
+
+                             +-----------------------------------------+
+                             |               Type Requested:           |
+                             +----------+----------+-------+-----------+
+                             |  String  |  Number  | Array | Undefined |
+       +---------+-----------+----------+----------+-------+-----------+
+       | Type    | String    |  String  |   false  | false |   String  |
+       | of      +-----------+----------+----------+-------+-----------+
+       | Actual  | Number    |   false  |  Number  | false |   Number  |
+       | Value:  +-----------+----------+----------+-------+-----------+
+       |         | Array     |   false  |   false  | Array |   Array   |
+       |         +-----------+----------+----------+-------+-----------+
+       |         | Undefined |   false  |   false  | false | Undefined |
+       +---------+-----------+----------+----------+-------+-----------+
         */
-       awk_value_t *(*get_curfunc_param)(awk_ext_id_t id, size_t count,
+       awk_bool_t (*get_argument)(awk_ext_id_t id, size_t count,
                                          awk_valtype_t wanted,
                                          awk_value_t *result);
 
@@ -221,7 +241,7 @@ typedef struct gawk_api {
                        const char *namespace);
 
        /* Add an exit call back, returns true upon success */
-       awk_bool_t (*awk_atexit)(awk_ext_id_t id,
+       void (*awk_atexit)(awk_ext_id_t id,
                        void (*funcp)(void *data, int exit_status),
                        void *arg0);
 
@@ -233,20 +253,23 @@ typedef struct gawk_api {
         *        to scalar or array. 
         */
        /*
-        * Lookup a variable, return its value. No messing with the value
-        * returned. Return value is NULL if the variable doesn't exist.
-        *
-        * Returns a pointer to a static variable. Correct usage is thus:
+        * Lookup a variable, fills in value. No messing with the value
+        * returned. Returns false if the variable doesn't exist
+        * or the wrong type was requested.
+        * In the latter case, fills in vaule->val_type with the real type.
+        * Built-in variables (except PROCINFO) may not be accessed by an 
extension.
         *
         *      awk_value_t val;
-        *      if (api->sym_lookup(id, name, &val, wanted) == NULL)
+        *      if (! api->sym_lookup(id, name, wanted, & val))
         *              error_code();
         *      else {
         *              // safe to use val
         *      }
         */
-       awk_value_t *(*sym_lookup)(awk_ext_id_t id, const char *name, 
awk_value_t *result,
-                       awk_valtype_t wanted);
+       awk_bool_t (*sym_lookup)(awk_ext_id_t id,
+                               const char *name,
+                               awk_valtype_t wanted,
+                               awk_value_t *result);
 
        /*
         * Update a value. Adds it to the symbol table if not there.
@@ -260,10 +283,13 @@ typedef struct gawk_api {
        /*
         * Return the value of an element - read only!
         * Use set_array_element() to change it.
+        * Behavior for value and return is same as for get_argument
+        * and sym_lookup.
         */
-       awk_value_t *(*get_array_element)(awk_ext_id_t id,
+       awk_bool_t (*get_array_element)(awk_ext_id_t id,
                        awk_array_t a_cookie, const awk_value_t *const index,
-                       awk_value_t *result, awk_valtype_t wanted);
+                       awk_valtype_t wanted,
+                       awk_value_t *result);
 
        /*
         * Change (or create) element in existing array with
@@ -321,8 +347,8 @@ typedef struct gawk_api {
 #define do_debug       (api->do_flags[gawk_do_debug])
 #define do_mpfr                (api->do_flags[gawk_do_mpfr])
 
-#define get_curfunc_param(count, wanted, result) \
-       (api->get_curfunc_param(ext_id, count, wanted, result))
+#define get_argument(count, wanted, result) \
+       (api->get_argument(ext_id, count, wanted, result))
 
 #define fatal          api->api_fatal
 #define warning                api->api_warning
diff --git a/test/ChangeLog b/test/ChangeLog
index 72a7c9f..ac8737d 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2012-06-12         Arnold D. Robbins     <address@hidden>
+
+       * Makefile.am (clean): Add fork.tmp.* to the list.
+
 2012-06-10         Andrew J. Schorr     <address@hidden>
 
        * Makefile.am (EXTRA_DIST): Add new files time.awk and time.ok.
diff --git a/test/Makefile.am b/test/Makefile.am
index 6c65ae3..6b052f1 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1588,7 +1588,7 @@ $(srcdir)/Maketests: $(srcdir)/Makefile.am 
$(srcdir)/Gentests
        $(AWK) -f $(srcdir)/Gentests "$(srcdir)/Makefile.am" $$files > 
$(srcdir)/Maketests
 
 clean:
-       rm -fr _* core core.* fmtspcl.ok junk out1 out2 out3 strftime.ok test1 
test2 seq *~ readfile.ok
+       rm -fr _* core core.* fmtspcl.ok junk out1 out2 out3 strftime.ok test1 
test2 seq *~ readfile.ok fork.tmp.*
 
 # An attempt to print something that can be grepped for in build logs
 pass-fail:
diff --git a/test/Makefile.in b/test/Makefile.in
index 2ec9024..05f9db1 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -3195,7 +3195,7 @@ $(srcdir)/Maketests: $(srcdir)/Makefile.am 
$(srcdir)/Gentests
        $(AWK) -f $(srcdir)/Gentests "$(srcdir)/Makefile.am" $$files > 
$(srcdir)/Maketests
 
 clean:
-       rm -fr _* core core.* fmtspcl.ok junk out1 out2 out3 strftime.ok test1 
test2 seq *~ readfile.ok
+       rm -fr _* core core.* fmtspcl.ok junk out1 out2 out3 strftime.ok test1 
test2 seq *~ readfile.ok fork.tmp.*
 
 # An attempt to print something that can be grepped for in build logs
 pass-fail:

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

commit b4a2d75b7d9fd23069a55dc91a42f7fddd0c7570
Merge: 21a01e3 5472c2c
Author: Arnold D. Robbins <address@hidden>
Date:   Tue Jun 12 21:51:41 2012 +0300

    Merge branch 'extgawk' of ssh://git.sv.gnu.org/srv/git/gawk into extgawk


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

commit 21a01e3ad4e2e77dccf73e8fd069370749880757
Author: Arnold D. Robbins <address@hidden>
Date:   Wed Jun 6 22:14:32 2012 +0300

    Hook in extension at_exit functions.

diff --git a/ChangeLog b/ChangeLog
index f7e9ac9..78ae5bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,9 @@
        * eval.c (set_LINT): Call update_ext_api() at the end.
        * gawkapi.h: Document that do_XXX could change on the fly.
 
+       * awk.h (run_ext_exit_handlers): Add declaration.
+       * msg.c (gawk_exit): Call it.
+
 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 280563c..d8aa238 100644
--- a/awk.h
+++ b/awk.h
@@ -707,10 +707,12 @@ struct break_point;
 
 #if 1
 #include "gawkapi.h"
+/* gawkapi.c: */
 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 *);
+extern void run_ext_exit_handlers(int exitval);
 #endif
 
 typedef struct exp_instruction {
diff --git a/msg.c b/msg.c
index c579b62..22cf556 100644
--- a/msg.c
+++ b/msg.c
@@ -158,5 +158,9 @@ gawk_exit(int status)
                exit_val = status;
                longjmp(fatal_tag, 1);
        }
+
+       /* run any extension exit handlers */
+       run_ext_exit_handlers(status);
+
        exit(status);
 }

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

Summary of changes:
 ChangeLog             |   34 +++++++
 awk.h                 |    3 +
 ext.c                 |    9 +-
 extension/ChangeLog   |   22 ++++
 extension/Makefile.am |    7 +-
 extension/Makefile.in |   22 +++-
 extension/filefuncs.c |   14 ++--
 extension/fork.c      |    4 +-
 extension/ordchr.c    |    4 +-
 extension/readfile.c  |    2 +-
 extension/testext.c   |  124 ++++++++++++++++++++----
 extension/time.c      |    5 +-
 gawkapi.c             |  262 +++++++++++++++++++++++++++++++++----------------
 gawkapi.h             |   68 +++++++++----
 main.c                |    4 +-
 msg.c                 |   12 +++
 profile.c             |    2 +-
 test/ChangeLog        |    4 +
 test/Makefile.am      |    2 +-
 test/Makefile.in      |    2 +-
 20 files changed, 449 insertions(+), 157 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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