From 5ea469de363ab319f1cf0707c56bf31652877958 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 13 Jul 2023 23:18:08 +0200 Subject: Fix warning --- src/HtmlParser.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/HtmlParser.c b/src/HtmlParser.c index 31a5e70..709196e 100644 --- a/src/HtmlParser.c +++ b/src/HtmlParser.c @@ -71,18 +71,31 @@ 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)) { size_t i = 0; + if(size == 0) { + *output_str = str; + *output_size = size; + return; + } + 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)) { - long i = size - 1; + long i = (long)size - 1; + if(size == 0) { + *output_size = size; + return; + } + while(i >= 0 && strip_filter_func(str[i])) { --i; } + *output_size = i + 1; } -- cgit v1.2.3