diff options
| author | Mattias EngdegÄrd | 2024-04-28 23:17:48 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-04-29 14:29:52 +0200 |
| commit | 9b1e44c7fb5281688488ec077c048e268b716ad2 (patch) | |
| tree | a91248ffc1279ca3a946dca275b4e434bdd7d273 /src | |
| parent | 05215177a61437e864ef771afc99b130866fbcb5 (diff) | |
| download | emacs-9b1e44c7fb5281688488ec077c048e268b716ad2.tar.gz emacs-9b1e44c7fb5281688488ec077c048e268b716ad2.zip | |
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.c | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -481,7 +481,7 @@ string_cmp (Lisp_Object string1, Lisp_Object string2) | |||
| 481 | int d = memcmp (SSDATA (string1), SSDATA (string2), n); | 481 | int d = memcmp (SSDATA (string1), SSDATA (string2), n); |
| 482 | if (d) | 482 | if (d) |
| 483 | return d; | 483 | return d; |
| 484 | return n < SCHARS (string2) ? -1 : n > SCHARS (string2); | 484 | return n < SCHARS (string2) ? -1 : n < SCHARS (string1); |
| 485 | } | 485 | } |
| 486 | else if (STRING_MULTIBYTE (string1) && STRING_MULTIBYTE (string2)) | 486 | else if (STRING_MULTIBYTE (string1) && STRING_MULTIBYTE (string2)) |
| 487 | { | 487 | { |
| @@ -515,7 +515,7 @@ string_cmp (Lisp_Object string1, Lisp_Object string2) | |||
| 515 | 515 | ||
| 516 | if (b >= nb) | 516 | if (b >= nb) |
| 517 | /* One string is a prefix of the other. */ | 517 | /* One string is a prefix of the other. */ |
| 518 | return b < nb2 ? -1 : b > nb2; | 518 | return b < nb2 ? -1 : b < nb1; |
| 519 | 519 | ||
| 520 | /* Now back up to the start of the differing characters: | 520 | /* Now back up to the start of the differing characters: |
| 521 | it's the last byte not having the bit pattern 10xxxxxx. */ | 521 | it's the last byte not having the bit pattern 10xxxxxx. */ |
| @@ -540,7 +540,7 @@ string_cmp (Lisp_Object string1, Lisp_Object string2) | |||
| 540 | if (c1 != c2) | 540 | if (c1 != c2) |
| 541 | return c1 < c2 ? -1 : 1; | 541 | return c1 < c2 ? -1 : 1; |
| 542 | } | 542 | } |
| 543 | return i1 < SCHARS (string2) ? -1 : i1 > SCHARS (string2); | 543 | return i1 < SCHARS (string2) ? -1 : i1 < SCHARS (string1); |
| 544 | } | 544 | } |
| 545 | else | 545 | else |
| 546 | { | 546 | { |
| @@ -553,7 +553,7 @@ string_cmp (Lisp_Object string1, Lisp_Object string2) | |||
| 553 | if (c1 != c2) | 553 | if (c1 != c2) |
| 554 | return c1 < c2 ? -1 : 1; | 554 | return c1 < c2 ? -1 : 1; |
| 555 | } | 555 | } |
| 556 | return i1 < SCHARS (string2) ? -1 : i1 > SCHARS (string2); | 556 | return i1 < SCHARS (string2) ? -1 : i1 < SCHARS (string1); |
| 557 | } | 557 | } |
| 558 | } | 558 | } |
| 559 | 559 | ||