Skip to content

Commit 62d128e

Browse files
committed
PEG: Improved quote detection
1 parent 86e7e9b commit 62d128e

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/PEG.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,23 @@ std::string PEG::removeComment (const std::string& line)
336336

337337
while ((character = utf8_next_char (line, i)))
338338
{
339-
if (character == '\'' && previous != '\\')
339+
if (insideQuote)
340+
{
341+
if (character == quote)
342+
{
343+
quote = 0;
344+
insideQuote = false;
345+
}
346+
}
347+
else if (character == '\'' && previous != '\\')
340348
{
341349
quote = '\'';
342-
insideQuote = ! insideQuote;
350+
insideQuote = true;
343351
}
344352
else if (character == '"' && previous != '\\')
345353
{
346354
quote = '"';
347-
insideQuote = ! insideQuote;
355+
insideQuote = true;
348356
}
349357

350358
if (character == '#' && previous != '\\' && ! insideQuote)

0 commit comments

Comments
 (0)