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

[email protected] (Hartmut Holzgraefe) Thu, 01 Jun 2000 16:33:14 +0200
Newsgroups php.version4
Message-ID <[email protected]>
Andrei Zmievski wrote:
 
> > -                     *++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.

the two assignments are equivalent, as the ++ operator has
a higher precedence then assingments or pointer de-referencing

see script below for proof of operation

> -Andrei
> * Use the source, Luke. *
so that's where i get all theese obi-wan errors from ?


<?
$tests = array( "a"     => "A",
		" a"    => " A",
		"a "    => "A ",
		" a "   => " A ",
		"a a a" => "A A A",
		"\ta\na\ra a" >= "\tA\nA\rA\A",
		"a  a   a    a     a" => "A  A   A    A     A"
);


reset($tests);
while(list($key,$val)=each($tests)) {
  if(!is_string($key)&&!is_string($val)) {
    continue;
  }
  if(ucwords($key)!==$val) {
    print "ucwords($key) is ".ucwords($key)."instead of $val\n";
  } else {
    print "ucwords($key) ok\n";
  }
}
?>