commit ea4b47003b1b2bb0ec204e90e3a3f1b0bb0a6090
parent 52cc53185e44a7e8690fb5ec856863a4d259034b
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Wed, 28 Dec 2016 12:45:40 -0500
fix escapes handling (patch from ac)
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git 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;
}
}