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. 93e689fa83ef9a78f2bdfa


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. 93e689fa83ef9a78f2bdfa093af31fcecb429d58
Date: Mon, 25 Jun 2012 18:29:23 +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  93e689fa83ef9a78f2bdfa093af31fcecb429d58 (commit)
      from  6139211362667682c3022a72321e0cd8945b6592 (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=93e689fa83ef9a78f2bdfa093af31fcecb429d58

commit 93e689fa83ef9a78f2bdfa093af31fcecb429d58
Author: Arnold D. Robbins <address@hidden>
Date:   Mon Jun 25 21:28:29 2012 +0300

    Fix lint checking for extension functions.

diff --git a/ChangeLog b/ChangeLog
index 0043aaf..8b5e241 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-06-25         Arnold D. Robbins     <address@hidden>
+
+       * TODO.xgawk: Updated.
+       * awk.h (track_ext_func): Declared.
+       * awkgram.y (enum defref): Add option for extension function.
+       (struct fdesc): Add member for extension function.
+       (func_use): Handle extension function, mark as extension and defined.
+       (track_ext_func): New function.
+       (check_funcs): Update logic for extension functions.
+       * ext.c (make_builtin): Call track_ext_func.
+
 2012-06-24         Andrew J. Schorr     <address@hidden>
 
        * TODO.xgawk: Most of IOBUF has been hidden.
diff --git a/TODO.xgawk b/TODO.xgawk
index 3ea2029..6e14929 100644
--- a/TODO.xgawk
+++ b/TODO.xgawk
@@ -56,25 +56,10 @@ hosting for these projects:
 
 Low priority:
 
-- Fix extension/rwarray.c.  It does not currently compile due to changes
-  in the NODE structure relating to array support.  The MPFR changes will
-  also make this more complicated.  John is best equipped to solve this
-  problem.
-
 - Enhance extension/fork.c waitpid to allow the caller to specify the options.
   And add an optional array argument to wait and waitpid in which to return
   exit status information.
 
-- Fix lint complaints about shared library functions being called without
-  having been defined.  For example, try:
-     gawk --lint -lordchr 'BEGIN {print chr(65)}'
-     gawk: warning: function `chr' called but never defined
-     A
-  In ext.c, make_builtin needs to call awkgram.y:func_use.  If done naively,
-  I think this would result in complaints about shared library functions
-  defined but not used.  So there should probably be an enhancement to func_use
-  and ftable to indicate if it's a shared library function.
-
 
 Possible future changes requiring (further) discussion:
 
@@ -159,3 +144,15 @@ Done:
    unless called by the "extension" function that nobody uses.
 
 - Hide private parts of IOBUF from extensions.
+
+- Fix extension/rwarray.c.
+
+- Fix lint complaints about shared library functions being called without
+  having been defined.  For example, try:
+     gawk --lint -lordchr 'BEGIN {print chr(65)}'
+     gawk: warning: function `chr' called but never defined
+     A
+  In ext.c, make_builtin needs to call awkgram.y:func_use.  If done naively,
+  I think this would result in complaints about shared library functions
+  defined but not used.  So there should probably be an enhancement to func_use
+  and ftable to indicate if it's a shared library function.
diff --git a/awk.h b/awk.h
index a2e0e39..f08d7d9 100644
--- a/awk.h
+++ b/awk.h
@@ -1406,6 +1406,7 @@ extern unsigned long (*hash)(const char *s, size_t len, 
unsigned long hsize, siz
 /* awkgram.c */
 extern NODE *variable(int location, char *name, NODETYPE type);
 extern int parse_program(INSTRUCTION **pcode);
+extern void track_ext_func(const char *name);
 extern void dump_funcs(void);
 extern void dump_vars(const char *fname);
 extern const char *getfname(NODE *(*)(int));
diff --git a/awkgram.c b/awkgram.c
index a454b0c..104c554 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -120,7 +120,7 @@ static int count_expressions(INSTRUCTION **list, bool 
isarg);
 static INSTRUCTION *optimize_assignment(INSTRUCTION *exp);
 static void add_lint(INSTRUCTION *list, LINTTYPE linttype);
 
-enum defref { FUNC_DEFINE, FUNC_USE };
+enum defref { FUNC_DEFINE, FUNC_USE, FUNC_EXT };
 static void func_use(const char *name, enum defref how);
 static void check_funcs(void);
 
@@ -6937,6 +6937,7 @@ static struct fdesc {
        char *name;
        short used;
        short defined;
+       short extension;
        struct fdesc *next;
 } *ftable[HASHSIZE];
 
@@ -6956,7 +6957,10 @@ func_use(const char *name, enum defref how)
                if (strcmp(fp->name, name) == 0) {
                        if (how == FUNC_DEFINE)
                                fp->defined++;
-                       else
+                       else if (how == FUNC_EXT) {
+                               fp->defined++;
+                               fp->extension++;
+                       } else
                                fp->used++;
                        return;
                }
@@ -6970,12 +6974,23 @@ func_use(const char *name, enum defref how)
        strcpy(fp->name, name);
        if (how == FUNC_DEFINE)
                fp->defined++;
-       else
+       else if (how == FUNC_EXT) {
+               fp->defined++;
+               fp->extension++;
+       } else
                fp->used++;
        fp->next = ftable[ind];
        ftable[ind] = fp;
 }
 
+/* track_ext_func --- add an extension function to the table */
+
+void
+track_ext_func(const char *name)
+{
+       func_use(name, FUNC_EXT);
+}
+
 /* check_funcs --- verify functions that are called but not defined */
 
 static void
@@ -6989,19 +7004,19 @@ check_funcs()
  
        for (i = 0; i < HASHSIZE; i++) {
                for (fp = ftable[i]; fp != NULL; fp = fp->next) {
+                       if (fp->defined == 0 && ! fp->extension) {
 #ifdef REALLYMEAN
-                       /* making this the default breaks old code. sigh. */
-                       if (fp->defined == 0) {
+                               /* making this the default breaks old code. 
sigh. */
                                error(
                _("function `%s' called but never defined"), fp->name);
                                errcount++;
-                       }
 #else
-                       if (do_lint && fp->defined == 0)
                                lintwarn(
                _("function `%s' called but never defined"), fp->name);
 #endif
-                       if (do_lint && fp->used == 0) {
+                       }
+
+                       if (do_lint && fp->used == 0 && ! fp->extension) {
                                lintwarn(_("function `%s' defined but never 
called directly"),
                                        fp->name);
                        }
diff --git a/awkgram.y b/awkgram.y
index 7949829..eed0693 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -76,7 +76,7 @@ static int count_expressions(INSTRUCTION **list, bool isarg);
 static INSTRUCTION *optimize_assignment(INSTRUCTION *exp);
 static void add_lint(INSTRUCTION *list, LINTTYPE linttype);
 
-enum defref { FUNC_DEFINE, FUNC_USE };
+enum defref { FUNC_DEFINE, FUNC_USE, FUNC_EXT };
 static void func_use(const char *name, enum defref how);
 static void check_funcs(void);
 
@@ -4217,6 +4217,7 @@ static struct fdesc {
        char *name;
        short used;
        short defined;
+       short extension;
        struct fdesc *next;
 } *ftable[HASHSIZE];
 
@@ -4236,7 +4237,10 @@ func_use(const char *name, enum defref how)
                if (strcmp(fp->name, name) == 0) {
                        if (how == FUNC_DEFINE)
                                fp->defined++;
-                       else
+                       else if (how == FUNC_EXT) {
+                               fp->defined++;
+                               fp->extension++;
+                       } else
                                fp->used++;
                        return;
                }
@@ -4250,12 +4254,23 @@ func_use(const char *name, enum defref how)
        strcpy(fp->name, name);
        if (how == FUNC_DEFINE)
                fp->defined++;
-       else
+       else if (how == FUNC_EXT) {
+               fp->defined++;
+               fp->extension++;
+       } else
                fp->used++;
        fp->next = ftable[ind];
        ftable[ind] = fp;
 }
 
+/* track_ext_func --- add an extension function to the table */
+
+void
+track_ext_func(const char *name)
+{
+       func_use(name, FUNC_EXT);
+}
+
 /* check_funcs --- verify functions that are called but not defined */
 
 static void
@@ -4269,19 +4284,19 @@ check_funcs()
  
        for (i = 0; i < HASHSIZE; i++) {
                for (fp = ftable[i]; fp != NULL; fp = fp->next) {
+                       if (fp->defined == 0 && ! fp->extension) {
 #ifdef REALLYMEAN
-                       /* making this the default breaks old code. sigh. */
-                       if (fp->defined == 0) {
+                               /* making this the default breaks old code. 
sigh. */
                                error(
                _("function `%s' called but never defined"), fp->name);
                                errcount++;
-                       }
 #else
-                       if (do_lint && fp->defined == 0)
                                lintwarn(
                _("function `%s' called but never defined"), fp->name);
 #endif
-                       if (do_lint && fp->used == 0) {
+                       }
+
+                       if (do_lint && fp->used == 0 && ! fp->extension) {
                                lintwarn(_("function `%s' defined but never 
called directly"),
                                        fp->name);
                        }
diff --git a/ext.c b/ext.c
index 14d55c5..af6542d 100644
--- a/ext.c
+++ b/ext.c
@@ -123,6 +123,7 @@ make_builtin(const awk_ext_func_t *funcinfo)
 
                symbol = install_symbol(estrdup(name, strlen(name)), 
Node_ext_func);
        symbol->code_ptr = b;
+       track_ext_func(name);
        return true;
 }
 

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

Summary of changes:
 ChangeLog  |   11 +++++++++++
 TODO.xgawk |   27 ++++++++++++---------------
 awk.h      |    1 +
 awkgram.c  |   31 +++++++++++++++++++++++--------
 awkgram.y  |   31 +++++++++++++++++++++++--------
 ext.c      |    1 +
 6 files changed, 71 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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