Re: [PHP4BETA] cvs: php4 /ext/standard/ string.c
[email protected] (Zeev Suraski) Thu, 1 Jun 2000 17:26:37 +0300 (IDT)
| Newsgroups | php.version4 |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 1 Jun 2000 [email protected] 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 <[email protected]> http://www.zend.com/