bison-patches
[Top][All Lists]
Advanced

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

Re: Bison, yystpcpy, yystrlen


From: Paul Eggert
Subject: Re: Bison, yystpcpy, yystrlen
Date: Tue, 4 Dec 2001 06:35:39 -0800 (PST)

On second thought, I installed the following patch instead.  It avoids
the YYPOINTER portability problem in my previous patch, and it can
generate better code on some hosts since the compiler now knows that
yyptr is properly aligned.

2001-12-04  Paul Eggert  <address@hidden>

        * src/bison.simple (union yyalloc): Change member names
        to be the same as the stack names.
        (yyparse): yyptr is now union yyalloc *, not char *.
        (YYSTACK_RELOCATE): Likewise.  This avoids a GCC warning,
        and may generate better code on some machines.
        (yystpcpy): Use prototype if __STDC__ is defined, not just
        if __cplusplus is defined.

--- bison.simple        2001/11/30 13:14:10     1.53.2.10
+++ bison.simple        2001/12/04 14:06:06     1.53.2.12
@@ -81,8 +81,8 @@
 union yyalloc
 {
-  short yys;
-  YYSTYPE yyv;
+  short yyss;
+  YYSTYPE yyvs;
 # if YYLSP_NEEDED
-  YYLTYPE yyl;
+  YYLTYPE yyls;
 # endif
 };
@@ -112,10 +112,9 @@ union yyalloc
       {                                                                        
\
        YYSIZE_T yynewbytes;                                            \
-       yymemcpy (yyptr, (char *) (Stack),                              \
+       yymemcpy ((char *) yyptr, (char *) (Stack),                     \
                  yysize * (YYSIZE_T) sizeof (Type));                   \
-       (Stack) = (Type *) yyptr;                                       \
+       Stack = &yyptr->Stack;                                          \
        yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;     \
-       yynewbytes -= yynewbytes % sizeof (union yyalloc);              \
-       yyptr += yynewbytes;                                            \
+       yyptr += yynewbytes / sizeof (*yyptr);                          \
       }                                                                        
\
     while (0)
@@ -302,10 +301,10 @@ yystrlen (yystr)
    YYDEST.  */
 static char *
-#   ifndef __cplusplus
+#   if defined (__STDC__) || defined (__cplusplus)
+yystpcpy (char *yydest, const char *yysrc)
+#   else
 yystpcpy (yydest, yysrc)
      char *yydest;
      const char *yysrc;
-#   else
-yystpcpy (char *yydest, const char *yysrc)
 #   endif
 {
@@ -520,5 +519,6 @@ yyparse (YYPARSE_PARAM_ARG)
       {
        short *yyss1 = yyss;
-       char *yyptr = (char *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+       union yyalloc *yyptr =
+         (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
        if (! yyptr)
          goto yyoverflowlab;
@@ -798,5 +798,5 @@ yyerrlab:
        }
       else
-#endif /* YYERROR_VERBOSE */
+#endif /* defined (YYERROR_VERBOSE) */
        yyerror ("parse error");
     }



reply via email to

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