diff options
Diffstat (limited to 'awkgram.y')
-rw-r--r-- | awkgram.y | 23 |
1 files changed, 8 insertions, 15 deletions
@@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2013 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2014 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -4308,18 +4308,9 @@ func_use(const char *name, enum defref how) len = strlen(name); ind = hash(name, len, HASHSIZE, NULL); - for (fp = ftable[ind]; fp != NULL; fp = fp->next) { - if (strcmp(fp->name, name) == 0) { - if (how == FUNC_DEFINE) - fp->defined++; - else if (how == FUNC_EXT) { - fp->defined++; - fp->extension++; - } else - fp->used++; - return; - } - } + for (fp = ftable[ind]; fp != NULL; fp = fp->next) + if (strcmp(fp->name, name) == 0) + goto update_value; /* not in the table, fall through to allocate a new one */ @@ -4327,6 +4318,10 @@ func_use(const char *name, enum defref how) memset(fp, '\0', sizeof(struct fdesc)); emalloc(fp->name, char *, len + 1, "func_use"); strcpy(fp->name, name); + fp->next = ftable[ind]; + ftable[ind] = fp; + +update_value: if (how == FUNC_DEFINE) fp->defined++; else if (how == FUNC_EXT) { @@ -4334,8 +4329,6 @@ func_use(const char *name, enum defref how) fp->extension++; } else fp->used++; - fp->next = ftable[ind]; - ftable[ind] = fp; } /* track_ext_func --- add an extension function to the table */ |