From e503aa60d52dffa585eed44dee29c1620653a9a3 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 6 Oct 2004 15:52:24 +0000 Subject: [PATCH] * src/parse-gram.y (add_param): Fix the truncation of trailing spaces. --- ChangeLog | 5 +++++ src/parse-gram.c | 7 ++++--- src/parse-gram.y | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 845b21cc..242b0a97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-10-06 Akim Demaille + + * src/parse-gram.y (add_param): Fix the truncation of trailing + spaces. + 2004-10-05 Akim Demaille In Bison 1.875's yacc.c, YYLLOC_DEFAULT was called regardless diff --git a/src/parse-gram.c b/src/parse-gram.c index 266b4e8a..3c31b282 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -2024,17 +2024,18 @@ add_param (char const *type, char *decl, location loc) char const *name_start = NULL; char *p; - for (p = decl; *p; p++) + for (p = decl; p[1]; p++) if ((p == decl || ! memchr (alphanum, p[-1], sizeof alphanum)) && memchr (alphanum, p[0], sizeof alphanum - 10)) name_start = p; - + fprintf (stderr, "DECLI: {%s}(%c)\n", decl, *p); /* Strip the surrounding '{' and '}', and any blanks just inside the braces. */ while (*--p == ' ' || *p == '\t') continue; - *p = '\0'; + p[1] = '\0'; + fprintf (stderr, "DECLO: {%s}\n", decl); while (*++decl == ' ' || *decl == '\t') continue; diff --git a/src/parse-gram.y b/src/parse-gram.y index 5dec642d..6016cea7 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -480,7 +480,8 @@ add_param (char const *type, char *decl, location loc) char const *name_start = NULL; char *p; - for (p = decl; *p; p++) + /* Stop on last actual character. */ + for (p = decl; p[1]; p++) if ((p == decl || ! memchr (alphanum, p[-1], sizeof alphanum)) && memchr (alphanum, p[0], sizeof alphanum - 10)) @@ -490,7 +491,7 @@ add_param (char const *type, char *decl, location loc) the braces. */ while (*--p == ' ' || *p == '\t') continue; - *p = '\0'; + p[1] = '\0'; while (*++decl == ' ' || *decl == '\t') continue; -- 2.47.2