changeset 25:18681e5ae6e4

fix some more bugs
author David A. Holland
date Mon, 20 Dec 2010 04:38:43 -0500
parents daa801fe719e
children ac45dcc57ff9
files Makefile macro.c
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Mon Dec 20 04:30:02 2010 -0500
+++ b/Makefile	Mon Dec 20 04:38:43 2010 -0500
@@ -7,4 +7,6 @@
 NOMAN=	1
 WARNS=	5
 
+DBG=-g
+
 .include <bsd.prog.mk>
--- a/macro.c	Mon Dec 20 04:30:02 2010 -0500
+++ b/macro.c	Mon Dec 20 04:38:43 2010 -0500
@@ -493,7 +493,7 @@
 				if (pos > blockstart) {
 					ei = expansionitem_create_stringlen(
 						buf + blockstart,
-						blockstart - pos);
+						pos - blockstart);
 					expansionitemarray_add(&m->expansion,
 							       ei, NULL);
 				}
@@ -508,7 +508,7 @@
 	}
 	if (pos > blockstart) {
 		ei = expansionitem_create_stringlen(buf + blockstart,
-						    blockstart - pos);
+						    pos - blockstart);
 		expansionitemarray_add(&m->expansion, ei, NULL);
 	}
 }
@@ -534,6 +534,7 @@
 	struct macro *m;
 
 	m = macro_define_common_start(p1, macro, p3);
+	m->hasparams = true;
 	macro_parse_parameters(m, p2, params);
 	macro_parse_expansion(m, expansion);
 	macro_define_common_end(m);
@@ -734,6 +735,7 @@
 		}
 		m = macrotable_find(stringarray_get(&es->args, 0), false);
 		expand_send(es, p, (m != NULL) ? "1" : "0", 1);
+		expstate_destroyargs(es);
 		return;
 	}
 
@@ -743,6 +745,7 @@
 	newbuf = expand_substitute(es);
 	newbuf2 = macroexpand(p, newbuf, strlen(newbuf), false);
 	free(newbuf);
+	expstate_destroyargs(es);
 	doexpand(es, p, newbuf2, strlen(newbuf2));
 	free(newbuf2);