X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/dd5611579b3978eff5c4aa22dc8459b8f53c2fc0..0e16927b48c881317a38132923b6f3150802a7d3:/src/parse-gram.y diff --git a/src/parse-gram.y b/src/parse-gram.y index da0aef71..eb034b08 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -32,6 +32,7 @@ #include "symlist.h" #include "scan-gram.h" #include "scan-code.h" +#include "xmemdup0.h" #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) static YYLTYPE lloc_default (YYLTYPE const *, int); @@ -322,7 +323,7 @@ prologue_declaration: xmalloc (dir_length + 1 + strlen (skeleton_user) + 1); if (dir_length > 0) { - strncpy (skeleton_build, current_file, dir_length); + memcpy (skeleton_build, current_file, dir_length); skeleton_build[dir_length++] = '/'; } strcpy (skeleton_build + dir_length, skeleton_user); @@ -733,17 +734,7 @@ add_param (char const *type, char *decl, location loc) complain_at (loc, _("missing identifier in parameter declaration")); else { - char *name; - size_t name_len; - - for (name_len = 1; - memchr (alphanum, name_start[name_len], sizeof alphanum); - name_len++) - continue; - - name = xmalloc (name_len + 1); - memcpy (name, name_start, name_len); - name[name_len] = '\0'; + char *name = xmemdup0 (name_start, strspn (name_start, alphanum)); muscle_pair_list_grow (type, decl, name); free (name); } @@ -759,7 +750,7 @@ version_check (location const *loc, char const *version) { complain_at (*loc, "require bison %s, but have %s", version, PACKAGE_VERSION); - exit (EX_CONFIG); + exit (EX_MISMATCH); } }