Re: Patch for define() / zend_builtin_functions.c

From: Date: Tue, 02 Oct 2001 08:00:35 +0000
Subject: Re: Patch for define() / zend_builtin_functions.c
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-66981@lists.php.net to get a copy of this message
On October 2, 2001 01:55 am, Derick Rethans wrote:
> On Tue, 2 Oct 2001, Zak Greant wrote:
> > Bug report 13505 got me thinking about the behavior of define() -
> > if you try to define a constant name that is a reserved word, or an
> > existing function or class name, no warning is generated.
> >
> > This could have  been a conscious decision - a case where it was
> > decided that some safety could be traded for a bit of extra speed.
> > If it wasn't, then here is a patch to check that the constant name
> > does not clash with a reserved work, function name or class name.
> >
> > I used an array of reserved words and a for loop to handle finding
> > conflicting reserved words. Is there a better way to do this.
> > AFAICT the other methods for handling reserved word conflicts are
> > handled at the parser level. i.e. Trying to define 'function and
> > (){}' generates a parser error.
> >
> > Anyhoo, perhaps someone could take a look at the patch? :)
>
> The idea looks ok, but the looping through the reserved words array
> would be very slow. However, keeping the first two checks in place it
> would be good IMO.

Hi Derick,

Thanks for taking a look! :) Attached is the fixed patch.

Perhaps tying the keyword checking to a certain error level would do 
the trick? Say perhaps if E_NOTICE is enabled, then do the checks? 

Also is there a faster way to do the search? My knowledge of C is still 
rather rudimentary. :o)

-- 
Zak Greant

PHP Quality Assurance Team
http://qa.php.net/

"We must be the change we wish to see." - M. K. Ghandi


Attachment: [text/x-diff] zend_builtin_functions.c.patch

Thread (6 messages)

« previous php.dev (#66981) next »