# HG changeset patch
# User David A. Holland
# Date 1370914584 14400
# Node ID c91dc131574588450fb9744f615906eb67e073c1
# Parent  7e4723d3424842d1e4fe8974beaa6dc1e052b077
Don't expand macros inside comments.

diff -r 7e4723d34248 -r c91dc1315745 macro.c
--- a/macro.c	Mon Jun 10 21:34:59 2013 -0400
+++ b/macro.c	Mon Jun 10 21:36:24 2013 -0400
@@ -1051,7 +1051,9 @@
 void
 doexpand(struct expstate *es, struct place *p, char *buf, size_t len)
 {
+	char *s;
 	size_t x;
+	bool inquote = false;
 
 	while (len > 0) {
 		x = strspn(buf, ws);
@@ -1080,6 +1082,19 @@
 			continue;
 		}
 
+		if (!inquote && len > 1 && buf[0] == '/' && buf[1] == '*') {
+			s = strstr(buf, "*/");
+			if (s) {
+				x = s - buf;
+			} else {
+				x = len;
+			}
+			expand_got_ws(es, p, buf, x);
+			buf += x;
+			len -= x;
+			continue;
+		}
+
 		if (buf[0] == '(') {
 			expand_got_lparen(es, p, buf, 1);
 			buf++;
@@ -1101,6 +1116,16 @@
 			continue;
 		}
 
+		if (len > 1 && buf[0] == '\\' && buf[1] == '"') {
+			expand_got_other(es, p, buf, 2);
+			buf += 2;
+			len -= 2;
+			continue;
+		}
+		if (buf[0] == '"') {
+			inquote = !inquote;
+		}
+
 		expand_got_other(es, p, buf, 1);
 		buf++;
 		len--;