ID:               29075
 Updated by:       [EMAIL PROTECTED]
 Reported By:      oliver at burtchen dot com
-Status:           Analyzed
+Status:           Closed
 Bug Type:         Strings related
 Operating System: *
 PHP Version:      4CVS, 5CVS
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2004-07-11 22:41:20] [EMAIL PROTECTED]

The problem is that spaces at the end of the string cause the ap and bp
pointers to be looking at strlen+1 here is the patch to prevent that.

Index: ext/standard/strnatcmp.c
===================================================================
RCS file: /repository/php-src/ext/standard/strnatcmp.c,v
retrieving revision 1.9
diff -u -r1.9 strnatcmp.c
--- ext/standard/strnatcmp.c    16 Apr 2003 21:10:29 -0000      1.9
+++ ext/standard/strnatcmp.c    11 Jul 2004 20:38:30 -0000
@@ -153,13 +153,13 @@
                        return +1;

                ++ap; ++bp;
-               if (ap == aend && bp == bend)
+               if (ap >= aend && bp >= bend)
                        /* The strings compare the same.  Perhaps the
caller
                           will want to call strcmp to break the tie.
*/
                        return 0;
-               else if (ap == aend)
+               else if (ap >= aend)
                        return -1;
-               else if (bp == bend)
+               else if (bp >= bend)
                        return 1;
        }
 }


------------------------------------------------------------------------

[2004-07-11 19:27:43] [EMAIL PROTECTED]

See also bug #19795 (there doesn't seem to be any test case for this
function..the one who fixes should add that too, I can't access CVS
atm)



------------------------------------------------------------------------

[2004-07-09 17:23:12] oliver at burtchen dot com

Description:
------------
strnatcmp('foo ', 'foo ') returns -1 and not 0 as expected. As far as I
can see, it depends on the trailling whitespace.




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29075&edit=1

Reply via email to