bison-patches
[Top][All Lists]
Advanced

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

[PATCH 10/11] grammar: do not add a \n at the end of blocks of code


From: Akim Demaille
Subject: [PATCH 10/11] grammar: do not add a \n at the end of blocks of code
Date: Thu, 4 Apr 2013 17:36:27 +0200

We now use "braceless" (which is {...} blocks of code with initial and
final braces stripped) to denote "short" values (such as
api.namespaces), the added end-of-line is a nuisance.  As a matter of
fact, this extra-safety is useless, as every expansion of "braceless"
(aka, "user code") is followed by an end of line.

* src/parse-gram.y, src/parse-gram.c (braceless): Instead of replacing
the final brace by \n, just delete the brace.
---
 src/parse-gram.c | 2 +-
 src/parse-gram.y | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/parse-gram.c b/src/parse-gram.c
index 8ff1d06..2cf9e86 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -2676,7 +2676,7 @@ yyreduce:
 #line 683 "src/parse-gram.y" /* yacc.c:1668  */
     {
       code_props plain_code;
-      (yyvsp[0].code)[strlen ((yyvsp[0].code)) - 1] = '\n';
+      (yyvsp[0].code)[strlen ((yyvsp[0].code)) - 1] = '\0';
       code_props_plain_init (&plain_code, (yyvsp[0].code)+1, (yylsp[0]));
       code_props_translate_code (&plain_code);
       gram_scanner_last_string_free ();
diff --git a/src/parse-gram.y b/src/parse-gram.y
index b633859..ebcd31b 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -682,7 +682,7 @@ braceless:
   "{...}"
     {
       code_props plain_code;
-      $1[strlen ($1) - 1] = '\n';
+      $1[strlen ($1) - 1] = '\0';
       code_props_plain_init (&plain_code, $1+1, @1);
       code_props_translate_code (&plain_code);
       gram_scanner_last_string_free ();
-- 
1.8.2




reply via email to

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