]> git.saurik.com Git - bison.git/blobdiff - src/files.c
README-alpha: New.
[bison.git] / src / files.c
index 24a17fa62e72ee2121f7d3e766219747df55e081..7433076a1f81e8afe07f30a9b73366e484791b41 100644 (file)
 #include "complain.h"
 
 FILE *finput = NULL;
-FILE *foutput = NULL;
 
 struct obstack action_obstack;
 struct obstack attrs_obstack;
 struct obstack table_obstack;
 struct obstack defines_obstack;
 struct obstack guard_obstack;
+struct obstack output_obstack;
 
 char *spec_outfile;    /* for -o. */
 char *spec_file_prefix; /* for -b. */
@@ -185,11 +185,11 @@ compute_base_names (void)
       base_length = strlen (spec_outfile);
       if (strsuffix (spec_outfile, ".c"))
        base_length -= 2;
+      base_name = strndup (spec_outfile, base_length);
       /* SHORT_BASE_LENGTH includes neither ".tab" nor ".c".  */
       short_base_length = base_length;
-      if (strsuffix (spec_outfile, ".tab") || strsuffix (spec_outfile, "_tab"))
+      if (strsuffix (base_name, ".tab") || strsuffix (base_name, "_tab"))
        short_base_length -= 4;
-      base_name = strndup (spec_outfile, base_length);
       short_base_name = strndup (spec_outfile, short_base_length);
 
       return;
@@ -249,11 +249,6 @@ open_files (void)
 
   finput = xfopen (infile, "r");
 
-  if (verbose_flag)
-    /* We used to use just .out if spec_name_prefix (-p) was used, but
-       that conflicts with Posix.  */
-    foutput = xfopen (stringappend (short_base_name, EXT_OUTPUT), "w");
-
   attrsfile = stringappend (short_base_name, EXT_STYPE_H);
 
   /* Initialize the obstacks. */
@@ -262,6 +257,7 @@ open_files (void)
   obstack_init (&table_obstack);
   obstack_init (&defines_obstack);
   obstack_init (&guard_obstack);
+  obstack_init (&output_obstack);
 }
 
 
@@ -274,7 +270,6 @@ void
 output_files (void)
 {
   xfclose (finput);
-  xfclose (foutput);
 
   /* Output the main file.  */
   if (spec_outfile)
@@ -298,4 +293,9 @@ output_files (void)
       obstack_save (&guard_obstack,
                    stringappend (short_base_name, EXT_GUARD_C));
     }
+
+  if (verbose_flag)
+    /* We used to use just .out if spec_name_prefix (-p) was used, but
+       that conflicts with Posix.  */
+    obstack_save (&output_obstack, stringappend (short_base_name, EXT_OUTPUT));
 }