diff options
m--------- | depends/html-parser | 0 | ||||
-rw-r--r-- | src/HtmlSearch.c | 13 |
2 files changed, 13 insertions, 0 deletions
diff --git a/depends/html-parser b/depends/html-parser -Subproject 66ec83b862ea2a8dbda1c1f3663af88a8d12d9b +Subproject 5ea469de363ab319f1cf0707c56bf3165287795 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; } |