aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/HtmlParser.c15
1 files changed, 14 insertions, 1 deletions
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;
}