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 <akim@lrde.epita.fr>
This commit is contained in:
Jim Meyering
2012-05-03 23:01:05 +02:00
parent bb3b912b0a
commit 60457f308d

View File

@@ -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);
}