From 5c1e664f29d06396f1a44c5f86e7d7d8d869c0e8 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Mon, 24 Aug 2020 19:04:27 +0200 Subject: [PATCH] configparser: allow multiple quotes in one line --- core/src/lib/lex.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/lib/lex.cc b/core/src/lib/lex.cc index 7750267d6e7..6d7924abbd2 100644 --- a/core/src/lib/lex.cc +++ b/core/src/lib/lex.cc @@ -585,6 +585,17 @@ static bool NextLineContinuesWithQuotes(LEX* lf) return false; } +static bool CurrentLineContinuesWithQuotes(LEX* lf) +{ + int i = lf->col_no; + while (lf->line[i] != '\0') { + if (lf->line[i] == '"') { return true; } + if (lf->line[i] != ' ' && lf->line[i] != '\t') { return false; } + ++i; + }; + return false; +} + /* * * Get the next token from the input @@ -647,10 +658,7 @@ int LexGetToken(LEX* lf, int expect) BeginStr(lf, ch); break; case ' ': - if (continue_string) { - // - continue; - } + if (continue_string) { continue; } break; case '"': lf->state = lex_quoted_string; @@ -810,7 +818,8 @@ int LexGetToken(LEX* lf, int expect) break; } if (ch == '"') { - if (NextLineContinuesWithQuotes(lf)) { + if (NextLineContinuesWithQuotes(lf) || + CurrentLineContinuesWithQuotes(lf)) { continue_string = true; lf->state = lex_none; continue;