summary refs log tree commit diff
path: root/minic
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-10-04 15:17:58 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-10-04 15:17:58 -0400
commit4beee73fd38818a287c00087d3d1e3cf2a3ccfa5 (patch)
treef4617b7d3d046d02a4cd00214c9cb97d9035f103 /minic
parent5b8b78f2f1d4ad7d82ac1c92c9aa00d01c343f32 (diff)
downloadroux-4beee73fd38818a287c00087d3d1e3cf2a3ccfa5.tar.gz
update miniyacc
Diffstat (limited to 'minic')
-rw-r--r--minic/yacc.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/minic/yacc.c b/minic/yacc.c
index 52fd891..91c0be7 100644
--- a/minic/yacc.c
+++ b/minic/yacc.c
@@ -851,7 +851,7 @@ nexttk()
 char *
 cpycode()
 {
-	int c, nest, len, pos;
+	int c, nest, in, len, pos;
 	char *s;
 
 	len = 64;
@@ -859,17 +859,26 @@ cpycode()
 	s[0] = '{';
 	pos = 1;
 	nest = 1;
+	in = 0;
 
 	while (nest) {
 		c = fgetc(fin);
-		if (c == '{')
-			nest++;
-		if (c == '}')
-			nest--;
-		if (c == EOF)
-			die("syntax error, unclosed code block");
-		if (c == '\n')
-			lineno++;
+		if (in) {
+			if (c == in)
+			if (s[pos-1] != '\\')
+				in = 0;
+		} else {
+			if (c == '"' || c == '\'')
+				in = c;
+			if (c == '{')
+				nest++;
+			if (c == '}')
+				nest--;
+			if (c == EOF)
+				die("syntax error, unclosed code block");
+			if (c == '\n')
+				lineno++;
+		}
 		if (pos>=len)
 		if (!(s=realloc(s, len=2*len+1)))
 			die("out of memory");