Fix comment removal regex

The trailing comment removal pattern unnecessarily required that a leading
space is present in all trailing comments.

Also, the pattern didn't match if no line ending was included in the SQL
statement. The subject ending should be the third valid terminator in
addition to UNIX and Windows style line endings.
This commit is contained in:
Markus Mäkelä
2017-12-27 16:42:06 +02:00
parent c6bc1f7327
commit 5ede5a4f96

View File

@ -555,7 +555,7 @@ static pcre2_code* remove_comments_re = NULL;
static const PCRE2_SPTR remove_comments_pattern = (PCRE2_SPTR)
"(?:`[^`]*`\\K)|"
"(\\/[*](?!(M?!)).*?[*]\\/)|"
"([[:space:]](?:#.*|--[[:space:]].*(\\n|\\r\\n)))";
"((?:#.*|--[[:space:]].*)(\\n|\\r\\n|$))";
/**
* Remove SQL comments from the end of a string