aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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;
}