From 534a16fff14e44de335040f070034e42c298a0d2 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 7 Jan 2006 23:40:21 +0100 Subject: [PATCH] Improve error detection --- src/dom/sgml/scanner.c | 15 ++++++++++++--- src/dom/test/test-sgml-parser-error | 2 -- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/dom/sgml/scanner.c b/src/dom/sgml/scanner.c index 875938ba..3b887dcb 100644 --- a/src/dom/sgml/scanner.c +++ b/src/dom/sgml/scanner.c @@ -133,16 +133,25 @@ static struct dom_scanner_token * set_sgml_error(struct dom_scanner *scanner, unsigned char *end) { struct dom_scanner_token *token = scanner->current; + struct dom_scanner_token *next; assert(!scanner->found_error); - scanner->found_error = 1; + if (scanner->current >= scanner->table + DOM_SCANNER_TOKENS) { + scanner->found_error = 1; + next = NULL; + + } else { + scanner->current++; + next = scanner->current; + copy_struct(next, token); + } token->type = SGML_TOKEN_ERROR; token->lineno = scanner->lineno; set_dom_string(&token->string, scanner->position, end - scanner->position); - return scanner->found_error ? NULL : scanner->current; + return next; } @@ -609,7 +618,7 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t return; } - if (check_sgml_error(scanner)) { + if (check_sgml_error(scanner) && string == scanner->end) { unsigned char *end = string; switch (type) { diff --git a/src/dom/test/test-sgml-parser-error b/src/dom/test/test-sgml-parser-error index fe83da3e..bcf1fb46 100755 --- a/src/dom/test/test-sgml-parser-error +++ b/src/dom/test/test-sgml-parser-error @@ -143,7 +143,6 @@ test_output_error \ ' error on line 1: attr...' -cat >/dev/null <