+ * @param ... Name/value pairs to rewrite
+ * @return Rewritten parse tree
+ *
+ * The name/value pair list consists of pairs of strings and is terminated by
+ * (char *)0. Names and values are both copied so need not survive the call.
+ */
+const struct mx_node *mx_rewritel(const struct mx_node *m,
+ ...) {
+ va_list ap;
+ hash *h = hash_new(sizeof (struct mx_node *));
+ const char *n, *v;
+ struct mx_node *e;
+
+ va_start(ap, m);
+ while((n = va_arg(ap, const char *))) {
+ v = va_arg(ap, const char *);
+ e = xmalloc(sizeof *e);
+ e->next = 0;
+ e->filename = m->filename;
+ e->line = m->line;
+ e->type = MX_TEXT;
+ e->text = xstrdup(v);
+ hash_add(h, n, &e, HASH_INSERT);
+ /* hash_add() copies n */
+ }
+ return mx_rewrite(m, h);
+}
+
+/** @brief Rewrite a parse tree substituting in macro arguments
+ * @param definition Parse tree to rewrite (from macro definition)