aboutsummaryrefslogtreecommitdiffstats
path: root/memrcaseeqlen.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-08-18 09:58:23 +0200
committerMattias Andrée <maandree@kth.se>2024-08-18 09:58:23 +0200
commita69f0f613687edf6c1f1ee83b462f77e8ea3c9a9 (patch)
treed976683461a0f427d2f1ef79a8732a048dd0c67b /memrcaseeqlen.c
parentMerge tag '1.3' into since (diff)
parentUpdate VERSION_MINOR (diff)
downloadlibsimple-a69f0f613687edf6c1f1ee83b462f77e8ea3c9a9.tar.gz
libsimple-a69f0f613687edf6c1f1ee83b462f77e8ea3c9a9.tar.bz2
libsimple-a69f0f613687edf6c1f1ee83b462f77e8ea3c9a9.tar.xz
Merge tag '1.4' into since
Version 1.4
Diffstat (limited to '')
-rw-r--r--memrcaseeqlen.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/memrcaseeqlen.c b/memrcaseeqlen.c
index 3f586b7..6042f4a 100644
--- a/memrcaseeqlen.c
+++ b/memrcaseeqlen.c
@@ -1,14 +1,20 @@
/* See LICENSE file for copyright and license details. */
-#include "libsimple.h"
+#include "common.h"
#ifndef TEST
size_t
libsimple_memrcaseeqlen(const void *a_, size_t n, const void *b_, size_t m)
{
- const char *a = &((char *)a_)[n], *b = &((char *)b_)[m];
+ const char *a = &((const char *)a_)[n];
+ const char *b = &((const char *)b_)[m];
size_t i = 0, len = n < m ? n : m;
- for (; i < len && (--a, --b, tolower(*a) == tolower(*b)); i++);
+ for (; i < len; i++) {
+ a--;
+ b--;
+ if (tolower(*a) != tolower(*b))
+ break;
+ }
return i;
}