diff output.c @ 81:27c9aafcaca1

Don't recognize comments within double-quote strings. Blah.
author David A. Holland
date Mon, 10 Jun 2013 21:30:20 -0400
parents 4cc1c575951f
children 343af355df1b
line wrap: on
line diff
--- a/output.c	Mon Jun 10 20:19:49 2013 -0400
+++ b/output.c	Mon Jun 10 21:30:20 2013 -0400
@@ -99,10 +99,12 @@
 filter_output(const struct place *p, const char *buf, size_t len)
 {
 	size_t pos, start;
+	bool inesc = false;
+	bool inquote = false;
 
 	start = 0;
 	for (pos = 0; pos < len - 1; pos++) {
-		if (buf[pos] == '/' && buf[pos+1] == '*') {
+		if (!inquote && buf[pos] == '/' && buf[pos+1] == '*') {
 			if (!incomment) {
 				if (pos > start) {
 					dowrite(buf + start, pos - start);
@@ -127,6 +129,16 @@
 				continue;
 			}
 		}
+
+		if (incomment) {
+			/* nothing */
+		} else if (inesc) {
+			inesc = false;
+		} else if (buf[pos] == '\\') {
+			inesc = true;
+		} else if (buf[pos] == '"') {
+			inquote = !inquote;
+		}
 	}
 	pos++;