branch: externals/hotfuzz
commit 1afac1f005e44679c0b309df73362db8fde60c25
Author: Axel Forsman <[email protected]>
Commit: Axel Forsman <[email protected]>
Fix strtolower only altering first 8 characters
---
README.md | 11 +++++------
hotfuzz-module.c | 7 +++----
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index f11c576392..087da80c19 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ for improved performance.
Ensure GCC, CMake and GNU Make or similar are present, and run
```sh
-cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-march=native . &&
+cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-march=native &&
cmake --build build
```
@@ -59,11 +59,10 @@ the dynamic module uses an unstable sorting algorithm.
> [!NOTE]
> Dynamic modules are unable to access invalid Unicode strings.
>
-> [Consult] appends invisible so-called *tofus* to disambiguate
-> completions and encode line numbers. Problematically, characters
-> outside the Unicode range, unlikely to be matched by a search
-> string, are used. Using e.g. the Supplementary Private Use Area-B
-> instead circumvents the encoding issues:
+> [Consult] appends invisible *tofus*, characters outside the Unicode
+> range (unlikely to match search strings), to attach line numbers and
+> disambiguate completions. Using e.g. the Supplementary Private Use
+> Area-B instead circumvents encoding issues:
> ```elisp
> (setq consult--tofu-char #x100000
> consult--tofu-range #x00fffe)
diff --git a/hotfuzz-module.c b/hotfuzz-module.c
index f5fc27ab15..b1fb91d2c6 100644
--- a/hotfuzz-module.c
+++ b/hotfuzz-module.c
@@ -3,7 +3,6 @@
*
* See the Lisp source for an explanation of the algorithm.
*/
-#define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
@@ -29,12 +28,12 @@ static char toupper_utf8(char c) {
static void strtolower(struct Str s) {
uint64_t ones = ~UINT64_C(0) / 0xff, x;
for (size_t i = 0; i < s.len; i += sizeof x) {
- memcpy(&x, s.b, sizeof x);
+ memcpy(&x, s.b + i, sizeof x);
uint64_t is_gt_Z = (0x7f * ones & x) + (0x7f - *u8"Z") * ones,
is_ge_A = (0x7f * ones & x) + (0x80 - *u8"A") * ones,
is_upper = 0x80 * ones & ~x & (is_ge_A ^ is_gt_Z);
x |= is_upper >> 2;
- memcpy(s.b, &x, sizeof x);
+ memcpy(s.b + i, &x, sizeof x);
}
}
@@ -75,7 +74,7 @@ static int calc_cost(struct Str needle, struct Str haystack,
bool ignore_case) {
int bonuses[MAX_HAYSTACK_LEN];
char ch, lastch = '/';
- for (size_t i = 0; i < n; ++i, lastch = ch)
+ for (unsigned i = 0; i < n; ++i, lastch = ch)
bonuses[i] = char_bonus(lastch, ch = haystack.b[i]);
if (ignore_case) strtolower(haystack);