From 81500c7260ee68193619a0b8b7cb78d4c62c9496 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Sat, 22 Aug 2009 13:44:05 +0000 Subject: [PATCH] Optimize $offset git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@998 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/sql.inc.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index c8492ff2..46480872 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -34,10 +34,11 @@ if (!$error && $_POST) { $offset = $match[0][1] + strlen($found); if ($found && $found != $delimiter) { // is not end of a query - find closing part - if (ereg('-- |#', $found)) { - $offset = strpos($query, "\n", $offset); - } elseif ($found == "/*") { - $offset = strpos($query, "*/", $offset); + if (ereg('/\\*|-- |#', $found)) { + $offset = strpos($query, ($found == "/*" ? "*/" : "\n"), $offset); + if (!$offset) { + $offset = strlen($query); + } } else { // find matching quote while (preg_match("~$found|\\\\.|\$~s", $query, $match, PREG_OFFSET_CAPTURE, $offset)) { @@ -48,9 +49,6 @@ if (!$error && $_POST) { } } } - if (!$offset) { - $offset = strlen($query); - } } else { $empty = false; echo "
" . shorten_utf8(trim(substr($query, 0, $match[0][1]))) . "
\n";