summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--awk.h3
-rw-r--r--awkgram.c3
-rw-r--r--awkgram.y3
-rw-r--r--ext.c50
-rw-r--r--main.c2
6 files changed, 24 insertions, 48 deletions
diff --git a/ChangeLog b/ChangeLog
index 57da23e3..dbfc8efb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2012-06-21 Arnold D. Robbins <arnold@skeeve.com>
+ More API and cleanup:
+
* awk.h (stopme): Make signature match other built-ins.
* awkgram.y (stopme): Make signature match other built-ins.
(regexp): Minor edit.
@@ -7,6 +9,15 @@
Set parent_array field of array value.
* TODO.xgawk: Update some.
+ Remove extension() builtin.
+
+ * awk.h (do_ext): Removed.
+ (load_ext): Signature changed.
+ * awkgram.y (tokentab): Remove do_ext.
+ Change calls to do_ext.
+ * ext.c (load_ext): Make init function a constant.
+ * main.c (main): Change calls to do_ext.
+
2012-06-20 Arnold D. Robbins <arnold@skeeve.com>
Restore lost debugging function:
diff --git a/awk.h b/awk.h
index d433a6ec..6450cbdc 100644
--- a/awk.h
+++ b/awk.h
@@ -1503,8 +1503,7 @@ extern STACK_ITEM *grow_stack(void);
extern void dump_fcall_stack(FILE *fp);
extern int register_exec_hook(Func_pre_exec preh, Func_post_exec posth);
/* ext.c */
-NODE *do_ext(int nargs);
-NODE *load_ext(const char *lib_name, const char *init_func);
+void load_ext(const char *lib_name);
#ifdef DYNAMIC
awk_bool_t make_builtin(const awk_ext_func_t *);
NODE *get_argument(int);
diff --git a/awkgram.c b/awkgram.c
index c8c7a084..a454b0c9 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4562,7 +4562,6 @@ static const struct token tokentab[] = {
{"eval", Op_symbol, LEX_EVAL, 0, 0, 0},
{"exit", Op_K_exit, LEX_EXIT, 0, 0, 0},
{"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp, MPF(exp)},
-{"extension", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_ext, 0},
{"fflush", Op_builtin, LEX_BUILTIN, RESX|A(0)|A(1), do_fflush, 0},
{"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0, 0},
{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
@@ -5160,7 +5159,7 @@ load_library(INSTRUCTION *file)
return -1;
}
- (void) load_ext(s->fullpath, "dl_load");
+ load_ext(s->fullpath);
return 0;
}
diff --git a/awkgram.y b/awkgram.y
index 3ed450d7..7949829c 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -1842,7 +1842,6 @@ static const struct token tokentab[] = {
{"eval", Op_symbol, LEX_EVAL, 0, 0, 0},
{"exit", Op_K_exit, LEX_EXIT, 0, 0, 0},
{"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp, MPF(exp)},
-{"extension", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_ext, 0},
{"fflush", Op_builtin, LEX_BUILTIN, RESX|A(0)|A(1), do_fflush, 0},
{"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0, 0},
{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
@@ -2440,7 +2439,7 @@ load_library(INSTRUCTION *file)
return -1;
}
- (void) load_ext(s->fullpath, "dl_load");
+ load_ext(s->fullpath);
return 0;
}
diff --git a/ext.c b/ext.c
index d0755ccd..911754bf 100644
--- a/ext.c
+++ b/ext.c
@@ -33,32 +33,12 @@
#include <dlfcn.h>
-/* do_ext --- load an extension at run-time: interface to load_ext */
-
-NODE *
-do_ext(int nargs)
-{
- NODE *obj, *fun, *ret = NULL;
- SRCFILE *s;
- extern SRCFILE *srcfiles;
-
- fun = POP_STRING(); /* name of initialization function */
- obj = POP_STRING(); /* name of shared object */
-
- s = add_srcfile(SRC_EXTLIB, obj->stptr, srcfiles, NULL, NULL);
- if (s != NULL)
- ret = load_ext(s->fullpath, fun->stptr);
- DEREF(obj);
- DEREF(fun);
- if (ret == NULL)
- ret = dupnode(Nnull_string);
- return ret;
-}
+#define INIT_FUNC "dl_load"
/* load_ext --- load an external library */
-NODE *
-load_ext(const char *lib_name, const char *init_func)
+void
+load_ext(const char *lib_name)
{
int (*install_func)(const gawk_api_t *const, awk_ext_id_t);
void *dl;
@@ -69,7 +49,7 @@ load_ext(const char *lib_name, const char *init_func)
fatal(_("extensions are not allowed in sandbox mode"));
if (do_traditional || do_posix)
- fatal(_("-l / @load / `extension' are gawk extensions"));
+ fatal(_("-l / @load are gawk extensions"));
if ((dl = dlopen(lib_name, flags)) == NULL)
fatal(_("load_ext: cannot open library `%s' (%s)\n"), lib_name,
@@ -81,14 +61,14 @@ load_ext(const char *lib_name, const char *init_func)
fatal(_("load_ext: library `%s': does not define `plugin_is_GPL_compatible' (%s)\n"),
lib_name, dlerror());
install_func = (int (*)(const gawk_api_t *const, awk_ext_id_t))
- dlsym(dl, init_func);
+ dlsym(dl, INIT_FUNC);
if (install_func == NULL)
fatal(_("load_ext: library `%s': cannot call function `%s' (%s)\n"),
- lib_name, init_func, dlerror());
+ lib_name, INIT_FUNC, dlerror());
if (install_func(& api_impl, NULL /* ext_id */) == 0) {
warning(_("load_ext: library `%s' initialization routine `%s' failed\n"),
- lib_name, init_func);
+ lib_name, INIT_FUNC);
return make_number(-1);
}
return make_number(0);
@@ -231,23 +211,11 @@ get_actual_argument(int i, bool optional, bool want_array)
#else
-/* do_ext --- dummy version if extensions not available */
-
-NODE *
-do_ext(int nargs)
-{
- const char *emsg = _("Operation Not Supported");
-
- update_ERRNO_string(emsg, DONT_TRANSLATE);
- return make_number((AWKNUM) -1);
-}
-
/* load_ext --- dummy version if extensions not available */
-NODE *
-load_ext(const char *lib_name, const char *init_func, NODE *obj)
+void
+load_ext(const char *lib_name)
{
fatal(_("dynamic loading of library not supported"));
- return NULL;
}
#endif
diff --git a/main.c b/main.c
index b3f7f9ec..bbe656da 100644
--- a/main.c
+++ b/main.c
@@ -644,7 +644,7 @@ out:
/* load extension libs */
for (s = srcfiles->next; s != srcfiles; s = s->next) {
if (s->stype == SRC_EXTLIB)
- (void) load_ext(s->fullpath, "dl_load");
+ load_ext(s->fullpath);
else if (s->stype != SRC_INC)
have_srcfile++;
}