mirror of
https://github.com/yaml/libyaml.git
synced 2026-01-26 11:14:28 +00:00
Emitter: Output space after an alias mapping key (#185)
Before:
a: &b x
*b: c
Now:
a: &b x
*b : c
Passing tests:
* 26DV: Whitespace around colon in mappings
* E76Z: Aliases in Implicit Block Mapping
* X38W: Aliases in Flow Objects
Test manually because `make test-suite` will overwrite changes in the skiplist:
./tests/run-parser-test-suite tests/run-test-suite/data/26DV/in.yaml | ./tests/run-emitter-test-suite
./tests/run-parser-test-suite tests/run-test-suite/data/E76Z/in.yaml | ./tests/run-emitter-test-suite
./tests/run-parser-test-suite tests/run-test-suite/data/X38W/in.yaml | ./tests/run-emitter-test-suite
Or edit tests/run-test-suite/test/blacklist/libyaml-emitter and do:
(cd tests/run-test-suite; prove -lv test)
Also I added some newlines to yaml.h to help identifying states by number.
This commit is contained in:
parent
f41d3600d6
commit
6e2fa9786a
@ -1020,6 +1020,7 @@ typedef enum yaml_parser_state_e {
|
||||
YAML_PARSE_DOCUMENT_CONTENT_STATE,
|
||||
/** Expect DOCUMENT-END. */
|
||||
YAML_PARSE_DOCUMENT_END_STATE,
|
||||
|
||||
/** Expect a block node. */
|
||||
YAML_PARSE_BLOCK_NODE_STATE,
|
||||
/** Expect a block node or indentless sequence. */
|
||||
@ -1030,6 +1031,7 @@ typedef enum yaml_parser_state_e {
|
||||
YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE,
|
||||
/** Expect an entry of a block sequence. */
|
||||
YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE,
|
||||
|
||||
/** Expect an entry of an indentless sequence. */
|
||||
YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE,
|
||||
/** Expect the first key of a block mapping. */
|
||||
@ -1040,6 +1042,7 @@ typedef enum yaml_parser_state_e {
|
||||
YAML_PARSE_BLOCK_MAPPING_VALUE_STATE,
|
||||
/** Expect the first entry of a flow sequence. */
|
||||
YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE,
|
||||
|
||||
/** Expect an entry of a flow sequence. */
|
||||
YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE,
|
||||
/** Expect a key of an ordered mapping. */
|
||||
@ -1051,6 +1054,7 @@ typedef enum yaml_parser_state_e {
|
||||
/** Expect the first key of a flow mapping. */
|
||||
YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE,
|
||||
/** Expect a key of a flow mapping. */
|
||||
|
||||
YAML_PARSE_FLOW_MAPPING_KEY_STATE,
|
||||
/** Expect a value of a flow mapping. */
|
||||
YAML_PARSE_FLOW_MAPPING_VALUE_STATE,
|
||||
@ -1489,6 +1493,7 @@ typedef enum yaml_emitter_state_e {
|
||||
YAML_EMIT_DOCUMENT_CONTENT_STATE,
|
||||
/** Expect DOCUMENT-END. */
|
||||
YAML_EMIT_DOCUMENT_END_STATE,
|
||||
|
||||
/** Expect the first item of a flow sequence. */
|
||||
YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE,
|
||||
/** Expect an item of a flow sequence. */
|
||||
@ -1499,6 +1504,7 @@ typedef enum yaml_emitter_state_e {
|
||||
YAML_EMIT_FLOW_MAPPING_KEY_STATE,
|
||||
/** Expect a value for a simple key of a flow mapping. */
|
||||
YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE,
|
||||
|
||||
/** Expect a value of a flow mapping. */
|
||||
YAML_EMIT_FLOW_MAPPING_VALUE_STATE,
|
||||
/** Expect the first item of a block sequence. */
|
||||
@ -1509,6 +1515,7 @@ typedef enum yaml_emitter_state_e {
|
||||
YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE,
|
||||
/** Expect the key of a block mapping. */
|
||||
YAML_EMIT_BLOCK_MAPPING_KEY_STATE,
|
||||
|
||||
/** Expect a value for a simple key of a block mapping. */
|
||||
YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE,
|
||||
/** Expect a value of a block mapping. */
|
||||
|
||||
@ -1023,6 +1023,8 @@ yaml_emitter_emit_alias(yaml_emitter_t *emitter, SHIM(yaml_event_t *event))
|
||||
{
|
||||
if (!yaml_emitter_process_anchor(emitter))
|
||||
return 0;
|
||||
if (emitter->simple_key_context)
|
||||
if (!PUT(emitter, ' ')) return 0;
|
||||
emitter->state = POP(emitter, emitter->states);
|
||||
|
||||
return 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user