# Use of "empty character constant?"

- Thread: https://externals.io/message/24291
- Original archive: https://news-web.php.net/php.internals/24291
- Started by Matt W on 2006-07-08T09:12:26+00:00
- Messages: 12
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #24291 — Matt W — 2006-07-08T09:12:26+00:00

URL: https://externals.io/message/24291#24291

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

---

## #24292 — Pierre — 2006-07-08T09:17:54+00:00

URL: https://externals.io/message/24291#24292 · In reply to: #24291

> 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

---

## #24293 — Matt W — 2006-07-08T09:50:00+00:00

URL: https://externals.io/message/24291#24293 · In reply to: #24292

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?"


> 
> > […]
char
> > […]
etc.
> > […]
are
> > […]
if I
> > […]
with
> > […]
>
> http://publications.gbdirect.co.uk/c_book/chapter5/character_handling.html
>
> Cheers,
> --Pierre

---

## #24294 — Pierre — 2006-07-08T10:12:31+00:00

URL: https://externals.io/message/24291#24294 · In reply to: #24293

> 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

---

## #24295 — Michael Wallner — 2006-07-08T10:47:19+00:00

URL: https://externals.io/message/24291#24295 · In reply to: #24291

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

---

## #24296 — Matt W — 2006-07-08T10:48:03+00:00

URL: https://externals.io/message/24291#24296 · In reply to: #24294

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?"


> 
> > […]
character
> > […]
>
> Then I do not understand your question. Do you have the exact
> error/warning/notice? And some example code?
>
> --Pierre

---

## #24297 — Antony Dovgal — 2006-07-08T11:02:43+00:00

URL: https://externals.io/message/24291#24297 · In reply to: #24296

> 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

---

## #24298 — Matt W — 2006-07-08T11:10:31+00:00

URL: https://externals.io/message/24291#24298 · In reply to: #24297

Hi Antony,

----- Original Message ----- 
From: "Antony Dovgal"


> 
> > […]
thought
> > […]
>
> '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

---

## #24300 — Antony Dovgal — 2006-07-08T11:17:38+00:00

URL: https://externals.io/message/24291#24300 · In reply to: #24298

> Hi Antony,
> 
> ----- Original Message ----- 
> From: "Antony Dovgal"
> 
> 
> > […]
> thought
> > […]
> 
> 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

---

## #24299 — Matt W — 2006-07-08T11:28:22+00:00

URL: https://externals.io/message/24291#24299 · In reply to: #24300

Hi Antony,

----- Original Message ----- 
From: "Antony Dovgal"


> 
> > […]
on
> > […]
>
> 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

---

## #24306 — Antony Dovgal — 2006-07-10T11:10:54+00:00

URL: https://externals.io/message/24291#24306 · In reply to: #24299

> 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.

Please report it to LXR developers: http://lxr.linux.no/

-- 
Wbr, 
Antony Dovgal

---

## #24305 — Mike Dransfield — 2006-07-10T11:16:47+00:00

URL: https://externals.io/message/24291#24305 · In reply to: #24295

Michael Wallner wrote:
> Matt W wrote:
> > […]
> 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
