summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Chabanon <git@matchab.fr>2012-10-12 15:33:15 +0200
committerJeremy Dorn <jeremy@jeremy.(none)>2012-10-12 12:41:42 -0700
commitedfe2063dc730d1a81167583abcce1e104273885 (patch)
tree30439fe08808b9e00ebfd1086d3ccdb54e5181a7
parentf5759ef3169fb4ef5a2bb206f3bdb8e1026546a7 (diff)
downloadsql-formatter-edfe2063dc730d1a81167583abcce1e104273885.zip
sql-formatter-edfe2063dc730d1a81167583abcce1e104273885.tar.gz
sql-formatter-edfe2063dc730d1a81167583abcce1e104273885.tar.bz2
UNIX mode restored (Fffuuuu).
-rw-r--r--lib/SqlFormatter.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/SqlFormatter.php b/lib/SqlFormatter.php
index c406e3c..c41c49d 100644
--- a/lib/SqlFormatter.php
+++ b/lib/SqlFormatter.php
@@ -104,9 +104,15 @@ class SqlFormatter
// If the next item is a string
if (in_array($string[0], self::$quotes)) {
$quote = $string[0];
- for ($i = 1; $i < strlen($string); $i++) {
+ for ($i = 1; $i < strlen($string); $i++)
+ {
+ $next_char = '';
+ if (isset($string[$i + 1])) {
+ $next_char = $string[$i + 1];
+ }
+
// Escaped (either backslash or backtick escaped)
- if (($quote != '`' && $string[$i] === '\\') || ($quote === '`' && $string[$i] === '`' && $string[$i + 1] === '`')) {
+ if (($quote != '`' && $string[$i] === '\\') || ($quote === '`' && $string[$i] === '`' && $next_char === '`')) {
$i++;
} elseif ($string[$i] === $quote) {
break;