mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-22 07:09:54 +00:00
Fix value< string comparison ungoodthink
* src/fns.c (string_cmp): Fix bad comparisons for certain strings. This only affected `value<` for aggregates, not `string<`. * test/src/fns-tests.el (fns-value<-ordered): Add test cases.
This commit is contained in:
parent
05215177a6
commit
9b1e44c7fb
@ -481,7 +481,7 @@ string_cmp (Lisp_Object string1, Lisp_Object string2)
|
||||
int d = memcmp (SSDATA (string1), SSDATA (string2), n);
|
||||
if (d)
|
||||
return d;
|
||||
return n < SCHARS (string2) ? -1 : n > SCHARS (string2);
|
||||
return n < SCHARS (string2) ? -1 : n < SCHARS (string1);
|
||||
}
|
||||
else if (STRING_MULTIBYTE (string1) && STRING_MULTIBYTE (string2))
|
||||
{
|
||||
@ -515,7 +515,7 @@ string_cmp (Lisp_Object string1, Lisp_Object string2)
|
||||
|
||||
if (b >= nb)
|
||||
/* One string is a prefix of the other. */
|
||||
return b < nb2 ? -1 : b > nb2;
|
||||
return b < nb2 ? -1 : b < nb1;
|
||||
|
||||
/* Now back up to the start of the differing characters:
|
||||
it's the last byte not having the bit pattern 10xxxxxx. */
|
||||
@ -540,7 +540,7 @@ string_cmp (Lisp_Object string1, Lisp_Object string2)
|
||||
if (c1 != c2)
|
||||
return c1 < c2 ? -1 : 1;
|
||||
}
|
||||
return i1 < SCHARS (string2) ? -1 : i1 > SCHARS (string2);
|
||||
return i1 < SCHARS (string2) ? -1 : i1 < SCHARS (string1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -553,7 +553,7 @@ string_cmp (Lisp_Object string1, Lisp_Object string2)
|
||||
if (c1 != c2)
|
||||
return c1 < c2 ? -1 : 1;
|
||||
}
|
||||
return i1 < SCHARS (string2) ? -1 : i1 > SCHARS (string2);
|
||||
return i1 < SCHARS (string2) ? -1 : i1 < SCHARS (string1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1614,6 +1614,12 @@
|
||||
;; strings
|
||||
("" . "a") ("a" . "b") ("A" . "a") ("abc" . "abd")
|
||||
("b" . "ba")
|
||||
;; strings again, but in a context where 3-way comparison
|
||||
;; matters
|
||||
(("" . 2) . ("a" . 1))
|
||||
(("å" . 2) . ("åü" . 1))
|
||||
(("a" . 2) . ("aå" . 1))
|
||||
(("\x80" . 2) . ("\x80å" . 1))
|
||||
|
||||
;; lists
|
||||
((1 2 3) . (2 3 4)) ((2) . (2 1)) (() . (0))
|
||||
|
Loading…
Reference in New Issue
Block a user