bug-bison
[Top][All Lists]
Advanced

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

Re: bison bug when standard input is closed


From: Paul Eggert
Subject: Re: bison bug when standard input is closed
Date: Sat, 01 Jan 2005 01:26:14 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Hans Aberg <address@hidden> writes:

> Ther is a bug in the scan-skel.l dating back to at least Bison 1.75: The
> rule that opens the file streams, at the first run, it tries to close the
> standard output stream.

Thanks for reporting this.  I installed the following patch.

2005-01-01  Paul Eggert  <address@hidden>

        * src/scan-skel.l ("@output ".*\n): Don't close standard output.
        Problem reported by Hans Aberg.
        * tests/output.at (AT_CHECK_OUTPUT): New arg SHELLIO.
        (Output file names.): Add a test for the case when standard output
        is closed.

Index: src/scan-skel.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-skel.l,v
retrieving revision 1.27
diff -p -u -r1.27 scan-skel.l
--- src/scan-skel.l     11 Dec 2004 06:16:44 -0000      1.27
+++ src/scan-skel.l     1 Jan 2005 09:09:45 -0000
@@ -1,6 +1,6 @@
 /* Scan Bison Skeletons.                                       -*- C -*-
 
-   Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -59,9 +59,12 @@ int skel_lex (void);
        fatal ("invalid token in skeleton: %s", yytext);
     }
 
-  free (outname);
+  if (outname)
+    {
+      free (outname);
+      xfclose (yyout);
+    }
   outname = xstrdup (filename);
-  xfclose (yyout);
   yyout = xfopen (outname, "w");
   lineno = 1;
 }
@@ -73,14 +76,14 @@ int skel_lex (void);
 "@oline@"  fprintf (yyout, "%d", lineno + 1);
 "@ofile@"  QPUTS (outname);
 "@output_parser_name@" QPUTS (parser_file_name);
-"@output_header_name@"  QPUTS (spec_defines_file);
+"@output_header_name@" QPUTS (spec_defines_file);
 
   /* This pattern must not match more than the previous @ patterns. */
 @address@hidden fatal ("invalid @ in skeleton: %s", yytext);
 \n        lineno++; ECHO;
 address@hidden    ECHO;
 
-<<EOF>>           xfclose (yyout); free (outname); return EOF;
+<<EOF>>           free (outname); xfclose (yyout); return EOF;
 %%
 
 /*------------------------.
Index: tests/output.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/output.at,v
retrieving revision 1.6
diff -p -u -r1.6 output.at
--- tests/output.at     4 Mar 2002 16:23:35 -0000       1.6
+++ tests/output.at     1 Jan 2005 09:09:45 -0000
@@ -1,5 +1,5 @@
 # Checking the output filenames.                    -*- Autotest -*-
-# Copyright 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -19,23 +19,26 @@
 AT_BANNER([[Output file names.]])
 
 
-# AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES)
-# ------------------------------------------------------------------
+# AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [SHELLIO])
+# -----------------------------------------------------------------------------
 m4_define([AT_CHECK_OUTPUT],
-[AT_SETUP([Output files: $2 & $3.])
+[AT_SETUP([Output files: $2 & $3 $5.])
 AT_DATA([$1],
 [[$2
 %%
 foo: {};
 ]])
 
-AT_CHECK([bison $3 $1], 0)
+AT_CHECK([bison $3 $1 $5], 0)
 AT_CHECK([ls $4], [], [ignore])
 AT_CLEANUP
 ])
 
 AT_CHECK_OUTPUT([foo.y], [], [-dv],
                 [foo.output foo.tab.c foo.tab.h])
+AT_CHECK_OUTPUT([foo.y], [], [-dv],
+                [foo.output foo.tab.c foo.tab.h],
+                [>&-])
 AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
                 [foo.c foo.h foo.output])
 AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],




reply via email to

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