X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/77315a51c1fb97dc07e1de1105551f8250cdde31..45aab21d7764f05b57450d61599fd83fa39ed71e:/src/parse-gram.y diff --git a/src/parse-gram.y b/src/parse-gram.y index 5f46d293..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); } @@ -758,8 +749,8 @@ version_check (location const *loc, char const *version) if (strverscmp (version, PACKAGE_VERSION) > 0) { complain_at (*loc, "require bison %s, but have %s", - version, PACKAGE_VERSION); - exit (63); + version, PACKAGE_VERSION); + exit (EX_MISMATCH); } }