Update LibYAML (#150)
* Update .swift-version to latest stable Swift version * Update LibYAML to latest upstream head * Fix tests * Add changelog entry * Fix includes in yaml_private.h * Fix uninitialized warning
This commit is contained in:
parent
a856ca6c4b
commit
5d0bb5ec15
|
@ -1 +1 @@
|
|||
4.0
|
||||
4.2.1
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
the String type's native encoding.
|
||||
[Norio Nomura](https://github.com/norio-nomura)
|
||||
|
||||
* Update LibYAML sources to latest versions as of January 6 2018.
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
|
||||
##### Bug Fixes
|
||||
|
||||
* Fix some test failures with the latest Swift 5 snapshot on Apple platforms.
|
||||
|
|
|
@ -52,7 +52,7 @@ YAML_DECLARE(int)
|
|||
yaml_string_extend(yaml_char_t **start,
|
||||
yaml_char_t **pointer, yaml_char_t **end)
|
||||
{
|
||||
yaml_char_t *new_start = yaml_realloc(*start, (*end - *start)*2);
|
||||
yaml_char_t *new_start = (yaml_char_t *)yaml_realloc((void*)*start, (*end - *start)*2);
|
||||
|
||||
if (!new_start) return 0;
|
||||
|
||||
|
@ -72,8 +72,9 @@ yaml_string_extend(yaml_char_t **start,
|
|||
YAML_DECLARE(int)
|
||||
yaml_string_join(
|
||||
yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
|
||||
yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end)
|
||||
yaml_char_t **b_start, yaml_char_t **b_pointer, SHIM(yaml_char_t **b_end))
|
||||
{
|
||||
UNUSED_PARAM(b_end)
|
||||
if (*b_start == *b_pointer)
|
||||
return 1;
|
||||
|
||||
|
@ -95,7 +96,12 @@ yaml_string_join(
|
|||
YAML_DECLARE(int)
|
||||
yaml_stack_extend(void **start, void **top, void **end)
|
||||
{
|
||||
void *new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2);
|
||||
void *new_start;
|
||||
|
||||
if ((char *)*end - (char *)*start >= INT_MAX / 2)
|
||||
return 0;
|
||||
|
||||
new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2);
|
||||
|
||||
if (!new_start) return 0;
|
||||
|
||||
|
@ -155,17 +161,17 @@ yaml_parser_initialize(yaml_parser_t *parser)
|
|||
goto error;
|
||||
if (!BUFFER_INIT(parser, parser->buffer, INPUT_BUFFER_SIZE))
|
||||
goto error;
|
||||
if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE))
|
||||
if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE, yaml_token_t*))
|
||||
goto error;
|
||||
if (!STACK_INIT(parser, parser->indents, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(parser, parser->indents, int*))
|
||||
goto error;
|
||||
if (!STACK_INIT(parser, parser->simple_keys, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(parser, parser->simple_keys, yaml_simple_key_t*))
|
||||
goto error;
|
||||
if (!STACK_INIT(parser, parser->states, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(parser, parser->states, yaml_parser_state_t*))
|
||||
goto error;
|
||||
if (!STACK_INIT(parser, parser->marks, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(parser, parser->marks, yaml_mark_t*))
|
||||
goto error;
|
||||
if (!STACK_INIT(parser, parser->tag_directives, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(parser, parser->tag_directives, yaml_tag_directive_t*))
|
||||
goto error;
|
||||
|
||||
return 1;
|
||||
|
@ -221,7 +227,7 @@ static int
|
|||
yaml_string_read_handler(void *data, unsigned char *buffer, size_t size,
|
||||
size_t *size_read)
|
||||
{
|
||||
yaml_parser_t *parser = data;
|
||||
yaml_parser_t *parser = (yaml_parser_t *)data;
|
||||
|
||||
if (parser->input.string.current == parser->input.string.end) {
|
||||
*size_read = 0;
|
||||
|
@ -247,7 +253,7 @@ static int
|
|||
yaml_file_read_handler(void *data, unsigned char *buffer, size_t size,
|
||||
size_t *size_read)
|
||||
{
|
||||
yaml_parser_t *parser = data;
|
||||
yaml_parser_t *parser = (yaml_parser_t *)data;
|
||||
|
||||
*size_read = fread(buffer, 1, size, parser->input.file);
|
||||
return !ferror(parser->input.file);
|
||||
|
@ -333,13 +339,13 @@ yaml_emitter_initialize(yaml_emitter_t *emitter)
|
|||
goto error;
|
||||
if (!BUFFER_INIT(emitter, emitter->raw_buffer, OUTPUT_RAW_BUFFER_SIZE))
|
||||
goto error;
|
||||
if (!STACK_INIT(emitter, emitter->states, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(emitter, emitter->states, yaml_emitter_state_t*))
|
||||
goto error;
|
||||
if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE))
|
||||
if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE, yaml_event_t*))
|
||||
goto error;
|
||||
if (!STACK_INIT(emitter, emitter->indents, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(emitter, emitter->indents, int*))
|
||||
goto error;
|
||||
if (!STACK_INIT(emitter, emitter->tag_directives, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(emitter, emitter->tag_directives, yaml_tag_directive_t*))
|
||||
goto error;
|
||||
|
||||
return 1;
|
||||
|
@ -391,7 +397,7 @@ yaml_emitter_delete(yaml_emitter_t *emitter)
|
|||
static int
|
||||
yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
|
||||
{
|
||||
yaml_emitter_t *emitter = data;
|
||||
yaml_emitter_t *emitter = (yaml_emitter_t *)data;
|
||||
|
||||
if (emitter->output.string.size - *emitter->output.string.size_written
|
||||
< size) {
|
||||
|
@ -417,7 +423,7 @@ yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
|
|||
static int
|
||||
yaml_file_write_handler(void *data, unsigned char *buffer, size_t size)
|
||||
{
|
||||
yaml_emitter_t *emitter = data;
|
||||
yaml_emitter_t *emitter = (yaml_emitter_t *)data;
|
||||
|
||||
return (fwrite(buffer, 1, size, emitter->output.file) == size);
|
||||
}
|
||||
|
@ -695,7 +701,7 @@ yaml_document_start_event_initialize(yaml_event_t *event,
|
|||
/* Valid tag directives are expected. */
|
||||
|
||||
if (version_directive) {
|
||||
version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t));
|
||||
version_directive_copy = YAML_MALLOC_STATIC(yaml_version_directive_t);
|
||||
if (!version_directive_copy) goto error;
|
||||
version_directive_copy->major = version_directive->major;
|
||||
version_directive_copy->minor = version_directive->minor;
|
||||
|
@ -703,7 +709,7 @@ yaml_document_start_event_initialize(yaml_event_t *event,
|
|||
|
||||
if (tag_directives_start != tag_directives_end) {
|
||||
yaml_tag_directive_t *tag_directive;
|
||||
if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(&context, tag_directives_copy, yaml_tag_directive_t*))
|
||||
goto error;
|
||||
for (tag_directive = tag_directives_start;
|
||||
tag_directive != tag_directives_end; tag_directive ++) {
|
||||
|
@ -824,7 +830,7 @@ yaml_scalar_event_initialize(yaml_event_t *event,
|
|||
}
|
||||
|
||||
if (!yaml_check_utf8(value, length)) goto error;
|
||||
value_copy = yaml_malloc(length+1);
|
||||
value_copy = YAML_MALLOC(length+1);
|
||||
if (!value_copy) goto error;
|
||||
memcpy(value_copy, value, length);
|
||||
value_copy[length] = '\0';
|
||||
|
@ -1036,10 +1042,10 @@ yaml_document_initialize(yaml_document_t *document,
|
|||
(tag_directives_start == tag_directives_end));
|
||||
/* Valid tag directives are expected. */
|
||||
|
||||
if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error;
|
||||
if (!STACK_INIT(&context, nodes, yaml_node_t*)) goto error;
|
||||
|
||||
if (version_directive) {
|
||||
version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t));
|
||||
version_directive_copy = YAML_MALLOC_STATIC(yaml_version_directive_t);
|
||||
if (!version_directive_copy) goto error;
|
||||
version_directive_copy->major = version_directive->major;
|
||||
version_directive_copy->minor = version_directive->minor;
|
||||
|
@ -1047,7 +1053,7 @@ yaml_document_initialize(yaml_document_t *document,
|
|||
|
||||
if (tag_directives_start != tag_directives_end) {
|
||||
yaml_tag_directive_t *tag_directive;
|
||||
if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(&context, tag_directives_copy, yaml_tag_directive_t*))
|
||||
goto error;
|
||||
for (tag_directive = tag_directives_start;
|
||||
tag_directive != tag_directives_end; tag_directive ++) {
|
||||
|
@ -1097,13 +1103,8 @@ error:
|
|||
YAML_DECLARE(void)
|
||||
yaml_document_delete(yaml_document_t *document)
|
||||
{
|
||||
struct {
|
||||
yaml_error_type_t error;
|
||||
} context;
|
||||
yaml_tag_directive_t *tag_directive;
|
||||
|
||||
context.error = YAML_NO_ERROR; /* Eliminate a compliler warning. */
|
||||
|
||||
assert(document); /* Non-NULL document object is expected. */
|
||||
|
||||
while (!STACK_EMPTY(&context, document->nodes)) {
|
||||
|
@ -1203,7 +1204,7 @@ yaml_document_add_scalar(yaml_document_t *document,
|
|||
}
|
||||
|
||||
if (!yaml_check_utf8(value, length)) goto error;
|
||||
value_copy = yaml_malloc(length+1);
|
||||
value_copy = YAML_MALLOC(length+1);
|
||||
if (!value_copy) goto error;
|
||||
memcpy(value_copy, value, length);
|
||||
value_copy[length] = '\0';
|
||||
|
@ -1253,7 +1254,7 @@ yaml_document_add_sequence(yaml_document_t *document,
|
|||
tag_copy = yaml_strdup(tag);
|
||||
if (!tag_copy) goto error;
|
||||
|
||||
if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error;
|
||||
if (!STACK_INIT(&context, items, yaml_node_item_t*)) goto error;
|
||||
|
||||
SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,
|
||||
style, mark, mark);
|
||||
|
@ -1301,7 +1302,7 @@ yaml_document_add_mapping(yaml_document_t *document,
|
|||
tag_copy = yaml_strdup(tag);
|
||||
if (!tag_copy) goto error;
|
||||
|
||||
if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error;
|
||||
if (!STACK_INIT(&context, pairs, yaml_node_pair_t*)) goto error;
|
||||
|
||||
MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,
|
||||
style, mark, mark);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define PUT(emitter,value) \
|
||||
(FLUSH(emitter) \
|
||||
&& (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \
|
||||
emitter->column ++, \
|
||||
emitter->column++, \
|
||||
1))
|
||||
|
||||
/*
|
||||
|
@ -221,7 +221,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter);
|
|||
|
||||
static int
|
||||
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
|
||||
char *indicator, int need_whitespace,
|
||||
const char *indicator, int need_whitespace,
|
||||
int is_whitespace, int is_indention);
|
||||
|
||||
static int
|
||||
|
@ -649,13 +649,6 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
|
|||
|
||||
else if (event->type == YAML_STREAM_END_EVENT)
|
||||
{
|
||||
if (emitter->open_ended)
|
||||
{
|
||||
if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
|
||||
return 0;
|
||||
if (!yaml_emitter_write_indent(emitter))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!yaml_emitter_flush(emitter))
|
||||
return 0;
|
||||
|
@ -1002,7 +995,7 @@ yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
|
|||
*/
|
||||
|
||||
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;
|
||||
|
@ -1087,7 +1080,7 @@ yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event)
|
|||
*/
|
||||
|
||||
static int
|
||||
yaml_emitter_check_empty_document(yaml_emitter_t *emitter)
|
||||
yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -1784,7 +1777,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter)
|
|||
|
||||
static int
|
||||
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
|
||||
char *indicator, int need_whitespace,
|
||||
const char *indicator, int need_whitespace,
|
||||
int is_whitespace, int is_indention)
|
||||
{
|
||||
size_t indicator_length;
|
||||
|
@ -1946,6 +1939,10 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
|
|||
|
||||
emitter->whitespace = 0;
|
||||
emitter->indention = 0;
|
||||
if (emitter->root_context)
|
||||
{
|
||||
emitter->open_ended = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -2004,6 +2001,9 @@ yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
|
|||
}
|
||||
}
|
||||
|
||||
if (breaks)
|
||||
if (!yaml_emitter_write_indent(emitter)) return 0;
|
||||
|
||||
if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0))
|
||||
return 0;
|
||||
|
||||
|
@ -2174,7 +2174,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
|
|||
yaml_string_t string)
|
||||
{
|
||||
char indent_hint[2];
|
||||
char *chomp_hint = NULL;
|
||||
const char *chomp_hint = NULL;
|
||||
|
||||
if (IS_SPACE(string) || IS_BREAK(string))
|
||||
{
|
||||
|
|
|
@ -605,7 +605,7 @@ yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
|
|||
if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) {
|
||||
size_t prefix_len = strlen((char *)tag_directive->prefix);
|
||||
size_t suffix_len = strlen((char *)tag_suffix);
|
||||
tag = yaml_malloc(prefix_len+suffix_len+1);
|
||||
tag = YAML_MALLOC(prefix_len+suffix_len+1);
|
||||
if (!tag) {
|
||||
parser->error = YAML_MEMORY_ERROR;
|
||||
goto error;
|
||||
|
@ -685,7 +685,7 @@ yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
|
|||
return 1;
|
||||
}
|
||||
else if (anchor || tag) {
|
||||
yaml_char_t *value = yaml_malloc(1);
|
||||
yaml_char_t *value = YAML_MALLOC(1);
|
||||
if (!value) {
|
||||
parser->error = YAML_MEMORY_ERROR;
|
||||
goto error;
|
||||
|
@ -730,7 +730,7 @@ yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
|
|||
|
||||
if (first) {
|
||||
token = PEEK_TOKEN(parser);
|
||||
if (!token || !PUSH(parser, parser->marks, token->start_mark))
|
||||
if (!PUSH(parser, parser->marks, token->start_mark))
|
||||
return 0;
|
||||
SKIP_TOKEN(parser);
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
|
|||
else if (token->type == YAML_BLOCK_END_TOKEN)
|
||||
{
|
||||
parser->state = POP(parser, parser->states);
|
||||
POP(parser, parser->marks);
|
||||
(void)POP(parser, parser->marks);
|
||||
SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
||||
SKIP_TOKEN(parser);
|
||||
return 1;
|
||||
|
@ -838,7 +838,7 @@ yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
|
|||
|
||||
if (first) {
|
||||
token = PEEK_TOKEN(parser);
|
||||
if (!token || !PUSH(parser, parser->marks, token->start_mark))
|
||||
if (!PUSH(parser, parser->marks, token->start_mark))
|
||||
return 0;
|
||||
SKIP_TOKEN(parser);
|
||||
}
|
||||
|
@ -869,7 +869,7 @@ yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
|
|||
else if (token->type == YAML_BLOCK_END_TOKEN)
|
||||
{
|
||||
parser->state = POP(parser, parser->states);
|
||||
POP(parser, parser->marks);
|
||||
(void)POP(parser, parser->marks);
|
||||
MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
||||
SKIP_TOKEN(parser);
|
||||
return 1;
|
||||
|
@ -953,7 +953,7 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
|
|||
|
||||
if (first) {
|
||||
token = PEEK_TOKEN(parser);
|
||||
if (!token || !PUSH(parser, parser->marks, token->start_mark))
|
||||
if (!PUSH(parser, parser->marks, token->start_mark))
|
||||
return 0;
|
||||
SKIP_TOKEN(parser);
|
||||
}
|
||||
|
@ -994,7 +994,7 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
|
|||
}
|
||||
|
||||
parser->state = POP(parser, parser->states);
|
||||
POP(parser, parser->marks);
|
||||
(void)POP(parser, parser->marks);
|
||||
SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
||||
SKIP_TOKEN(parser);
|
||||
return 1;
|
||||
|
@ -1104,7 +1104,7 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
|
|||
|
||||
if (first) {
|
||||
token = PEEK_TOKEN(parser);
|
||||
if (!token || !PUSH(parser, parser->marks, token->start_mark))
|
||||
if (!PUSH(parser, parser->marks, token->start_mark))
|
||||
return 0;
|
||||
SKIP_TOKEN(parser);
|
||||
}
|
||||
|
@ -1154,7 +1154,7 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
|
|||
}
|
||||
|
||||
parser->state = POP(parser, parser->states);
|
||||
POP(parser, parser->marks);
|
||||
(void)POP(parser, parser->marks);
|
||||
MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
||||
SKIP_TOKEN(parser);
|
||||
return 1;
|
||||
|
@ -1208,7 +1208,7 @@ yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event,
|
|||
{
|
||||
yaml_char_t *value;
|
||||
|
||||
value = yaml_malloc(1);
|
||||
value = YAML_MALLOC(1);
|
||||
if (!value) {
|
||||
parser->error = YAML_MEMORY_ERROR;
|
||||
return 0;
|
||||
|
@ -1245,7 +1245,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|||
} tag_directives = { NULL, NULL, NULL };
|
||||
yaml_token_t *token;
|
||||
|
||||
if (!STACK_INIT(parser, tag_directives, INITIAL_STACK_SIZE))
|
||||
if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
|
||||
goto error;
|
||||
|
||||
token = PEEK_TOKEN(parser);
|
||||
|
@ -1266,7 +1266,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|||
"found incompatible YAML document", token->start_mark);
|
||||
goto error;
|
||||
}
|
||||
version_directive = yaml_malloc(sizeof(yaml_version_directive_t));
|
||||
version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t);
|
||||
if (!version_directive) {
|
||||
parser->error = YAML_MEMORY_ERROR;
|
||||
goto error;
|
||||
|
@ -1316,6 +1316,8 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|||
STACK_DEL(parser, tag_directives);
|
||||
}
|
||||
|
||||
if (!version_directive_ref)
|
||||
yaml_free(version_directive);
|
||||
return 1;
|
||||
|
||||
error:
|
||||
|
|
|
@ -460,10 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
|||
|
||||
}
|
||||
|
||||
if (parser->offset >= PTRDIFF_MAX)
|
||||
if (parser->offset >= MAX_FILE_SIZE) {
|
||||
return yaml_parser_set_reader_error(parser, "input is too long",
|
||||
PTRDIFF_MAX, -1);
|
||||
parser->offset, -1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
* BLOCK-END # Indentation decrease.
|
||||
* FLOW-SEQUENCE-START # '['
|
||||
* FLOW-SEQUENCE-END # ']'
|
||||
* BLOCK-SEQUENCE-START # '{'
|
||||
* BLOCK-SEQUENCE-END # '}'
|
||||
* FLOW-MAPPING-START # '{'
|
||||
* FLOW-MAPPING-END # '}'
|
||||
* BLOCK-ENTRY # '-'
|
||||
* FLOW-ENTRY # ','
|
||||
* KEY # '?' or nothing (simple keys).
|
||||
|
@ -1188,7 +1188,7 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
|
|||
{
|
||||
if (parser->flow_level) {
|
||||
parser->flow_level --;
|
||||
POP(parser, parser->simple_keys);
|
||||
(void)POP(parser, parser->simple_keys);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1639,7 +1639,7 @@ yaml_parser_fetch_key(yaml_parser_t *parser)
|
|||
|
||||
if (!parser->flow_level)
|
||||
{
|
||||
/* Check if we are allowed to start a new key (not nessesary simple). */
|
||||
/* Check if we are allowed to start a new key (not necessary simple). */
|
||||
|
||||
if (!parser->simple_key_allowed) {
|
||||
return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
|
||||
|
@ -2402,7 +2402,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
|
|||
{
|
||||
/* Set the handle to '' */
|
||||
|
||||
handle = yaml_malloc(1);
|
||||
handle = YAML_MALLOC(1);
|
||||
if (!handle) goto error;
|
||||
handle[0] = '\0';
|
||||
|
||||
|
@ -2454,7 +2454,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
|
|||
/* Set the handle to '!'. */
|
||||
|
||||
yaml_free(handle);
|
||||
handle = yaml_malloc(2);
|
||||
handle = YAML_MALLOC(2);
|
||||
if (!handle) goto error;
|
||||
handle[0] = '!';
|
||||
handle[1] = '\0';
|
||||
|
@ -2863,7 +2863,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|||
|
||||
if (!CACHE(parser, 1)) goto error;
|
||||
|
||||
while ((int)parser->mark.column == indent && !IS_Z(parser->buffer))
|
||||
while ((int)parser->mark.column == indent && !(IS_Z(parser->buffer)))
|
||||
{
|
||||
/*
|
||||
* We are at the beginning of a non-empty line.
|
||||
|
@ -3167,10 +3167,6 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|||
*(string.pointer++) = '/';
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
*(string.pointer++) = '\'';
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
*(string.pointer++) = '\\';
|
||||
break;
|
||||
|
@ -3437,11 +3433,22 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|||
|
||||
while (!IS_BLANKZ(parser->buffer))
|
||||
{
|
||||
/* Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". */
|
||||
/* Check for "x:" + one of ',?[]{}' in the flow context. TODO: Fix the test "spec-08-13".
|
||||
* This is not completely according to the spec
|
||||
* See http://yaml.org/spec/1.1/#id907281 9.1.3. Plain
|
||||
*/
|
||||
|
||||
if (parser->flow_level
|
||||
&& CHECK(parser->buffer, ':')
|
||||
&& !IS_BLANKZ_AT(parser->buffer, 1)) {
|
||||
&& (
|
||||
CHECK_AT(parser->buffer, ',', 1)
|
||||
|| CHECK_AT(parser->buffer, '?', 1)
|
||||
|| CHECK_AT(parser->buffer, '[', 1)
|
||||
|| CHECK_AT(parser->buffer, ']', 1)
|
||||
|| CHECK_AT(parser->buffer, '{', 1)
|
||||
|| CHECK_AT(parser->buffer, '}', 1)
|
||||
)
|
||||
) {
|
||||
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
|
||||
start_mark, "found unexpected ':'");
|
||||
goto error;
|
||||
|
@ -3451,7 +3458,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|||
|
||||
if ((CHECK(parser->buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1))
|
||||
|| (parser->flow_level &&
|
||||
(CHECK(parser->buffer, ',') || CHECK(parser->buffer, ':')
|
||||
(CHECK(parser->buffer, ',')
|
||||
|| CHECK(parser->buffer, '?') || CHECK(parser->buffer, '[')
|
||||
|| CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
|
||||
|| CHECK(parser->buffer, '}'))))
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
#if HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "yaml.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#ifdef _WIN64
|
||||
#define PTRDIFF_MAX _I64_MAX
|
||||
#else
|
||||
#define PTRDIFF_MAX INT_MAX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Memory management.
|
||||
*/
|
||||
|
@ -76,6 +62,17 @@ yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
|
|||
|
||||
#define OUTPUT_RAW_BUFFER_SIZE (OUTPUT_BUFFER_SIZE*2+2)
|
||||
|
||||
/*
|
||||
* The maximum size of a YAML input file.
|
||||
* This used to be PTRDIFF_MAX, but that's not entirely portable
|
||||
* because stdint.h isn't available on all platforms.
|
||||
* It is not entirely clear why this isn't the maximum value
|
||||
* that can fit into the parser->offset field.
|
||||
*/
|
||||
|
||||
#define MAX_FILE_SIZE (~(size_t)0 / 2)
|
||||
|
||||
|
||||
/*
|
||||
* The size of other stacks and queues.
|
||||
*/
|
||||
|
@ -89,7 +86,7 @@ yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
|
|||
*/
|
||||
|
||||
#define BUFFER_INIT(context,buffer,size) \
|
||||
(((buffer).start = yaml_malloc(size)) ? \
|
||||
(((buffer).start = (yaml_char_t *)yaml_malloc(size)) ? \
|
||||
((buffer).last = (buffer).pointer = (buffer).start, \
|
||||
(buffer).end = (buffer).start+(size), \
|
||||
1) : \
|
||||
|
@ -129,7 +126,7 @@ yaml_string_join(
|
|||
(value).pointer = (string))
|
||||
|
||||
#define STRING_INIT(context,string,size) \
|
||||
(((string).start = yaml_malloc(size)) ? \
|
||||
(((string).start = YAML_MALLOC(size)) ? \
|
||||
((string).pointer = (string).start, \
|
||||
(string).end = (string).start+(size), \
|
||||
memset((string).start, 0, (size)), \
|
||||
|
@ -170,14 +167,14 @@ yaml_string_join(
|
|||
* Check the octet at the specified position.
|
||||
*/
|
||||
|
||||
#define CHECK_AT(string,octet,offset) \
|
||||
#define CHECK_AT(string,octet,offset) \
|
||||
((string).pointer[offset] == (yaml_char_t)(octet))
|
||||
|
||||
/*
|
||||
* Check the current octet in the buffer.
|
||||
*/
|
||||
|
||||
#define CHECK(string,octet) CHECK_AT((string),(octet),0)
|
||||
#define CHECK(string,octet) (CHECK_AT((string),(octet),0))
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is an alphabetical
|
||||
|
@ -419,10 +416,10 @@ yaml_stack_extend(void **start, void **top, void **end);
|
|||
YAML_DECLARE(int)
|
||||
yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
||||
|
||||
#define STACK_INIT(context,stack,size) \
|
||||
(((stack).start = yaml_malloc((size)*sizeof(*(stack).start))) ? \
|
||||
#define STACK_INIT(context,stack,type) \
|
||||
(((stack).start = (type)yaml_malloc(INITIAL_STACK_SIZE*sizeof(*(stack).start))) ? \
|
||||
((stack).top = (stack).start, \
|
||||
(stack).end = (stack).start+(size), \
|
||||
(stack).end = (stack).start+INITIAL_STACK_SIZE, \
|
||||
1) : \
|
||||
((context)->error = YAML_MEMORY_ERROR, \
|
||||
0))
|
||||
|
@ -452,8 +449,8 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
|||
#define POP(context,stack) \
|
||||
(*(--(stack).top))
|
||||
|
||||
#define QUEUE_INIT(context,queue,size) \
|
||||
(((queue).start = yaml_malloc((size)*sizeof(*(queue).start))) ? \
|
||||
#define QUEUE_INIT(context,queue,size,type) \
|
||||
(((queue).start = (type)yaml_malloc((size)*sizeof(*(queue).start))) ? \
|
||||
((queue).head = (queue).tail = (queue).start, \
|
||||
(queue).end = (queue).start+(size), \
|
||||
1) : \
|
||||
|
@ -656,3 +653,28 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
|||
(node).data.mapping.pairs.end = (node_pairs_end), \
|
||||
(node).data.mapping.pairs.top = (node_pairs_start), \
|
||||
(node).data.mapping.style = (node_style))
|
||||
|
||||
/* Strict C compiler warning helpers */
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
# define HASATTRIBUTE_UNUSED
|
||||
#endif
|
||||
#ifdef HASATTRIBUTE_UNUSED
|
||||
# define __attribute__unused__ __attribute__((__unused__))
|
||||
#else
|
||||
# define __attribute__unused__
|
||||
#endif
|
||||
|
||||
/* Shim arguments are arguments that must be included in your function,
|
||||
* but serve no purpose inside. Silence compiler warnings. */
|
||||
#define SHIM(a) /*@unused@*/ a __attribute__unused__
|
||||
|
||||
/* UNUSED_PARAM() marks a shim argument in the body to silence compiler warnings */
|
||||
#ifdef __clang__
|
||||
# define UNUSED_PARAM(a) (void)(a);
|
||||
#else
|
||||
# define UNUSED_PARAM(a) /*@-noeffect*/if (0) (void)(a)/*@=noeffect*/;
|
||||
#endif
|
||||
|
||||
#define YAML_MALLOC_STATIC(type) (type*)yaml_malloc(sizeof(type))
|
||||
#define YAML_MALLOC(size) (yaml_char_t *)yaml_malloc(size)
|
||||
|
|
|
@ -537,7 +537,7 @@ class SpecTests: XCTestCase { // swiftlint:disable:this type_body_length
|
|||
let expectedYaml = """
|
||||
accomplishment: 'Mark set a major league home run record in 1998.
|
||||
|
||||
'
|
||||
'
|
||||
name: Mark McGwire
|
||||
stats: '65 Home Runs
|
||||
|
||||
|
@ -702,7 +702,7 @@ class SpecTests: XCTestCase { // swiftlint:disable:this type_body_length
|
|||
|
||||
different documents.
|
||||
|
||||
'
|
||||
'
|
||||
not-date: 2002-04-28
|
||||
picture: R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmleECcgggoBADs=
|
||||
|
||||
|
@ -788,7 +788,7 @@ class SpecTests: XCTestCase { // swiftlint:disable:this type_body_length
|
|||
|
||||
Suite #292
|
||||
|
||||
'
|
||||
'
|
||||
postal: 48046
|
||||
state: MI
|
||||
family: Dumars
|
||||
|
@ -812,7 +812,7 @@ class SpecTests: XCTestCase { // swiftlint:disable:this type_body_length
|
|||
|
||||
Suite #292
|
||||
|
||||
'
|
||||
'
|
||||
postal: 48046
|
||||
state: MI
|
||||
family: Dumars
|
||||
|
@ -901,7 +901,7 @@ class SpecTests: XCTestCase { // swiftlint:disable:this type_body_length
|
|||
Stack:
|
||||
- code: 'x = MoreObject(\"345\\n\")
|
||||
|
||||
'
|
||||
'
|
||||
file: TopClass.py
|
||||
line: 23
|
||||
- code: foo = bar
|
||||
|
|
Loading…
Reference in New Issue