gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, extgawk, updated. eec7101174a3b2807fb282


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. eec7101174a3b2807fb282272f75cc13d4b953c3
Date: Fri, 25 May 2012 12:19:01 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, extgawk has been updated
       via  eec7101174a3b2807fb282272f75cc13d4b953c3 (commit)
      from  577c3fc31a2718461fba2e599d162de96fe838fa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=eec7101174a3b2807fb282272f75cc13d4b953c3

commit eec7101174a3b2807fb282272f75cc13d4b953c3
Author: Arnold D. Robbins <address@hidden>
Date:   Fri May 25 15:18:43 2012 +0300

    Additional changes / some cleanups.

diff --git a/ChangeLog b/ChangeLog
index 8814c36..abdcf13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-05-25         Arnold D. Robbins     <address@hidden>
+
+       * 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     <address@hidden>
 
        * gawkapi.h (awk_param_type_t): Remove (use awk_valtype_t instead).
diff --git a/awk.h b/awk.h
index 0ac5958..ea4819e 100644
--- a/awk.h
+++ b/awk.h
@@ -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 54a9710..67faf76 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 11c9f4d..4fa1a7f 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-25         Arnold D. Robbins     <address@hidden>
+
+       * filefuncs.c (array_set_numeric): Don't return a value from
+       a void function.
+
 2012-05-24         Andrew J. Schorr     <address@hidden>
 
        * Makefile.am (AM_CPPFLAGS): Use $(srcdir) to work properly when
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 74a086a..fb19f2b 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 */
diff --git a/gawkapi.c b/gawkapi.c
index dbaa730..a25a890 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -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);
diff --git a/gawkapi.h b/gawkapi.h
index 3b52bff..54122ca 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -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;
diff --git a/main.c b/main.c
index 844052f..e8f087c 100644
--- a/main.c
+++ b/main.c
@@ -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 72c7b9e..563f8e0 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-25         Arnold D. Robbins     <address@hidden>
+
+       * Makefile.am (readfile): Don't copy the Makefile over readfile.ok
+       if there's a problem.
+
 2012-05-24         Andrew J. Schorr     <address@hidden>
 
        * Makefile.am (fmtspcl, include2, incdupe, incdup2, incdupe3): Fix
diff --git a/test/Makefile.am b/test/Makefile.am
index 2af0e38..ea7e9a9 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 address@hidden
+       @-$(CMP) Makefile _$@ && rm -f _$@
 
 include2::
        @echo $@
diff --git a/test/Makefile.in b/test/Makefile.in
index 0c99091..34b7e93 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 address@hidden
+       @-$(CMP) Makefile _$@ && rm -f _$@
 
 include2::
        @echo $@

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             |    9 +++++++++
 awk.h                 |    1 +
 bootstrap.sh          |    4 ++++
 extension/ChangeLog   |    5 +++++
 extension/filefuncs.c |    2 +-
 gawkapi.c             |    6 +++++-
 gawkapi.h             |    5 +++++
 main.c                |   21 ++++++++++++++++++++-
 test/ChangeLog        |    5 +++++
 test/Makefile.am      |    2 +-
 test/Makefile.in      |    2 +-
 11 files changed, 57 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]