bug-bison
[Top][All Lists]
Advanced

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

Re: Bison 2.0 available from alpha.gnu.org


From: Hans Aberg
Subject: Re: Bison 2.0 available from alpha.gnu.org
Date: Wed, 29 Dec 2004 19:15:36 +0100
User-agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6

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. On my system, it causes other stream problems as
well. Therefore, I have inserted the code:

"@output ".*\n {
  char const *filename = yytext + sizeof "@output " - 1;
  yytext[yyleng - 1] = '\0';

  if (*filename == '@')
    {
      if (strcmp (filename, "@output_header_name@") == 0)
    filename = spec_defines_file;
      else if (strcmp (filename, "@output_parser_name@") == 0)
    filename = parser_file_name;
      else
    fatal ("invalid token in skeleton: %s", yytext);
    }

  free (outname);
  outname = xstrdup (filename);
  if (yyout != stdout)  /* Do not attempt to close stdout! */
    xfclose (yyout);
  yyout = xfopen (outname, "w");
  lineno = 1;
}

It is probable better to have an initialize flag set, and then check that
one instead. I.e.:
%%

%{
  int lineno IF_LINT (= 0);
  char *outname = NULL;
  int file_open = 0;
%}

...

"@output ".*\n {
  char const *filename = yytext + sizeof "@output " - 1;
  yytext[yyleng - 1] = '\0';

  if (*filename == '@')
    {
      if (strcmp (filename, "@output_header_name@") == 0)
    filename = spec_defines_file;
      else if (strcmp (filename, "@output_parser_name@") == 0)
    filename = parser_file_name;
      else
    fatal ("invalid token in skeleton: %s", yytext);
    }

  free (outname);
  outname = xstrdup (filename);
  if (file_open)
    xfclose (yyout);
  yyout = xfopen (outname, "w");
  file_open = 1;
  lineno = 1;
}

  Hans Aberg






reply via email to

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