|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-13 04:23 UTC] jan at horde dot org
Either PEAR (1.0.1) fails in calculating release numbers or the apd maintainers chose an invalid release number: $ pear list [...] | apd | 0.4p1 | stable | [...] $ pear list-upgrades AVAILABLE UPGRADES (STABLE): ============================ +---------+---------+------+ | PACKAGE | VERSION | SIZE | | apd | 0.4 | 39kB | +---------+---------+------+ $ pear upgrade apd downloading apd-0.4p1.tgz ... ...done: bytes upgrade to a newer version (0.4p1 is not newer than 0.4p1) $ pear upgrade-all RELEASE WARNINGS ================ +---+ | w | +---+ w downloading apd-0.4p1.tgz ... ...done: p39,605 bytes upgrade to a newer version (0.4p1 is not newer than 0.4p1) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 19:00:01 2025 UTC |
version_compare does handle suffixes. (see example below) However, p1 is not a valid suffix for this function. So, solutions would be imo: A) use the pl suffix and document this B) make version_compare handle pl and p equally Example script: <?php $version[] = "4.0.1pl2"; $version[] = "4.0.1pl1"; $version[] = "4.0.1b"; $version[] = "4.0.1a"; $version[] = "4.0.1p1"; $version[] = "4.0.1"; printf("%10s | %10s | %10s\n", "Version 1", "Version 2", "New Vers."); print str_repeat('-',36)."\n"; for ($i = 0, $s = count($version); $i < $s; $i++ ) { for ($j = $i; $j < $s; $j++) { printf("%10s | %10s | ",$version[$i],$version[$j]); $c = version_compare($version[$i], $version[$j]); switch ($c) { case -1: $r = $version[$j]; break; case 0: $r = 'equal'; break; case 1: $r = $version[$i]; } printf("%10s\n", $r); } } ?> Result: Version 1 | Version 2 | New Vers. ------------------------------------ 4.0.1pl2 | 4.0.1pl2 | equal 4.0.1pl2 | 4.0.1pl1 | 4.0.1pl2 4.0.1pl2 | 4.0.1b | 4.0.1pl2 4.0.1pl2 | 4.0.1a | 4.0.1pl2 4.0.1pl2 | 4.0.1p1 | 4.0.1pl2 4.0.1pl2 | 4.0.1 | 4.0.1pl2 4.0.1pl1 | 4.0.1pl1 | equal 4.0.1pl1 | 4.0.1b | 4.0.1pl1 4.0.1pl1 | 4.0.1a | 4.0.1pl1 4.0.1pl1 | 4.0.1p1 | 4.0.1pl1 4.0.1pl1 | 4.0.1 | 4.0.1pl1 4.0.1b | 4.0.1b | equal 4.0.1b | 4.0.1a | 4.0.1b 4.0.1b | 4.0.1p1 | 4.0.1b 4.0.1b | 4.0.1 | 4.0.1 4.0.1a | 4.0.1a | equal 4.0.1a | 4.0.1p1 | 4.0.1a 4.0.1a | 4.0.1 | 4.0.1 4.0.1p1 | 4.0.1p1 | equal 4.0.1p1 | 4.0.1 | 4.0.1 4.0.1 | 4.0.1 | equalI'd go for B) and change it, since it's easy and the p suffix is quite common... here's a patch that does it: Index: versioning.c =================================================================== RCS file: /repository/php-src/ext/standard/versioning.c,v retrieving revision 1.15 diff -u -r1.15 versioning.c --- versioning.c 10 Jun 2003 20:03:39 -0000 1.15 +++ versioning.c 2 Aug 2003 14:28:45 -0000 @@ -90,7 +90,7 @@ compare_special_version_forms(char *form1, char *form2) { int found1 = -1, found2 = -1; - special_forms_t special_forms[9] = { + special_forms_t special_forms[10] = { {"dev", 0}, {"alpha", 1}, {"a", 1}, @@ -99,6 +99,7 @@ {"RC", 3}, {"#", 4}, {"pl", 5}, + {"p", 5}, {NULL, 0}, }; special_forms_t *pp;