From 867581dd755bd202cefc605af5e081ba2ba8c1ec Mon Sep 17 00:00:00 2001 From: hsbt Date: Mon, 27 Aug 2018 00:44:04 +0000 Subject: Merge psych-3.1.0.pre1. * Update bundled libyaml-0.2.1 from 0.1.7. https://github.com/ruby/psych/pull/368 * Unify Psych's API: To use keyword arguments with method call. https://github.com/ruby/psych/pull/358 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/psych/yaml/api.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'ext/psych/yaml/api.c') diff --git a/ext/psych/yaml/api.c b/ext/psych/yaml/api.c index b1a8da0bda..ee170d87de 100644 --- a/ext/psych/yaml/api.c +++ b/ext/psych/yaml/api.c @@ -74,7 +74,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; @@ -94,8 +94,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; @@ -177,17 +178,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; @@ -243,7 +244,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; @@ -269,7 +270,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); @@ -355,13 +356,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; @@ -413,7 +414,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) { @@ -439,7 +440,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); } @@ -717,7 +718,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; @@ -725,7 +726,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 ++) { @@ -843,7 +844,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'; @@ -1055,10 +1056,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; @@ -1066,7 +1067,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 ++) { @@ -1219,7 +1220,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'; @@ -1266,7 +1267,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); @@ -1311,7 +1312,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); -- cgit v1.2.3