1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Add sgml_parser_flag which can be used to specify SGML_PARSER_COUNT_LINES

This commit is contained in:
Jonas Fonseca 2006-01-02 00:14:58 +01:00 committed by Jonas Fonseca
parent 1801a21b50
commit b83bbf9c4a
2 changed files with 12 additions and 5 deletions

View File

@ -368,11 +368,12 @@ sgml_parsing_push(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct sgml_parser *parser = get_sgml_parser(stack); struct sgml_parser *parser = get_sgml_parser(stack);
struct sgml_parsing_state *parsing = data; struct sgml_parsing_state *parsing = data;
int count_lines = !!(parser->flags & SGML_PARSER_COUNT_LINES);
parsing->depth = parser->stack.depth; parsing->depth = parser->stack.depth;
get_dom_stack_top(&parser->stack)->immutable = 1; get_dom_stack_top(&parser->stack)->immutable = 1;
init_dom_scanner(&parsing->scanner, &sgml_scanner_info, &node->string, init_dom_scanner(&parsing->scanner, &sgml_scanner_info, &node->string,
SGML_STATE_TEXT, 0); SGML_STATE_TEXT, count_lines);
} }
static void static void
@ -486,7 +487,7 @@ static struct dom_stack_context_info sgml_parser_context_info = {
struct sgml_parser * struct sgml_parser *
init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype, init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype,
struct dom_string *uri) struct dom_string *uri, enum sgml_parser_flag flags)
{ {
struct sgml_parser *parser; struct sgml_parser *parser;
enum dom_stack_flag stack_flags = 0; enum dom_stack_flag stack_flags = 0;
@ -499,8 +500,9 @@ init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype,
return NULL; return NULL;
} }
parser->type = type; parser->type = type;
parser->info = get_sgml_info(doctype); parser->flags = type;
parser->info = get_sgml_info(doctype);
if (type == SGML_PARSER_TREE) if (type == SGML_PARSER_TREE)
stack_flags |= DOM_STACK_KEEP_NODES; stack_flags |= DOM_STACK_KEEP_NODES;

View File

@ -22,6 +22,10 @@ enum sgml_parser_type {
SGML_PARSER_STREAM, SGML_PARSER_STREAM,
}; };
enum sgml_parser_flag {
SGML_PARSER_COUNT_LINES = 1,
};
struct sgml_parser_state { struct sgml_parser_state {
/* Info about the properties of the node contained by state. /* Info about the properties of the node contained by state.
* This is only meaningful to element and attribute nodes. For * This is only meaningful to element and attribute nodes. For
@ -34,6 +38,7 @@ struct sgml_parser_state {
struct sgml_parser { struct sgml_parser {
enum sgml_parser_type type; /* Stream or tree */ enum sgml_parser_type type; /* Stream or tree */
enum sgml_parser_flag flags; /* Flags that control the behaviour */
struct sgml_info *info; /* Backend dependent info */ struct sgml_info *info; /* Backend dependent info */
@ -46,7 +51,7 @@ struct sgml_parser {
struct sgml_parser * struct sgml_parser *
init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype, init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype,
struct dom_string *uri); struct dom_string *uri, enum sgml_parser_flag flags);
void done_sgml_parser(struct sgml_parser *parser); void done_sgml_parser(struct sgml_parser *parser);