ruby-changes:61906
From: Hiroshi <ko1@a...>
Date: Tue, 23 Jun 2020 15:26:51 +0900 (JST)
Subject: [ruby-changes:61906] 70a4599869 (master): [ruby/psych] Bump libyaml version to 0.2.5
https://git.ruby-lang.org/ruby.git/commit/?id=70a4599869 From 70a459986988fecf245cf5eb62e7982e790c8260 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Tue, 23 Jun 2020 13:40:15 +0900 Subject: [ruby/psych] Bump libyaml version to 0.2.5 https://github.com/ruby/psych/commit/39996192cc diff --git a/ext/psych/yaml/api.c b/ext/psych/yaml/api.c index 95dc6b4..6add8b2 100644 --- a/ext/psych/yaml/api.c +++ b/ext/psych/yaml/api.c @@ -118,7 +118,12 @@ yaml_string_join( https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L118 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; @@ -618,10 +623,10 @@ yaml_token_delete(yaml_token_t *token) https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L623 */ static int -yaml_check_utf8(yaml_char_t *start, size_t length) +yaml_check_utf8(const yaml_char_t *start, size_t length) { - yaml_char_t *end = start+length; - yaml_char_t *pointer = start; + const yaml_char_t *end = start+length; + const yaml_char_t *pointer = start; while (pointer < end) { unsigned char octet; @@ -789,7 +794,7 @@ yaml_document_end_event_initialize(yaml_event_t *event, int implicit) https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L794 */ YAML_DECLARE(int) -yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor) +yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor) { yaml_mark_t mark = { 0, 0, 0 }; yaml_char_t *anchor_copy = NULL; @@ -814,8 +819,8 @@ yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor) https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L819 YAML_DECLARE(int) yaml_scalar_event_initialize(yaml_event_t *event, - yaml_char_t *anchor, yaml_char_t *tag, - yaml_char_t *value, int length, + const yaml_char_t *anchor, const yaml_char_t *tag, + const yaml_char_t *value, int length, int plain_implicit, int quoted_implicit, yaml_scalar_style_t style) { @@ -868,7 +873,7 @@ error: https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L873 YAML_DECLARE(int) yaml_sequence_start_event_initialize(yaml_event_t *event, - yaml_char_t *anchor, yaml_char_t *tag, int implicit, + const yaml_char_t *anchor, const yaml_char_t *tag, int implicit, yaml_sequence_style_t style) { yaml_mark_t mark = { 0, 0, 0 }; @@ -923,7 +928,7 @@ yaml_sequence_end_event_initialize(yaml_event_t *event) https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L928 YAML_DECLARE(int) yaml_mapping_start_event_initialize(yaml_event_t *event, - yaml_char_t *anchor, yaml_char_t *tag, int implicit, + const yaml_char_t *anchor, const yaml_char_t *tag, int implicit, yaml_mapping_style_t style) { yaml_mark_t mark = { 0, 0, 0 }; @@ -1117,15 +1122,8 @@ error: https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L1122 YAML_DECLARE(void) yaml_document_delete(yaml_document_t *document) { - struct { - yaml_error_type_t error; - } context; yaml_tag_directive_t *tag_directive; - /* Eliminate a compliler warning. */ - context.error = YAML_NO_ERROR; - (void)context.error; - assert(document); /* Non-NULL document object is expected. */ while (!STACK_EMPTY(&context, document->nodes)) { @@ -1195,7 +1193,7 @@ yaml_document_get_root_node(yaml_document_t *document) https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L1193 YAML_DECLARE(int) yaml_document_add_scalar(yaml_document_t *document, - yaml_char_t *tag, yaml_char_t *value, int length, + const yaml_char_t *tag, const yaml_char_t *value, int length, yaml_scalar_style_t style) { struct { @@ -1245,7 +1243,7 @@ error: https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L1243 YAML_DECLARE(int) yaml_document_add_sequence(yaml_document_t *document, - yaml_char_t *tag, yaml_sequence_style_t style) + const yaml_char_t *tag, yaml_sequence_style_t style) { struct { yaml_error_type_t error; @@ -1290,7 +1288,7 @@ error: https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/api.c#L1288 YAML_DECLARE(int) yaml_document_add_mapping(yaml_document_t *document, - yaml_char_t *tag, yaml_mapping_style_t style) + const yaml_char_t *tag, yaml_mapping_style_t style) { struct { yaml_error_type_t error; diff --git a/ext/psych/yaml/config.h b/ext/psych/yaml/config.h index da90513..9020943 100644 --- a/ext/psych/yaml/config.h +++ b/ext/psych/yaml/config.h @@ -1,10 +1,80 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/config.h#L1 +/* include/config.h. Generated from config.h.in by configure. */ +/* include/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "yaml" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "https://github.com/yaml/libyaml/issues/new" + +/* Define to the full name of this package. */ #define PACKAGE_NAME "yaml" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "yaml 0.2.1" + +/* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "yaml" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ #define PACKAGE_VERSION "0.2.1" -#define PACKAGE_STRING "yaml 0.2.1" -#define PACKAGE_BUGREPORT "https://github.com/yaml/libyaml/issues" -#define PACKAGE_URL "https://github.com/yaml/libyaml" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.2.1" + +/* Define the major version number. */ #define YAML_VERSION_MAJOR 0 + +/* Define the minor version number. */ #define YAML_VERSION_MINOR 2 + +/* Define the patch version number. */ #define YAML_VERSION_PATCH 1 + +/* Define the version string. */ #define YAML_VERSION_STRING "0.2.1" + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `unsigned int' if <sys/types.h> does not define. */ +/* #undef size_t */ diff --git a/ext/psych/yaml/dumper.c b/ext/psych/yaml/dumper.c index 29fb9c0..1fe940b 100644 --- a/ext/psych/yaml/dumper.c +++ b/ext/psych/yaml/dumper.c @@ -131,7 +131,7 @@ yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document) https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/dumper.c#L131 assert(emitter->opened); /* Emitter should be opened. */ - emitter->anchors = yaml_malloc(sizeof(*(emitter->anchors)) + emitter->anchors = (yaml_anchors_t*)yaml_malloc(sizeof(*(emitter->anchors)) * (document->nodes.top - document->nodes.start)); if (!emitter->anchors) goto error; memset(emitter->anchors, 0, sizeof(*(emitter->anchors)) diff --git a/ext/psych/yaml/emitter.c b/ext/psych/yaml/emitter.c index 92e21cd..796294c 100644 --- a/ext/psych/yaml/emitter.c +++ b/ext/psych/yaml/emitter.c @@ -16,7 +16,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/emitter.c#L16 #define PUT(emitter,value) \ (FLUSH(emitter) \ && (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \ - emitter->column ++, \ + emitter->column++, \ 1)) /* @@ -495,6 +495,7 @@ static int https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/emitter.c#L495 yaml_emitter_emit_stream_start(yaml_emitter_t *emitter, yaml_event_t *event) { + emitter->open_ended = 0; if (event->type == YAML_STREAM_START_EVENT) { if (!emitter->encoding) { @@ -597,13 +598,20 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter, https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/emitter.c#L598 if (!yaml_emitter_write_indent(emitter)) return 0; } + emitter->open_ended = 0; if (event->data.document_start.version_directive) { 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)) - return 0; + if (event->data.document_start.version_directive->minor == 1) { + if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0)) + return 0; + } + else { + if (!yaml_emitter_write_indicator(emitter, "1.2", 1, 0, 0)) + return 0; + (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/