mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
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:
@@ -733,17 +733,7 @@ add_param (char const *type, char *decl, location loc)
|
|||||||
complain_at (loc, _("missing identifier in parameter declaration"));
|
complain_at (loc, _("missing identifier in parameter declaration"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *name;
|
char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
|
||||||
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';
|
|
||||||
muscle_pair_list_grow (type, decl, name);
|
muscle_pair_list_grow (type, decl, name);
|
||||||
free (name);
|
free (name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user