diff --git a/src/dom/sgml/parser.c b/src/dom/sgml/parser.c index f0dd9b74..4172e46c 100644 --- a/src/dom/sgml/parser.c +++ b/src/dom/sgml/parser.c @@ -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_parsing_state *parsing = data; + int count_lines = !!(parser->flags & SGML_PARSER_COUNT_LINES); parsing->depth = parser->stack.depth; get_dom_stack_top(&parser->stack)->immutable = 1; init_dom_scanner(&parsing->scanner, &sgml_scanner_info, &node->string, - SGML_STATE_TEXT, 0); + SGML_STATE_TEXT, count_lines); } static void @@ -486,7 +487,7 @@ static struct dom_stack_context_info sgml_parser_context_info = { struct sgml_parser * 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; 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; } - parser->type = type; - parser->info = get_sgml_info(doctype); + parser->type = type; + parser->flags = type; + parser->info = get_sgml_info(doctype); if (type == SGML_PARSER_TREE) stack_flags |= DOM_STACK_KEEP_NODES; diff --git a/src/dom/sgml/parser.h b/src/dom/sgml/parser.h index 966bd406..858cd8ff 100644 --- a/src/dom/sgml/parser.h +++ b/src/dom/sgml/parser.h @@ -22,6 +22,10 @@ enum sgml_parser_type { SGML_PARSER_STREAM, }; +enum sgml_parser_flag { + SGML_PARSER_COUNT_LINES = 1, +}; + struct sgml_parser_state { /* Info about the properties of the node contained by state. * This is only meaningful to element and attribute nodes. For @@ -34,6 +38,7 @@ struct sgml_parser_state { struct sgml_parser { 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 */ @@ -46,7 +51,7 @@ struct sgml_parser { struct sgml_parser * 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);