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. 8d5a66b529a220239037a3


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. 8d5a66b529a220239037a3cd7a2421aab85de53d
Date: Sat, 11 Aug 2012 21:07:59 +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  8d5a66b529a220239037a3cd7a2421aab85de53d (commit)
      from  9cc3e7f1126d924a343f01be6a92cf6aefe97bab (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=8d5a66b529a220239037a3cd7a2421aab85de53d

commit 8d5a66b529a220239037a3cd7a2421aab85de53d
Author: Andrew J. Schorr <address@hidden>
Date:   Sat Aug 11 17:07:24 2012 -0400

    Make it a fatal error to load the same file with -f and -i (or @include).

diff --git a/ChangeLog b/ChangeLog
index 8601188..d75c82e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-11         Andrew J. Schorr     <address@hidden>
+
+       * awkgram.y (add_srcfile): It is now a fatal error to load the
+       same file with -f and -i (or @include).
+       * TODO.xgawk: Update to reflect this change.
+
 2012-08-10         Arnold D. Robbins     <address@hidden>
 
        * FUTURES, TODO.xgawk: Updates.
diff --git a/TODO.xgawk b/TODO.xgawk
index e091351..d26baa1 100644
--- a/TODO.xgawk
+++ b/TODO.xgawk
@@ -1,8 +1,5 @@
 To-do list for xgawk enhancements:
 
-- Attempting to load the same file with -f and -i (or @include) should
-  be a fatal error.
-
 Low priority:
 
 - Enhance extension/fork.c waitpid to allow the caller to specify the options.
@@ -141,3 +138,5 @@ Done:
        * Still to go: Rework iop_alloc, interaction with open hooks, and
          skipping command line directories.
 
+- Attempting to load the same file with -f and -i (or @include) should
+  be a fatal error.
diff --git a/awkgram.c b/awkgram.c
index 64a7583..83fc1dd 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -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 address@hidden 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;
                        }
                }
        }
diff --git a/awkgram.y b/awkgram.y
index d094b0e..a6669e9 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2328,11 +2328,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 address@hidden file'.
@@ -2352,6 +2354,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;
                        }
                }
        }
diff --git a/test/ChangeLog b/test/ChangeLog
index 2b1ac64..94c6ef1 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,11 @@
+2012-08-11         Andrew J. Schorr     <address@hidden>
+
+       * Makefile.am (EXTRA_DIST): Add inchello.awk and incdupe[4-7].ok.
+       (GAWK_EXT_TESTS): Add incdupe[4-7].
+       (incdupe[4-7]): New tests to ensure that mixing -f with include
+       causes a fatal error.
+       * incdupe[4-7].ok, inchello.awk: New files.
+
 2012-08-08         Arnold D. Robbins     <address@hidden>
 
        * Makefile.am (fts): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index 3a8e48c..c067f66 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -380,6 +380,11 @@ EXTRA_DIST = \
        incdupe.ok \
        incdupe2.ok \
        incdupe3.ok \
+       inchello.awk \
+       incdupe4.ok \
+       incdupe5.ok \
+       incdupe6.ok \
+       incdupe7.ok \
        indirectcall.awk \
        indirectcall.in \
        indirectcall.ok \
@@ -881,7 +886,8 @@ GAWK_EXT_TESTS = \
        rebuf regx8bit reint reint2 rsstart1 \
        rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
        strtonum switch2 \
-       include include2 incdupe incdupe2 incdupe3
+       include include2 incdupe incdupe2 incdupe3 \
+       incdupe4 incdupe5 incdupe6 incdupe7
 
 EXTRA_TESTS = inftest regtest
 
@@ -1593,6 +1599,26 @@ incdupe3::
        @AWKPATH=$(srcdir) $(AWK) --lint -f hello -f hello.awk >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 
+incdupe4::
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) --lint -f hello -i hello.awk >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+incdupe5::
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) --lint -i hello -f hello.awk >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+incdupe6::
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) --lint -i inchello -f hello.awk >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+incdupe7::
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) --lint -f hello -i inchello >_$@ 2>&1 || echo 
EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
 testext::
        @echo $@
        @$(AWK) '/^(@load|BEGIN)/,/^}/' $(top_srcdir)/extension/testext.c > 
