bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: 1.3x: name clashes


From: Akim Demaille
Subject: FYI: 1.3x: name clashes
Date: 04 Mar 2002 19:13:09 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

The equivalent remains to be done in the trunk.  Someone picking up
the ball?

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * 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.

Index: NEWS
===================================================================
RCS file: /cvsroot/bison/bison/NEWS,v
retrieving revision 1.21.2.60
diff -u -u -r1.21.2.60 NEWS
--- NEWS 4 Mar 2002 14:57:45 -0000 1.21.2.60
+++ NEWS 4 Mar 2002 18:03:03 -0000
@@ -3,6 +3,10 @@
 
 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
Index: src/files.c
===================================================================
RCS file: /cvsroot/bison/bison/src/files.c,v
retrieving revision 1.51.2.19
diff -u -u -r1.51.2.19 files.c
--- src/files.c 13 Feb 2002 16:13:31 -0000 1.51.2.19
+++ src/files.c 4 Mar 2002 18:03:03 -0000
@@ -22,6 +22,7 @@
 
 #include "system.h"
 #include "getargs.h"
+#include "quote.h"
 #include "files.h"
 #include "gram.h"
 #include "error.h"
@@ -419,7 +420,7 @@
 
       /* Computes the extensions from the grammar file name.  */
       filename_split (infile, &base, &tab, &ext);
-      
+
       if (ext && !yacc_flag)
        compute_exts_from_gf (ext);
     }
@@ -444,6 +445,20 @@
   /* It the defines filename if not given, we create it.  */
   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)
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.39.2.22
diff -u -u -r1.39.2.22 output.c
--- src/output.c 13 Feb 2002 18:34:59 -0000 1.39.2.22
+++ src/output.c 4 Mar 2002 18:03:03 -0000
@@ -1,7 +1,7 @@
 /* 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.
 
Index: tests/output.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/output.at,v
retrieving revision 1.1.2.8
diff -u -u -r1.1.2.8 output.at
--- tests/output.at 4 Mar 2002 14:57:46 -0000 1.1.2.8
+++ tests/output.at 4 Mar 2002 18:03:03 -0000
@@ -29,7 +29,7 @@
 foo: {};
 ]])
 
-AT_CHECK([bison $3 $1], 0)
+AT_CHECK([bison $3 $1])
 AT_CHECK([ls $4], [], [ignore])
 AT_CLEANUP
 ])
@@ -81,3 +81,15 @@
 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



reply via email to

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