#define PUT(emitter,value) \
(FLUSH(emitter) \
&& (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \
- emitter->column ++, \
+ emitter->column++, \
1))
/*
if (emitter->best_width < 0) {
emitter->best_width = INT_MAX;
}
-
+
if (!emitter->line_break) {
emitter->line_break = YAML_LN_BREAK;
}
implicit = 0;
}
+ if ((event->data.document_start.version_directive ||
+ (event->data.document_start.tag_directives.start
+ != event->data.document_start.tag_directives.end)) &&
+ emitter->open_ended)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+
if (event->data.document_start.version_directive) {
implicit = 0;
if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0))
if (!yaml_emitter_write_indent(emitter))
return 0;
}
-
+
if (event->data.document_start.tag_directives.start
!= event->data.document_start.tag_directives.end) {
implicit = 0;
else if (event->type == YAML_STREAM_END_EVENT)
{
+
if (!yaml_emitter_flush(emitter))
return 0;
}
/*
- *
+ *
* Expect a flow item node.
*/
*/
static int
-yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_event_t *event)
+yaml_emitter_emit_alias(yaml_emitter_t *emitter, SHIM(yaml_event_t *event))
{
if (!yaml_emitter_process_anchor(emitter))
return 0;
*/
static int
-yaml_emitter_check_empty_document(yaml_emitter_t *emitter)
+yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter))
{
return 0;
}
break;
case YAML_MAPPING_START_EVENT:
- if (!yaml_emitter_check_empty_sequence(emitter))
+ if (!yaml_emitter_check_empty_mapping(emitter))
return 0;
length += emitter->anchor_data.anchor_length
+ emitter->tag_data.handle_length
yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
yaml_tag_directive_t tag_directive)
{
- yaml_string_t handle = STRING(tag_directive.handle,
- strlen((char *)tag_directive.handle));
- yaml_string_t prefix = STRING(tag_directive.prefix,
- strlen((char *)tag_directive.prefix));
+ yaml_string_t handle;
+ yaml_string_t prefix;
+ size_t handle_length;
+ size_t prefix_length;
+
+ handle_length = strlen((char *)tag_directive.handle);
+ prefix_length = strlen((char *)tag_directive.prefix);
+ STRING_ASSIGN(handle, tag_directive.handle, handle_length);
+ STRING_ASSIGN(prefix, tag_directive.prefix, prefix_length);
if (handle.start == handle.end) {
return yaml_emitter_set_emitter_error(emitter,
yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
yaml_char_t *anchor, int alias)
{
- yaml_string_t string = STRING(anchor, strlen((char *)anchor));
+ size_t anchor_length;
+ yaml_string_t string;
+
+ anchor_length = strlen((char *)anchor);
+ STRING_ASSIGN(string, anchor, anchor_length);
if (string.start == string.end) {
return yaml_emitter_set_emitter_error(emitter, alias ?
yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
yaml_char_t *tag)
{
- yaml_string_t string = STRING(tag, strlen((char *)tag));
+ size_t tag_length;
+ yaml_string_t string;
yaml_tag_directive_t *tag_directive;
+ tag_length = strlen((char *)tag);
+ STRING_ASSIGN(string, tag, tag_length);
+
if (string.start == string.end) {
return yaml_emitter_set_emitter_error(emitter,
"tag value must not be empty");
yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
yaml_char_t *value, size_t length)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
int block_indicators = 0;
int flow_indicators = 0;
int break_space = 0;
int space_break = 0;
- int preceeded_by_whitespace = 0;
+ int preceded_by_whitespace = 0;
int followed_by_whitespace = 0;
int previous_space = 0;
int previous_break = 0;
+ STRING_ASSIGN(string, value, length);
+
emitter->scalar_data.value = value;
emitter->scalar_data.length = length;
flow_indicators = 1;
}
- preceeded_by_whitespace = 1;
+ preceded_by_whitespace = 1;
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
while (string.pointer != string.end)
}
}
- if (CHECK(string, '#') && preceeded_by_whitespace) {
+ if (CHECK(string, '#') && preceded_by_whitespace) {
flow_indicators = 1;
block_indicators = 1;
}
previous_break = 0;
}
- preceeded_by_whitespace = IS_BLANKZ(string);
+ preceded_by_whitespace = IS_BLANKZ(string);
MOVE(string);
if (string.pointer != string.end) {
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
char *indicator, int need_whitespace,
int is_whitespace, int is_indention)
{
- yaml_string_t string = STRING((yaml_char_t *)indicator, strlen(indicator));
+ size_t indicator_length;
+ yaml_string_t string;
+
+ indicator_length = strlen(indicator);
+ STRING_ASSIGN(string, (yaml_char_t *)indicator, indicator_length);
if (need_whitespace && !emitter->whitespace) {
if (!PUT(emitter, ' ')) return 0;
emitter->whitespace = is_whitespace;
emitter->indention = (emitter->indention && is_indention);
+ emitter->open_ended = 0;
return 1;
}
yaml_emitter_write_anchor(yaml_emitter_t *emitter,
yaml_char_t *value, size_t length)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
while (string.pointer != string.end) {
if (!WRITE(emitter, string)) return 0;
yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
yaml_char_t *value, size_t length)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
if (!emitter->whitespace) {
if (!PUT(emitter, ' ')) return 0;
yaml_char_t *value, size_t length,
int need_whitespace)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
if (need_whitespace && !emitter->whitespace) {
if (!PUT(emitter, ' ')) return 0;
yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
yaml_char_t *value, size_t length, int allow_breaks)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
int spaces = 0;
int breaks = 0;
+ STRING_ASSIGN(string, value, length);
+
if (!emitter->whitespace) {
if (!PUT(emitter, ' ')) return 0;
}
emitter->whitespace = 0;
emitter->indention = 0;
+ if (emitter->root_context)
+ {
+ emitter->open_ended = 1;
+ }
return 1;
}
yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
yaml_char_t *value, size_t length, int allow_breaks)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
int spaces = 0;
int breaks = 0;
+ STRING_ASSIGN(string, value, length);
+
if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0))
return 0;
}
}
+ if (breaks)
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+
if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0))
return 0;
yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
yaml_char_t *value, size_t length, int allow_breaks)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
int spaces = 0;
+ STRING_ASSIGN(string, value, length);
+
if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0))
return 0;
return 0;
}
+ emitter->open_ended = 0;
+
string.pointer = string.end;
if (string.start == string.pointer)
{
else if (string.start == string.pointer)
{
chomp_hint = "+";
+ emitter->open_ended = 1;
}
else
{
if (IS_BREAK(string))
{
chomp_hint = "+";
+ emitter->open_ended = 1;
}
}
}
yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
yaml_char_t *value, size_t length)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
int breaks = 1;
+ STRING_ASSIGN(string, value, length);
+
if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0))
return 0;
if (!yaml_emitter_write_block_scalar_hints(emitter, string))
yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
yaml_char_t *value, size_t length)
{
- yaml_string_t string = STRING(value, length);
+ yaml_string_t string;
int breaks = 1;
int leading_spaces = 1;
+ STRING_ASSIGN(string, value, length);
+
if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0))
return 0;
if (!yaml_emitter_write_block_scalar_hints(emitter, string))
while (IS_BREAK_AT(string, k)) {
k += WIDTH_AT(string, k);
}
- if (!IS_BLANK_AT(string, k)) {
+ if (!IS_BLANKZ_AT(string, k)) {
if (!PUT_BREAK(emitter)) return 0;
}
}
return 1;
}
-