X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b233d5558f67378a1fb55b332da8726d827b09bb..5f6da1c0f87fce6498af745949507b5991641251:/src/parse-gram.y diff --git a/src/parse-gram.y b/src/parse-gram.y index 40117c53..6a98d202 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -1,6 +1,6 @@ %{/* Bison Grammar Parser -*- C -*- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -16,8 +16,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA */ #include "system.h" @@ -29,6 +29,7 @@ #include "gram.h" #include "muscle_tab.h" #include "output.h" +#include "quotearg.h" #include "reader.h" #include "symlist.h" @@ -403,25 +404,23 @@ symbol: action: BRACED_CODE - { $$ = $1; } + { $$ = $1; } ; -/* A string used as an ID: we have to keep the quotes. */ +/* A string used as an ID: quote it. */ string_as_id: STRING { - $$ = symbol_get ($1, @1); + $$ = symbol_get (quotearg_style (c_quoting_style, $1), @1); symbol_class_set ($$, token_sym, @1); } ; -/* A string used for its contents. Strip the quotes. */ +/* A string used for its contents. Don't quote it. */ string_content: STRING - { - $$ = $1 + 1; - $$[strlen ($$) - 1] = '\0'; - }; + { $$ = $1; } +; epilogue.opt: @@ -472,29 +471,28 @@ lloc_default (YYLTYPE const *rhs, int n) static void add_param (char const *type, char *decl, location loc) { - static char const alphanum[] = - "0123456789" + static char const alphanum[26 + 26 + 1 + 10] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "_"; - static char const blank[] = " \t"; - char const *alpha = alphanum + 10; + "_" + "0123456789"; char const *name_start = NULL; char *p; - for (p = decl; *p; p++) - if ((p == decl || ! strchr (alphanum, p[-1])) && strchr (alpha, p[0])) + /* 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)) name_start = p; - /* Strip the surrounding '{' and '}'. */ - decl++; - *--p = '\0'; - - /* Strip surrounding white spaces. */ - while (strchr (blank, *decl)) - ++decl; - while (strchr (blank, p[-1])) - *--p = '\0'; + /* Strip the surrounding '{' and '}', and any blanks just inside + the braces. */ + while (*--p == ' ' || *p == '\t') + continue; + p[1] = '\0'; + while (*++decl == ' ' || *decl == '\t') + continue; if (! name_start) complain_at (loc, _("missing identifier in parameter declaration")); @@ -504,7 +502,7 @@ add_param (char const *type, char *decl, location loc) size_t name_len; for (name_len = 1; - name_start[name_len] && strchr (alphanum, name_start[name_len]); + memchr (alphanum, name_start[name_len], sizeof alphanum); name_len++) continue;