ID:               21611
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jan at horde dot org
-Status:           Open
+Status:           Closed
 Bug Type:         PHP options/info functions
 Operating System: Any
 PHP Version:      4CVS-2003-01-13 (stable)
 New Comment:

Patch committed.



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

[2003-08-02 10:03:18] [EMAIL PROTECTED]

reclassifying as PHP options/info functions

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

[2003-08-02 09:35:44] [EMAIL PROTECTED]

I'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;


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

[2003-08-01 05:40:08] [EMAIL PROTECTED]

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 |      equal



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

[2003-07-31 15:19:07] [EMAIL PROTECTED]

Um, PHP version 5.0.0b1 is a PHP version with a suffix.  I'd call this
a valid bug, especially because this can be fixed by using
strnatcasecmp() instead of version_compare().  Perhaps this is a bug in
version_compare(), and should be noted as such?

Greg

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

[2003-07-31 14:16:24] [EMAIL PROTECTED]

this should be then at least noted in the PEAR developer
documenation... My package is not the first one with this problem....
(and using p1 as suffix is pretty standard for software versions) so
that note is needed.


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

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/21611

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

Reply via email to