diff directive.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 123168887da8
children 05a94332f08b
line wrap: on
line diff
--- a/directive.c	Mon Jun 10 20:19:49 2013 -0400
+++ b/directive.c	Mon Jun 10 21:30:20 2013 -0400
@@ -60,6 +60,8 @@
 {
 	char *s, *t, *u = NULL;
 	bool incomment = false;
+	bool inesc = false;
+	bool inquote = false;
 
 	for (s = t = buf; *s; s++) {
 		if (incomment) {
@@ -68,9 +70,17 @@
 				incomment = false;
 			}
 		} else {
-			if (s[0] == '/' && s[1] == '*') {
+			if (!inquote && s[0] == '/' && s[1] == '*') {
 				incomment = true;
 			} else {
+				if (inesc) {
+					inesc = false;
+				} else if (s[0] == '\\') {
+					inesc = true;
+				} else if (s[0] == '"') {
+					inquote = !inquote;
+				}
+
 				if (t != s) {
 					*t = *s;
 				}