summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Ungureanu <udan1107@gmail.com>2016-01-09 15:08:27 +0200
committerDan Ungureanu <udan1107@gmail.com>2016-01-09 15:08:27 +0200
commit57f6825cae2761119f391ab8399f4580f9db7925 (patch)
tree823455b9d7ed506fee1e970d17a22ad88fe1dcde
parent47d03c5dc614939b2df057b984544635ae6217db (diff)
downloadsql-parser-57f6825cae2761119f391ab8399f4580f9db7925.zip
sql-parser-57f6825cae2761119f391ab8399f4580f9db7925.tar.gz
sql-parser-57f6825cae2761119f391ab8399f4580f9db7925.tar.bz2
BufferedQuery: Backslashes in comments escaped characters in comments.
-rw-r--r--src/Utils/BufferedQuery.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php
index f399220..1aaa9d7 100644
--- a/src/Utils/BufferedQuery.php
+++ b/src/Utils/BufferedQuery.php
@@ -29,12 +29,18 @@ class BufferedQuery
{
// Constants that describe the current status of the parser.
- const STATUS_STRING_SINGLE_QUOTES = 1;
- const STATUS_STRING_DOUBLE_QUOTES = 2;
- const STATUS_STRING_BACKTICK = 3;
- const STATUS_COMMENT_BASH = 4;
- const STATUS_COMMENT_C = 5;
- const STATUS_COMMENT_SQL = 6;
+
+ // A string is being parsed.
+ const STATUS_STRING = 16; // 0001 0000
+ const STATUS_STRING_SINGLE_QUOTES = 17; // 0001 0001
+ const STATUS_STRING_DOUBLE_QUOTES = 18; // 0001 0010
+ const STATUS_STRING_BACKTICK = 20; // 0001 0100
+
+ // A comment is being parsed.
+ const STATUS_COMMENT = 32; // 0010 0000
+ const STATUS_COMMENT_BASH = 33; // 0010 0001
+ const STATUS_COMMENT_C = 34; // 0010 0010
+ const STATUS_COMMENT_SQL = 36; // 0010 0100
/**
* The query that is being processed.
@@ -193,7 +199,7 @@ class BufferedQuery
* treated differently, because of the preceding backslash, it will
* be ignored.
*/
- if ($this->query[$i] === '\\') {
+ if (($this->status & static::STATUS_COMMENT == 0) && ($this->query[$i] === '\\')) {
$this->current .= $this->query[$i] . $this->query[++$i];
continue;
}