From: Akim Demaille Date: Mon, 27 Sep 2004 07:42:04 +0000 (+0000) Subject: * src/parse-gram.y (add_param): Strip the leading and trailing X-Git-Tag: BISON-2_0~104 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/b233d5558f67378a1fb55b332da8726d827b09bb?ds=sidebyside * src/parse-gram.y (add_param): Strip the leading and trailing blanks from a formal argument declaration. (YY_LOCATION_PRINT): New. --- diff --git a/ChangeLog b/ChangeLog index 4d16e99a..e61781c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-09-24 Akim Demaille + + * src/parse-gram.y (add_param): Strip the leading and trailing + blanks from a formal argument declaration. + (YY_LOCATION_PRINT): New. + 2004-09-24 Akim Demaille * data/c.m4 (b4_yysymprint_generate): Move the YYINPUT invocation diff --git a/src/parse-gram.y b/src/parse-gram.y index 0f81bf18..40117c53 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -35,6 +35,9 @@ #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) static YYLTYPE lloc_default (YYLTYPE const *, int); +#define YY_LOCATION_PRINT(File, Loc) \ + location_print (File, Loc) + /* Request detailed syntax error messages, and pass them to GRAM_ERROR. FIXME: depends on the undocumented availability of YYLLOC. */ #undef yyerror @@ -474,6 +477,7 @@ add_param (char const *type, char *decl, location loc) "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "_"; + static char const blank[] = " \t"; char const *alpha = alphanum + 10; char const *name_start = NULL; char *p; @@ -484,7 +488,13 @@ add_param (char const *type, char *decl, location loc) /* Strip the surrounding '{' and '}'. */ decl++; - p[-1] = '\0'; + *--p = '\0'; + + /* Strip surrounding white spaces. */ + while (strchr (blank, *decl)) + ++decl; + while (strchr (blank, p[-1])) + *--p = '\0'; if (! name_start) complain_at (loc, _("missing identifier in parameter declaration"));