From: Akim Demaille Date: Thu, 4 Apr 2013 15:21:55 +0000 (+0200) Subject: grammar: do not add a \n at the end of blocks of code X-Git-Tag: v2.7.90~52 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/57597927ef1b9cc751df4314764a6edd575ffc8b grammar: do not add a \n at the end of blocks of code Now that we 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 was 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. --- diff --git a/src/parse-gram.c b/src/parse-gram.c index 8ff1d067..2cf9e86c 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 b6338597..ebcd31b3 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 ();