bison-patches
[Top][All Lists]
Advanced

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

GLR regression-test patch to try to dump core faster on MacOS


From: Paul Eggert
Subject: GLR regression-test patch to try to dump core faster on MacOS
Date: Fri, 18 Mar 2005 13:00:52 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

In an attempt to track down why Bison's test "Improper handling of
embedded actions and dollar(-N) in GLR parsers" is failing on one
MacOS installation (and even then, only if "make check" is invoked;
the test succeeds if invoked by hand), I installed this:

2005-03-18  Paul Eggert  <address@hidden>

        * tests/glr-regression.at (glr-regr2a.y): Try to dump core
        immediately if a data overrun has occurred; this may help us track
        down what may be a spurious failure on MacOS.

--- glr-regression.at   7 Feb 2005 23:14:22 -0000       1.3
+++ glr-regression.at   18 Mar 2005 20:57:19 -0000      1.4
@@ -127,6 +127,7 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
 
   #include <ctype.h>
   #include <stdio.h>
+  #include <stdlib.h>
   #include <string.h>
   int yylex (void);
   void yyerror (char const *);
@@ -155,11 +156,10 @@ var_list:
     { $$ = $1; }
   | var ',' var_list
     {
-      char buffer[50];
-      strcpy (buffer, $1);
-      strcat (buffer, ",");
-      strcat (buffer, $3);
-      $$ = strdup (buffer);
+      $$ = malloc (strlen ($1) + 1 + strlen ($3) + 1);
+      strcpy ($$, $1);
+      strcat ($$, ",");
+      strcat ($$, $3);
     }
   ;
 
@@ -182,8 +182,12 @@ yylex (void)
   default:
     break;
   }
-  fscanf (yyin, "%s", buf);
-  yylval = strdup (buf);
+  if (fscanf (yyin, "%49s", buf) != 1)
+    abort ();
+  if (sizeof buf - 1 <= strlen (buf))
+    abort ();
+  yylval = malloc (strlen (buf) + 1);
+  strcpy (yylval, buf);
   return 'V';
 }
 




reply via email to

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