cvs: pear /DBA Sql_lex.php ctype.php phptype.php

From: Date: Fri, 19 Jul 2002 05:35:26 +0000
Subject: cvs: pear /DBA Sql_lex.php ctype.php phptype.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5191@lists.php.net to get a copy of this message
busterb Fri Jul 19 01:35:26 2002 EDT Added files: /pear/DBA ctype.php Removed files: /pear/DBA phptype.php Modified files: /pear/DBA Sql_lex.php Log: Renamed phptype.php to ctype.php, use the built-in ctype functions if available (only compiled in by default since 4.2), work around a bug in built-in ctype functions that returns TRUE on an empty string.

Index: pear/DBA/Sql_lex.php diff -u pear/DBA/Sql_lex.php:1.15 pear/DBA/Sql_lex.php:1.16 --- pear/DBA/Sql_lex.php:1.15 Wed Jul 17 12:57:20 2002 +++ pear/DBA/Sql_lex.php Fri Jul 19 01:35:26 2002 @@ -18,10 +18,10 @@ // | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA| // +----------------------------------------------------------------------+ // -// $Id: Sql_lex.php,v 1.15 2002/07/17 16:57:20 busterb Exp $ +// $Id: Sql_lex.php,v 1.16 2002/07/19 05:35:26 busterb Exp $ // -include 'DB/DBA/phptype.php'; +include 'DB/DBA/ctype.php'; // {{{ token definitions // variables @@ -98,10 +98,10 @@ $state = 0; while (1) { - //echo "State: $state, Char: $c\n"; + echo "State: $state, Char: $c\n"; switch($state) { // {{{ State 0 : Start of token - CASE(0): + case 0: $this->tokPtr = $this->tokStart; $this->tokText = ''; $this->tokLen = 0; @@ -123,17 +123,17 @@ $state = 18; break; } - if (isAlpha($c)) { + if (strlen($c) && ctype_alpha($c)) { $state = 1; break; } - if (isDigit($c)) { + if (strlen($c) && ctype_digit($c)) { $state = 5; break; } if ($c == '.') { $t = $this->get(); - if (isDigit($t)) { + if (strlen($c) && ctype_digit($t)) { $this->unget(); $state = 7; break; @@ -162,9 +162,9 @@ // }}} // {{{ State 1 : Incomplete keyword or ident - CASE(1): + case 1: $c = $this->get(); - if (isAlnum($c) || ($c == '_')) { + if (strlen($c) && ctype_alnum($c) || ($c == '_')) { $state = 1; break; } @@ -173,7 +173,7 @@ // }}} /* {{{ State 2 : Complete keyword or ident */ - CASE(2): + case 2: $this->unget(); $this->tokText = substr($this->string, $this->tokStart, $this->tokLen); @@ -189,9 +189,9 @@ // }}} // {{{ State 5: Incomplete real or int number - CASE(5): + case 5: $c = $this->get(); - if (isDigit($c)) { + if (strlen($c) && ctype_digit($c)) { $state = 5; break; } @@ -204,7 +204,7 @@ // }}} // {{{ State 6: Complete integer number - CASE(6): + case 6: $this->unget(); $this->tokText = substr($this->string,$this->tokStart,$this->tokLen); $this->tokStart = $this->tokPtr; @@ -213,7 +213,7 @@ // }}} // {{{ State 7: Incomplete real number - CASE(7): + case 7: $c = $this->get(); /* Analogy Start */ @@ -223,7 +223,7 @@ } /* Analogy End */ - if (isDigit($c)) { + if (strlen($c) && ctype_digit($c)) { $state = 7; break; } @@ -232,7 +232,7 @@ // }}} // {{{ State 8: Complete real number */ - CASE(8): + case 8: $this->unget(); $this->tokText = substr($this->string, $this->tokStart, $this->tokLen); $this->tokStart = $this->tokPtr; @@ -240,9 +240,9 @@ // }}} // {{{ State 9: Incomplete signed number - CASE(9): + case 9: $c = $this->get(); - if (isDigit($c)) { + if (strlen($c) && ctype_digit($c)) { $state = 5; break; } @@ -255,7 +255,7 @@ // }}} // {{{ State 10: Incomplete comparison operator - CASE(10): + case 10: $c = $this->get(); if ($this->isCompop($c)) { @@ -267,7 +267,7 @@ // }}} // {{{ State 11: Complete comparison operator - CASE(11): + case 11: $this->unget(); $tokval = $this->symtab[ substr($this->string,$this->tokStart,$this->tokLen)]; @@ -281,7 +281,7 @@ // }}} // {{{ State 12: Incomplete text string - CASE(12): + case 12: $bail = false; while (!$bail) { switch ($this->get()) { @@ -312,14 +312,14 @@ // }}} // {{{ State 13: Complete text string - CASE(13): + case 13: $this->tokStart = $this->tokPtr; return (TOK_TEXT_VAL); break; // }}} // {{{ State 14: Comment - CASE(14): + case 14: $c = $this->skip(); if ($c == '\n') { $state = 0; @@ -331,7 +331,7 @@ // Analogy Start // {{{ State 15: Exponent Sign in Scientific Notation - CASE(15): + case 15: $c = $this->get(); if($c == '-' || $c == '+') { $state = 16; @@ -342,9 +342,9 @@ // }}} // {{{ state 16: Exponent Value-first digit in Scientific Notation - CASE(16): + case 16: $c = $this->get(); - if (isDigit($c)) { + if (strlen($c) && ctype_digit($c)) { $state = 17; break; } @@ -353,9 +353,9 @@ // }}} // {{{ State 17: Exponent Value in Scientific Notation - CASE(17): + case 17: $c = $this->get(); - if (isDigit($c)) { + if (strlen($c) && ctype_digit($c)) { $state = 17; break; } @@ -365,9 +365,9 @@ // Analogy End // {{{ State 18 : Incomplete System Variable - CASE(18): + case 18: $c = $this->get(); - if (isalnum($c) || $c == '_') { + if (strlen($c) && ctype_alnum($c) || $c == '_') { $state = 18; break; } @@ -376,7 +376,7 @@ // }}} // {{{ State 19: Complete Sys Var - CASE(19): + case 19: $this->unget(); $this->tokText = substr($this->tokStart,$this->tokLen); $this->tokStart = $this->tokPtr; @@ -384,7 +384,7 @@ // }}} // {{{ State 999 : Unknown token. Revert to single char - CASE(999): + case 999: $this->revert(); $this->tokText = $this->get(); $this->tokStart = $this->tokPtr; @@ -392,7 +392,7 @@ // }}} // {{{ State 1000 : End Of Input - CASE(1000): + case 1000: $this->tokText = '*end of input*'; $this->tokStart = $this->tokPtr; return (TOK_END_OF_INPUT); Index: pear/DBA/ctype.php +++ pear/DBA/ctype.php <?php /** * PHP ctype compatibility functions. See the ctype module for more information * on usage. * * @author John Millaway * @author Brent Cook * * Note: These functions expect a character, * such as 'a', or '?', not an * integer. If you want to use integers, first convert the integer using * the chr() function. * */ if (!function_exists('ctype_alnum')) { function ctype_alnum($c) { global $ctype__; return !($ctype__[ord($c)] & (01 | 02 | 04)); } function ctype_alpha($c) { global $ctype__; return !($ctype__[ord($c)] & (01 | 02)); } function ctype_cntrl($c) { global $ctype__; return !($ctype__[ord($c)] & 040); } function ctype_digit($c) { global $ctype__; return !($ctype__[ord($c)] & 04); } function ctype_graph($c) { global $ctype__; return !($ctype__[ord($c)] & (020 | 01 | 02 | 04)); } function ctype_lower($c) { global $ctype__; return !($ctype__[ord($c)] & 02); } function ctype_print($c) { global $ctype__; return !($ctype__[ord($c)] & (020 | 01 | 02 | 04 | 0200)); } function ctype_punct($c) { global $ctype__; return !($ctype__[ord($c)] & 020); } function ctype_space($c) { global $ctype__; return !($ctype__[ord($c)] & 010); } function ctype_upper($c) { global $ctype__; return !($ctype__[ord($c)] & 01); } function ctype_xdigit($c) { global $ctype__; return !($ctype__[ord($c)] & (0100 | 04)); } $ctype__ = array(32,32,32,32,32,32,32,32,32,40,40,40,40,40,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,-120,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,4,4,4,4,4,4,4,4,4,4,16,16,16,16,16,16,16,65,65,65,65,65,65, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,16,16,16,16,16,16,66,66,66, 66,66,66,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,16,16,16,16,32,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); } ?>
« previous php.pear.cvs (#5191) next »