[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fixes to allow glr.c to be used for C++ as well.
From: |
Paul Eggert |
Subject: |
Re: [PATCH] Fixes to allow glr.c to be used for C++ as well. |
Date: |
14 Jan 2004 11:47:04 -0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Paul Hilfinger <address@hidden> writes:
> I've checked in a few small modifications to remove compilation
> errors from C++ parsers produced from glr.c.
Thanks; I had just discovered the same thing when I was looking into
the glr.c segfault problem reported in
<http://mail.gnu.org/archive/html/bug-bison/2004-01/msg00002.html>.
Have you had a chance to look into the segfault? Here's a fix adapted from
<http://mail.gnu.org/archive/html/bug-bison/2004-01/msg00007.html>,
but I worry that the problem is a symptom of something deeper.
2004-01-12 Paul Eggert <address@hidden>
* data/glr.c (yyreportSyntaxError): Don't dump core if
*yytokenp == YYEMPTY.
Index: glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.66
diff -p -u -r1.66 glr.c
--- glr.c 14 Jan 2004 01:40:12 -0000 1.66
+++ glr.c 14 Jan 2004 19:44:31 -0000
@@ -1,7 +1,7 @@
m4_divert(-1) -*- C -*-
# GLR skeleton for Bison
-# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004 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
@@ -1647,14 +1647,19 @@ yyreportSyntaxError (yyGLRStack* yystack
}
yyprefix = " or ";
}
- yysize += (sizeof ("syntax error, unexpected ")
- + strlen (yytokenName (*yytokenp)));
+ yysize += (*yytokenp == YYEMPTY
+ ? sizeof "syntax error"
+ : (sizeof "syntax error, unexpected "
+ + strlen (yytokenName (*yytokenp))));
yymsg = (char*) YYMALLOC (yysize);
if (yymsg != 0)
{
char* yyp = yymsg;
- sprintf (yyp, "syntax error, unexpected %s",
- yytokenName (*yytokenp));
+ if (*yytokenp == YYEMPTY)
+ strcpy (yyp, "syntax error");
+ else
+ sprintf (yyp, "syntax error, unexpected %s",
+ yytokenName (*yytokenp));
yyp += strlen (yyp);
if (yycount < 5)
{