diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | awk.h | 1 | ||||
-rwxr-xr-x | bootstrap.sh | 4 | ||||
-rw-r--r-- | extension/ChangeLog | 5 | ||||
-rw-r--r-- | extension/filefuncs.c | 2 | ||||
-rw-r--r-- | gawkapi.c | 6 | ||||
-rw-r--r-- | gawkapi.h | 5 | ||||
-rw-r--r-- | main.c | 21 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/Makefile.in | 2 |
11 files changed, 57 insertions, 5 deletions
@@ -1,3 +1,12 @@ +2012-05-25 Arnold D. Robbins <arnold@skeeve.com> + + * main.c (is_off_limits_var): New function to check if a variable + is one that an extension function may not change. + * awk.h (is_off_limits_var): Declare it. + * gawkapi.c (api_sym_lookup): Use it. + + * bootstrap.h: Touch various files in the extension directory also. + 2012-05-24 Andrew J. Schorr <aschorr@telemetry-investments.com> * gawkapi.h (awk_param_type_t): Remove (use awk_valtype_t instead). @@ -1565,6 +1565,7 @@ extern int nextfile(IOBUF **curfile, bool skipping); /* main.c */ extern int arg_assign(char *arg, bool initing); extern int is_std_var(const char *var); +extern int is_off_limits_var(const char *var); extern char *estrdup(const char *str, size_t len); extern void update_global_values(); extern long getenv_long(const char *name); diff --git a/bootstrap.sh b/bootstrap.sh index 54a97108..67faf76a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -37,3 +37,7 @@ touch po/stamp-po touch awkgram.c touch command.c touch version.c + +touch extension/configure +sleep 2 +touch extension/configh.in diff --git a/extension/ChangeLog b/extension/ChangeLog index 11c9f4d3..4fa1a7f5 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,8 @@ +2012-05-25 Arnold D. Robbins <arnold@skeeve.com> + + * filefuncs.c (array_set_numeric): Don't return a value from + a void function. + 2012-05-24 Andrew J. Schorr <aschorr@telemetry-investments.com> * Makefile.am (AM_CPPFLAGS): Use $(srcdir) to work properly when diff --git a/extension/filefuncs.c b/extension/filefuncs.c index 74a086a9..fb19f2b3 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -230,7 +230,7 @@ static void array_set_numeric(awk_array_t array, const char *sub, double num) { awk_value_t tmp; - return array_set(array, sub, make_number(num, & tmp)); + array_set(array, sub, make_number(num, & tmp)); } /* do_stat --- provide a stat() function for gawk */ @@ -255,13 +255,17 @@ node_to_awk_value(NODE *node, awk_value_t *val) /* * Lookup a variable, return its value. No messing with the value * returned. Return value is NULL if the variable doesn't exist. + * Built-in variables (except PROCINFO) may not be changed by an extension. */ static awk_value_t * api_sym_lookup(awk_ext_id_t id, const char *name, awk_value_t *result) { NODE *node; - if (name == NULL || (node = lookup(name)) == NULL) + if ( name == NULL + || *name == '\0' + || is_off_limits_var(name) /* most built-in vars not allowed */ + || (node = lookup(name)) == NULL) return NULL; return node_to_awk_value(node, result); @@ -149,6 +149,11 @@ typedef struct awk_element { * A record describing an extension function. Upon being * loaded, the extension should pass in one of these for * each C function. + * + * Each called function must fill in the result with eiher a number + * or string. Gawk takes ownership of any string memory. + * + * The called function should return the value of `result'. */ typedef struct { const char *name; @@ -950,6 +950,7 @@ struct varinit { int flags; #define NO_INSTALL 0x01 #define NON_STANDARD 0x02 +#define NOT_OFF_LIMITS 0x04 /* may be accessed by extension function */ }; static const struct varinit varinit[] = { @@ -973,7 +974,7 @@ static const struct varinit varinit[] = { {&OFMT_node, "OFMT", "%.6g", 0, NULL, set_OFMT, true, 0 }, {&OFS_node, "OFS", " ", 0, NULL, set_OFS, true, 0 }, {&ORS_node, "ORS", "\n", 0, NULL, set_ORS, true, 0 }, -{NULL, "PROCINFO", NULL, 0, NULL, NULL, false, NO_INSTALL | NON_STANDARD }, +{NULL, "PROCINFO", NULL, 0, NULL, NULL, false, NO_INSTALL | NON_STANDARD | NOT_OFF_LIMITS }, {&RLENGTH_node, "RLENGTH", NULL, 0, NULL, NULL, false, 0 }, {&ROUNDMODE_node, "ROUNDMODE", DEFAULT_ROUNDMODE, 0, NULL, set_ROUNDMODE, false, NON_STANDARD }, {&RS_node, "RS", "\n", 0, NULL, set_RS, true, 0 }, @@ -1190,6 +1191,24 @@ is_std_var(const char *var) return false; } +/* + * is_off_limits_var --- return true if a variable is off limits + * to extension functions + */ + +int +is_off_limits_var(const char *var) +{ + const struct varinit *vp; + + for (vp = varinit; vp->name != NULL; vp++) { + if ( (vp->flags & NOT_OFF_LIMITS) != 0 + && strcmp(vp->name, var) == 0) + return false; + } + + return true; +} /* get_spec_varname --- return the name of a special variable with the given assign or update routine. diff --git a/test/ChangeLog b/test/ChangeLog index 72c7b9e8..563f8e05 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2012-05-25 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (readfile): Don't copy the Makefile over readfile.ok + if there's a problem. + 2012-05-24 Andrew J. Schorr <aschorr@telemetry-investments.com> * Makefile.am (fmtspcl, include2, incdupe, incdup2, incdupe3): Fix diff --git a/test/Makefile.am b/test/Makefile.am index 2af0e38b..ea7e9a9e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1555,7 +1555,7 @@ ordchr2:: readfile:: @echo $@ @$(AWK) -l readfile 'BEGIN {printf "%s", readfile("Makefile")}' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ - @-$(CMP) Makefile _$@ && rm -f _$@ || cp -p Makefile $@.ok + @-$(CMP) Makefile _$@ && rm -f _$@ include2:: @echo $@ diff --git a/test/Makefile.in b/test/Makefile.in index 0c990912..34b7e930 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1936,7 +1936,7 @@ ordchr2:: readfile:: @echo $@ @$(AWK) -l readfile 'BEGIN {printf "%s", readfile("Makefile")}' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ - @-$(CMP) Makefile _$@ && rm -f _$@ || cp -p Makefile $@.ok + @-$(CMP) Makefile _$@ && rm -f _$@ include2:: @echo $@ |