diff output.c @ 128:1cda505ddc78

Don't expand macros within character constants.
author David A. Holland
date Fri, 14 Jun 2013 20:59:24 -0400
parents 343af355df1b
children ed45f2d8d3bc
line wrap: on
line diff
--- a/output.c	Wed Jun 12 10:52:56 2013 -0400
+++ b/output.c	Fri Jun 14 20:59:24 2013 -0400
@@ -101,6 +101,7 @@
 	size_t pos, start;
 	bool inesc = false;
 	bool inquote = false;
+	char quote = '\0';
 
 	start = 0;
 	for (pos = 0; pos < len - 1; pos++) {
@@ -136,8 +137,11 @@
 			inesc = false;
 		} else if (buf[pos] == '\\') {
 			inesc = true;
-		} else if (buf[pos] == '"') {
-			inquote = !inquote;
+		} else if (!inquote && (buf[pos] == '"' || buf[pos] == '\'')) {
+			inquote = true;
+			quote = buf[pos];
+		} else if (inquote && buf[pos] == quote) {
+			inquote = false;
 		}
 	}
 	pos++;