aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDEC05EBA <dec05eba@protonmail.com>2019-12-31 09:55:47 +0100
committerDEC05EBA <dec05eba@protonmail.com>2019-12-31 09:55:47 +0100
commit89a1be9a63aa4c7f4b9fb9a2a3041cf9270b6a79 (patch)
treec346eb6a281dc5c0db3dbaa8d4b2fe76d6c239cc
parent0ecbffb885254f5abfc6abfe837852ec0f3ba81c (diff)
Change name of StringView to prevent name conflicts with other projects
-rw-r--r--include/HtmlParser.h12
-rw-r--r--src/HtmlParser.c54
2 files changed, 33 insertions, 33 deletions
diff --git a/include/HtmlParser.h b/include/HtmlParser.h
index 72de123..48660da 100644
--- a/include/HtmlParser.h
+++ b/include/HtmlParser.h
@@ -11,7 +11,7 @@
typedef struct {
const char *data;
size_t size;
-} StringView;
+} HtmlStringView;
typedef struct HtmlParser HtmlParser;
@@ -34,16 +34,16 @@ struct HtmlParser {
HtmlParseCallback parse_callback;
void *callback_userdata;
- StringView tag_name;
- StringView attribute_key;
- StringView attribute_value;
- StringView text;
+ HtmlStringView tag_name;
+ HtmlStringView attribute_key;
+ HtmlStringView attribute_value;
+ HtmlStringView text;
int is_tag_void;
int inside_script_tag;
size_t unclosed_tags_offset;
- StringView unclosed_tags[UNCLOSED_TAGS_SIZE];
+ HtmlStringView unclosed_tags[UNCLOSED_TAGS_SIZE];
};
void html_parser_init(HtmlParser *self, const char *html_source, size_t len, HtmlParseCallback parse_callback, void *userdata);
diff --git a/src/HtmlParser.c b/src/HtmlParser.c
index a1b62cd..2e52555 100644
--- a/src/HtmlParser.c
+++ b/src/HtmlParser.c
@@ -3,29 +3,29 @@
#include <string.h>
#include <assert.h>
-static StringView void_tags[] = {
- {.data = "area", .size = 4},
- {.data = "base", .size = 4},
- {.data = "br", .size = 2},
- {.data = "col", .size = 3},
- {.data = "command", .size = 7},
- {.data = "embed", .size = 5},
- {.data = "hr", .size = 2},
- {.data = "img", .size = 3},
- {.data = "input", .size = 5},
- {.data = "keygen", .size = 6},
- {.data = "link", .size = 4},
- {.data = "meta", .size = 4},
- {.data = "param", .size = 5},
- {.data = "source", .size = 6},
- {.data = "track", .size = 5},
- {.data = "wbr", .size = 3},
- {.data = NULL, .size = 0}
+static HtmlStringView void_tags[] = {
+ {"area", 4},
+ {"base", 4},
+ {"br", 2},
+ {"col", 3},
+ {"command", 7},
+ {"embed", 5},
+ {"hr", 2},
+ {"img", 3},
+ {"input", 5},
+ {"keygen", 6},
+ {"link", 4},
+ {"meta", 4},
+ {"param", 5},
+ {"source", 6},
+ {"track", 5},
+ {"wbr", 3},
+ {NULL, 0}
};
-static StringView script_tag = {.data = "script", .size = 6};
+static HtmlStringView script_tag = {"script", 6};
-static int string_view_equals(StringView *self, StringView *other) {
+static int string_view_equals(HtmlStringView *self, HtmlStringView *other) {
return self->size == other->size && memcmp(self->data, other->data, self->size) == 0;
}
@@ -68,8 +68,8 @@ static void strip(const char *str, size_t size, const char **output_str, size_t
rstrip(*output_str, *output_size, output_size, strip_filter_func);
}
-static int is_void_tag(StringView *tag_name) {
- StringView *tag_iter = &void_tags[0];
+static int is_void_tag(HtmlStringView *tag_name) {
+ HtmlStringView *tag_iter = &void_tags[0];
/* !DOCTYPE, !--, etc.... */
if(tag_name->size > 0 && tag_name->data[0] == '!')
return 1;
@@ -160,7 +160,7 @@ static void html_parser_try_pop_unclosed_tag(HtmlParser *self) {
--self->unclosed_tags_offset;
}
-static int html_parser_try_get_top_unclosed_tag(HtmlParser *self, StringView *result) {
+static int html_parser_try_get_top_unclosed_tag(HtmlParser *self, HtmlStringView *result) {
if(self->unclosed_tags_offset > 0) {
*result = self->unclosed_tags[self->unclosed_tags_offset - 1];
return 1;
@@ -304,7 +304,7 @@ static void html_parser_parse_tag_start(HtmlParser *self) {
return;
}
} else if(is_identifier_char(c)) {
- StringView identifier;
+ HtmlStringView identifier;
identifier.data = self->source + self->offset - 1;
for(;;) {
c = html_parser_peek_char(self);
@@ -361,7 +361,7 @@ static void html_parser_parse_tag_end(HtmlParser *self) {
html_parser_advance_char(self);
return;
} else if(!tag_name_found && is_identifier_char(c)) {
- StringView tag_end_name;
+ HtmlStringView tag_end_name;
tag_end_name.data = self->source + self->offset;
html_parser_advance_char(self);
for(;;) {
@@ -380,7 +380,7 @@ static void html_parser_parse_tag_end(HtmlParser *self) {
continue;
}
- StringView top_unclosed_tag;
+ HtmlStringView top_unclosed_tag;
while(html_parser_try_get_top_unclosed_tag(self, &top_unclosed_tag)) {
self->tag_name = top_unclosed_tag;
self->parse_callback(self, HTML_PARSE_TAG_END, self->callback_userdata);
@@ -425,7 +425,7 @@ void html_parser_parse(HtmlParser *self) {
}
}
- StringView top_unclosed_tag;
+ HtmlStringView top_unclosed_tag;
while(html_parser_try_get_top_unclosed_tag(self, &top_unclosed_tag)) {
self->tag_name = top_unclosed_tag;
self->parse_callback(self, HTML_PARSE_TAG_END, self->callback_userdata);