]> git.saurik.com Git - bison.git/commitdiff
Bison dumps core when trying to complain about broken input files.
authorAkim Demaille <akim@epita.fr>
Tue, 22 Jan 2002 10:29:28 +0000 (10:29 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 22 Jan 2002 10:29:28 +0000 (10:29 +0000)
Reported by Cris van Pelt.
* src/lex.c (parse_percent_token): Be sure to set token_buffer.
* tests/regression.at (Invalid input: 1, Invalid input: 2): Merge
into...
(Invalid inputs): Strengthen: exercise parse_percent_token.

ChangeLog
NEWS
THANKS
src/lex.c
tests/regression.at

index 26cced1f4d1873e193fa12dc585bd26a886d9b92..93992df6a514c403dda3af02a7d9d279ab7ab341 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-01-22  Akim Demaille  <akim@epita.fr>
+
+       Bison dumps core when trying to complain about broken input files.
+       Reported by Cris van Pelt.
+
+       * src/lex.c (parse_percent_token): Be sure to set token_buffer.
+       * tests/regression.at (Invalid input: 1, Invalid input: 2): Merge
+       into...
+       (Invalid inputs): Strengthen: exercise parse_percent_token.
+
 2002-01-21  Paolo Bonzini <bonzini@gnu.org>
 
        * po/it.po: New.
diff --git a/NEWS b/NEWS
index f8fb697c9268f685daa712e779c2a09a0e96af3e..75187a441b0a0db40bfec444e563d1fe67b01f01 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,11 +3,12 @@ Bison News
 
 Changes in version 1.31a:
 
-* Fix YACC option output file names
+* Fix Yacc output file names
 
 * Portability fixes
 
 * Italian translation
+
 \f
 Changes in version 1.31, 2002-01-14:
 
diff --git a/THANKS b/THANKS
index e6424c84efdd7f84684fb932c4523eda0817882d..7f3784810686a032461e5cd21de091d516b3e3ea 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -6,6 +6,7 @@ Akim Demaille           akim@freefriends.org
 Albert Chin-A-Young     china@thewrittenword.com
 Alexander Belopolsky    alexb@rentec.com
 Arnold Robbins         arnold@skeeve.com
+Cris van Pelt           cris@amf03054.office.wxs.nl
 Daniel Hagerty          hag@gnu.org
 David J. MacKenzie      djm@gnu.org
 Dick Streefland                dick.streefland@altium.nl
index b0c1ef1813625206d1a47d43d987af8fab6ed6ed..1d2424e2b421c73f6e98f4621996262c8a609af2 100644 (file)
--- a/src/lex.c
+++ b/src/lex.c
@@ -590,43 +590,54 @@ parse_percent_token (void)
   size_t arg_offset = 0;
 
   int c = getc (finput);
+  obstack_1grow (&token_obstack, '%');
+  obstack_1grow (&token_obstack, c);
 
   switch (c)
     {
     case '%':
+      token_buffer = obstack_finish (&token_obstack);
       return tok_two_percents;
 
     case '{':
+      token_buffer = obstack_finish (&token_obstack);
       return tok_percent_left_curly;
 
-      /* FIXME: Who the heck are those 5 guys!?! `%<' = `%left'!!!
-        Let's ask for there removal.  */
+      /* The following guys are here for backward compatibility with
+        very ancient Yacc versions.  The paper of Johnson mentions
+        them (as ancient :).  */
     case '<':
+      token_buffer = obstack_finish (&token_obstack);
       return tok_left;
 
     case '>':
+      token_buffer = obstack_finish (&token_obstack);
       return tok_right;
 
     case '2':
+      token_buffer = obstack_finish (&token_obstack);
       return tok_nonassoc;
 
     case '0':
+      token_buffer = obstack_finish (&token_obstack);
       return tok_token;
 
     case '=':
+      token_buffer = obstack_finish (&token_obstack);
       return tok_prec;
     }
 
   if (!isalpha (c))
-    return tok_illegal;
+    {
+      token_buffer = obstack_finish (&token_obstack);
+      return tok_illegal;
+    }
 
-  obstack_1grow (&token_obstack, '%');
-  while (isalpha (c) || c == '_' || c == '-')
+  while (c = getc (finput), isalpha (c) || c == '_' || c == '-')
     {
       if (c == '_')
        c = '-';
       obstack_1grow (&token_obstack, c);
-      c = getc (finput);
     }
 
   /* %DIRECTIVE="ARG".  Separate into
index 11016d0f619ad29dd2af646af7f4859e08ea71c5..8f07dd911a893ba62a916b72831fc65873bd2529 100644 (file)
@@ -545,40 +545,30 @@ AT_CHECK([fgrep '//*' union-comment.tab.c], [1], [])
 AT_CLEANUP
 
 
-## ----------------- ##
-## Invalid input 1.  ##
-## ----------------- ##
+## ---------------- ##
+## Invalid inputs.  ##
+## ---------------- ##
 
 
-AT_SETUP([Invalid input: 1])
+AT_SETUP([Invalid inputs])
 
 AT_DATA([input.y],
 [[%%
 ?
-]])
-
-AT_CHECK([bison input.y], [1], [],
-[[input.y:2: invalid input: `?'
-input.y:3: fatal error: no rules in the input grammar
-]])
-
-AT_CLEANUP
-
-
-## ----------------- ##
-## Invalid input 2.  ##
-## ----------------- ##
-
-
-AT_SETUP([Invalid input: 2])
-
-AT_DATA([input.y],
-[[%%
 default: 'a' }
+%{
+%&
+%a
+%-
 ]])
 
 AT_CHECK([bison input.y], [1], [],
-[[input.y:2: invalid input: `}'
+[[input.y:2: invalid input: `?'
+input.y:3: invalid input: `}'
+input.y:4: invalid input: `%{'
+input.y:5: invalid input: `%&'
+input.y:6: invalid input: `%a'
+input.y:7: invalid input: `%-'
 ]])
 
 AT_CLEANUP