aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-07-13 23:20:38 +0200
committerdec05eba <dec05eba@protonmail.com>2023-07-13 23:20:38 +0200
commit3e01d0dc158358d091bdee0ddf90b0f0562e1c89 (patch)
treeb30ee3a5d9ab6ff3bd4dcce4cb25e50dc10c171f /src
parentf317303d77b519bb5d7e13db6247c1cf3ae0a5ae (diff)
Fix warning
Diffstat (limited to 'src')
-rw-r--r--src/HtmlSearch.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/HtmlSearch.c b/src/HtmlSearch.c
index f1631a7..8449ac9 100644
--- a/src/HtmlSearch.c
+++ b/src/HtmlSearch.c
@@ -349,19 +349,32 @@ static int is_newline(int c) {
}
static void lstrip(const char *str, size_t size, const char **output_str, size_t *output_size, int(*strip_filter_func)(int)) {
+ if(size == 0) {
+ *output_str = str;
+ *output_size = size;
+ return;
+ }
+
size_t i = 0;
while(i < size && strip_filter_func(str[i])) {
++i;
}
+
*output_str = str + i;
*output_size = size - i;
}
static void rstrip(const char *str, size_t size, size_t *output_size, int(*strip_filter_func)(int)) {
+ if(size == 0) {
+ *output_size = size;
+ return;
+ }
+
ssize_t i = size - 1;
while(i >= 0 && strip_filter_func(str[i])) {
--i;
}
+
*output_size = i + 1;
}