aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-06-25 21:28:29 +0300
committerArnold D. Robbins <arnold@skeeve.com>2012-06-25 21:28:29 +0300
commit93e689fa83ef9a78f2bdfa093af31fcecb429d58 (patch)
tree18521d2c5e2d9f186f2e95df3164e220d3b37aae /awkgram.c
parent6139211362667682c3022a72321e0cd8945b6592 (diff)
downloadegawk-93e689fa83ef9a78f2bdfa093af31fcecb429d58.tar.gz
egawk-93e689fa83ef9a78f2bdfa093af31fcecb429d58.tar.bz2
egawk-93e689fa83ef9a78f2bdfa093af31fcecb429d58.zip
Fix lint checking for extension functions.
Diffstat (limited to 'awkgram.c')
-rw-r--r--awkgram.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/awkgram.c b/awkgram.c
index a454b0c9..104c5545 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);
}