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. 73533707616e119778993f


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. 73533707616e119778993fe18540098239ecbb2e
Date: Wed, 11 Jul 2012 18:42:28 +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  73533707616e119778993fe18540098239ecbb2e (commit)
      from  6d1724214a95330b63a6a557f89fb9b40b4a521f (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=73533707616e119778993fe18540098239ecbb2e

commit 73533707616e119778993fe18540098239ecbb2e
Author: Arnold D. Robbins <address@hidden>
Date:   Wed Jul 11 21:41:54 2012 +0300

    Add ability to call an initialization routine.

diff --git a/ChangeLog b/ChangeLog
index 2429bd8..8305718 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,8 @@
        (make_const_string): New macro, renamed from dup_string.
        (make_malloced_string): New macro, renamed from make_string.
        (make_null_string): New inline function.
+       (dl_load_func): Add call to init routine through pointer if
+       not NULL.
 
        * gawkapi.c (awk_value_to_node): Assume that string values came
        from malloc.
diff --git a/extension/ChangeLog b/extension/ChangeLog
index be31561..2ea13e3 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -9,6 +9,9 @@
        (test_array_elem): Duplicate strings coming from gawk before passing
        them back in.
 
+       All files: Add null 'init_func' file pointer for dl_load_func
+       to work.
+
 2012-07-09         Arnold D. Robbins     <address@hidden>
 
        * filefuncs.c (do_readfile): Return "" and set ERRNO on error
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 74af8b1..71387cb 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -44,6 +44,7 @@
 
 static const gawk_api_t *api;  /* for convenience macros to work */
 static awk_ext_id_t *ext_id;
+static awk_bool_t (*init_func)(void) = NULL;
 
 int plugin_is_GPL_compatible;
 
diff --git a/extension/fork.c b/extension/fork.c
index 8423266..02b6b6f 100644
--- a/extension/fork.c
+++ b/extension/fork.c
@@ -41,6 +41,7 @@
 
 static const gawk_api_t *api;  /* for convenience macros to work */
 static awk_ext_id_t *ext_id;
+static awk_bool_t (*init_func)(void) = NULL;
 
 int plugin_is_GPL_compatible;
 
diff --git a/extension/ordchr.c b/extension/ordchr.c
index 3ab0f87..7773f1b 100644
--- a/extension/ordchr.c
+++ b/extension/ordchr.c
@@ -43,6 +43,7 @@
 
 static const gawk_api_t *api;  /* for convenience macros to work */
 static awk_ext_id_t *ext_id;
+static awk_bool_t (*init_func)(void) = NULL;
 
 int plugin_is_GPL_compatible;
 
diff --git a/extension/readfile.c b/extension/readfile.c
index 1b6772f..f9a364f 100644
--- a/extension/readfile.c
+++ b/extension/readfile.c
@@ -50,6 +50,7 @@
 
 static const gawk_api_t *api;  /* for convenience macros to work */
 static awk_ext_id_t *ext_id;
+static awk_bool_t (*init_func)(void) = NULL;
 
 int plugin_is_GPL_compatible;
 
diff --git a/extension/rwarray.c b/extension/rwarray.c
index 64c501d..8a74949 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -47,6 +47,7 @@
 
 static const gawk_api_t *api;  /* for convenience macros to work */
 static awk_ext_id_t *ext_id;
+static awk_bool_t (*init_func)(void) = NULL;
 
 int plugin_is_GPL_compatible;
 
diff --git a/extension/testext.c b/extension/testext.c
index 8dac1c2..d446fb8 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -39,6 +39,7 @@
 
 static const gawk_api_t *api;  /* for convenience macros to work */
 static awk_ext_id_t *ext_id;
+static awk_bool_t (*init_func)(void) = NULL;
 
 int plugin_is_GPL_compatible;
 
diff --git a/extension/time.c b/extension/time.c
index 2024510..eb42eee 100644
--- a/extension/time.c
+++ b/extension/time.c
@@ -39,6 +39,7 @@
 
 static const gawk_api_t *api;  /* for convenience macros to work */
 static awk_ext_id_t *ext_id;
+static awk_bool_t (*init_func)(void) = NULL;
 
 int plugin_is_GPL_compatible;
 
diff --git a/gawkapi.h b/gawkapi.h
index 2bef258..9f541cf 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -533,9 +533,13 @@ make_number(double num, awk_value_t *result)
  *
  *     int dl_load(gawk_api_t *api_p, awk_ext_id_t id)
  *
+ * The return value should be zero on failure and non-zero on success.
+ *
  * For the macros to work, the function should save api_p in a global
  * variable named 'api' and save id in a global variable named 'ext_id'.
- * The return value should be zero on failure and non-zero on success.
+ * In addition, a global function pointer named 'init_func' should be
+ * defined and set to either NULL or an initialization function that
+ * returns non-zero on success and zero upon failure.
  */
 
 extern int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id);
@@ -549,6 +553,19 @@ static awk_ext_func_t func_table[] = {
        /* ... */
 };
 
+/* EITHER: */
+
+static awk_bool_t (*init_func)(void) = NULL;
+
+/* OR: */
+
+static awk_bool_t init_my_module(void)
+{
+       ...
+}
+
+static awk_bool_t (*init_func)(void) = init_my_module;
+
 dl_load_func(func_table, some_name, "name_space_in_quotes")
 #endif
 
@@ -579,6 +596,13 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t 
id)  \
                } \
        } \
 \
+       if (init_func != NULL) { \
+               if (! init_func()) { \
+                       warning(ext_id, #module ": initialization function 
failed\n"); \
+                       errors++; \
+               } \
+       } \
+\
        return (errors == 0); \
 }
 

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

Summary of changes:
 ChangeLog             |    2 ++
 extension/ChangeLog   |    3 +++
 extension/filefuncs.c |    1 +
 extension/fork.c      |    1 +
 extension/ordchr.c    |    1 +
 extension/readfile.c  |    1 +
 extension/rwarray.c   |    1 +
 extension/testext.c   |    1 +
 extension/time.c      |    1 +
 gawkapi.h             |   26 +++++++++++++++++++++++++-
 10 files changed, 37 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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