diff files.c @ 128:1cda505ddc78

Don't expand macros within character constants.
author David A. Holland
date Fri, 14 Jun 2013 20:59:24 -0400
parents 1e7144176a42
children ed45f2d8d3bc
line wrap: on
line diff
--- a/files.c	Wed Jun 12 10:52:56 2013 -0400
+++ b/files.c	Fri Jun 14 20:59:24 2013 -0400
@@ -127,6 +127,7 @@
 	size_t i;
 	int incomment = 0;
 	bool inquote = false;
+	char quote = '\0';
 
 	for (i=start; i<limit; i++) {
 		if (incomment) {
@@ -139,10 +140,13 @@
 			i++;
 			incomment = 1;
 		} else if (i+1 < limit &&
-			   buf[i] == '\\' && buf[i+1] == '"') {
+			   buf[i] == '\\' && buf[i+1] != '\n') {
 			i++;
-		} else if (buf[i] == '"') {
-			inquote = !inquote;
+		} else if (!inquote && (buf[i] == '"' || buf[i] == '\'')) {
+			inquote = true;
+			quote = buf[i];
+		} else if (inquote && buf[i] == quote) {
+			inquote = false;
 		} else if (buf[i] == '\n') {
 			return i;
 		}