diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-06-26 11:58:14 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-06-26 11:58:14 +0300 |
commit | 077f43dbe53c80e3edb974454e25c3f0c93d0fd5 (patch) | |
tree | 6a4d84c50ec4cdb7f3a1543dd185e7a11de37b28 | |
parent | e81708082f8b3526fb10f9599d1368dfab6d25e7 (diff) | |
download | egawk-077f43dbe53c80e3edb974454e25c3f0c93d0fd5.tar.gz egawk-077f43dbe53c80e3edb974454e25c3f0c93d0fd5.tar.bz2 egawk-077f43dbe53c80e3edb974454e25c3f0c93d0fd5.zip |
Remove support for old-style extensions.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | awk.h | 4 | ||||
-rw-r--r-- | awkgram.c | 5 | ||||
-rw-r--r-- | awkgram.y | 5 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | ext.c | 147 | ||||
-rw-r--r-- | interpret.h | 18 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/id.ok | 1 |
10 files changed, 26 insertions, 175 deletions
@@ -1,3 +1,15 @@ +2015-06-26 Arnold D. Robbins <arnold@skeeve.com> + + Remove support for old-style extensions. + + * awk.h (Node_old_ext_func, Op_old_ext_func): Removed. + Remove all uses throughout the code. + (load_old_ext, make_old_builtin): Remove declarations. + * ext.c (load_old_ext, make_old_builtin): Removed. + * awkgram.y (tokentab): Remove "extension" entry. + * eval.c (Node_old_ext_funci, Op_old_ext_func): Remove from tables. + * interpret.h (interpret): Remove stuff for old extensions. + 2015-06-25 Arnold D. Robbins <arnold@skeeve.com> Further work straightening out memory management for typeof. @@ -64,6 +64,9 @@ Changes from 4.1.x to 4.2.0 array element is an array, regexp, string or number. The isarray() function is deprecated in favor of typeof(). +16. As promised when 4.1 was released, the old extension mechanism, + using the `extension' function, is now gone. + Changes from 4.1.2 to 4.1.3 --------------------------- @@ -286,7 +286,6 @@ typedef enum nodevals { Node_param_list, /* lnode is a variable, rnode is more list */ Node_func, /* lnode is param. list, rnode is body */ Node_ext_func, /* extension function, code_ptr is builtin code */ - Node_old_ext_func, /* extension function, code_ptr is builtin code */ Node_builtin_func, /* built-in function, main use is for FUNCTAB */ Node_array_ref, /* array passed by ref as parameter */ @@ -634,7 +633,6 @@ typedef enum opcodeval { Op_builtin, Op_sub_builtin, /* sub, gsub and gensub */ Op_ext_builtin, - Op_old_ext_builtin, /* temporary */ Op_in_array, /* boolean test of membership in array */ /* function call instruction */ @@ -1426,10 +1424,8 @@ extern NODE **r_get_field(NODE *n, Func_ptr *assign, bool reference); /* ext.c */ extern NODE *do_ext(int nargs); void load_ext(const char *lib_name); /* temporary */ -extern NODE *load_old_ext(SRCFILE *s, const char *init_func, const char *fini_func, NODE *obj); extern void close_extensions(void); #ifdef DYNAMIC -extern void make_old_builtin(const char *, NODE *(*)(int), int); extern awk_bool_t make_builtin(const awk_ext_func_t *); extern NODE *get_argument(int); extern NODE *get_actual_argument(int, bool, bool); @@ -3953,7 +3953,7 @@ regular_print: if (! at_seen) { n = lookup((yyvsp[-3])->func_name); if (n != NULL && n->type != Node_func - && n->type != Node_ext_func && n->type != Node_old_ext_func) { + && n->type != Node_ext_func) { error_ln((yyvsp[-3])->source_line, _("attempt to use non-function `%s' in function call"), (yyvsp[-3])->func_name); @@ -4475,9 +4475,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)}, -#ifdef DYNAMIC -{"extension", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_ext, 0}, -#endif {"fflush", Op_builtin, LEX_BUILTIN, 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}, @@ -1809,7 +1809,7 @@ direct_func_call if (! at_seen) { n = lookup($1->func_name); if (n != NULL && n->type != Node_func - && n->type != Node_ext_func && n->type != Node_old_ext_func) { + && n->type != Node_ext_func) { error_ln($1->source_line, _("attempt to use non-function `%s' in function call"), $1->func_name); @@ -2055,9 +2055,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)}, -#ifdef DYNAMIC -{"extension", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_ext, 0}, -#endif {"fflush", Op_builtin, LEX_BUILTIN, 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}, @@ -241,7 +241,6 @@ static const char *const nodetypes[] = { "Node_param_list", "Node_func", "Node_ext_func", - "Node_old_ext_func", "Node_builtin_func", "Node_array_ref", "Node_array_tree", @@ -332,7 +331,6 @@ static struct optypetab { { "Op_builtin", NULL }, { "Op_sub_builtin", NULL }, { "Op_ext_builtin", NULL }, - { "Op_old_ext_builtin", NULL }, /* temporary */ { "Op_in_array", " in " }, { "Op_func_call", NULL }, { "Op_indirect_func_call", NULL }, @@ -32,9 +32,6 @@ extern SRCFILE *srcfiles; #ifdef DYNAMIC -#define OLD_INIT_FUNC "dlload" -#define OLD_FINI_FUNC "dlunload" - #include <dlfcn.h> /* @@ -91,95 +88,6 @@ load_ext(const char *lib_name) lib_name, INIT_FUNC); } -/* do_ext --- load an extension at run-time: interface to load_ext */ - -NODE * -do_ext(int nargs) -{ - NODE *obj, *init = NULL, *fini = NULL, *ret = NULL; - SRCFILE *s; - char *init_func = NULL; - char *fini_func = NULL; - - if (nargs == 3) { - fini = POP_STRING(); - fini_func = fini->stptr; - } - if (nargs >= 2) { - init = POP_STRING(); - init_func = init->stptr; - } - obj = POP_STRING(); - - s = add_srcfile(SRC_EXTLIB, obj->stptr, srcfiles, NULL, NULL); - if (s != NULL) - ret = load_old_ext(s, init_func, fini_func, obj); - - DEREF(obj); - if (fini != NULL) - DEREF(fini); - if (init != NULL) - DEREF(init); - if (ret == NULL) - ret = dupnode(Nnull_string); - return ret; -} - -/* load_old_ext --- load an external library */ - -NODE * -load_old_ext(SRCFILE *s, const char *init_func, const char *fini_func, NODE *obj) -{ - NODE *(*func)(NODE *, void *); - NODE *tmp; - void *dl; - int flags = RTLD_LAZY; - int *gpl_compat; - const char *lib_name = s->fullpath; - - if (init_func == NULL || init_func[0] == '\0') - init_func = OLD_INIT_FUNC; - - if (fini_func == NULL || fini_func[0] == '\0') - fini_func = OLD_FINI_FUNC; - - if (do_sandbox) - fatal(_("extensions are not allowed in sandbox mode")); - - if (do_traditional || do_posix) - fatal(_("`extension' is a gawk extension")); - - if (lib_name == NULL) - fatal(_("extension: received NULL lib_name")); - - if ((dl = dlopen(lib_name, flags)) == NULL) - fatal(_("extension: cannot open library `%s' (%s)"), lib_name, - dlerror()); - - /* Per the GNU Coding standards */ - gpl_compat = (int *) dlsym(dl, "plugin_is_GPL_compatible"); - if (gpl_compat == NULL) - fatal(_("extension: library `%s': does not define `plugin_is_GPL_compatible' (%s)"), - lib_name, dlerror()); - func = (NODE *(*)(NODE *, void *)) dlsym(dl, init_func); - if (func == NULL) - fatal(_("extension: library `%s': cannot call function `%s' (%s)"), - lib_name, init_func, dlerror()); - - if (obj == NULL) { - obj = make_string(lib_name, strlen(lib_name)); - tmp = (*func)(obj, dl); - unref(tmp); - unref(obj); - tmp = NULL; - } else - tmp = (*func)(obj, dl); - - s->fini_func = (void (*)(void)) dlsym(dl, fini_func); - return tmp; -} - - /* make_builtin --- register name to be called as func with a builtin body */ awk_bool_t @@ -237,61 +145,6 @@ make_builtin(const awk_ext_func_t *funcinfo) return awk_true; } -/* make_old_builtin --- register name to be called as func with a builtin body */ - -void -make_old_builtin(const char *name, NODE *(*func)(int), int count) /* temporary */ -{ - NODE *symbol, *f; - INSTRUCTION *b; - const char *sp; - char c; - - sp = name; - if (sp == NULL || *sp == '\0') - fatal(_("extension: missing function name")); - - if (! is_letter(*sp)) - fatal(_("extension: illegal character `%c' in function name `%s'"), *sp, name); - - for (sp++; (c = *sp++) != '\0';) { - if (! is_identchar(c)) - fatal(_("extension: illegal character `%c' in function name `%s'"), c, name); - } - - f = lookup(name); - - if (f != NULL) { - if (f->type == Node_func) { - /* user-defined function */ - fatal(_("extension: can't redefine function `%s'"), name); - } else if (f->type == Node_ext_func) { - /* multiple extension() calls etc. */ - if (do_lint) - lintwarn(_("extension: function `%s' already defined"), name); - return; - } else - /* variable name etc. */ - fatal(_("extension: function name `%s' previously defined"), name); - } else if (check_special(name) >= 0) - fatal(_("extension: can't use gawk built-in `%s' as function name"), name); - - if (count < 0) - fatal(_("make_builtin: negative argument count for function `%s'"), - name); - - b = bcalloc(Op_symbol, 1, 0); - b->builtin = func; - b->expr_count = count; - - /* NB: extension sub must return something */ - - symbol = install_symbol(estrdup(name, strlen(name)), Node_old_ext_func); - symbol->code_ptr = b; - track_ext_func(name); -} - - /* get_argument --- get the i'th argument of a dynamically linked function */ NODE * diff --git a/interpret.h b/interpret.h index 1005174a..fab4f1c6 100644 --- a/interpret.h +++ b/interpret.h @@ -948,7 +948,6 @@ arrayfor: break; case Op_ext_builtin: - case Op_old_ext_builtin: { int arg_count = pc->expr_count; awk_value_t result; @@ -1084,8 +1083,7 @@ match_re: PUSH(r); break; } else if (f->type != Node_func) { - if ( f->type == Node_ext_func - || f->type == Node_old_ext_func) { + if (f->type == Node_ext_func) { /* code copied from below, keep in sync */ INSTRUCTION *bc; char *fname = pc->func_name; @@ -1096,10 +1094,7 @@ match_re: bc = f->code_ptr; assert(bc->opcode == Op_symbol); - if (f->type == Node_ext_func) - npc[0].opcode = Op_ext_builtin; /* self modifying code */ - else - npc[0].opcode = Op_old_ext_builtin; /* self modifying code */ + npc[0].opcode = Op_ext_builtin; /* self modifying code */ npc[0].extfunc = bc->extfunc; npc[0].expr_count = arg_count; /* actual argument count */ npc[1] = pc[1]; @@ -1125,12 +1120,12 @@ match_re: f = pc->func_body; if (f == NULL) { f = lookup(pc->func_name); - if (f == NULL || (f->type != Node_func && f->type != Node_ext_func && f->type != Node_old_ext_func)) + if (f == NULL || (f->type != Node_func && f->type != Node_ext_func)) fatal(_("function `%s' not defined"), pc->func_name); pc->func_body = f; /* save for next call */ } - if (f->type == Node_ext_func || f->type == Node_old_ext_func) { + if (f->type == Node_ext_func) { /* keep in sync with indirect call code */ INSTRUCTION *bc; char *fname = pc->func_name; @@ -1138,10 +1133,7 @@ match_re: bc = f->code_ptr; assert(bc->opcode == Op_symbol); - if (f->type == Node_ext_func) - pc->opcode = Op_ext_builtin; /* self modifying code */ - else - pc->opcode = Op_old_ext_builtin; /* self modifying code */ + pc->opcode = Op_ext_builtin; /* self modifying code */ pc->extfunc = bc->extfunc; pc->expr_count = arg_count; /* actual argument count */ (pc + 1)->func_name = fname; /* name of the builtin */ diff --git a/test/ChangeLog b/test/ChangeLog index 82f52b83..f0717584 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -5,6 +5,10 @@ * dbugtypedre1.awk, dbugtypedre1.in, dbugtypedre1.ok: Renamed files. * dbugtypedre2.awk, dbugtypedre2.in, dbugtypedre2.ok: New files. + Unrelated: + + * id.ok: Update after code changes. + 2015-06-25 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (negtime): Fix out-of-tree test run. @@ -57,7 +57,6 @@ an_array -> untyped patsplit -> builtin NR -> scalar SUBSEP -> scalar -extension -> builtin i -> untyped sub -> builtin OFMT -> scalar |