From 5af160e9c8f0156ccc61e2e789e0839354405337 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 26 Apr 2023 12:23:18 -0500 Subject: T5185: drop assumption in case of a sequence of 0's In the original implementation, it was mistakenly assumed that strings of digits of differing lengths would not have equal value, but strings of 0's are a counterexample. --- src/lexical_numeric_compare.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lexical_numeric_compare.c b/src/lexical_numeric_compare.c index e1395d7..3905f3f 100644 --- a/src/lexical_numeric_compare.c +++ b/src/lexical_numeric_compare.c @@ -66,9 +66,9 @@ CAMLprim value caml_lex_numeric_compare(value str1, value str2) { return Val_int(0); } - // if here, pos1 == pos2, or something is horribly wrong - if (pos1 != pos2) caml_failwith(inconsistent); - pos = pos1; + // if a sequence of 0's were encountered, it is possible that + // pos1 != pos2; adjust + pos = pos1 > pos2 ? pos2 : pos1; p1 = s1; p2 = s2; len = len - pos; -- cgit v1.2.3