diff options
author | Tina Müller (tinita) <cpan2@tinita.de> | 2020-04-10 21:45:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 21:45:15 +0200 |
commit | 3d5b7e65dbd57a4d6f8508658efd3ad38d5125ce (patch) | |
tree | c6ec603db0715972e4cfed779932710c1ca745d2 | |
parent | 1b5bac0d3d1195496ac92547005673018619a111 (diff) | |
download | libyaml-git-3d5b7e65dbd57a4d6f8508658efd3ad38d5125ce.tar.gz |
Support %YAML 1.2 directives (#172)
This will simply allow `%YAML 1.2` directives additionally to `%YAML 1.1`.
There is no change in behaviour.
See also #20
No changes are needed regarding tag directives.
In YAML 1.2 tag directives are for the following document only.
This is already implemented like that in libyaml.
We would rather have to fix the code if we want to have the correct behaviour
(global directives) in YAML 1.1. This would be a bit more complicated, as we
would have to save the default version and the current version in the parser
object.
New passing parser tests:
* 27NA: Spec Example 5.9. Directive Indicator
* 6ZKB: Spec Example 9.6. Stream
* 9DXL: Spec Example 9.6. Stream [1.3]
* RTP8: Spec Example 9.2. Document Markers
New failing error parser tests (before they were errors for the wrong reason):
* EB22: Missing document-end marker before directive
* RHX7: YAML directive without document end marker
-rw-r--r-- | src/emitter.c | 5 | ||||
-rw-r--r-- | src/parser.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/emitter.c b/src/emitter.c index f2b215f..a22c6b1 100644 --- a/src/emitter.c +++ b/src/emitter.c @@ -1341,7 +1341,10 @@ static int yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter, yaml_version_directive_t version_directive) { - if (version_directive.major != 1 || version_directive.minor != 1) { + if (version_directive.major != 1 || ( + version_directive.minor != 1 + && version_directive.minor != 2 + )) { return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive"); } diff --git a/src/parser.c b/src/parser.c index 1198c73..ec2f8d3 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1261,7 +1261,10 @@ yaml_parser_process_directives(yaml_parser_t *parser, goto error; } if (token->data.version_directive.major != 1 - || token->data.version_directive.minor != 1) { + || ( + token->data.version_directive.minor != 1 + && token->data.version_directive.minor != 2 + )) { yaml_parser_set_parser_error(parser, "found incompatible YAML document", token->start_mark); goto error; |