]> git.saurik.com Git - bison.git/commitdiff
* tests/output.at (AT_CHECK_OUTPUT): Another test, making sure
authorAkim Demaille <akim@epita.fr>
Mon, 4 Mar 2002 18:06:42 +0000 (18:06 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 4 Mar 2002 18:06:42 +0000 (18:06 +0000)
bison fails when trying to output a parser and a header under the
same name.
* src/files.c (compute_output_file_names): Refuse when parser and
header have the same name.

ChangeLog
NEWS
src/files.c
src/output.c
tests/output.at

index 0a75128aff809a815b3cb724393311ca79a2daed..f4a5ec07ff41100a4dbed555b09f238be350a08f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-03-04  Akim Demaille  <akim@epita.fr>
+
+       * tests/output.at (AT_CHECK_OUTPUT): Another test, making sure
+       bison fails when trying to output a parser and a header under the
+       same name.
+       * src/files.c (compute_output_file_names): Refuse when parser and
+       header have the same name.
+
 2002-03-04  Akim Demaille  <akim@epita.fr>
 
        * src/reader.c (readgram): A missing `;' is a warning, not an
 2002-03-04  Akim Demaille  <akim@epita.fr>
 
        * src/reader.c (readgram): A missing `;' is a warning, not an
diff --git a/NEWS b/NEWS
index a30792b1084b376c70835222c5c567b4ce60104d..446dee35c53075e9bee1e44c9404889744197e6b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,10 @@ Bison News
 
 Changes in version 1.33b:
 
 
 Changes in version 1.33b:
 
+* File name clashes are detected
+  $ bison foo.y -d -o foo.x
+  fatal error: header and parser would be both named `foo.x'
+
 * A missing `;' ending a rule triggers a warning
   In accordance with POSIX, and in agreement with other
   Yacc implementations, Bison will mandate this semicolon in a near
 * A missing `;' ending a rule triggers a warning
   In accordance with POSIX, and in agreement with other
   Yacc implementations, Bison will mandate this semicolon in a near
index 83c863ffcaa9b1465a35d00706f2999cf58e713c..a7061d32237fe68f83c0c97630c6bc13885f83e4 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "system.h"
 #include "getargs.h"
 
 #include "system.h"
 #include "getargs.h"
+#include "quote.h"
 #include "files.h"
 #include "gram.h"
 #include "error.h"
 #include "files.h"
 #include "gram.h"
 #include "error.h"
@@ -419,7 +420,7 @@ compute_base_names (void)
 
       /* Computes the extensions from the grammar file name.  */
       filename_split (infile, &base, &tab, &ext);
 
       /* Computes the extensions from the grammar file name.  */
       filename_split (infile, &base, &tab, &ext);
-      
+
       if (ext && !yacc_flag)
        compute_exts_from_gf (ext);
     }
       if (ext && !yacc_flag)
        compute_exts_from_gf (ext);
     }
@@ -445,6 +446,20 @@ compute_output_file_names (void)
   if (!spec_defines_file)
     spec_defines_file = stringappend (full_base_name, header_extension);
 
   if (!spec_defines_file)
     spec_defines_file = stringappend (full_base_name, header_extension);
 
+  if (defines_flag)
+    {
+      /* This is really Q&D, but I don't want to spend time on issues
+        which will be different with 1.50.  */
+      const char *parser_filename = NULL;
+      if (spec_outfile)
+       parser_filename = spec_outfile;
+      else
+       parser_filename = stringappend (full_base_name, src_extension);
+      if (!strcmp (spec_defines_file, parser_filename))
+       fatal ("header and parser would be both named %s",
+              quote (parser_filename));
+    }
+
   /* It the graph filename if not given, we create it.  */
   if (!spec_graph_file)
     spec_graph_file = stringappend (short_base_name, ".vcg");
   /* It the graph filename if not given, we create it.  */
   if (!spec_graph_file)
     spec_graph_file = stringappend (short_base_name, ".vcg");
index 437383167d644036aef652a9b03fe96b8a9563a8..72289e873b4aeb5e0ca017135c95c43b26073124 100644 (file)
@@ -1,7 +1,7 @@
 /* Output the generated parsing program for bison,
 
 /* Output the generated parsing program for bison,
 
-   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001 Free Software
-   Foundation, Inc.
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002
+   Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
 
    This file is part of Bison, the GNU Compiler Compiler.
 
index 147e8b28addf0d9f43ea902604163a6b9ddf65a1..a1ac99477e324b1fb49ac4ff9943905fdf9b9d3e 100644 (file)
@@ -29,7 +29,7 @@ AT_DATA([$1],
 foo: {};
 ]])
 
 foo: {};
 ]])
 
-AT_CHECK([bison $3 $1], 0)
+AT_CHECK([bison $3 $1])
 AT_CHECK([ls $4], [], [ignore])
 AT_CLEANUP
 ])
 AT_CHECK([ls $4], [], [ignore])
 AT_CLEANUP
 ])
@@ -81,3 +81,15 @@ AT_CHECK_OUTPUT([foo.yy], [],
 AT_CHECK_OUTPUT([foo.yy], [],
                 [-o foo.c++ --graph=foo.gph],
                 [foo.c++ foo.gph])
 AT_CHECK_OUTPUT([foo.yy], [],
                 [-o foo.c++ --graph=foo.gph],
                 [foo.c++ foo.gph])
+
+# Be sure to reject cases where the parser and the header would have
+# the same name.
+AT_SETUP([Clashing Output Files.])
+AT_DATA([foo.y],
+[[%% foo: {};
+]])
+
+AT_CHECK([bison -do foo.x foo.y], [1], [],
+         [foo.y:2: fatal error: header and parser would be both named `foo.x'
+])
+AT_CLEANUP