From 5e52c31904e21cf7a80a1ebd7a349c59f13e6aed Mon Sep 17 00:00:00 2001 From: Kirill Simonov Date: Tue, 17 Apr 2007 17:39:54 +0000 Subject: Fixed a problem when the DOCUMENT-END event is not emitted until the beginning of the next document is available. Fixed #51. Thanks edward(at)sweetbytes.net for the bug report. --- src/parser.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/parser.c b/src/parser.c index bad2fc6..81122f6 100644 --- a/src/parser.c +++ b/src/parser.c @@ -352,6 +352,17 @@ yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event, token = PEEK_TOKEN(parser); if (!token) return 0; + /* Parse extra document end indicators. */ + + if (!implicit) + { + while (token->type == YAML_DOCUMENT_END_TOKEN) { + SKIP_TOKEN(parser); + token = PEEK_TOKEN(parser); + if (!token) return 0; + } + } + /* Parse an implicit document. */ if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN && @@ -467,11 +478,9 @@ yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event) start_mark = end_mark = token->start_mark; - while (token->type == YAML_DOCUMENT_END_TOKEN) { + if (token->type == YAML_DOCUMENT_END_TOKEN) { end_mark = token->end_mark; SKIP_TOKEN(parser); - token = PEEK_TOKEN(parser); - if (!token) return 0; implicit = 0; } -- cgit v1.2.1