changeset 167:fa9752f194c6

Don't shortcut macro expansion of non-parameter macros. It won't work once we have more kinds of expansion items than strings and arguments, viz., magic tokens for __FILE__ and __LINE__ and so on. (separate version of this applied against Joerg's changes, because we need to revert some of them)
author David A. Holland
date Fri, 12 Jun 2015 01:55:31 -0400
parents 4ea0ce804d22
children 8d8a4bfd4684
files macro.c
diffstat 1 files changed, 2 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/macro.c	Fri Jun 12 01:31:49 2015 -0400
+++ b/macro.c	Fri Jun 12 01:55:31 2015 -0400
@@ -948,8 +948,6 @@
 expand_got_word(struct expstate *es, struct place *p, char *buf, size_t len)
 {
 	struct macro *m;
-	struct expansionitem *ei;
-	char *newbuf;
 
 	switch (es->state) {
 	    case ES_NORMAL:
@@ -962,23 +960,10 @@
 		m = macrotable_findlen(buf, len, false);
 		if (m == NULL || m->inuse) {
 			expand_send(es, p, buf, len);
-		} else if (m->isspecial) {
+		} else if (!m->hasparams) {
 			es->curmacro = m;
-			newbuf = expand_substitute(p, es);
-			expand_send(es, p, newbuf, strlen(newbuf));
-			dostrfree(newbuf);
+			expand_domacro(es, p);
 			es->curmacro = NULL;
-			m->inuse = false;
-		} else if (!m->hasparams) {
-			m->inuse = true;
-			assert(expansionitemarray_num(&m->expansion) == 1);
-			ei = expansionitemarray_get(&m->expansion, 0);
-			assert(ei->itemtype == EI_STRING);
-			newbuf = macroexpand(p, ei->string,
-					     strlen(ei->string), false);
-			doexpand(es, p, newbuf, strlen(newbuf));
-			dostrfree(newbuf);
-			m->inuse = false;
 		} else {
 			es->curmacro = m;
 			es->state = ES_WANTLPAREN;