bug #1567317 [sqp] Syntax highlighter: extra spaces

This commit is contained in:
Sebastian Mendel
2007-03-19 16:12:17 +00:00
parent 8878baf7b1
commit a7568078af
2 changed files with 29 additions and 17 deletions

View File

@@ -12,15 +12,16 @@ $HeadURL$
- bug #1679055 #1050 - Table '<table name>' already exists - bug #1679055 #1050 - Table '<table name>' already exists
- bug #1668724 JavaScript focus login Opera - bug #1668724 JavaScript focus login Opera
- bug #1667887 HTML maxlength - bug #1667887 HTML maxlength
- bug #1666657 Cookie password delete on timeout / inactivity - bug #1666657 [auth] Cookie password delete on timeout / inactivity
- bug #1648802 different mysql library and server version - bug #1648802 different mysql library and server version
- bug #1239401 table dot numeric field name - bug #1239401 table dot numeric field name
- bug #1674972 no export with %afm% - bug #1674972 no export with %afm%
- bug #1664212 querywindow loses url encoded characters - bug #1664212 querywindow loses url encoded characters
- bug #1682044 Export file even if file not selected - bug #1682044 [export] Export file even if file not selected
- bug #1672789 Undefined offset: 4 in sqlparser.lib.php #1674 - bug #1672789 [sqp] Undefined offset: 4 in sqlparser.lib.php #1674
- bug #1662976 Authentication fails when controluser/pass is set - bug #1662976 [auth] Authentication fails when controluser/pass is set
- bug #1643758 Error #1264 importing NULL values in MySQL 5.0 - bug #1643758 [import] Error #1264 importing NULL values in MySQL 5.0
- bug #1567317 [sqp] Syntax highlighter: extra spaces
- [gui] avoid displaying a wide selector in server selection - [gui] avoid displaying a wide selector in server selection
+ [core] added PMA_fatalError() and made use of it + [core] added PMA_fatalError() and made use of it
. [i18n] use generic $strOptions . [i18n] use generic $strOptions

View File

@@ -224,6 +224,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
$punct_listsep = ','; $punct_listsep = ',';
$punct_level_plus = '('; $punct_level_plus = '(';
$punct_level_minus = ')'; $punct_level_minus = ')';
$punct_user = '@';
$digit_floatdecimal = '.'; $digit_floatdecimal = '.';
$digit_hexset = 'x'; $digit_hexset = 'x';
$bracket_list = '()[]{}'; $bracket_list = '()[]{}';
@@ -252,6 +253,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
$this_was_punct = false; $this_was_punct = false;
$previous_was_listsep = false; $previous_was_listsep = false;
$this_was_listsep = false; $this_was_listsep = false;
$previous_was_quote = false;
$this_was_quote = false;
while ($count2 < $len) { while ($count2 < $len) {
$c = PMA_substr($sql, $count2, 1); $c = PMA_substr($sql, $count2, 1);
@@ -265,6 +268,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
$this_was_punct = false; $this_was_punct = false;
$previous_was_listsep = $this_was_listsep; $previous_was_listsep = $this_was_listsep;
$this_was_listsep = false; $this_was_listsep = false;
$previous_was_quote = $this_was_quote;
$this_was_quote = false;
if (($c == "\n")) { if (($c == "\n")) {
$this_was_space = true; $this_was_space = true;
@@ -357,12 +362,15 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
switch ($quotetype) { switch ($quotetype) {
case '\'': case '\'':
$type .= 'single'; $type .= 'single';
$this_was_quote = true;
break; break;
case '"': case '"':
$type .= 'double'; $type .= 'double';
$this_was_quote = true;
break; break;
case '`': case '`':
$type .= 'backtick'; $type .= 'backtick';
$this_was_quote = true;
break; break;
default: default:
break; break;
@@ -430,7 +438,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
* in this case, the @ is wrongly marked as alpha_variable * in this case, the @ is wrongly marked as alpha_variable
*/ */
$is_identifier = $previous_was_punct; $is_identifier = $previous_was_punct;
$is_sql_variable = $c == '@'; $is_sql_variable = $c == '@' && ! $previous_was_quote;
$is_user = $c == '@' && $previous_was_quote;
$is_digit = !$is_identifier && !$is_sql_variable && PMA_STR_isDigit($c); $is_digit = !$is_identifier && !$is_sql_variable && PMA_STR_isDigit($c);
$is_hex_digit = $is_digit && $c == '0' && $count2 < $len && PMA_substr($sql, $count2, 1) == 'x'; $is_hex_digit = $is_digit && $c == '0' && $count2 < $len && PMA_substr($sql, $count2, 1) == 'x';
$is_float_digit = $c == '.'; $is_float_digit = $c == '.';
@@ -516,12 +525,12 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
} else { } else {
$type .= '_integer'; $type .= '_integer';
} }
} else { } elseif ($is_user) {
if ($is_sql_variable != FALSE) { $type = 'punct_user';
} elseif ($is_sql_variable != FALSE) {
$type = 'alpha_variable'; $type = 'alpha_variable';
} else { } else {
$type = 'alpha'; $type = 'alpha';
}
} // end if... else.... } // end if... else....
PMA_SQP_arrayAdd($sql_array, $type, $str, $arraysize); PMA_SQP_arrayAdd($sql_array, $type, $str, $arraysize);
@@ -613,6 +622,11 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
} // end while ($count2 < $len) } // end while ($count2 < $len)
/*
echo '<pre>';
print_r($sql_array);
echo '</pre>';
*/
if ($arraysize > 0) { if ($arraysize > 0) {
$t_next = $sql_array[0]['type']; $t_next = $sql_array[0]['type'];
@@ -2123,6 +2137,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
$after .= ' '; $after .= ' ';
} }
break; break;
case 'punct_user':
case 'punct_qualifier': case 'punct_qualifier':
$before = ''; $before = '';
$after = ''; $after = '';
@@ -2316,11 +2331,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
} }
break; break;
case 'alpha_variable': case 'alpha_variable':
// other workaround for a problem similar to the one
// explained below for quote_single
if (!$in_priv_list && $typearr[3] != 'quote_backtick') {
$after = ' '; $after = ' ';
}
break; break;
case 'quote_double': case 'quote_double':
case 'quote_single': case 'quote_single':
@@ -2329,7 +2340,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
// the @ is incorrectly marked as alpha_variable // the @ is incorrectly marked as alpha_variable
// in the parser, and here, the '%' gets a blank before, // in the parser, and here, the '%' gets a blank before,
// which is a syntax error // which is a syntax error
if ($typearr[1] !='alpha_variable') { if ($typearr[1] != 'punct_user') {
$before .= ' '; $before .= ' ';
} }
if ($infunction && $typearr[3] == 'punct_bracket_close_round') { if ($infunction && $typearr[3] == 'punct_bracket_close_round') {