aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-07-12 22:56:09 +0300
committerArnold D. Robbins <arnold@skeeve.com>2012-07-12 22:56:09 +0300
commit7c209cbe1b2fd054769512e325ede72d865f0c84 (patch)
tree998c060190432c7a26461e50393dcbc87e9fd195
parent28daef44c3c08f16002c678319a30b816f6972fd (diff)
downloadegawk-7c209cbe1b2fd054769512e325ede72d865f0c84.tar.gz
egawk-7c209cbe1b2fd054769512e325ede72d865f0c84.tar.bz2
egawk-7c209cbe1b2fd054769512e325ede72d865f0c84.zip
Simplify code in testext.c.
-rw-r--r--extension/ChangeLog5
-rw-r--r--extension/testext.c34
2 files changed, 12 insertions, 27 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog
index ce8d6b78..e71d0719 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -7,6 +7,11 @@
* fnmatch.c (init_fnmatch): Use sym_constant for FNM_NOMATCH.
* testext.c (dl_load): Use sym_constant for answer_num.
+ * testext.c (init_testext): Move extra code to here.
+ (init_func): Change to point to init_testext.
+ (dl_load): Deleted.
+ (dl_load_func): Use the macro.
+
2012-07-11 Arnold D. Robbins <arnold@skeeve.com>
* filefuncs.c (array_set, do_stat): Use make_const_string.
diff --git a/extension/testext.c b/extension/testext.c
index dc3002a9..0eff62b7 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -39,7 +39,6 @@
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;
@@ -577,36 +576,13 @@ static awk_ext_func_t func_table[] = {
{ "print_do_lint", print_do_lint, 0 },
};
-/* dl_load --- extension load routine, called from gawk */
+/* init_testext --- additional initialization function */
-int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id)
+static awk_bool_t init_testext(void)
{
- 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;
-
- if (api->major_version != GAWK_API_MAJOR_VERSION
- || api->minor_version < GAWK_API_MINOR_VERSION) {
- fprintf(stderr, "testfuncs: version mismatch with gawk!\n");
- fprintf(stderr, "\tmy version (%d, %d), gawk version (%d, %d)\n",
- GAWK_API_MAJOR_VERSION, GAWK_API_MINOR_VERSION,
- api->major_version, api->minor_version);
- exit(1);
- }
-
- /* load functions */
- for (i = 0, j = sizeof(func_table) / sizeof(func_table[0]); i < j; i++) {
- if (! add_ext_func(& func_table[i], "")) {
- warning(ext_id, "testfuncs: could not add %s\n",
- func_table[i].name);
- errors++;
- }
- }
-
/* add at_exit functions */
awk_atexit(at_exit0, NULL);
awk_atexit(at_exit1, & data_for_1);
@@ -632,5 +608,9 @@ BEGIN {
create_new_array();
- return (errors == 0);
+ return 1;
}
+
+static awk_bool_t (*init_func)(void) = init_testext;
+
+dl_load_func(func_table, testext, "")