Use hb_char_t in rules

This commit is contained in:
Wilson Lin 2018-07-05 19:50:36 +12:00
parent 294de8a4b0
commit 4c311819cc
16 changed files with 54 additions and 39 deletions

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_ATTRNAME
#include "../../ext/nicehash/set/int32.h"
#include "../../util/hbchar.h"
#include "./c0.c"
static nh_set_int32_t hb_r_attrname_blacklist;
@ -18,7 +19,7 @@ void hb_r_attrname_init(void) {
// NOTE: Unicode noncharacters not tested (https://html.spec.whatwg.org/multipage/syntax.html#syntax-attribute-name)
}
int hb_r_attrname_check(char c) {
int hb_r_attrname_check(hb_char_t c) {
return !nh_set_int32_has(hb_r_attrname_blacklist, c);
}

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_C0
#include "../../ext/nicehash/set/int32.h"
#include "../../util/hbchar.h"
static nh_set_int32_t hb_r_c0_set;
@ -16,7 +17,7 @@ void hb_r_c0_init(void) {
hb_r_c0_add_elems(hb_r_c0_set);
}
int hb_r_c0_check(char c) {
int hb_r_c0_check(hb_char_t c) {
return nh_set_int32_has(hb_r_c0_set, c);
}

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_DIGIT
#include "../../ext/nicehash/set/int32.h"
#include "../../util/hbchar.h"
static nh_set_int32_t hb_r_digit_set;
@ -16,7 +17,7 @@ void hb_r_digit_init(void) {
hb_r_digit_add_elems(hb_r_digit_set);
}
int hb_r_digit_check(char c) {
int hb_r_digit_check(hb_char_t c) {
return nh_set_int32_has(hb_r_digit_set, c);
}

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_LCALPHA
#include "../../ext/nicehash/set/int32.h"
#include "../../util/hbchar.h"
static nh_set_int32_t hb_r_lcalpha_set;
@ -16,7 +17,7 @@ void hb_r_lcalpha_init(void) {
hb_r_lcalpha_add_elems(hb_r_lcalpha_set);
}
int hb_r_lcalpha_check(char c) {
int hb_r_lcalpha_check(hb_char_t c) {
return nh_set_int32_has(hb_r_lcalpha_set, c);
}

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_TAGNAME
#include "../../ext/nicehash/set/int32.h"
#include "../../util/hbchar.h"
#include "./lcalpha.c"
#include "./ucalpha.c"
#include "./digit.c"
@ -15,7 +16,7 @@ void hb_r_tagname_init(void) {
hb_r_digit_add_elems(hb_r_tagname_set);
}
int hb_r_tagname_check(char c) {
int hb_r_tagname_check(hb_char_t c) {
return nh_set_int32_has(hb_r_tagname_set, c);
}

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_UCALPHA
#include "../../ext/nicehash/set/int32.h"
#include "../../util/hbchar.h"
static nh_set_int32_t hb_r_ucalpha_set;
@ -16,7 +17,7 @@ void hb_r_ucalpha_init(void) {
hb_r_ucalpha_add_elems(hb_r_ucalpha_set);
}
int hb_r_ucalpha_check(char c) {
int hb_r_ucalpha_check(hb_char_t c) {
return nh_set_int32_has(hb_r_ucalpha_set, c);
}

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_UNQUOTEDATTRVAL
#include "../../ext/nicehash/set/int32.h"
#include "../../util/hbchar.h"
#include "./whitespace.c"
static nh_set_int32_t hb_r_unquotedattrval_set;
@ -17,8 +18,7 @@ void hb_r_unquotedattrval_init(void) {
nh_set_int32_add(hb_r_unquotedattrval_set, '>');
}
int hb_r_unquotedattrval_check(char c) {
return nh_set_int32_has(hb_r_unquotedattrval_set, c);
int hb_r_unquotedattrval_check(hb_char_t c) {
}
#endif // _HDR_HYPERBUILD_RULE_UNQUOTEDATTRVAL

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_WHITESPACE
#include "../../ext/nicehash/set/int32.h"
#include "../../util/hbchar.h"
static nh_set_int32_t hb_r_whitespace_set;
@ -18,7 +19,7 @@ void hb_r_whitespace_init(void) {
hb_r_whitespace_add_elems(hb_r_whitespace_set);
}
int hb_r_whitespace_check(char c) {
int hb_r_whitespace_check(hb_char_t c) {
return nh_set_int32_has(hb_r_whitespace_set, c);
}

View File

@ -3,6 +3,7 @@
#include <stdint.h>
#include "../../datastructure/map/str-int32.h"
#include "../../util/hbchar.h"
// Sourced from https://dev.w3.org/html5/html-author/charref at 2018-07-02T10:00:00Z
@ -2043,12 +2044,12 @@ void hb_r_entityrefs_init(void) {
nh_map_str_int32_set(hb_r_entityrefs_map, "zwnj", 0x200c);
}
int hb_r_entityrefs_check(char *ref) {
return nh_map_str_int32_has(hb_r_entityrefs_map, ref);
int hb_r_entityrefs_check(hb_char_t *ref) {
return nh_map_str_int32_has(hb_r_entityrefs_map, (char *) ref);
}
uint32_t hb_r_entityrefs_get(char *ref) {
return nh_map_str_int32_get(hb_r_entityrefs_map, ref, 0);
uint32_t hb_r_entityrefs_get(hb_char_t *ref) {
return nh_map_str_int32_get(hb_r_entityrefs_map, (char *) ref, 0);
}
#endif // _HDR_HYPERBUILD_RULE_ENTITYREFS

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_BLACKLISTCHILDREN
#include "../../datastructure/map/str-strset.h"
#include "../../util/hbchar.h"
static nh_map_str_strset_t hb_r_blacklistchildren_map;
@ -9,13 +10,13 @@ void hb_r_blacklistchildren_init(void) {
hb_r_blacklistchildren_map = nh_map_str_strset_create();
}
int hb_r_blacklistchildren_check(char *parent) {
return nh_map_str_strset_has(hb_r_blacklistchildren_map, parent);
int hb_r_blacklistchildren_check(hb_char_t *parent) {
return nh_map_str_strset_has(hb_r_blacklistchildren_map, (char *) parent);
}
int hb_r_blacklistchildren_has(char *parent, char *child) {
nh_map_str_strset_t set = nh_map_str_strset_get(hb_r_blacklistchildren_map, parent, NULL);
return nh_set_str_has(set, child);
int hb_r_blacklistchildren_has(hb_char_t *parent, hb_char_t *child) {
nh_set_str_t set = nh_map_str_strset_get(hb_r_blacklistchildren_map, (char *) parent, NULL);
return nh_set_str_has(set, (char *) child);
}
#endif // _HDR_HYPERBUILD_RULE_BLACKLISTCHILDREN

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_BLACKLISTPARENTS
#include "../../datastructure/map/str-strset.h"
#include "../../util/hbchar.h"
static nh_map_str_strset_t hb_r_blacklistparents_map;
@ -9,13 +10,13 @@ void hb_r_blacklistparents_init(void) {
hb_r_blacklistparents_map = nh_map_str_strset_create();
}
int hb_r_blacklistparents_check(char *child) {
return nh_map_str_strset_has(hb_r_blacklistparents_map, child);
int hb_r_blacklistparents_check(hb_char_t *child) {
return nh_map_str_strset_has(hb_r_blacklistparents_map, (char *) child);
}
int hb_r_blacklistparents_has(char *child, char *parent) {
nh_map_str_strset_t set = nh_map_str_strset_get(hb_r_blacklistparents_map, child, NULL);
return nh_set_str_has(set, parent);
int hb_r_blacklistparents_has(hb_char_t *child, hb_char_t *parent) {
nh_set_str_t set = nh_map_str_strset_get(hb_r_blacklistparents_map, (char *) child, NULL);
return nh_set_str_has(set, (char *) parent);
}
#endif // _HDR_HYPERBUILD_RULE_BLACKLISTPARENTS

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_WHITELISTCHILDREN
#include "../../datastructure/map/str-strset.h"
#include "../../util/hbchar.h"
static nh_map_str_strset_t hb_r_whitelistchildren_map;
@ -19,13 +20,13 @@ void hb_r_whitelistchildren_init(void) {
nh_map_str_strset_set(hb_r_whitelistchildren_map, "table", table);
}
int hb_r_whitelistchildren_check(char *parent) {
return nh_map_str_strset_has(hb_r_whitelistchildren_map, parent);
int hb_r_whitelistchildren_check(hb_char_t *parent) {
return nh_map_str_strset_has(hb_r_whitelistchildren_map, (char *) parent);
}
int hb_r_whitelistchildren_has(char *parent, char *child) {
nh_map_str_strset_t set = nh_map_str_strset_get(hb_r_whitelistchildren_map, parent, NULL);
return nh_set_str_has(set, child);
int hb_r_whitelistchildren_has(hb_char_t *parent, hb_char_t *child) {
nh_set_str_t set = nh_map_str_strset_get(hb_r_whitelistchildren_map, (char *) parent, NULL);
return nh_set_str_has(set, (char *) child);
}
#endif // _HDR_HYPERBUILD_RULE_WHITELISTCHILDREN

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_WHITELISTPARENTS
#include "../../datastructure/map/str-strset.h"
#include "../../util/hbchar.h"
static nh_map_str_strset_t hb_r_whitelistparents_map;
@ -34,13 +35,13 @@ void hb_r_whitelistparents_init(void) {
nh_map_str_strset_set(hb_r_whitelistparents_map, "col", col);
}
int hb_r_whitelistparents_check(char *child) {
return nh_map_str_strset_has(hb_r_whitelistparents_map, child);
int hb_r_whitelistparents_check(hb_char_t *child) {
return nh_map_str_strset_has(hb_r_whitelistparents_map, (char *) child);
}
int hb_r_whitelistparents_has(char *child, char *parent) {
nh_map_str_strset_t set = nh_map_str_strset_get(hb_r_whitelistparents_map, child, NULL);
return nh_set_str_has(set, parent);
int hb_r_whitelistparents_has(hb_char_t *child, hb_char_t *parent) {
nh_set_str_t set = nh_map_str_strset_get(hb_r_whitelistparents_map, (char *) child, NULL);
return nh_set_str_has(set, (char *) parent);
}
#endif // _HDR_HYPERBUILD_RULE_WHITELISTPARENTS

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_FORMATTINGTAGS
#include "../../ext/nicehash/set/str.h"
#include "../../util/hbchar.h"
static nh_set_str_t hb_r_formattingtags_set;
@ -40,8 +41,8 @@ void hb_r_formattingtags_init(void) {
nh_set_str_add(hb_r_formattingtags_set, "wbr");
}
int hb_r_formattingtags_check(char *tag) {
return nh_set_str_has(hb_r_formattingtags_set, tag);
int hb_r_formattingtags_check(hb_char_t *tag) {
return nh_set_str_has(hb_r_formattingtags_set, (char *) tag);
}
#endif // _HDR_HYPERBUILD_RULE_FORMATTINGTAGS

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_TAGS
#include "../../ext/nicehash/set/str.h"
#include "../../util/hbchar.h"
// Sourced from https://developer.mozilla.org/en-US/docs/Web/HTML/Element at 2018-07-01T05:55:00Z
@ -161,8 +162,8 @@ void hb_r_tags_init(void) {
nh_set_str_add(hb_r_tags_set, "xmp");
}
int hb_r_tags_check(char *tag) {
return nh_set_str_has(hb_r_tags_set, tag);
int hb_r_tags_check(hb_char_t *tag) {
return nh_set_str_has(hb_r_tags_set, (char *) tag);
}
#endif // _HDR_HYPERBUILD_RULE_TAGS

View File

@ -2,6 +2,7 @@
#define _HDR_HYPERBUILD_RULE_VOIDTAGS
#include "../../ext/nicehash/set/str.h"
#include "../../util/hbchar.h"
static nh_set_str_t hb_r_voidtags_set;
@ -24,8 +25,8 @@ void hb_r_voidtags_init(void) {
nh_set_str_add(hb_r_voidtags_set, "wbr");
}
int hb_r_voidtags_check(char *tag) {
return nh_set_str_has(hb_r_voidtags_set, tag);
int hb_r_voidtags_check(hb_char_t *tag) {
return nh_set_str_has(hb_r_voidtags_set, (char *) tag);
}
#endif // _HDR_HYPERBUILD_RULE_VOIDTAGS