mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Merge with elution
This commit is contained in:
commit
92767165cc
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
#include "dom/css/scanner.h"
|
#include "dom/css/scanner.h"
|
||||||
#include "dom/scanner.h"
|
#include "dom/scanner.h"
|
||||||
|
#include "dom/string.h"
|
||||||
#include "util/error.h"
|
#include "util/error.h"
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* Bitmap entries for the CSS character groups used in the scanner table */
|
/* Bitmap entries for the CSS character groups used in the scanner table */
|
||||||
@ -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);
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "dom/node.h"
|
#include "dom/node.h"
|
||||||
|
#include "dom/string.h"
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
|
|
||||||
static void done_dom_node_data(struct dom_node *node);
|
static void done_dom_node_data(struct dom_node *node);
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "dom/scanner.h"
|
#include "dom/scanner.h"
|
||||||
|
#include "dom/string.h"
|
||||||
#include "util/error.h"
|
#include "util/error.h"
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,17 +27,10 @@ struct dom_scanner_token {
|
|||||||
#define skip_dom_scanner_token_char(token) \
|
#define skip_dom_scanner_token_char(token) \
|
||||||
do { (token)->string.string++; (token)->string.length--; } while (0)
|
do { (token)->string.string++; (token)->string.length--; } while (0)
|
||||||
|
|
||||||
/* The naming of these two macros is a bit odd .. we compare often with
|
/* Compare the string of @token with the "static" string in @str. */
|
||||||
* "static" strings (I don't have a better word) so the macro name should
|
|
||||||
* be short. --jonas */
|
|
||||||
|
|
||||||
/* Compare the string of @token with @string */
|
|
||||||
#define dom_scanner_token_strlcasecmp(token, str, len) \
|
|
||||||
((token) && !strlcasecmp((token)->string.string, (token)->string.length, str, len))
|
|
||||||
|
|
||||||
/* Also compares the token string but using a "static" string */
|
|
||||||
#define dom_scanner_token_contains(token, str) \
|
#define dom_scanner_token_contains(token, str) \
|
||||||
dom_scanner_token_strlcasecmp(token, str, sizeof(str) - 1)
|
((token)->string.length == (sizeof(str) - 1) \
|
||||||
|
&& !strncasecmp((token)->string.string, str, sizeof(str) - 1))
|
||||||
|
|
||||||
|
|
||||||
struct dom_scan_table_info {
|
struct dom_scan_table_info {
|
||||||
@ -61,11 +54,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 {
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
#include "dom/scanner.h"
|
#include "dom/scanner.h"
|
||||||
#include "dom/select.h"
|
#include "dom/select.h"
|
||||||
#include "dom/stack.h"
|
#include "dom/stack.h"
|
||||||
|
#include "dom/string.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* Selector parsing: */
|
/* Selector parsing: */
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "dom/node.h"
|
#include "dom/node.h"
|
||||||
#include "dom/stack.h"
|
|
||||||
#include "dom/sgml/parser.h"
|
#include "dom/sgml/parser.h"
|
||||||
#include "dom/sgml/scanner.h"
|
#include "dom/sgml/scanner.h"
|
||||||
#include "dom/sgml/sgml.h"
|
#include "dom/sgml/sgml.h"
|
||||||
|
#include "dom/stack.h"
|
||||||
|
#include "dom/string.h"
|
||||||
#include "util/error.h"
|
#include "util/error.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
|
|
||||||
static struct sgml_parsing_state *
|
static struct sgml_parsing_state *
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "dom/sgml/scanner.h"
|
|
||||||
#include "util/error.h"
|
|
||||||
#include "dom/scanner.h"
|
#include "dom/scanner.h"
|
||||||
#include "util/string.h"
|
#include "dom/sgml/scanner.h"
|
||||||
|
#include "dom/string.h"
|
||||||
|
#include "util/error.h"
|
||||||
|
|
||||||
|
|
||||||
/* Bitmap entries for the SGML character groups used in the scanner table */
|
/* Bitmap entries for the SGML character groups used in the scanner table */
|
||||||
@ -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);
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
#include "dom/node.h"
|
#include "dom/node.h"
|
||||||
#include "dom/sgml/sgml.h"
|
#include "dom/sgml/sgml.h"
|
||||||
|
#include "dom/string.h"
|
||||||
#include "util/error.h"
|
#include "util/error.h"
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
/* Backend includes: */
|
/* Backend includes: */
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
#include "dom/node.h"
|
#include "dom/node.h"
|
||||||
#include "dom/stack.h"
|
#include "dom/stack.h"
|
||||||
|
#include "dom/string.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* Navigator states */
|
/* Navigator states */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef EL_DOM_STRING_H
|
#ifndef EL_DOM_STRING_H
|
||||||
#define EL_DOM_STRING_H
|
#define EL_DOM_STRING_H
|
||||||
|
|
||||||
#include "util/string.h"
|
#include "util/memory.h"
|
||||||
|
|
||||||
struct dom_string {
|
struct dom_string {
|
||||||
size_t length;
|
size_t length;
|
||||||
@ -19,7 +19,7 @@ set_dom_string(struct dom_string *string, unsigned char *value, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
dom_string_casecmp(struct dom_string *string1, struct dom_string *string2)
|
dom_string_casecmp(const struct dom_string *string1, const struct dom_string *string2)
|
||||||
{
|
{
|
||||||
size_t length = int_min(string1->length, string2->length);
|
size_t length = int_min(string1->length, string2->length);
|
||||||
size_t string_diff = strncasecmp(string1->string, string2->string, length);
|
size_t string_diff = strncasecmp(string1->string, string2->string, length);
|
||||||
@ -41,12 +41,20 @@ dom_string_ncasecmp(struct dom_string *string1, struct dom_string *string2, size
|
|||||||
static inline struct dom_string *
|
static inline struct dom_string *
|
||||||
init_dom_string(struct dom_string *string, unsigned char *str, size_t len)
|
init_dom_string(struct dom_string *string, unsigned char *str, size_t len)
|
||||||
{
|
{
|
||||||
string->string = memacpy(str, len);
|
string->string = mem_alloc(len + 1);
|
||||||
return string->string ? string : NULL;
|
if (!string->string)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
memcpy(string->string, str, len);
|
||||||
|
string->string[len] = 0;
|
||||||
|
string->length = len;
|
||||||
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define is_dom_string_set(str) ((str)->string && (str)->length)
|
#define is_dom_string_set(str) ((str)->string && (str)->length)
|
||||||
|
|
||||||
#define done_dom_string(str) mem_free((str)->string);
|
#define done_dom_string(str) mem_free((str)->string);
|
||||||
|
|
||||||
|
#define isquote(c) ((c) == '"' || (c) == '\'')
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user