commit d05c901052dbfd84f4653ac95918871b4d4c8f5b
parent 53f769b1d999f6964bc2431b316cf07a3b8166ec
Author: lumidify <nobody@lumidify.org>
Date: Sun, 17 Jul 2022 18:25:43 +0200
Fix bug
Diffstat:
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/util.c b/util.c
@@ -52,9 +52,9 @@ sort_range(size_t *l1, size_t *b1, size_t *l2, size_t *b2) {
int
str_array_equal(char *terminated, char *array, size_t len) {
if (!strncmp(terminated, array, len)) {
- /* 'terminated' and 'array' are equal for the first 'len'
- characters, so this index in 'terminated' must exist */
- return terminated[len] == '\0';
+ /* this is kind of inefficient, but there's no way to know
+ otherwise if strncmp just stopped comparing after a '\0' */
+ return strlen(terminated) == len;
}
return 0;
}
diff --git a/view.c b/view.c
@@ -701,6 +701,7 @@ line_prev_bigword(
int found_word = 0;
if (char_index > (size_t)nattrs - 1)
char_index = (size_t)nattrs - 1;
+ /* FIXME: use for (size_t i = ...; i-- > 0;) everywhere */
/* this is a bit weird because size_t can't be negative */
for (size_t i = char_index; i > 0; i--) {
if (!found_word && !attrs[i-1].is_white) {