Re: zend_compare & co

From: Date: Sat, 06 Oct 2001 15:00:55 +0000
Subject: Re: zend_compare & co
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-67431@lists.php.net to get a copy of this message
> >Can you trust on the compare functions to return either -1, 0 or 1? I don't > >think so... but since that assumption is made in various locations in PHP4, > >it maybe is true? As of the current CVS the zend strcmp functions returns either 0 if the two strings are identical or otherwise the size of the first string minus the size of second string. Like all other Zend engine functions strcmp is binary safe. BTW, even the libc implementation of the strcmp function (the Zend engine does not use it) is different on the different platforms (it returns -1, 0, 1 on linux glibc21,22 and -N,0,N on FreeBSD and Solaris). However, I can hardly imagine a case when this behaviour can be important. Regards: -- Alex > > I think Zend's internal compare functions where normalized a while ago. > > > >Similar question for zend booleans, can you trust the lval to be either 0 or > >1, or not? > > Yes, booleans should be 0 or 1. > > All of this doesn't meant here aren't bugs someplace :) However, I think in > general if you want to write a robust function which relies on these things > you're best off relying on the 0 being false and all the rest being true. > > Andi > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.dev (#67431) next »