changeset 85:c91dc1315745

Don't expand macros inside comments.
author David A. Holland
date Mon, 10 Jun 2013 21:36:24 -0400
parents 7e4723d34248
children 70d7ebeb4523
files macro.c
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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--;