]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Support caret in rpm's EVR comparison
authorMichael Schroeder <mls@suse.de>
Wed, 21 Nov 2018 13:15:34 +0000 (14:15 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 21 Nov 2018 13:15:34 +0000 (14:15 +0100)
Currently only active if RPM_CARET_DEPS is defined, so that Igor
can do some testing.

src/evr.c

index a7d43112635c608ac25982323bdcc0bd040f6583..4a0c549b6a90fe0b3be6208f99063ffa72885912 100644 (file)
--- a/src/evr.c
+++ b/src/evr.c
@@ -76,12 +76,33 @@ solv_vercmp_rpm(const char *s1, const char *q1, const char *s2, const char *q2)
 
   for (;;)
     {
+#ifdef RPM_CARET_DEPS
+      while (s1 < q1 && !(*s1 >= '0' && *s1 <= '9') &&
+          !(*s1 >= 'a' && *s1 <= 'z') && !(*s1 >= 'A' && *s1 <= 'Z') && *s1 != '~' && *s1 != '^')
+       s1++;
+      while (s2 < q2 && !(*s2 >= '0' && *s2 <= '9') &&
+          !(*s2 >= 'a' && *s2 <= 'z') && !(*s2 >= 'A' && *s2 <= 'Z') && *s2 != '~' && *s2 != '^')
+       s2++;
+      if (s1 < q1 && *s1 == '^')
+       {
+         if (s2 < q2 && *s2 == '^')
+           {
+             s1++;
+             s2++;
+             continue;
+           }
+         return s2 < q2 ? -1 : 1;
+       }
+      if (s2 < q2 && *s2 == '^')
+       return s1 < q1 ? 1 : -1;
+#else
       while (s1 < q1 && !(*s1 >= '0' && *s1 <= '9') &&
           !(*s1 >= 'a' && *s1 <= 'z') && !(*s1 >= 'A' && *s1 <= 'Z') && *s1 != '~')
        s1++;
       while (s2 < q2 && !(*s2 >= '0' && *s2 <= '9') &&
           !(*s2 >= 'a' && *s2 <= 'z') && !(*s2 >= 'A' && *s2 <= 'Z') && *s2 != '~')
        s2++;
+#endif
       if (s1 < q1 && *s1 == '~')
         {
          if (s2 < q2 && *s2 == '~')