#44929 [Com]: [PATCH] natsort and natcasesort fail if numbers in strings prepended by 0
| From: | bax_70 at hotmail dot com | Date: | Wed, 08 Apr 2009 14:35:44 +0000 |
| Subject: | #44929 [Com]: [PATCH] natsort and natcasesort fail if numbers in strings prepended by 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-135658@lists.php.net to get a copy of this message | ||
ID: 44929
Comment by: bax_70 at hotmail dot com
Reported By: kae at verens dot com
Status: No Feedback
Bug Type: Arrays related
Operating System: Linux
PHP Version: 5.2.6
Assigned To: rasmus
New Comment:
Bad result.
$a[0]=00001;
$a[1]=00008;
$a[2]=00005;
$a[3]=000011;
$a[4]=00003;
$a[5]=000014;
natsort($a);
print_r($a);
Array ( [1] => 0 [0] => 1 [4] => 3 [2] => 5 [3] => 9 [5] => 12 )
Previous Comments:
------------------------------------------------------------------------
[2008-09-04 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2008-08-27 08:41:25] rasmus@php.net
Checking this further, this patch messes up the order of "0" in an
array that contains negative values like "-123", so it still needs some
work.
------------------------------------------------------------------------
[2008-08-27 07:53:46] rasmus@php.net
I was hoping for some feedback on the patch to hear if it actually
fixes it.
------------------------------------------------------------------------
[2008-08-26 22:57:53] jani@php.net
Rasmus, why don't you commit the patch if it fixes this..?
------------------------------------------------------------------------
[2008-05-07 18:35:04] rasmus@php.net
This should fix this one:
Index: strnatcmp.c
===================================================================
RCS file: /repository/php-src/ext/standard/strnatcmp.c,v
retrieving revision 1.10
diff -u -1 -r1.10 strnatcmp.c
--- strnatcmp.c 15 Jul 2004 01:26:03 -0000 1.10
+++ strnatcmp.c 7 May 2008 18:34:31 -0000
@@ -118,6 +118,6 @@
/* skip over leading spaces or zeros */
- while (isspace((int)(unsigned char)ca))
+ while (isspace((int)(unsigned char)ca) || ca=='0')
ca = *++ap;
- while (isspace((int)(unsigned char)cb))
+ while (isspace((int)(unsigned char)cb) || cb=='0')
cb = *++bp;
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/44929
--
Edit this bug report at http://bugs.php.net/?id=44929&edit=1