com php-src: correct fix to the natcmp_ex: ext/standard/s trnatcmp.c ext/standard/tests/strings/strnatcasecmp_varia tion1.phpt

From: Date: Mon, 15 Sep 2014 10:58:46 +0000
Subject: com php-src: correct fix to the natcmp_ex: ext/standard/s trnatcmp.c ext/standard/tests/strings/strnatcasecmp_varia tion1.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81641@lists.php.net to get a copy of this message
Commit: 172ca172d135fc3ade5a08b5b3ef8cedcdc5018d Author: Anatol Belski <ab@php.net> Mon, 15 Sep 2014 12:54:46 +0200 Parents: 836fd73cce8d0550baf5477bfb0ea0edbfae455a Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=172ca172d135fc3ade5a08b5b3ef8cedcdc5018d Log: correct fix to the natcmp_ex Till now the actualy length diff between the strings was under circumstances returned. Whereby for a compare function only return values of (1, 0, -1) make sense. Thus the old behavior isn't present anymore, natcmp_ex now behaves as a standard compare function. Changed paths: M ext/standard/strnatcmp.c M ext/standard/tests/strings/strnatcasecmp_variation1.phpt Diff: diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c index 7b3826b..de6f727 100644 --- a/ext/standard/strnatcmp.c +++ b/ext/standard/strnatcmp.c @@ -109,23 +109,7 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len short leading = 1; if (a_len == 0 || b_len == 0) { - result = 0; - - if (a_len > b_len) { - if (a_len - b_len <= INT_MAX) { - result = (int)(a_len - b_len); - } else { - result = 1; - } - } else { - if (b_len - a_len <= (size_t)(-INT_MIN)) { - result = -(int)(b_len - a_len); - } else { - result = -1; - } - } - - return result; + return (a_len == b_len ? 0 : (a_len > b_len ? 1 : -1)); } ap = a; diff --git a/ext/standard/tests/strings/strnatcasecmp_variation1.phpt b/ext/standard/tests/strings/strnatcasecmp_variation1.phpt index fb0fb79...e74f6b7 100644 --- a/ext/standard/tests/strings/strnatcasecmp_variation1.phpt +++ b/ext/standard/tests/strings/strnatcasecmp_variation1.phpt @@ -48,8 +48,8 @@ str_dump($a, $b); --EXPECT-- *** Testing strnatcasecmp() : variation *** int(1) -int(6) -int(-2) +int(1) +int(-1) int(-1) int(0) int(0)

« previous php.cvs (#81641) next »