comparison macro.c @ 192:255db24bc29b

Fix output corruption; see CHANGES entry.
author David A. Holland
date Fri, 12 Jun 2015 21:54:32 -0400
parents c8d4ab9aeff0
children 1d2bad7151f9
comparison
equal deleted inserted replaced
191:c8d4ab9aeff0 192:255db24bc29b
890 expand_send(es, p, (m != NULL) ? "1" : "0", 1); 890 expand_send(es, p, (m != NULL) ? "1" : "0", 1);
891 expstate_destroyargs(es); 891 expstate_destroyargs(es);
892 return; 892 return;
893 } 893 }
894 894
895 assert(es->curmacro->inuse == false); 895 m = es->curmacro;
896 es->curmacro->inuse = true; 896 assert(m->inuse == false);
897 m->inuse = true;
897 898
898 newbuf = expand_substitute(p, es); 899 newbuf = expand_substitute(p, es);
899 newbuf2 = macroexpand(p, newbuf, strlen(newbuf), false); 900 newbuf2 = macroexpand(p, newbuf, strlen(newbuf), false);
900 dostrfree(newbuf); 901 dostrfree(newbuf);
901 expstate_destroyargs(es); 902 expstate_destroyargs(es);
902 doexpand(es, p, newbuf2, strlen(newbuf2)); 903 doexpand(es, p, newbuf2, strlen(newbuf2));
903 dostrfree(newbuf2); 904 dostrfree(newbuf2);
904 905
905 es->curmacro->inuse = false; 906 m->inuse = false;
906 } 907 }
907 908
908 /* 909 /*
909 * The traditional behavior if a function-like macro appears without 910 * The traditional behavior if a function-like macro appears without
910 * arguments is to pretend it isn't a macro; that is, just emit its 911 * arguments is to pretend it isn't a macro; that is, just emit its
968 if (m == NULL || m->inuse) { 969 if (m == NULL || m->inuse) {
969 expand_send(es, p, buf, len); 970 expand_send(es, p, buf, len);
970 } else if (!m->hasparams) { 971 } else if (!m->hasparams) {
971 es->curmacro = m; 972 es->curmacro = m;
972 expand_domacro(es, p); 973 expand_domacro(es, p);
973 es->curmacro = NULL;
974 } else { 974 } else {
975 es->curmacro = m; 975 es->curmacro = m;
976 es->state = ES_WANTLPAREN; 976 es->state = ES_WANTLPAREN;
977 } 977 }
978 break; 978 break;