branch: externals/hotfuzz
commit 864d07cadb0ecbbf6c296db6ecfbb38358436e21
Author: Axel Forsman <[email protected]>
Commit: Axel Forsman <[email protected]>

    Specify expected POSIX standard
---
 hotfuzz-module.c | 9 +++++----
 hotfuzz.el       | 6 +++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/hotfuzz-module.c b/hotfuzz-module.c
index 145f1de161..a11289c3e5 100644
--- a/hotfuzz-module.c
+++ b/hotfuzz-module.c
@@ -3,6 +3,7 @@
  *
  * See the Lisp source for an explanation of the algorithm.
  */
+#define _POSIX_C_SOURCE 200809L
 #include <stdlib.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -62,7 +63,7 @@ static void match_row(struct Str a, struct Str b, int 
*bonuses, unsigned i, int
        for (size_t j = 0; j < m; ++j, s = oldc) {
                oldc = c[j];
                d[j] = MIN(d[j], oldc + g) + (j == m - 1 ? h : 2 * h);
-               c[j] = MIN(d[j], a.b[i] == b.b[j] ? s - bonuses[i] : 100000);
+               c[j] = a.b[i] == b.b[j] ? MIN(d[j], s - bonuses[i]) : d[j];
        }
 }
 
@@ -93,9 +94,9 @@ static int calc_cost(struct Str needle, struct Str haystack, 
bool ignore_case) {
  */
 static bool is_match(char *needle, char *haystack, bool ignore_case) {
        while (*needle)
-               if (ignore_case
-                       ? (haystack = strpbrk(haystack, (char[]) { *needle, 
toupper_utf8(*needle), '\0' }))
-                       : (haystack = strchr(haystack, *needle)))
+               if (haystack = ignore_case
+                       ? strpbrk(haystack, (char[]) { *needle, 
toupper_utf8(*needle), '\0' })
+                       : strchr(haystack, *needle))
                        ++needle, ++haystack; // Skip past matched character
                else
                        return false;
diff --git a/hotfuzz.el b/hotfuzz.el
index 6a9d7f79d2..50ceaa5c6a 100644
--- a/hotfuzz.el
+++ b/hotfuzz.el
@@ -34,7 +34,7 @@
 Large values will decrease performance."
   :type 'integer)
 
-;; Pre-allocated vectors make the cost-only calulation optimization
+;; Pre-allocated vectors make the cost-only calculation optimization
 ;; where symmetricity w.r.t. insertions/deletions means it suffices to
 ;; allocate min(#needle, #haystack) for C/D inapplicable.
 (defconst hotfuzz--max-needle-len 128)
@@ -101,13 +101,13 @@ and ND/PD respectively may alias."
   "Highlight destructively the characters NEEDLE matched in HAYSTACK.
 HAYSTACK has to be a match according to `hotfuzz-all-completions'."
   (let ((n (length haystack)) (m (length needle))
-        (c (fillarray hotfuzz--c 10000)) (d (fillarray hotfuzz--d 10000))
         (case-fold-search completion-ignore-case))
     (unless (or (> n hotfuzz--max-haystack-len) (> m hotfuzz--max-needle-len))
       (hotfuzz--calc-bonus haystack)
       (cl-loop
        with rows initially
-       (cl-loop for i below n and pc = c then nc and pd = d then nd
+       (cl-loop for i below n and pc = (fillarray hotfuzz--c 10000) then nc
+                and pd = (fillarray hotfuzz--d 10000) then nd
                 and nc = (make-vector m 0) and nd = (make-vector m 0) do
                 (hotfuzz--match-row haystack needle i nc nd pc pd)
                 (push (cons nc nd) rows))

Reply via email to