Hi all,
I'm a C newbie and just started experimenting with the PHP internals a
couple weeks ago... A few days ago I noticed assignment/comparison of char
variables to '' (nothing between single quotes) in, for example, the
is_numeric_string function (zend_operators.h), snprintf.c, spprintf.c, etc.
I don't understand what it's doing. :-/ The only references I can find are
about "empty character constant" compiler errors, which is what happens if I
try to use '' in the same way (VC++ Express). Though PHP compiles fine with
these "constructs," so something must be special there?
Sorry to bother the list with this if it's a general C thing that should be
known and not PHP-code specific. But I've tried to figure it out on my own
(which I have with other stuff so far :-)) and can't, so I'd appreciate it
if someone can clue me in!
Thanks,
Matt
Hi all,
I'm a C newbie and just started experimenting with the PHP internals a
couple weeks ago... A few days ago I noticed assignment/comparison of char
variables to '' (nothing between single quotes) in, for example, the
is_numeric_string function (zend_operators.h), snprintf.c, spprintf.c, etc.
I don't understand what it's doing. :-/ The only references I can find are
about "empty character constant" compiler errors, which is what happens if I
try to use '' in the same way (VC++ Express). Though PHP compiles fine with
these "constructs," so something must be special there?
http://publications.gbdirect.co.uk/c_book/chapter5/character_handling.html
Cheers,
--Pierre
Hi Pierre,
Thanks for the reply, but where does that page talk about an EMPTY character
constant? I pretty much understand character handling otherwise. :-)
Thanks,
Matt
----- Original Message -----
From: "Pierre"
Subject: Re: [PHP-DEV] Use of "empty character constant?"
Hi all,
I'm a C newbie and just started experimenting with the PHP internals a
couple weeks ago... A few days ago I noticed assignment/comparison of
char
variables to '' (nothing between single quotes) in, for example, the
is_numeric_string function (zend_operators.h), snprintf.c, spprintf.c,
etc.
I don't understand what it's doing. :-/ The only references I can find
are
about "empty character constant" compiler errors, which is what happens
if I
try to use '' in the same way (VC++ Express). Though PHP compiles fine
with
these "constructs," so something must be special there?http://publications.gbdirect.co.uk/c_book/chapter5/character_handling.html
Cheers,
--Pierre
Hi Pierre,
Thanks for the reply, but where does that page talk about an EMPTY character
constant? I pretty much understand character handling otherwise. :-)
Then I do not understand your question. Do you have the exact
error/warning/notice? And some example code?
--Pierre
Hi Pierre,
:-O I was just going to give you an example from zend_operators.h,
is_numeric_string() and guess what? It's the "correct" way that I thought
it should be! I thought PHP 6 changed something, to where
/* handle hex numbers */
if (length>=2 && str[0]=='0' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
}
which is easy to understand :-) became
if (length>=2 && str[0]=='' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
}
BUT, I recently started looking at http://lxr.php.net so I could
cross-reference, etc., instead of searching my local sources, and that's
where I first saw this "change." It took you asking for an example for me
to realize that LXR is the problem, screwing up the display of '0' !
(Though I think I saw it correctly in some places?) LOL, I can't believe
it. I kinda thought, "Oh well, I just don't get it," but I'm glad I
e-mailed before spending more time than I have trying to figure out what the
empty char constant does!
http://lxr.php.net/ident?i=is_numeric_string -- check out 12 lines into the
function definition. :-/
Well, thanks for helping me get on the right track to "solving" this. The
LXR thing needs fixing I guess.
Matt
----- Original Message -----
From: "Pierre"
Subject: Re: [PHP-DEV] Use of "empty character constant?"
Hi Pierre,
Thanks for the reply, but where does that page talk about an EMPTY
character
constant? I pretty much understand character handling otherwise. :-)Then I do not understand your question. Do you have the exact
error/warning/notice? And some example code?--Pierre
Hi Pierre,
:-O I was just going to give you an example from zend_operators.h,
is_numeric_string() and guess what? It's the "correct" way that I thought
it should be! I thought PHP 6 changed something, to where/* handle hex numbers */
if (length>=2 && str[0]=='0' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
}which is easy to understand :-) became
if (length>=2 && str[0]=='' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
}
'0' became '' ?
Why would character 0 become nothing?
--
Wbr,
Antony Dovgal
Hi Antony,
----- Original Message -----
From: "Antony Dovgal"
Hi Pierre,
:-O I was just going to give you an example from zend_operators.h,
is_numeric_string() and guess what? It's the "correct" way that I
thought
it should be! I thought PHP 6 changed something, to where/* handle hex numbers */
if (length>=2 && str[0]=='0' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
}which is easy to understand :-) became
if (length>=2 && str[0]=='' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
}'0' became '' ?
Why would character 0 become nothing?
I don't know; was wondering the same thing. :-) But, that is what I saw on
http://lxr.php.net :-(
Matt
Hi Antony,
----- Original Message -----
From: "Antony Dovgal"Hi Pierre,
:-O I was just going to give you an example from zend_operators.h,
is_numeric_string() and guess what? It's the "correct" way that I
thought
it should be! I thought PHP 6 changed something, to where/* handle hex numbers */
if (length>=2 && str[0]=='0' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
}which is easy to understand :-) became
if (length>=2 && str[0]=='' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
}'0' became '' ?
Why would character 0 become nothing?I don't know; was wondering the same thing. :-) But, that is what I saw on
http://lxr.php.net :-(
What do you mean "I saw on lxr"?
I still don't understand a word..
--
Wbr,
Antony Dovgal
Hi Antony,
----- Original Message -----
From: "Antony Dovgal"
Hi Antony,
----- Original Message -----
From: "Antony Dovgal"'0' became '' ?
Why would character 0 become nothing?I don't know; was wondering the same thing. :-) But, that is what I saw
on
http://lxr.php.net :-(What do you mean "I saw on lxr"?
I still don't understand a word..
Didn't you see my explanation in the e-mail you first replied to? :-)
http://lxr.php.net/source/ZendEngine2/zend_operators.h#82
That's where I saw that " '0' became '' " The LXR code-cross-referencing
thing wrongly displays '0' , which was the cause of my confusion.
Matt
Didn't you see my explanation in the e-mail you first replied to? :-)
http://lxr.php.net/source/ZendEngine2/zend_operators.h#82That's where I saw that " '0' became '' " The LXR code-cross-referencing
thing wrongly displays '0' , which was the cause of my confusion.
Please report it to LXR developers: http://lxr.linux.no/
--
Wbr,
Antony Dovgal
Matt W wrote:
Hi all,
I'm a C newbie and just started experimenting with the PHP internals
a couple weeks ago... A few days ago I noticed assignment/comparison
of char variables to '' (nothing between single quotes) in, for
example, the is_numeric_string function (zend_operators.h),
snprintf.c, spprintf.c, etc. I don't understand what it's doing. :-/
I don't see what you're seeing and cannot find a single occurrence of ''.
--
Michael
Michael Wallner wrote:
Matt W wrote:
Hi all,
I'm a C newbie and just started experimenting with the PHP internals
a couple weeks ago... A few days ago I noticed assignment/comparison
of char variables to '' (nothing between single quotes) in, for
example, the is_numeric_string function (zend_operators.h),
snprintf.c, spprintf.c, etc. I don't understand what it's doing. :-/I don't see what you're seeing and cannot find a single occurrence of ''.
http://lxr.php.net/source/ZendEngine2/zend_operators.h#71
I think he is talking about this, it appears as '' on lxr