From: Jim Meyering Date: Thu, 3 May 2012 21:01:05 +0000 (+0200) Subject: maint: simplify parse-gram.y X-Git-Tag: v2.5.1_rc2~32 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/60457f308d3cbe377472b610aafcb86e194081a4 maint: simplify parse-gram.y * src/parse-gram.y (add_param): Use xmemdup0 in place of xmalloc+memcpy, and strspn in place of an open-coded loop. Co-authored-by: Akim Demaille --- diff --git a/src/parse-gram.y b/src/parse-gram.y index 1968e310..8d745491 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -733,17 +733,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); }