aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libq/atom.c36
-rw-r--r--tests/atom_compare/static.good1
-rw-r--r--tests/atom_compare/static.tests1
3 files changed, 28 insertions, 10 deletions
diff --git a/libq/atom.c b/libq/atom.c
index 50e9520c..31299f1b 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -784,22 +784,38 @@ atom_compare_flg(const depend_atom *data, const depend_atom *query, int flags)
*ends1 != '_';
ends1++)
;
+ if (ends1 != s1)
+ ends1--;
for (ends2 = s2;
*ends2 != '\0' &&
*ends2 != '.' &&
*ends2 != '_';
ends2++)
;
- /* 3.3L2-3: remove *trailing* zeros */
- for (ends1--; ends1 > s1 && *ends1 == '0'; ends1--)
- ;
- for (ends2--; ends2 > s2 && *ends2 == '0'; ends2--)
- ;
- /* 3.3L4 ASCII stringwise comparison */
- n1 = ends1 - s1;
- n2 = ends2 - s2;
- n1 = strncmp(s1, s2, n1 > n2 ? n1 : n2);
- n2 = 0;
+ if (ends2 != s2)
+ ends2--;
+ /* bug 852197: leading 0 means something else
+ * must follow */
+ if (ends1 - s1 > 1 || ends2 - s2 > 1) {
+ /* 3.3L2-3: remove *trailing* zeros */
+ for (; ends1 > s1 && *ends1 == '0'; ends1--)
+ ;
+ for (; ends2 > s2 && *ends2 == '0'; ends2--)
+ ;
+ /* 3.3L4 ASCII stringwise comparison */
+ n1 = ends1 - s1;
+ n2 = ends2 - s2;
+ n1 = strncmp(s1, s2, n1 > n2 ? n1 : n2);
+ n2 = 0;
+ } else {
+ /* repeat of 3.3#L9 (else case below) */
+ n1 = strtoll(s1, &ends1, 10);
+ if (ends1 == s1)
+ n1 = -1;
+ n2 = strtoll(s2, &ends2, 10);
+ if (ends2 == s2)
+ n2 = -1;
+ }
} else { /* 3.3#L9 */
n1 = strtoll(s1, &ends1, 10);
if (ends1 == s1)
diff --git a/tests/atom_compare/static.good b/tests/atom_compare/static.good
index 6da5553b..83bf7ec7 100644
--- a/tests/atom_compare/static.good
+++ b/tests/atom_compare/static.good
@@ -52,3 +52,4 @@ a-1 != =a-1.2z*
a-1_alpha1 == =a-1*
a-1 != =a-1_alpha1*
a-1_alpha-r1 == =a-1_alpha*
+a-3.10.5 == >=a-3.10.0_p1_r1
diff --git a/tests/atom_compare/static.tests b/tests/atom_compare/static.tests
index 168f3583..213fb5e1 100644
--- a/tests/atom_compare/static.tests
+++ b/tests/atom_compare/static.tests
@@ -52,3 +52,4 @@ a-1 =a-1.2z*
a-1_alpha1 =a-1*
a-1 =a-1_alpha1*
a-1_alpha-r1 =a-1_alpha*
+a-3.10.5 >=a-3.10.0_p1_r1