diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | awk.h | 20 | ||||
-rw-r--r-- | extension/ChangeLog | 15 | ||||
-rw-r--r-- | extension/filefuncs.c | 1 | ||||
-rw-r--r-- | extension/fnmatch.c | 1 | ||||
-rw-r--r-- | extension/fork.c | 1 | ||||
-rw-r--r-- | extension/ordchr.c | 1 | ||||
-rw-r--r-- | extension/readdir.c | 1 | ||||
-rw-r--r-- | extension/readfile.c | 1 | ||||
-rw-r--r-- | extension/revoutput.c | 1 | ||||
-rw-r--r-- | extension/revtwoway.c | 1 | ||||
-rw-r--r-- | extension/rwarray.c | 1 | ||||
-rw-r--r-- | extension/rwarray0.c | 1 | ||||
-rw-r--r-- | extension/testext.c | 1 | ||||
-rw-r--r-- | extension/time.c | 1 | ||||
-rw-r--r-- | gawkapi.c | 40 | ||||
-rw-r--r-- | gawkapi.h | 12 | ||||
-rw-r--r-- | main.c | 11 |
18 files changed, 114 insertions, 12 deletions
@@ -1,3 +1,19 @@ +2012-08-24 Arnold D. Robbins <arnold@skeeve.com> + + Add version facility to API. Thanks to Manuel Collado + for the idea. + + * awk.h (print_ext_versions): Declare. + Rearrange includes and decls to make more sense. + * gawkapi.h (register_ext_version): New API. + (dl_load_func): Add code for ext_version. + * gawkapi.c (api_register_ext_version, print_ext_versions): + New functions. + * main.c (do_version): New variable. + (optab): Set it for -v / --version. + (main): Set it in arg parsing switch. Call version() after the + extensions have been loaded. + 2012-08-22 Arnold D. Robbins <arnold@skeeve.com> Add output wrapper and two-way processor to extension API. @@ -244,6 +244,8 @@ typedef struct Regexp { #define RE_NEED_START 1 /* need to know start/end of match */ #define RE_NO_BOL 2 /* not allowed to match ^ in regexp */ +#include "gawkapi.h" + /* Stuff for losing systems. */ #if !defined(HAVE_STRTOD) extern double gawk_strtod(); @@ -705,16 +707,6 @@ enum redirval { 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 { struct exp_instruction *nexti; union { @@ -1525,6 +1517,14 @@ typedef enum { } field_sep_type; extern field_sep_type current_field_sep(void); +/* 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); +extern void print_ext_versions(void); + /* gawkmisc.c */ extern char *gawk_name(const char *filespec); extern void os_arg_fixup(int *argcp, char ***argvp); diff --git a/extension/ChangeLog b/extension/ChangeLog index 0a15220a..be3cf086 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,18 @@ +2012-08-24 Arnold D. Robbins <arnold@skeeve.com> + + * filefuncs.c, fnmatch.c, fork.c, ordchr.c, readdir.c, readfile.c, + revoutput.c, revtwoway.c, rwarray.c, rwarray0.c, testext.c, + time.c: Add ext_version string. + +2012-08-23 Arnold D. Robbins <arnold@skeeve.com> + + * revoutwoway.c: New testing extension for two way processor. + * Makefile.am: Build revtwoway extension. + * readdir.c: Fix to fall back to stat if d_type is 'u' and + do_ftype is one. + * readdir.3am: Revise doc that some GNU/Linux filesystems + don't support d_type. + 2012-08-22 Arnold D. Robbins <arnold@skeeve.com> * revoutput.c: New testing extension for output wrapper. diff --git a/extension/filefuncs.c b/extension/filefuncs.c index e27e51bf..9f498706 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -61,6 +61,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; static awk_bool_t init_filefuncs(void); static awk_bool_t (*init_func)(void) = init_filefuncs; +static const char *ext_version = "filefuncs extension: version 1.0"; int plugin_is_GPL_compatible; diff --git a/extension/fnmatch.c b/extension/fnmatch.c index 3ebae595..6a4d4635 100644 --- a/extension/fnmatch.c +++ b/extension/fnmatch.c @@ -61,6 +61,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "fnmatch extension: version 1.0"; static awk_bool_t init_fnmatch(void); static awk_bool_t (*init_func)(void) = init_fnmatch; diff --git a/extension/fork.c b/extension/fork.c index 7bee8ba1..9f9fc086 100644 --- a/extension/fork.c +++ b/extension/fork.c @@ -45,6 +45,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "fork extension: version 1.0"; static awk_bool_t (*init_func)(void) = NULL; int plugin_is_GPL_compatible; diff --git a/extension/ordchr.c b/extension/ordchr.c index 01466f1a..5abb6236 100644 --- a/extension/ordchr.c +++ b/extension/ordchr.c @@ -47,6 +47,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "ordchr extension: version 1.0"; static awk_bool_t (*init_func)(void) = NULL; int plugin_is_GPL_compatible; diff --git a/extension/readdir.c b/extension/readdir.c index 3eae4079..6ce7bea7 100644 --- a/extension/readdir.c +++ b/extension/readdir.c @@ -54,6 +54,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "readdir extension: version 1.0"; static awk_bool_t init_readdir(void); static awk_bool_t (*init_func)(void) = init_readdir; diff --git a/extension/readfile.c b/extension/readfile.c index 8f68c247..5abb5763 100644 --- a/extension/readfile.c +++ b/extension/readfile.c @@ -54,6 +54,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "readfile extension: version 1.0"; static awk_bool_t (*init_func)(void) = NULL; int plugin_is_GPL_compatible; diff --git a/extension/revoutput.c b/extension/revoutput.c index c1ea1ddc..bb195a29 100644 --- a/extension/revoutput.c +++ b/extension/revoutput.c @@ -45,6 +45,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "revoutput extension: version 1.0"; static awk_bool_t init_revout(void); static awk_bool_t (*init_func)(void) = init_revout; diff --git a/extension/revtwoway.c b/extension/revtwoway.c index 7ab9366e..9ce0c733 100644 --- a/extension/revtwoway.c +++ b/extension/revtwoway.c @@ -47,6 +47,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "revtwoway extension: version 1.0"; static awk_bool_t init_revtwoway(void); static awk_bool_t (*init_func)(void) = init_revtwoway; diff --git a/extension/rwarray.c b/extension/rwarray.c index 0eca9779..371078ed 100644 --- a/extension/rwarray.c +++ b/extension/rwarray.c @@ -51,6 +51,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "rwarray extension: version 1.0"; static awk_bool_t (*init_func)(void) = NULL; int plugin_is_GPL_compatible; diff --git a/extension/rwarray0.c b/extension/rwarray0.c index 75c735a4..c511ce00 100644 --- a/extension/rwarray0.c +++ b/extension/rwarray0.c @@ -51,6 +51,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "rwarray0 extension: version 1.0"; static awk_bool_t (*init_func)(void) = NULL; int plugin_is_GPL_compatible; diff --git a/extension/testext.c b/extension/testext.c index d1ebac17..d0215d9d 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 const char *ext_version = "testext extension: version 1.0"; int plugin_is_GPL_compatible; diff --git a/extension/time.c b/extension/time.c index 7e3fc521..24c7572f 100644 --- a/extension/time.c +++ b/extension/time.c @@ -43,6 +43,7 @@ static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t *ext_id; +static const char *ext_version = "time extension: version 1.0"; static awk_bool_t (*init_func)(void) = NULL; int plugin_is_GPL_compatible; @@ -980,6 +980,33 @@ api_release_value(awk_ext_id_t id, awk_value_cookie_t value) return true; } +/* + * Register a version string for this extension with gawk. + */ + +static struct version_info { + const char *version; + struct version_info *next; +}; + +static struct version_info *vi_head; + +/* api_register_ext_version --- add an extension version string to the list */ + +static void +api_register_ext_version(awk_ext_id_t id, const char *version) +{ + + struct version_info *info; + + (void) id; + + emalloc(info, struct version_info *, sizeof(struct version_info), "register_ext_version"); + info->version = version; + info->next = vi_head; + vi_head = info; +} + gawk_api_t api_impl = { GAWK_API_MAJOR_VERSION, /* major and minor versions */ GAWK_API_MINOR_VERSION, @@ -1021,6 +1048,8 @@ gawk_api_t api_impl = { api_create_value, api_release_value, + + api_register_ext_version, }; /* init_ext_api --- init the extension API */ @@ -1052,3 +1081,14 @@ set_constant() { fatal(_("cannot assign to defined constant")); } + +/* print_ext_versions --- print the list */ + +extern void +print_ext_versions(void) +{ + struct version_info *p; + + for (p = vi_head; p != NULL; p = p->next) + printf("%s\n", p->version); +} @@ -576,6 +576,11 @@ typedef struct gawk_api { * Please call this to free memory when the value is no longer needed. */ awk_bool_t (*api_release_value)(awk_ext_id_t id, awk_value_cookie_t vc); + + /* + * Register a version string for this extension with gawk. + */ + void (*api_register_ext_version)(awk_ext_id_t id, const char *version); } gawk_api_t; #ifndef GAWK /* these are not for the gawk code itself! */ @@ -654,6 +659,9 @@ typedef struct gawk_api { #define release_value(value) \ (api->api_release_value(ext_id, value)) +#define register_ext_version(version) \ + (api->api_register_ext_version(ext_id, version)) + #define emalloc(pointer, type, size, message) \ do { \ if ((pointer = (type) malloc(size)) == 0) \ @@ -748,6 +756,7 @@ static awk_ext_func_t func_table[] = { { "name", do_name, 1 }, /* ... */ }; +static const char *ext_version = NULL; /* or ... = "some string" */ /* EITHER: */ @@ -801,6 +810,9 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id) \ } \ } \ \ + if (ext_version != NULL) \ + register_ext_version(ext_version); \ +\ return (errors == 0); \ } @@ -138,6 +138,7 @@ int do_flags = false; bool do_optimize = true; /* apply default optimizations */ static int do_nostalgia = false; /* provide a blast from the past */ static int do_binary = false; /* hands off my data! */ +static int do_version = false; /* print version info */ int use_lc_numeric = false; /* obey locale for decimal point */ @@ -180,7 +181,7 @@ static const struct option optab[] = { { "load", required_argument, NULL, 'l' }, { "dump-variables", optional_argument, NULL, 'd' }, { "assign", required_argument, NULL, 'v' }, - { "version", no_argument, NULL, 'V' }, + { "version", no_argument, & do_version, 'V' }, { "help", no_argument, NULL, 'h' }, { "exec", required_argument, NULL, 'E' }, { "use-lc-numeric", no_argument, & use_lc_numeric, 1 }, @@ -469,7 +470,7 @@ main(int argc, char **argv) break; case 'V': - version(); + do_version = true; break; case 'W': /* gawk specific options - now in getopt_long */ @@ -652,6 +653,10 @@ out: have_srcfile++; } + /* do version check after extensions are loaded to get extension info */ + if (do_version) + version(); + /* No -f or --source options, use next arg */ if (! have_srcfile) { if (optind > argc - 1 || stopped_early) /* no args left or no program */ @@ -1409,6 +1414,8 @@ version() printf(" (GNU MPFR %s, GNU MP %s)", mpfr_get_version(), gmp_version); #endif printf("\n"); + print_ext_versions(); + /* * Per GNU coding standards, print copyright info, * then exit successfully, do nothing else. |