From ea4b47003b1b2bb0ec204e90e3a3f1b0bb0a6090 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Wed, 28 Dec 2016 12:45:40 -0500 Subject: [PATCH] fix escapes handling (patch from ac) --- parse.c | 7 ++++--- 1 file 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; } }