This commit is contained in:
CK Tan 2021-04-11 15:36:04 -07:00
parent a7557174ae
commit 45e8f3c903
1 changed files with 9 additions and 7 deletions

16
toml.c
View File

@ -1696,16 +1696,18 @@ static int scan_string(context_t* ctx, char* p, int lineno, int dotisspecial)
if (strchr("0123456789ABCDEF", *p)) continue; if (strchr("0123456789ABCDEF", *p)) continue;
return e_syntax(ctx, lineno, "expect hex char"); return e_syntax(ctx, lineno, "expect hex char");
} }
if (*p == '\\') { escape = 1; continue; } if (sqcnt) {
if (*p == '\n') break; if (*p == '\'') {
if (*p == '"') break; if (++sqcnt < 3) continue;
if (*p == '\'') {
if (++sqcnt == 3) {
return e_syntax(ctx, lineno, "triple-s-quote inside string lit"); return e_syntax(ctx, lineno, "triple-s-quote inside string lit");
} }
continue; sqcnt = 0;
} }
sqcnt = 0;
if (*p == '\\') { escape = 1; continue; }
if (*p == '\'') { sqcnt = 1; continue; }
if (*p == '\n') break;
if (*p == '"') break;
} }
if (*p != '"') { if (*p != '"') {
return e_syntax(ctx, lineno, "unterminated quote"); return e_syntax(ctx, lineno, "unterminated quote");