X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/8fc93a3745553c2cbc8df2240877dd40f1569431..c617bac5ba2c520255597c36a9e25f8ae704cfd0:/lib/macros.c diff --git a/lib/macros.c b/lib/macros.c index d5786a0..98e1436 100644 --- a/lib/macros.c +++ b/lib/macros.c @@ -557,13 +557,13 @@ int mx_expand_file(const char *path, * @param h Hash mapping argument names to argument values * @return Rewritten parse tree */ -static const struct mx_node *mx__rewrite(const struct mx_node *m, +static const struct mx_node *mx__rewrite(const struct mx_node *definition, hash *h) { - const struct mx_node *head = 0, **tailp = &head, *argvalue, *mm; + const struct mx_node *head = 0, **tailp = &head, *argvalue, *m, *mm; struct mx_node *nm; int n; - for(; m; m = m->next) { + for(m = definition; m; m = m->next) { switch(m->type) { case MX_TEXT: nm = xmalloc(sizeof *nm); @@ -596,6 +596,7 @@ static const struct mx_node *mx__rewrite(const struct mx_node *m, * values according to h. */ nm = xmalloc(sizeof *nm); *nm = *m; + nm->args = xcalloc(nm->nargs, sizeof (struct mx_node *)); for(n = 0; n < nm->nargs; ++n) nm->args[n] = mx__rewrite(m->args[n], h); nm->next = 0;