chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Further macro expansion tests + fixes.
[disorder]
/
lib
/
macros.c
diff --git
a/lib/macros.c
b/lib/macros.c
index d5786a0dcd2e0aebd7b067a3fb2e0d39ffdd2811..98e1436fa779787ccab487b1de3d4f59bf353378 100644
(file)
--- 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
*/
* @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) {
hash *h) {
- const struct mx_node *head = 0, **tailp = &head, *argvalue, *mm;
+ const struct mx_node *head = 0, **tailp = &head, *argvalue, *m
, *m
m;
struct mx_node *nm;
int n;
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);
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;
* 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;
for(n = 0; n < nm->nargs; ++n)
nm->args[n] = mx__rewrite(m->args[n], h);
nm->next = 0;