From 45e8f3c903e109501be0b46f11131e0233bf4fc2 Mon Sep 17 00:00:00 2001 From: CK Tan Date: Sun, 11 Apr 2021 15:36:04 -0700 Subject: [PATCH] cleanup --- toml.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/toml.c b/toml.c index f00e48e..80b5d80 100644 --- a/toml.c +++ b/toml.c @@ -1696,16 +1696,18 @@ static int scan_string(context_t* ctx, char* p, int lineno, int dotisspecial) if (strchr("0123456789ABCDEF", *p)) continue; return e_syntax(ctx, lineno, "expect hex char"); } - if (*p == '\\') { escape = 1; continue; } - if (*p == '\n') break; - if (*p == '"') break; - if (*p == '\'') { - if (++sqcnt == 3) { + if (sqcnt) { + if (*p == '\'') { + if (++sqcnt < 3) continue; 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 != '"') { return e_syntax(ctx, lineno, "unterminated quote");