From 229d804d94e5a7d9e4be7731e0995bcd6e618610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Sun, 19 Apr 2020 13:19:43 +0200 Subject: 0.2.4 dist files --- src/emitter.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/emitter.c') diff --git a/src/emitter.c b/src/emitter.c index a22c6b1..7dd8331 100644 --- a/src/emitter.c +++ b/src/emitter.c @@ -495,6 +495,7 @@ static int yaml_emitter_emit_stream_start(yaml_emitter_t *emitter, yaml_event_t *event) { + emitter->open_ended = 0; if (event->type == YAML_STREAM_START_EVENT) { if (!emitter->encoding) { @@ -594,17 +595,23 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter, { if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) return 0; - emitter->open_ended = 0; if (!yaml_emitter_write_indent(emitter)) return 0; } + emitter->open_ended = 0; if (event->data.document_start.version_directive) { implicit = 0; if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0)) return 0; - if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0)) - return 0; + if (event->data.document_start.version_directive->minor == 1) { + if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0)) + return 0; + } + else { + if (!yaml_emitter_write_indicator(emitter, "1.2", 1, 0, 0)) + return 0; + } if (!yaml_emitter_write_indent(emitter)) return 0; } @@ -656,7 +663,7 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter, * This can happen if a block scalar with trailing empty lines * is at the end of the stream */ - if (emitter->open_ended) + if (emitter->open_ended == 2) { if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) return 0; @@ -709,6 +716,8 @@ yaml_emitter_emit_document_end(yaml_emitter_t *emitter, if (!yaml_emitter_write_indent(emitter)) return 0; } + else if (!emitter->open_ended) + emitter->open_ended = 1; if (!yaml_emitter_flush(emitter)) return 0; @@ -2216,7 +2225,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter, else if (string.start == string.pointer) { chomp_hint = "+"; - emitter->open_ended = 1; + emitter->open_ended = 2; } else { @@ -2226,7 +2235,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter, if (IS_BREAK(string)) { chomp_hint = "+"; - emitter->open_ended = 1; + emitter->open_ended = 2; } } } -- cgit v1.2.1