Re: [PHP4BETA] cvs: php4 /ext/standard/ string.c

From: Date: Thu, 01 Jun 2000 14:26:37 +0000
Subject: Re: [PHP4BETA] cvs: php4 /ext/standard/ string.c
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-16032@lists.php.net to get a copy of this message
On Thu, 1 Jun 2000 jah@mork.net wrote: > > > On Thu, 1 Jun 2000, Andrei Zmievski wrote: > > > On Thu, 01 Jun 2000, Jouni Ahto wrote: > > > jah Thu Jun 1 06:38:23 2000 EDT > > > > > > Modified files: > > > /php4/ext/standard string.c > > > Log: > > > > > > (ucwords) Fixed fix for fix for fix for #4748. > > > # Today's most fixed bug. > > > > > > r=return_value->value.str.val; > > > *r=toupper((unsigned char)*r); > > > - for(r_end = r + return_value->value.str.len -1 ; r < r_end ; r++ ) { > > > + for(r_end = r + return_value->value.str.len -1 ; r < r_end ; ) { > > > if(isspace(*r)) { > > > - *++r=toupper((unsigned char)*r); > > > + *r=toupper((unsigned char)*++r); > > > > Are you sure about this? It seems that you're replacing space character > > with the uppercased next one. > > Didn't happen for me. At what point of the line does r actually get > incremented? I read the first version as 'uppercase the char r points to > and assign it to incremented r', the second 'increment r, uppercase the > char it points to, and assign it to r (ie. itself)'. But in fact, both > versions did work for me. I was in fact fixing something else, skipping > over when there are an even number of space chars. What you're doing is not defined in C/C++. The order of evaluation of lvalue vs. rvalue is undefined. So, *r = foo(++*r); Could be equivalent to both: *r = foo(*r); ++*r; and ++*r; *r = foo(*r); It's compiler dependant. You need to fix it... Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/

« previous php.version4 (#16032) next »