summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2024-04-28 23:17:48 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2024-04-29 14:29:52 +0200
commit9b1e44c7fb5281688488ec077c048e268b716ad2 (patch)
treea91248ffc1279ca3a946dca275b4e434bdd7d273 /src
parent05215177a61437e864ef771afc99b130866fbcb5 (diff)
downloademacs-9b1e44c7fb5281688488ec077c048e268b716ad2.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/fns.c b/src/fns.c
index e987d64319f..9be42aa8b68 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -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);
}
}