OK, here we go...

After looking at this, I decided it is broken because rpmvercmp is not
honoring its contract to only return 1, 0, or -1.  Attached is a patch
that fixes rpmvercmp(), as well as the original problems I found.

Steve, can you try this guy out to see if it deals properly with your
RHL 7.3 problem?

Thanks for noticing this.

On Mon, 2005-02-28 at 15:20, [EMAIL PROTECTED] wrote:
>  > Have you found a case where strcmp() returns something other than that
>  > on one of your machines?
> 
> strcmp("1",x) for (almost all?) values of x>2 on RH7.3
> 
> and, like i said before, strcmp("42","44") is -2 on RH7.3!
> 
> couldn't find any in FC3 after about 150,000 tries.
> 
> steve 
> - - - 
> systems & network manager
> high energy physics
> university of wisconsin
> 
> ginseng(rader): cat /etc/redhat-release
> Red Hat Linux release 7.3 (Valhalla) UW-HEP $Revision 1.9$
> 
> ginseng(rader): cat strcmp.c 
> main (char *argc, char **argv) {
>   int i;
>   i = strcmp(argv[1],argv[2]);
>   printf("strcmp %s %s is %d\n",argv[1],argv[2],i);
> }
> 
> ginseng(rader): cc -o strcmp strcmp.c 
> 
> ginseng(rader): ./strcmp 42 44
> strcmp 42 44 is -2
-- 
Phil D'Amore                             "Sometimes there is a fine line
Senior System Administrator               between criminally abusive
Red Hat, Inc                              behavior and fun."
Office: 919.754.3700 x44395                 -- Ted the Generic Guy
Pager: 877.383.8795                            (Dilbert 4/19/2003)
diff -Naur cfengine-2.1.13.orig/src/package.c cfengine-2.1.13/src/package.c
--- cfengine-2.1.13.orig/src/package.c	2004-10-10 03:42:51.000000000 -0400
+++ cfengine-2.1.13/src/package.c	2005-02-28 16:34:27.366841036 -0500
@@ -198,23 +198,25 @@
      {
      result = cmpsense_lt;
      }
+
    /* If that did not decide it, try version.  We must *always* have
     * a version string.  That's just the way it is.*/
-
-   switch (rpmvercmp(vA, vB))
+   if (result == cmpsense_eq)
      {
-     case 1:    result = cmpsense_gt;
-                break;
-     case -1:   result = cmpsense_lt;
-                break;
+     switch (rpmvercmp(vA, vB))
+       {
+       case 1:    result = cmpsense_gt;
+                  break;
+       case -1:   result = cmpsense_lt;
+                  break;
+       }
      }
 
    /* if we wind up here, everything rides on the release if both have it.
     * RPM always stores a release internally in the database, so the A side
     * will have it.  It's just a matter of whether or not the user cares
     * about it at this point. */
-
-   if (rB && *rB)
+   if ((result == cmpsense_eq) && (rB && *rB))
       {
       switch (rpmvercmp(rA, rB))
          {
@@ -747,7 +749,8 @@
        {
        free(s1);
        free(s2);
-       return rc;
+       if (rc > 0) { return 1; }
+       if (rc < 0) { return -1; }
        }
     
     /* restore character that was replaced by null above */
_______________________________________________
Bug-cfengine mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-cfengine

Reply via email to