testext.awk
diff --git a/test/Makefile.in b/test/Makefile.in
index 0ba7c5c..10d7b6a 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -593,6 +593,11 @@ EXTRA_DIST = \
        incdupe.ok \
        incdupe2.ok \
        incdupe3.ok \
+       inchello.awk \
+       incdupe4.ok \
+       incdupe5.ok \
+       incdupe6.ok \
+       incdupe7.ok \
        indirectcall.awk \
        indirectcall.in \
        indirectcall.ok \
@@ -1094,7 +1099,8 @@ GAWK_EXT_TESTS = \
        rebuf regx8bit reint reint2 rsstart1 \
        rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
        strtonum switch2 \
-       include include2 incdupe incdupe2 incdupe3
+       include include2 incdupe incdupe2 incdupe3 \
+       incdupe4 incdupe5 incdupe6 incdupe7
 
 EXTRA_TESTS = inftest regtest
 INET_TESTS = inetdayu inetdayt inetechu inetecht
@@ -1976,6 +1982,26 @@ incdupe3::
        @AWKPATH=$(srcdir) $(AWK) --lint -f hello -f hello.awk >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 
+incdupe4::
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) --lint -f hello -i hello.awk >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+incdupe5::
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) --lint -i hello -f hello.awk >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+incdupe6::
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) --lint -i inchello -f hello.awk >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+incdupe7::
+       @echo $@
+       @AWKPATH=$(srcdir) $(AWK) --lint -f hello -i inchello >_$@ 2>&1 || echo 
EXIT CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
 testext::
        @echo $@
        @$(AWK) '/^(@load|BEGIN)/,/^}/' $(top_srcdir)/extension/testext.c > 
testext.awk
diff --git a/test/incdupe4.ok b/test/incdupe4.ok
new file mode 100644
index 0000000..a6fc26e
--- /dev/null
+++ b/test/incdupe4.ok
@@ -0,0 +1,2 @@
+gawk: fatal: can't include `hello.awk' and use it as a program file
+EXIT CODE: 2
diff --git a/test/incdupe5.ok b/test/incdupe5.ok
new file mode 100644
index 0000000..a6fc26e
--- /dev/null
+++ b/test/incdupe5.ok
@@ -0,0 +1,2 @@
+gawk: fatal: can't include `hello.awk' and use it as a program file
+EXIT CODE: 2
diff --git a/test/incdupe6.ok b/test/incdupe6.ok
new file mode 100644
index 0000000..42a4f9f
--- /dev/null
+++ b/test/incdupe6.ok
@@ -0,0 +1,3 @@
+gawk: inchello:1: warning: `include' is a gawk extension
+gawk: inchello:2: fatal: can't include `hello' and use it as a program file
+EXIT CODE: 2
diff --git a/test/incdupe7.ok b/test/incdupe7.ok
new file mode 100644
index 0000000..42a4f9f
--- /dev/null
+++ b/test/incdupe7.ok
@@ -0,0 +1,3 @@
+gawk: inchello:1: warning: `include' is a gawk extension
+gawk: inchello:2: fatal: can't include `hello' and use it as a program file
+EXIT CODE: 2
diff --git a/test/inchello.awk b/test/inchello.awk
new file mode 100644
index 0000000..148d4be
--- /dev/null
+++ b/test/inchello.awk
@@ -0,0 +1 @@
address@hidden "hello"

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

Summary of changes:
 ChangeLog         |    6 ++++++
 TODO.xgawk        |    5 ++---
 awkgram.c         |   19 ++++++++++++++-----
 awkgram.y         |   19 ++++++++++++++-----
 test/ChangeLog    |    8 ++++++++
 test/Makefile.am  |   28 +++++++++++++++++++++++++++-
 test/Makefile.in  |   28 +++++++++++++++++++++++++++-
 test/incdupe4.ok  |    2 ++
 test/incdupe5.ok  |    2 ++
 test/incdupe6.ok  |    3 +++
 test/incdupe7.ok  |    3 +++
 test/inchello.awk |    1 +
 12 files changed, 109 insertions(+), 15 deletions(-)
 create mode 100644 test/incdupe4.ok
 create mode 100644 test/incdupe5.ok
 create mode 100644 test/incdupe6.ok
 create mode 100644 test/incdupe7.ok
 create mode 100644 test/inchello.awk


hooks/post-receive
-- 
gawk



reply via email to

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