]> git.saurik.com Git - bison.git/commitdiff
* src/bison.simple (YYSTACK_REALLOC): New.
authorAkim Demaille <akim@epita.fr>
Mon, 12 Nov 2001 09:24:50 +0000 (09:24 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 12 Nov 2001 09:24:50 +0000 (09:24 +0000)
(yyparse) [!yyoverflow]: Use it and free the old stack.
Reported by FIXME: Who.

ChangeLog
THANKS
src/bison.simple

index 93cc7f02e200f58ba29bbef3e6a9fd70b0a24201..3d660360b0082e2196ef68c8ec9496a266d17bb3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-11-12  Akim Demaille  <akim@epita.fr>
+
+       * src/bison.simple (YYSTACK_REALLOC): New.
+       (yyparse) [!yyoverflow]: Use it and free the old stack.
+       Reported by FIXME: Who.
+
 2001-11-12  Pascal Bart  <pascal.bart@epita.fr>
 
        * src/bison.simple: Define type yystype instead of YYSTYPE, and
diff --git a/THANKS b/THANKS
index e74019f0aaf9a452d6e39d953b8bf9c5020abb95..f74230bb577924d04419b80760030ce8343f100f 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -2,7 +2,7 @@ Bison was originally written by Robert Corbett.  It would not be what
 it is today without the invaluable help of these people:
 
 Airy Andre              Airy.Andre@edf.fr
-Akim Demaille           akim@epita.fr
+Akim Demaille           akim@freefriends.org
 Albert Chin-A-Young     china@thewrittenword.com
 Alexander Belopolsky    alexb@rentec.com
 Daniel Hagerty          hag@gnu.org
@@ -20,6 +20,7 @@ Neil Booth              NeilB@earthling.net
 Noah Friedman           friedman@gnu.org
 Pascal Bart             pascal.bart@epita.fr
 Paul Eggert             eggert@twinsun.com
+Per Allansson           per@appgate.com
 Piotr Gackiewicz        gacek@intertel.com.pl
 Richard Stallman        rms@gnu.org
 Robert Anisko           anisko_r@epita.fr
index eb94f301b29121b7a4717ec580eb7884f7ead5aa..d08be3ff7cfeb2a424b01470c9d16d85244c13b5 100644 (file)
 # define YYSTACK_USE_ALLOCA 0
 #endif
 
+/* Realloc WHAT from SIZE to YYSTACKSIZE elements of TYPE.
+   If WHAT was malloc'ed (not the original automatic ARRAY), free it. */
 #if YYSTACK_USE_ALLOCA
-# define YYSTACK_ALLOC alloca
+# define YYSTACK_REALLOC(Type, What, Array)                            \
+do {                                                                   \
+  Type *old = What;                                                    \
+  What = (Type *) malloc (yystacksize * sizeof (Type));                        \
+  __yy_memcpy ((char *) What, (char *) old,                            \
+              (size) * (unsigned int) sizeof (Type));                  \
+  yyfree_stacks = 1;                                                   \
+  if (old != Array)                                                    \
+    free (old);                                                                \
+} while (0)
 #else
-# define YYSTACK_ALLOC malloc
+# define YYSTACK_REALLOC(Type, What, Array)                            \
+do {                                                                   \
+  Type *old = What;                                                    \
+  What = (Type *) alloca (yystacksize * sizeof (Type));                        \
+  __yy_memcpy ((char *) What, (char *) old,                            \
+              (size) * (unsigned int) sizeof (Type));                  \
+} while (0)
 #endif
 
 #define YYBISON        1       /* Identify Bison output.  */
@@ -452,7 +469,7 @@ yyparse (YYPARSE_PARAM_ARG)
 
   /* Three stacks and their tools:
      `yyss': related to states,
-     `yysv': related to semantic values,
+     `yyvs': related to semantic values,
      `yyls': related to locations.
 
      Refer to the stacks thru separate pointers, to allow yyoverflow
@@ -580,19 +597,11 @@ yyparse (YYPARSE_PARAM_ARG)
       yystacksize *= 2;
       if (yystacksize > YYMAXDEPTH)
        yystacksize = YYMAXDEPTH;
-# if !YYSTACK_USE_ALLOCA
-      yyfree_stacks = 1;
-# endif
-      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
-      __yy_memcpy ((char *)yyss, (char *)yyss1,
-                  size * (unsigned int) sizeof (*yyssp));
-      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
-      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
-                  size * (unsigned int) sizeof (*yyvsp));
+
+      YYSTACK_REALLOC (short, yyss, yyssa);
+      YYSTACK_REALLOC (YYSTYPE, yyvs, yyvsa);
 # if YYLSP_NEEDED
-      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
-      __yy_memcpy ((char *)yyls, (char *)yyls1,
-                  size * (unsigned int) sizeof (*yylsp));
+      YYSTACK_REALLOC (YYLTYPE, yyls, yylsa);
 # endif
 #endif /* no yyoverflow */