On Mon, 22 Jul 2002, Div Lo�c wrote:
Robin, I've just have had a look at the last
version of your parser. Here is some PHP3
problems i've noticed:
- function must be declared before they are
called. Then, for example, you can't call
"PMA_sqlParser_ArrayAdd_Timer()" in the
"PMA_sqlParser_ArrayAdd()" function because
the former is declared after the latter;
How does one deal with recursive
functions then ?
PMA_sqlParser_isEscaped() used to be recursive, but I found it slightly
faster as iterative (not that much).
- "include_once" and
"require_once" are PHP4
functions;
- "===" and "!==" are PHP4 operators.
How does one then
properly evaluate some expressions?
$f = FALSE;
$g = 0
($f == FALSE) -> true
($g == FALSE) -> true
($f === FALSE) -> true
($g === FALSE) -> false
My code relies on this difference, as some of the PHP functions (strpos
namely) return FALSE for not found, and integers [0-strlen).
In that case, a 0 is the first position of the string, which is distinctly
different from FALSE.
One of your changes:
function PMA_sqlParser_strInStr($needle,$haystack)
{
- return (strpos($haystack,$needle) !== FALSE);
-}
+ return (strpos(' ' . $haystack, $needle) > 0);
+} // end of the "PMA_sqlParser_strInStr()" function
Actually breaks the function, stopping it from recognizing some things.
Some coding standard fixes also :
- settings of function should be separated by
", " (comma plus a space character);
- keywords for control structures should be separated
from the condition by a space ie:
if (condition) {
do some stuff
}
else {
do some stuff
}
Tell me what text editor you are using with what settings, so that I can
work out settings for my vim to do this properly.
The one major problem I've had with all auto-indenting in vim so far is
that sometimes it seems to get out of sync at the end of an array, leaving
me with an extra level of indentation.
- function names should not contain escaped charcters
except after the "PMA" prefix ie "PMA_number_inrange()"
should be "PMA_numberInRange".
Ok, I was going to be renaming all of
the functions anyway.
I've modified your "sqlparse.php3" file
in order it fits
PEAR coding standards (excpet comments for function) and
may run with PHP3. But I can't test it before the end of
the week. You'll find it attached to this message.
Your changes _broke_ it on
PHP4, so there isn't a chance it work.
--
Robin Hugh Johnson
E-Mail : robbat2(a)orbis-terrarum.net
Home Page :
http://www.orbis-terrarum.net/?l=people.robbat2
ICQ# : 30269588 or 41961639