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))
{
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. */
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
{
if (c1 != c2)
return c1 < c2 ? -1 : 1;
}
- return i1 < SCHARS (string2) ? -1 : i1 > SCHARS (string2);
+ return i1 < SCHARS (string2) ? -1 : i1 < SCHARS (string1);
}
}
;; 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))