diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-29 13:01:41 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-29 13:01:41 +0200 |
commit | 46589f9d94ef95b851f4cb56b06eeb11753db25e (patch) | |
tree | b1e415e8ed97f9faa5f9d146a40dbb4ccfe954cf /ext | |
parent | 33f0d0b44b6272a572cc14494ea788c867ae190f (diff) | |
download | ruamel.yaml-46589f9d94ef95b851f4cb56b06eeb11753db25e.tar.gz |
allow version 1.2 using C loader/dumper0.15.62
This just allows to use version 1.2 instead of 1.1 fixed. There is no actual
parsing/dumping code changed. So documents with YAML 1.2 specific features
(e.g. octals) are likely to fail.
*When this change indeed resolves your problem, please **Close** this issue*.
*(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to 'ext')
-rw-r--r-- | ext/emitter.c | 14 | ||||
-rw-r--r-- | ext/parser.c | 5 |
2 files changed, 16 insertions, 3 deletions
diff --git a/ext/emitter.c b/ext/emitter.c index 59d00fe..70e1c04 100644 --- a/ext/emitter.c +++ b/ext/emitter.c @@ -547,10 +547,16 @@ yaml_emitter_emit_stream_start(yaml_emitter_t *emitter, * Expect DOCUMENT-START or STREAM-END. */ +/* assume 2 digits + . + 2 digits max and NUL*/ +#define VERSION_BUF_LEN 6 + static int yaml_emitter_emit_document_start(yaml_emitter_t *emitter, yaml_event_t *event, int first) { + char version_buf[VERSION_BUF_LEN]; + yaml_version_directive_t vdp; + if (event->type == YAML_DOCUMENT_START_EVENT) { yaml_tag_directive_t default_tag_directives[] = { @@ -602,7 +608,10 @@ 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)) + /* if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0)) */ + vdp = (yaml_version_directive_t) *event->data.document_start.version_directive; + snprintf(version_buf, VERSION_BUF_LEN, "%d.%d", vdp.major, vdp.minor); + if (!yaml_emitter_write_indicator(emitter, version_buf, 1, 0, 0)) return 0; if (!yaml_emitter_write_indent(emitter)) return 0; @@ -1333,7 +1342,8 @@ 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/ext/parser.c b/ext/parser.c index 0691d48..3aecb59 100644 --- a/ext/parser.c +++ b/ext/parser.c @@ -1265,7 +1265,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; |