help-bison
[Top][All Lists]
Advanced

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

Re: Compiling Reverse Polish Calculator Example


From: Akim Demaille
Subject: Re: Compiling Reverse Polish Calculator Example
Date: Thu, 1 Nov 2012 14:24:39 +0100

Le 31 oct. 2012 à 18:04, Akim Demaille a écrit :

> Le 31 oct. 2012 à 17:24, Paul Eggert a écrit :
> 
>> I suppose there should be a quote_mem or something like that.
> 
> How about this?
> 
> (the context for gnulibers:
> http://lists.gnu.org/archive/html/help-bison/2012-10/msg00017.html)
> 
> commit 4eb2dff11e4920ecbcec69a60f282900e152e400
> Author: Akim Demaille <address@hidden>
> Date:   Wed Oct 31 18:01:34 2012 +0100
> 
>    quote: provide a means to escape strings with nul characters
> 
>    * lib/quote.h, lib/quote.c (quote_mem, quote_n_mem): New functions.
>    (quote, quote_n): Rename formal arguments for consistency with
>    quotearg.

If the patch is accepted, then I'll proceed in Bison with the
following one.  Note that in the test case there are many people
living in '1.1':

  input.y:1.1: error: invalid character: '\0'
  input.y:1.1: error: invalid character: '\001'
  input.y:1.1: error: invalid character: '\002'
  input.y:1.1: error: invalid character: '\377'

that's apparently how mbsnwidth treats the control characters.
The documentation reads:

  /* If this bit is set, return -1 upon finding a non-printable character.
     Otherwise, assume unprintable characters have width 0 if they are
     control characters and 1 otherwise.  */
  #define MBSW_REJECT_UNPRINTABLE 2

so I guess this is expected.

commit 9cae2da2994a7e787e86002e4dceaf57f88fc3b8
Author: Akim Demaille <address@hidden>
Date:   Thu Nov 1 13:47:12 2012 +0100

    grammars: fix display of nul character in error message
    
    Reported by Marc Mendiola.
    http://lists.gnu.org/archive/html/help-bison/2012-10/msg00017.html
    
    * gnulib: Update to get quote_mem.
    * src/scan-gram.l: Use it.
    * tests/input.at (Invalid inputs): Additional checks.

diff --git a/THANKS b/THANKS
index 185097f..0c4d9fc 100644
--- a/THANKS
+++ b/THANKS
@@ -64,6 +64,7 @@ Laurent Mascherpa         address@hidden
 Lie Yan                   address@hidden
 Magnus Fromreide          address@hidden
 Marc Autret               address@hidden
+Marc Mendiola             address@hidden
 Martin Jacobs             address@hidden
 Martin Mokrejs            address@hidden
 Martin Nylin              address@hidden
diff --git a/gnulib b/gnulib
index 0e6a848..4eb2dff 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 0e6a848c8cd1e9442e3794c7dcd2f535ea9797c6
+Subproject commit 4eb2dff11e4920ecbcec69a60f282900e152e400
diff --git a/src/scan-gram.l b/src/scan-gram.l
index dbea2a1..ad061cc 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -291,7 +291,7 @@ splice       (\\[ \f\t\v]*\n)*
   }
 
   . {
-    complain_at (*loc, _("invalid character: %s"), quote (yytext));
+    complain_at (*loc, _("invalid character: %s"), quote_mem (yytext, yyleng));
   }
 
   <<EOF>> {
@@ -375,7 +375,7 @@ splice       (\\[ \f\t\v]*\n)*
   }
   . {
     complain_at (*loc, _("invalid character in bracketed name: %s"),
-                quote (yytext));
+                quote_mem (yytext, yyleng));
   }
   <<EOF>> {
     BEGIN bracketed_id_context_state;
diff --git a/tests/input.at b/tests/input.at
index d4510ff..35812c8 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -27,7 +27,8 @@ AT_BANNER([[Input Processing.]])
 AT_SETUP([Invalid inputs])
 
 AT_DATA([input.y],
-[[%%
+[[\000\001\002\377?
+%%
 ?
 default: 'a' }
 %&
@@ -35,17 +36,23 @@ default: 'a' }
 %-
 %{
 ]])
+AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]])
 
 AT_BISON_CHECK([input.y], [1], [],
-[[input.y:2.1: error: invalid character: '?'
-input.y:3.14: error: invalid character: '}'
-input.y:4.1: error: invalid character: '%'
-input.y:4.2: error: invalid character: '&'
-input.y:5.1-17: error: invalid directive: '%a-does-not-exist'
-input.y:6.1: error: invalid character: '%'
-input.y:6.2: error: invalid character: '-'
-input.y:7.1-8.0: error: missing '%}' at end of file
-input.y:7.1-8.0: error: syntax error, unexpected %{...%}
+[[input.y:1.1: error: invalid character: '\0'
+input.y:1.1: error: invalid character: '\001'
+input.y:1.1: error: invalid character: '\002'
+input.y:1.1: error: invalid character: '\377'
+input.y:1.2: error: invalid character: '?'
+input.y:3.1: error: invalid character: '?'
+input.y:4.14: error: invalid character: '}'
+input.y:5.1: error: invalid character: '%'
+input.y:5.2: error: invalid character: '&'
+input.y:6.1-17: error: invalid directive: '%a-does-not-exist'
+input.y:7.1: error: invalid character: '%'
+input.y:7.2: error: invalid character: '-'
+input.y:8.1-9.0: error: missing '%}' at end of file
+input.y:8.1-9.0: error: syntax error, unexpected %{...%}
 ]])
 
 AT_CLEANUP




reply via email to

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