bison-patches
[Top][All Lists]
Advanced

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

Re: Version 1.75-1 ignoring --no-lines flag


From: Akim Demaille
Subject: Re: Version 1.75-1 ignoring --no-lines flag
Date: 06 Nov 2002 17:21:31 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

| We use MsDev to run bison during a build.  In the generated C++ file, we
| were getting lines such as:
| 
| #line 512 "..\common\parser.h"
| 
| The MsDev compiler sees the quoted string and thinks the \c and the \p are
| unknown escaped characters and generates compiler warnings.  In another
| instance, this same sort of thing was causing a compiler error, but I can't
| remember exactly what the error was.

This is surprising!  Bison is expected to escape these guys!

/tmp % fgrep '#line' foo\\bar.tab.c                               nostromo 17:11
#line 92 "foo\bar.tab.c"
#line 910 "foo\bar.tab.c"
#line 2 "foo\\bar.y"

arg, indeed, it doesn't do that 100% correctly.

I'm installing the appended patch, which results in:

/tmp % fgrep '#line' foo\\bar.tab.c                               nostromo 17:17
#line 92 "foo\\bar.tab.c"
#line 910 "foo\\bar.tab.c"
#line 2 "foo\\bar.y"

Thanks!

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        #line should have quoted strings.
        Ideally, this should be done by m4_quotearg.

        * src/scan-skel.l: Include quotearg.h.
        Quote __ofile__.
        * src/output.c (symbol_printers_output)
        (symbol_destructors_output): Quote the file name.

Index: NEWS
===================================================================
RCS file: /cvsroot/bison/bison/NEWS,v
retrieving revision 1.69
diff -u -u -r1.69 NEWS
--- NEWS 6 Nov 2002 14:11:46 -0000 1.69
+++ NEWS 6 Nov 2002 16:20:32 -0000
@@ -8,13 +8,6 @@
 
 * --no-line works properly.
 
-Changes in version 1.75a, 2002-10-24:
-
-* Bison can no longer be built by a K&R C compiler; it requires C89 or
-  later to be built.  This change originally took place a few versions
-  ago, but nobody noticed until we recently asked someone to try
-  building Bison with a K&R C compiler.
-
 * %error-verbose
   This new directive is preferred over YYERROR_VERBOSE.
 
@@ -25,6 +18,16 @@
 
 * #line
   Bison now recognizes #line in its input, and forwards them.
+
+* #line
+  File names are properly escaped. E.g. foo\bar.y give #line 123 "foo\\bar.y".
+
+Changes in version 1.75a, 2002-10-24:
+
+* Bison can no longer be built by a K&R C compiler; it requires C89 or
+  later to be built.  This change originally took place a few versions
+  ago, but nobody noticed until we recently asked someone to try
+  building Bison with a K&R C compiler.
 
 Changes in version 1.75, 2002-10-14:
 
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.206
diff -u -u -r1.206 output.c
--- src/output.c 6 Nov 2002 14:11:47 -0000 1.206
+++ src/output.c 6 Nov 2002 16:20:35 -0000
@@ -380,7 +380,8 @@
           destructor, typename. */
        fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
                 first ? "" : ",\n",
-                symbol->destructor_location.file,
+                quotearg_style (escape_quoting_style,
+                                symbol->destructor_location.file),
                 symbol->destructor_location.first_line,
                 symbol->tag,
                 symbol->number,
@@ -414,7 +415,8 @@
           printer, typename. */
        fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
                 first ? "" : ",\n",
-                symbol->printer_location.file,
+                quotearg_style (escape_quoting_style,
+                                symbol->printer_location.file),
                 symbol->printer_location.first_line,
                 symbol->tag,
                 symbol->number,
Index: src/scan-skel.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-skel.l,v
retrieving revision 1.15
diff -u -u -r1.15 scan-skel.l
--- src/scan-skel.l 21 Oct 2002 05:30:50 -0000 1.15
+++ src/scan-skel.l 6 Nov 2002 16:20:35 -0000
@@ -23,12 +23,16 @@
 
 %{
 #include "system.h"
+#include "quotearg.h"
 #include "error.h"
 #include "getargs.h"
 #include "files.h"
+
 int skel_lex (void);
+
 static int yylineno = 1;
 static char *yyoutname = NULL;
+
 %}
 %%
   /* This is an approximation, but we don't need more. */
@@ -44,7 +48,7 @@
 "@:>@"           fputc (']', yyout);
 
 "__oline__"      fprintf (yyout, "%d", yylineno+1);
-"__ofile__"      fprintf (yyout, "%s", yyoutname);
+"__ofile__"      fprintf (yyout, "%s", quotearg_style (escape_quoting_style, 
yyoutname));
 address@hidden         ECHO;
 \n+              yylineno += yyleng; ECHO;
 .                ECHO;




reply via email to

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