This commit is contained in:
Robin Johnson
2002-10-13 09:55:26 +00:00
parent 519092b263
commit 7da05ddf04
2 changed files with 67 additions and 41 deletions

View File

@@ -5,6 +5,9 @@ phpMyAdmin - Changelog
$Id$
$Source$
2002-10-13 Robin Johnson <robbat2@users.sourceforge.net>
* libraries/sqlparser.lib.php3: bug #621357
2002-10-11 Marc Delisle <lem9@users.sourceforge.net>
* libraries/common.lib.php3: bug 620624

View File

@@ -32,6 +32,18 @@
if (!defined('PMA_SQP_LIB_INCLUDED')) {
define('PMA_SQP_LIB_INCLUDED', 1);
if(defined('PMA_MULTIBYTE_ENCODING')) {
$GLOBALS['PMA_SQP_strlen'] = 'mb_strlen';
$GLOBALS['PMA_SQP_strpos'] = 'mb_strpos';
$GLOBALS['PMA_SQP_strrpos'] = 'mb_strrpos';
$GLOBALS['PMA_SQP_substr'] = 'mb_substr';
} else {
$GLOBALS['PMA_SQP_strlen'] = 'strlen';
$GLOBALS['PMA_SQP_strpos'] = 'strpos';
$GLOBALS['PMA_SQP_strrpos'] = 'strrpos';
$GLOBALS['PMA_SQP_substr'] = 'substr';
}
/**
* Include the string library as we use it heavily
*/
@@ -169,7 +181,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
return $sql;
}
$len = strlen($sql);
$len = $GLOBALS['PMA_SQP_strlen']($sql);
if ($len == 0) {
return array();
}
@@ -234,18 +246,18 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
$type = 'mysql';
case '-':
$type = 'ansi';
$pos = strpos($sql, "\n", $count2);
$pos = $GLOBALS['PMA_SQP_strpos']($sql, "\n", $count2);
break;
case '/':
$type = 'c';
$pos = strpos($sql, '*/', $count2);
$pos = $GLOBALS['PMA_SQP_strpos']($sql, '*/', $count2);
$pos += 2;
break;
default:
break;
} // end switch
$count2 = ($pos < $count2) ? $len : $pos;
$str = substr($sql, $count1, $count2 - $count1);
$str = $GLOBALS['PMA_SQP_substr']($sql, $count1, $count2 - $count1);
PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
continue;
} // end if
@@ -261,7 +273,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
$oldpos = 0;
do {
$oldpos = $pos;
$pos = strpos(' ' . $sql, $quotetype, $oldpos + 1) - 1;
$pos = $GLOBALS['PMA_SQP_strpos'](' ' . $sql, $quotetype, $oldpos + 1) - 1;
// ($pos === FALSE)
if ($pos < 0) {
$debugstr = $GLOBALS['strSQPBugUnclosedQuote'] . ' @ ' . $startquotepos. "\n"
@@ -305,7 +317,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
default:
break;
} // end switch
$data = substr($sql, $count1, $count2 - $count1);
$data = $GLOBALS['PMA_SQP_substr']($sql, $count1, $count2 - $count1);
PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
continue;
}
@@ -344,7 +356,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
if ($l == 1) {
$punct_data = $c;
} else {
$punct_data = substr($sql, $count1, $l);
$punct_data = $GLOBALS['PMA_SQP_substr']($sql, $count1, $l);
}
// Special case, sometimes, althought two characters are
@@ -381,10 +393,10 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
$punct_data = $first;
} else if (($last2 == '/*') || ($last2 == '--')) {
$count2 -= 2;
$punct_data = substr($sql, $count1, $count2 - $count1);
$punct_data = $GLOBALS['PMA_SQP_substr']($sql, $count1, $count2 - $count1);
} else if (($last == '-') || ($last == '+') || ($last == '!')) {
$count2--;
$punct_data = substr($sql, $count1, $count2 - $count1);
$punct_data = $GLOBALS['PMA_SQP_substr']($sql, $count1, $count2 - $count1);
} else {
$debugstr = $GLOBALS['strSQPBugUnknownPunctuation'] . ' @ ' . ($count1+1) . "\n"
. 'STR: ' . $punct_data;
@@ -423,7 +435,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
continue;
} else {
$debugstr = $GLOBALS['strSQPBugInvalidIdentifer'] . ' @ ' . ($count1+1) . "\n"
. 'STR: ' . substr($sql, $count1, $count2 - $count1);
. 'STR: ' . $GLOBALS['PMA_SQP_substr']($sql, $count1, $count2 - $count1);
PMA_SQP_throwError($debugstr, $sql);
return $sql;
}
@@ -451,7 +463,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
} // end while
$l = $count2 - $count1;
$str = substr($sql, $count1, $l);
$str = $GLOBALS['PMA_SQP_substr']($sql, $count1, $l);
$type = '';
if ($is_digit) {
@@ -480,7 +492,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
$count2++;
$debugstr = 'C1 C2 LEN: ' . $count1 . ' ' . $count2 . ' ' . $len . "\n"
. 'STR: ' . substr($sql, $count1, $count2 - $count1) . "\n";
. 'STR: ' . $GLOBALS['PMA_SQP_substr']($sql, $count1, $count2 - $count1) . "\n";
PMA_SQP_bug($debugstr, $sql);
return $sql;
@@ -504,15 +516,26 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
if ($t_cur == 'alpha') {
$t_suffix = '_identifier';
$d_cur_upper = strtoupper($sql_array[$i]['data']);
if($d_cur_upper == 'SET') {
echo "T: $t_next\n";
}
if (($t_next == 'punct_qualifier') || ($t_prev == 'punct_qualifier')) {
$t_suffix = '_identifier';
} else if (($t_next == 'punct_bracket_open_round')
&& PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_function_name, $PMA_SQPdata_function_name_cnt)) {
$t_suffix = '_functionName';
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_reserved_word, $PMA_SQPdata_reserved_word_cnt)) {
$t_suffix = '_reservedWord';
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_type, $PMA_SQPdata_column_type_cnt)) {
$t_suffix = '_columnType';
//temporary fix for BUG #621357
//TODO FIX PROPERLY NEEDS OVERHAUL OF SQL TOKENIZER
if($d_cur_upper == 'SET' && $t_next != 'punct_bracket_open_round') {
$t_suffix = '_reservedWord';
}
//END OF TEMPORARY FIX
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_reserved_word, $PMA_SQPdata_reserved_word_cnt)) {
$t_suffix = '_reservedWord';
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_attrib, $PMA_SQPdata_column_attrib_cnt)) {
$t_suffix = '_columnAttrib';
} else {
@@ -634,10 +657,10 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
*/
function PMA_SQP_formatHtml_colorize($arr)
{
$i = strpos($arr['type'], '_');
$i = $GLOBALS['PMA_SQP_strpos']($arr['type'], '_');
$class = '';
if ($i > 0) {
$class = 'syntax_' . substr($arr['type'], 0, $i) . ' ';
$class = 'syntax_' . $GLOBALS['PMA_SQP_substr']($arr['type'], 0, $i) . ' ';
}
$class .= 'syntax_' . $arr['type'];