summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-12-28 12:45:40 -0500
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-12-28 12:45:40 -0500
commitea4b47003b1b2bb0ec204e90e3a3f1b0bb0a6090 (patch)
tree72320b723c3fbfbd72fe520d27b590048006072c
parent52cc53185e44a7e8690fb5ec856863a4d259034b (diff)
downloadroux-ea4b47003b1b2bb0ec204e90e3a3f1b0bb0a6090.tar.gz
fix escapes handling (patch from ac)
-rw-r--r--parse.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/parse.c b/parse.c
index f70bbc2..86a16b8 100644
--- a/parse.c
+++ b/parse.c
@@ -202,7 +202,7 @@ lex()
 		{ 0, Txxx }
 	};
 	static char tok[NString];
-	int c, i;
+	int c, i, esc;
 	int t;
 
 	do
@@ -262,16 +262,17 @@ lex()
 	}
 	if (c == '"') {
 		tokval.str = vnew(0, 1, alloc);
+		esc = 0;
 		for (i=0;; i++) {
 			c = fgetc(inf);
 			if (c == EOF)
 				err("unterminated string");
 			vgrow(&tokval.str, i+1);
-			if (c == '"')
-			if (!i || tokval.str[i-1] != '\\') {
+			if (c == '"' && !esc) {
 				tokval.str[i] = 0;
 				return Tstr;
 			}
+			esc = (c == '\\' && !esc);
 			tokval.str[i] = c;
 		}
 	}