On Tue, Oct 10, 2006 at 10:32:25PM -0700, Paul Eggert wrote:
> Bob Rossi <[EMAIL PROTECTED]> writes:
> 
> > Are you suggesting I could take the 
> > 'char yymsgbuf[128];' out of the 'struct yypvars' and simply use the
> > one on the stack that appears each time yypushparse is called?
> 
> Yes, I think so.  But you know the code better than I.

OK, one problem at a time. Here is a patch against push.c that removes
the yymsgbuf, yymsgbuf_ptr, yymsg and yymsg_alloc fields from the
yypvars structure. So, there is a yymsgbuf array in the yypushparse
function that yypushparse uses. The array is pushed on the stack 
each time yypushparse is called, and the data is not persistant between
yypushparse calls. I have absolutly no idea what yymsgbuf is used for.

If the data does not need to be persistant between calls, and if this
array does not cause the push parser to be non reentrant between calls,
then this patch should be applied.

What do you think?
Bob Rossi

2006-10-11  Bob Rossi  <[EMAIL PROTECTED]>

        * data/push.c (struct yypvars): Remove yymsgbuf, yymsgbuf_ptr, yymsg,
        yymsg_alloc fields.
        (yypvarsinit, yypushparse): Remove init of removed fields.
        (yypushparse): Use yymsgbuf instead of yymsgbuf_ptr.
Index: data/push.c
===================================================================
RCS file: /sources/bison/bison/data/push.c,v
retrieving revision 1.3
diff -u -r1.3 push.c
--- data/push.c 21 Sep 2006 17:45:21 -0000      1.3
+++ data/push.c 11 Oct 2006 15:25:57 -0000
@@ -1017,14 +1017,6 @@
     /* Look-ahead token as an internal (translated) token number.  */
     int yytoken;
 
-#if YYERROR_VERBOSE
-    /* Buffer for error messages, and its allocated size.  */
-    char yymsgbuf[128];
-    char *yymsgbuf_ptr;
-    char *yymsg;
-    YYSIZE_T yymsg_alloc;
-#endif
-
     /* Three stacks and their tools:
        `yyss': related to states,
        `yyvs': related to semantic values,
@@ -1070,12 +1062,6 @@
   pv->yyerrstatus = 0;
   pv->yytoken = 0;
 
-#if YYERROR_VERBOSE
-  pv->yymsgbuf_ptr = pv->yymsgbuf;
-  pv->yymsg = pv->yymsgbuf;
-  pv->yymsg_alloc = sizeof pv->yymsgbuf;
-#endif
-
   pv->yyssa_ptr = pv->yyssa;
   pv->yyss = pv->yyssa;
   pv->yyvs = pv->yyvsa;
@@ -1153,7 +1139,6 @@
 #if YYERROR_VERBOSE
   /* Buffer for error messages, and its allocated size.  */
   char yymsgbuf[128];
-  char *yymsgbuf_ptr = yymsgbuf;
   char *yymsg = yymsgbuf;
   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
 #endif
@@ -1248,11 +1233,7 @@
        yyresult = pv->yyresult;
        yyerrstatus = pv->yyerrstatus;
        yytoken = pv->yytoken;
-#if YYERROR_VERBOSE
-       yymsgbuf_ptr = pv->yymsgbuf_ptr;
-       yymsg = pv->yymsg;;
-       yymsg_alloc = pv->yymsg_alloc;
-#endif
+
        yyssa_ptr = pv->yyssa_ptr;
        yyss = pv->yyss;
        yyssp = pv->yyssp;
@@ -1393,11 +1374,7 @@
        pv->yyresult = yyresult;
        pv->yyerrstatus = yyerrstatus;
        pv->yytoken = yytoken;
-#if YYERROR_VERBOSE
-       pv->yymsgbuf_ptr = yymsgbuf_ptr;
-       pv->yymsg = yymsg;;
-       pv->yymsg_alloc = yymsg_alloc;
-#endif
+
        pv->yyssa_ptr = yyssa_ptr;
        pv->yyss = yyss;
        pv->yyssp = yyssp;
@@ -1541,14 +1518,14 @@
            YYSIZE_T yyalloc = 2 * yysize;
            if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
              yyalloc = YYSTACK_ALLOC_MAXIMUM;
-           if (yymsg != yymsgbuf_ptr)
+           if (yymsg != yymsgbuf)
              YYSTACK_FREE (yymsg);
            yymsg = (char *) YYSTACK_ALLOC (yyalloc);
            if (yymsg)
              yymsg_alloc = yyalloc;
            else
              {
-               yymsg = yymsgbuf_ptr;
+               yymsg = yymsgbuf;
                yymsg_alloc = sizeof yymsgbuf;
              }
          }
@@ -1705,7 +1682,7 @@
     YYSTACK_FREE (yyss);
 #endif
 #if YYERROR_VERBOSE
-  if (yymsg != yymsgbuf_ptr)
+  if (yymsg != yymsgbuf)
     YYSTACK_FREE (yymsg);
 #endif
   ]b4_push_if([pv->yyresult = YYID (yyresult);])[

Reply via email to