diff macro.c @ 21:e3fab8f1b52c

strip comments.
author David A. Holland
date Mon, 20 Dec 2010 04:15:02 -0500
parents f9792a9ec704
children 18681e5ae6e4
line wrap: on
line diff
--- a/macro.c	Mon Dec 20 04:03:35 2010 -0500
+++ b/macro.c	Mon Dec 20 04:15:02 2010 -0500
@@ -620,7 +620,7 @@
 
 static
 void
-expand_send(struct expstate *es, const char *buf, size_t len)
+expand_send(struct expstate *es, struct place *p, const char *buf, size_t len)
 {
 	if (es->tobuf) {
 		if (es->bufpos + len > es->bufmax) {
@@ -635,16 +635,16 @@
 		memcpy(es->buf + es->bufpos, buf, len);
 		es->bufpos += len;
 	} else {
-		output(buf, len);
+		output(p, buf, len);
 	}
 }
 
 static
 void
-expand_send_eof(struct expstate *es)
+expand_send_eof(struct expstate *es, struct place *p)
 {
 	if (es->tobuf) {
-		expand_send(es, "", 1);
+		expand_send(es, p, "", 1);
 		es->bufpos--;
 	} else {
 		output_eof();
@@ -729,11 +729,11 @@
 		if (stringarray_num(&es->args) != 1) {
 			complain(p, "Too many arguments for defined()");
 			complain_fail();
-			expand_send(es, "0", 1);
+			expand_send(es, p, "0", 1);
 			return;
 		}
 		m = macrotable_find(stringarray_get(&es->args, 0), false);
-		expand_send(es, (m != NULL) ? "1" : "0", 1);
+		expand_send(es, p, (m != NULL) ? "1" : "0", 1);
 		return;
 	}
 
@@ -755,8 +755,7 @@
 {
 	switch (es->state) {
 	    case ES_NORMAL:
-		expand_send(es, buf, len);
-		break;
+		expand_send(es, p, buf, len);
 		break;
 	    case ES_WANTLPAREN:
 		break;
@@ -786,7 +785,7 @@
 		}
 		m = macrotable_findlen(buf, len, false);
 		if (m == NULL) {
-			expand_send(es, buf, len);
+			expand_send(es, p, buf, len);
 		} else if (!m->hasparams) {
 			m->inuse = true;
 			assert(expansionitemarray_num(&m->expansion) == 1);
@@ -831,7 +830,7 @@
 {
 	switch (es->state) {
 	    case ES_NORMAL:
-		expand_send(es, buf, len);
+		expand_send(es, p, buf, len);
 		break;
 	    case ES_WANTLPAREN:
 		es->state = ES_NOARG;
@@ -854,7 +853,7 @@
 {
 	switch (es->state) {
 	    case ES_NORMAL:
-		expand_send(es, buf, len);
+		expand_send(es, p, buf, len);
 		break;
 	    case ES_WANTLPAREN:
 		if (es->curmacro) {
@@ -888,7 +887,7 @@
 {
 	switch (es->state) {
 	    case ES_NORMAL:
-		expand_send(es, buf, len);
+		expand_send(es, p, buf, len);
 		break;
 	    case ES_WANTLPAREN:
 		if (es->curmacro) {
@@ -919,7 +918,7 @@
 {
 	switch (es->state) {
 	    case ES_NORMAL:
-		expand_send(es, buf, len);
+		expand_send(es, p, buf, len);
 		break;
 	    case ES_WANTLPAREN:
 		if (es->curmacro) {
@@ -946,7 +945,7 @@
 {
 	switch (es->state) {
 	    case ES_NORMAL:
-		expand_send_eof(es);
+		expand_send_eof(es, p);
 		break;
 	    case ES_WANTLPAREN:
 		if (es->curmacro) {
@@ -1043,6 +1042,7 @@
 macro_sendline(struct place *p, char *buf, size_t len)
 {
 	doexpand(&mainstate, p, buf, len);
+	output(p, "\n", 1);
 }
 
 void