mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Use dom_string for storing the name member of dom_scanner_string_mapping
This commit is contained in:
parent
f1015f8a6a
commit
fb6ca9a390
@ -54,33 +54,36 @@ static const struct dom_scan_table_info css_scan_table_info[] = {
|
|||||||
DOM_SCAN_TABLE_END,
|
DOM_SCAN_TABLE_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define CSS_STRING_MAP(str, type, family) \
|
||||||
|
{ INIT_DOM_STRING(str, -1), CSS_TOKEN_##type, CSS_TOKEN_##family }
|
||||||
|
|
||||||
static const struct dom_scanner_string_mapping css_string_mappings[] = {
|
static const struct dom_scanner_string_mapping css_string_mappings[] = {
|
||||||
{ "Hz", CSS_TOKEN_FREQUENCY, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("Hz", FREQUENCY, DIMENSION),
|
||||||
{ "cm", CSS_TOKEN_LENGTH, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("cm", LENGTH, DIMENSION),
|
||||||
{ "deg", CSS_TOKEN_ANGLE, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("deg", ANGLE, DIMENSION),
|
||||||
{ "em", CSS_TOKEN_EM, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("em", EM, DIMENSION),
|
||||||
{ "ex", CSS_TOKEN_EX, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("ex", EX, DIMENSION),
|
||||||
{ "grad", CSS_TOKEN_ANGLE, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("grad", ANGLE, DIMENSION),
|
||||||
{ "in", CSS_TOKEN_LENGTH, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("in", LENGTH, DIMENSION),
|
||||||
{ "kHz", CSS_TOKEN_FREQUENCY, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("kHz", FREQUENCY, DIMENSION),
|
||||||
{ "mm", CSS_TOKEN_LENGTH, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("mm", LENGTH, DIMENSION),
|
||||||
{ "ms", CSS_TOKEN_TIME, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("ms", TIME, DIMENSION),
|
||||||
{ "pc", CSS_TOKEN_LENGTH, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("pc", LENGTH, DIMENSION),
|
||||||
{ "pt", CSS_TOKEN_LENGTH, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("pt", LENGTH, DIMENSION),
|
||||||
{ "px", CSS_TOKEN_LENGTH, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("px", LENGTH, DIMENSION),
|
||||||
{ "rad", CSS_TOKEN_ANGLE, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("rad", ANGLE, DIMENSION),
|
||||||
{ "s", CSS_TOKEN_TIME, CSS_TOKEN_DIMENSION },
|
CSS_STRING_MAP("s", TIME, DIMENSION),
|
||||||
|
|
||||||
{ "rgb", CSS_TOKEN_RGB, CSS_TOKEN_FUNCTION },
|
CSS_STRING_MAP("rgb", RGB, FUNCTION),
|
||||||
{ "url", CSS_TOKEN_URL, CSS_TOKEN_FUNCTION },
|
CSS_STRING_MAP("url", URL, FUNCTION),
|
||||||
|
|
||||||
{ "charset", CSS_TOKEN_AT_CHARSET, CSS_TOKEN_AT_KEYWORD },
|
CSS_STRING_MAP("charset", AT_CHARSET, AT_KEYWORD),
|
||||||
{ "font-face", CSS_TOKEN_AT_FONT_FACE, CSS_TOKEN_AT_KEYWORD },
|
CSS_STRING_MAP("font-face", AT_FONT_FACE, AT_KEYWORD),
|
||||||
{ "import", CSS_TOKEN_AT_IMPORT, CSS_TOKEN_AT_KEYWORD },
|
CSS_STRING_MAP("import", AT_IMPORT, AT_KEYWORD),
|
||||||
{ "media", CSS_TOKEN_AT_MEDIA, CSS_TOKEN_AT_KEYWORD },
|
CSS_STRING_MAP("media", AT_MEDIA, AT_KEYWORD),
|
||||||
{ "page", CSS_TOKEN_AT_PAGE, CSS_TOKEN_AT_KEYWORD },
|
CSS_STRING_MAP("page", AT_PAGE, AT_KEYWORD),
|
||||||
|
|
||||||
{ NULL, CSS_TOKEN_NONE, CSS_TOKEN_NONE },
|
DOM_STRING_MAP_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct dom_scanner_token *scan_css_tokens(struct dom_scanner *scanner);
|
static struct dom_scanner_token *scan_css_tokens(struct dom_scanner *scanner);
|
||||||
|
@ -19,11 +19,11 @@ map_dom_scanner_string(struct dom_scanner *scanner,
|
|||||||
unsigned char *ident, unsigned char *end, int base_type)
|
unsigned char *ident, unsigned char *end, int base_type)
|
||||||
{
|
{
|
||||||
const struct dom_scanner_string_mapping *mappings = scanner->info->mappings;
|
const struct dom_scanner_string_mapping *mappings = scanner->info->mappings;
|
||||||
int length = end - ident;
|
struct dom_string name = INIT_DOM_STRING(ident, end - ident);
|
||||||
|
|
||||||
for (; mappings->name; mappings++) {
|
for (; is_dom_string_set(&mappings->name); mappings++) {
|
||||||
if (mappings->base_type == base_type
|
if (mappings->base_type == base_type
|
||||||
&& !strlcasecmp(mappings->name, -1, ident, length))
|
&& !dom_string_casecmp(&mappings->name, &name))
|
||||||
return mappings->type;
|
return mappings->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +61,17 @@ struct dom_scan_table_info {
|
|||||||
DOM_SCAN_TABLE_INFO(DOM_SCAN_END, NULL, 0, 0)
|
DOM_SCAN_TABLE_INFO(DOM_SCAN_END, NULL, 0, 0)
|
||||||
|
|
||||||
struct dom_scanner_string_mapping {
|
struct dom_scanner_string_mapping {
|
||||||
unsigned char *name;
|
struct dom_string name;
|
||||||
int type;
|
int type;
|
||||||
int base_type;
|
int base_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define DOM_STRING_MAP(str, type, family) \
|
||||||
|
{ INIT_DOM_STRING(str, -1), (type), (family) }
|
||||||
|
|
||||||
|
#define DOM_STRING_MAP_END \
|
||||||
|
{ INIT_DOM_STRING(NULL, 0), 0, 0 }
|
||||||
|
|
||||||
struct dom_scanner;
|
struct dom_scanner;
|
||||||
|
|
||||||
struct dom_scanner_info {
|
struct dom_scanner_info {
|
||||||
|
@ -51,16 +51,19 @@ static struct dom_scan_table_info sgml_scan_table_info[] = {
|
|||||||
DOM_SCAN_TABLE_END,
|
DOM_SCAN_TABLE_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SGML_STRING_MAP(str, type, family) \
|
||||||
|
{ INIT_DOM_STRING(str, -1), SGML_TOKEN_##type, SGML_TOKEN_##family }
|
||||||
|
|
||||||
static struct dom_scanner_string_mapping sgml_string_mappings[] = {
|
static struct dom_scanner_string_mapping sgml_string_mappings[] = {
|
||||||
{ "--", SGML_TOKEN_NOTATION_COMMENT, SGML_TOKEN_NOTATION },
|
SGML_STRING_MAP("--", NOTATION_COMMENT, NOTATION),
|
||||||
{ "ATTLIST", SGML_TOKEN_NOTATION_ATTLIST, SGML_TOKEN_NOTATION },
|
SGML_STRING_MAP("ATTLIST", NOTATION_ATTLIST, NOTATION),
|
||||||
{ "DOCTYPE", SGML_TOKEN_NOTATION_DOCTYPE, SGML_TOKEN_NOTATION },
|
SGML_STRING_MAP("DOCTYPE", NOTATION_DOCTYPE, NOTATION),
|
||||||
{ "ELEMENT", SGML_TOKEN_NOTATION_ELEMENT, SGML_TOKEN_NOTATION },
|
SGML_STRING_MAP("ELEMENT", NOTATION_ELEMENT, NOTATION),
|
||||||
{ "ENTITY", SGML_TOKEN_NOTATION_ENTITY, SGML_TOKEN_NOTATION },
|
SGML_STRING_MAP("ENTITY", NOTATION_ENTITY, NOTATION),
|
||||||
|
|
||||||
{ "xml", SGML_TOKEN_PROCESS_XML, SGML_TOKEN_PROCESS },
|
SGML_STRING_MAP("xml", PROCESS_XML, PROCESS),
|
||||||
|
|
||||||
{ NULL, SGML_TOKEN_NONE, SGML_TOKEN_NONE },
|
DOM_STRING_MAP_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct dom_scanner_token *scan_sgml_tokens(struct dom_scanner *scanner);
|
static struct dom_scanner_token *scan_sgml_tokens(struct dom_scanner *scanner);
|
||||||
|
Loading…
Reference in New Issue
Block a user