summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTina Müller <cpan2@tinita.de>2020-04-17 21:36:49 +0200
committerTina Müller (tinita) <cpan2@tinita.de>2020-04-19 12:47:41 +0200
commit4e5cea6419cc7dc2f7816c239f1e989a9239b4fb (patch)
tree6329e0daa79befcbc380f96e377ba3c2c2934c9e /src
parent47bf3f086fbea5c02b30f99dcf2e56984af1a641 (diff)
downloadlibyaml-git-4e5cea6419cc7dc2f7816c239f1e989a9239b4fb.tar.gz
Allow emitting 1.2 directive
Before `1.1` was hardcoded in the emitter. * Also add --directive option to run-emitter-test-suite Allows to easily test how output looks like if %YAML directives are output.
Diffstat (limited to 'src')
-rw-r--r--src/emitter.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/emitter.c b/src/emitter.c
index a22c6b1..2c2e42a 100644
--- a/src/emitter.c
+++ b/src/emitter.c
@@ -603,8 +603,14 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
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;
}