diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2012-08-11 17:07:24 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2012-08-11 17:07:24 -0400 |
commit | 8d5a66b529a220239037a3cd7a2421aab85de53d (patch) | |
tree | 481b5086951c67d367c128b2551683c7421e372b /awkgram.c | |
parent | 9cc3e7f1126d924a343f01be6a92cf6aefe97bab (diff) | |
download | egawk-8d5a66b529a220239037a3cd7a2421aab85de53d.tar.gz egawk-8d5a66b529a220239037a3cd7a2421aab85de53d.tar.bz2 egawk-8d5a66b529a220239037a3cd7a2421aab85de53d.zip |
Make it a fatal error to load the same file with -f and -i (or @include).
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -5048,11 +5048,13 @@ add_srcfile(int stype, char *src, SRCFILE *thisfile, bool *already_included, int } /* N.B. We do not eliminate duplicate SRC_FILE (-f) programs. */ - if (stype == SRC_INC || stype == SRC_EXTLIB) { - for (s = srcfiles->next; s != srcfiles; s = s->next) { - if ((s->stype == SRC_FILE || s->stype == SRC_INC || s->stype == SRC_EXTLIB) - && files_are_same(path, s) - ) { + for (s = srcfiles->next; s != srcfiles; s = s->next) { + if ((s->stype == SRC_FILE || s->stype == SRC_INC || s->stype == SRC_EXTLIB) && files_are_same(path, s)) { + if (stype == SRC_INC || stype == SRC_EXTLIB) { + /* eliminate duplicates */ + if ((stype == SRC_INC) && (s->stype == SRC_FILE)) + fatal(_("can't include `%s' and use it as a program file"), src); + if (do_lint) { int line = sourceline; /* Kludge: the line number may be off for `@include file'. @@ -5072,6 +5074,13 @@ add_srcfile(int stype, char *src, SRCFILE *thisfile, bool *already_included, int if (already_included) *already_included = true; return NULL; + } else { + /* duplicates are allowed for -f */ + if (s->stype == SRC_INC) + fatal(_("can't include `%s' and use it as a program file"), src); + /* no need to scan for further matches, since + * they must be of homogeneous type */ + break; } } } |