cvs: pear /DBA ctype.php

From: Date: Fri, 19 Jul 2002 21:02:34 +0000
Subject: cvs: pear /DBA ctype.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5202@lists.php.net to get a copy of this message
busterb Fri Jul 19 17:02:34 2002 EDT Modified files: /pear/DBA ctype.php Log: optimize a little more, after this morning's exercise in creative fortune-telling Index: pear/DBA/ctype.php diff -u pear/DBA/ctype.php:1.2 pear/DBA/ctype.php:1.3 --- pear/DBA/ctype.php:1.2 Fri Jul 19 12:20:51 2002 +++ pear/DBA/ctype.php Fri Jul 19 17:02:33 2002 @@ -1,58 +1,59 @@ <?php /** - * PHP ctype compatibility functions. See the ctype module for more information - * on usage. + * PHP ctype compatibility functions. See the PHP ctype module for more + * information on usage. * * @author John Millaway * @author Brent Cook * - * Note: These functions expect an integer character, like the - * + * Note: These functions expect an integer argument, like the C versions + * To use with a PHP character, use ord($c). These functions do not support + * string arguments like their PHP extension counterparts */ if (!extension_loaded('ctype')) { function ctype_alnum($c) { global $ctype__; - return !($ctype__[$c] & (01 | 02 | 04)); + return ($ctype__[$c] & 7); // (1 | 2 | 4) } function ctype_alpha($c) { global $ctype__; - return !($ctype__[$c] & (01 | 02)); + return ($ctype__[$c] & 3); // (1 | 2) } function ctype_cntrl($c) { global $ctype__; - return !($ctype__[$c] & 040); + return ($ctype__[$c] & 40); } function ctype_digit($c) { global $ctype__; - return !($ctype__[$c] & 04); + return ($ctype__[$c] & 4); } function ctype_graph($c) { global $ctype__; - return !($ctype__[$c] & (020 | 01 | 02 | 04)); + return ($ctype__[$c] & 27); // (20 | 1 | 2 | 4) } function ctype_lower($c) { global $ctype__; - return !($ctype__[$c] & 02); + return ($ctype__[$c] & 2); } function ctype_print($c) { global $ctype__; - return !($ctype__[$c] & (020 | 01 | 02 | 04 | 0200)); + return ($ctype__[$c] & 227); // (20 | 1 | 2 | 4 | 200) } function ctype_punct($c) { global $ctype__; - return !($ctype__[$c] & 020); + return ($ctype__[$c] & 20); } function ctype_space($c) { global $ctype__; - return !($ctype__[$c] & 010); + return ($ctype__[$c] & 10); } function ctype_upper($c) { global $ctype__; - return !($ctype__[$c] & 01); + return ($ctype__[$c] & 1); } function ctype_xdigit($c) { global $ctype__; - return !($ctype__[$c] & (0100 | 04)); + return ($ctype__[$c] & 104); // (100 | 4)); } $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,

« previous php.pear.cvs (#5202) next »