diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-12-28 12:45:40 -0500 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-12-28 12:45:40 -0500 |
commit | ea4b47003b1b2bb0ec204e90e3a3f1b0bb0a6090 (patch) | |
tree | 72320b723c3fbfbd72fe520d27b590048006072c /parse.c | |
parent | 52cc53185e44a7e8690fb5ec856863a4d259034b (diff) | |
download | roux-ea4b47003b1b2bb0ec204e90e3a3f1b0bb0a6090.tar.gz |
fix escapes handling (patch from ac)
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 7 |
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; } } |