From b06a8adeac04a9fe00ca3fe5244c0591845d8193 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 6 Dec 2005 12:30:53 +0100 Subject: [PATCH] Move parser root node initialization to init_sgml_parser() ... parse_sgml() in theory should be able to be called multiple times. --- src/document/sgml/parser.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/document/sgml/parser.c b/src/document/sgml/parser.c index 745ff16fe..c65b36751 100644 --- a/src/document/sgml/parser.c +++ b/src/document/sgml/parser.c @@ -320,6 +320,12 @@ init_sgml_parser(enum sgml_parser_type type, void *renderer, struct uri *uri, init_dom_stack(&parser->stack, parser, renderer, push_callbacks, pop_callbacks, obj_size); + parser->root = add_sgml_document(&parser->stack, parser->uri); + if (!parser->root) { + mem_free(parser); + return NULL; + } + return parser; } @@ -342,10 +348,8 @@ parse_sgml(struct sgml_parser *parser, struct string *buffer) init_scanner(&parser->scanner, &sgml_scanner_info, source, end); - parser->root = add_sgml_document(&parser->stack, parser->uri); - if (parser->root) { - parse_sgml_document(&parser->stack, &parser->scanner); - } + /* FIXME: Make parse_sgml_document() return an error code. */ + parse_sgml_document(&parser->stack, &parser->scanner); return parser->root; }