diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/yaml | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/yaml')
-rw-r--r-- | contrib/libs/yaml/License | 4 | ||||
-rw-r--r-- | contrib/libs/yaml/include/yaml.h | 88 | ||||
-rw-r--r-- | contrib/libs/yaml/src/api.c | 88 | ||||
-rw-r--r-- | contrib/libs/yaml/src/config.h | 162 | ||||
-rw-r--r-- | contrib/libs/yaml/src/dumper.c | 6 | ||||
-rw-r--r-- | contrib/libs/yaml/src/emitter.c | 126 | ||||
-rw-r--r-- | contrib/libs/yaml/src/loader.c | 418 | ||||
-rw-r--r-- | contrib/libs/yaml/src/parser.c | 32 | ||||
-rw-r--r-- | contrib/libs/yaml/src/reader.c | 12 | ||||
-rw-r--r-- | contrib/libs/yaml/src/scanner.c | 158 | ||||
-rw-r--r-- | contrib/libs/yaml/src/writer.c | 2 | ||||
-rw-r--r-- | contrib/libs/yaml/src/yaml_private.h | 102 | ||||
-rw-r--r-- | contrib/libs/yaml/ya.make | 28 |
13 files changed, 613 insertions, 613 deletions
diff --git a/contrib/libs/yaml/License b/contrib/libs/yaml/License index 3d82c281ee..e8f596b4de 100644 --- a/contrib/libs/yaml/License +++ b/contrib/libs/yaml/License @@ -1,5 +1,5 @@ -Copyright (c) 2017-2020 Ingy döt Net -Copyright (c) 2006-2016 Kirill Simonov +Copyright (c) 2017-2020 Ingy döt Net +Copyright (c) 2006-2016 Kirill Simonov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/contrib/libs/yaml/include/yaml.h b/contrib/libs/yaml/include/yaml.h index 7ccd5ed97a..b7ad2eeb2a 100644 --- a/contrib/libs/yaml/include/yaml.h +++ b/contrib/libs/yaml/include/yaml.h @@ -1,7 +1,7 @@ /** * @file yaml.h * @brief Public interface for libyaml. - * + * * Include the header file with the code: * @code * #include <yaml.h> @@ -28,9 +28,9 @@ extern "C" { #define YAML_DECLARE_STATIC -#if defined(__MINGW32__) -# define YAML_DECLARE(type) type -#elif defined(_WIN32) +#if defined(__MINGW32__) +# define YAML_DECLARE(type) type +#elif defined(_WIN32) # if defined(YAML_DECLARE_STATIC) # define YAML_DECLARE(type) type # elif defined(YAML_DECLARE_EXPORT) @@ -234,7 +234,7 @@ typedef enum yaml_token_type_e { /** A BLOCK-SEQUENCE-START token. */ YAML_BLOCK_SEQUENCE_START_TOKEN, - /** A BLOCK-MAPPING-START token. */ + /** A BLOCK-MAPPING-START token. */ YAML_BLOCK_MAPPING_START_TOKEN, /** A BLOCK-END token. */ YAML_BLOCK_END_TOKEN, @@ -392,7 +392,7 @@ typedef struct yaml_event_s { /** The event data. */ union { - + /** The stream parameters (for @c YAML_STREAM_START_EVENT). */ struct { /** The document encoding. */ @@ -554,7 +554,7 @@ yaml_document_end_event_initialize(yaml_event_t *event, int implicit); */ YAML_DECLARE(int) -yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor); +yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor); /** * Create a SCALAR event. @@ -580,8 +580,8 @@ yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor); YAML_DECLARE(int) yaml_scalar_event_initialize(yaml_event_t *event, - const yaml_char_t *anchor, const yaml_char_t *tag, - const 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); @@ -603,7 +603,7 @@ yaml_scalar_event_initialize(yaml_event_t *event, YAML_DECLARE(int) yaml_sequence_start_event_initialize(yaml_event_t *event, - const yaml_char_t *anchor, const yaml_char_t *tag, int implicit, + const yaml_char_t *anchor, const yaml_char_t *tag, int implicit, yaml_sequence_style_t style); /** @@ -635,7 +635,7 @@ yaml_sequence_end_event_initialize(yaml_event_t *event); YAML_DECLARE(int) yaml_mapping_start_event_initialize(yaml_event_t *event, - const yaml_char_t *anchor, const yaml_char_t *tag, int implicit, + const yaml_char_t *anchor, const yaml_char_t *tag, int implicit, yaml_mapping_style_t style); /** @@ -667,7 +667,7 @@ yaml_event_delete(yaml_event_t *event); /** The tag @c !!null with the only possible value: @c null. */ #define YAML_NULL_TAG "tag:yaml.org,2002:null" -/** The tag @c !!bool with the values: @c true and @c false. */ +/** The tag @c !!bool with the values: @c true and @c false. */ #define YAML_BOOL_TAG "tag:yaml.org,2002:bool" /** The tag @c !!str for string values. */ #define YAML_STR_TAG "tag:yaml.org,2002:str" @@ -728,7 +728,7 @@ struct yaml_node_s { /** The node data. */ union { - + /** The scalar parameters (for @c YAML_SCALAR_NODE). */ struct { /** The scalar value. */ @@ -898,7 +898,7 @@ yaml_document_get_root_node(yaml_document_t *document); YAML_DECLARE(int) yaml_document_add_scalar(yaml_document_t *document, - const yaml_char_t *tag, const yaml_char_t *value, int length, + const yaml_char_t *tag, const yaml_char_t *value, int length, yaml_scalar_style_t style); /** @@ -915,7 +915,7 @@ yaml_document_add_scalar(yaml_document_t *document, YAML_DECLARE(int) yaml_document_add_sequence(yaml_document_t *document, - const yaml_char_t *tag, yaml_sequence_style_t style); + const yaml_char_t *tag, yaml_sequence_style_t style); /** * Create a MAPPING node and attach it to the document. @@ -931,7 +931,7 @@ yaml_document_add_sequence(yaml_document_t *document, YAML_DECLARE(int) yaml_document_add_mapping(yaml_document_t *document, - const yaml_char_t *tag, yaml_mapping_style_t style); + const yaml_char_t *tag, yaml_mapping_style_t style); /** * Add an item to a SEQUENCE node. @@ -939,7 +939,7 @@ yaml_document_add_mapping(yaml_document_t *document, * @param[in,out] document A document object. * @param[in] sequence The sequence node id. * @param[in] item The item node id. - * + * * @returns @c 1 if the function succeeded, @c 0 on error. */ @@ -954,7 +954,7 @@ yaml_document_append_sequence_item(yaml_document_t *document, * @param[in] mapping The mapping node id. * @param[in] key The key node id. * @param[in] value The value node id. - * + * * @returns @c 1 if the function succeeded, @c 0 on error. */ @@ -1022,7 +1022,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. */ @@ -1033,7 +1033,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. */ @@ -1044,7 +1044,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. */ @@ -1056,7 +1056,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, @@ -1211,7 +1211,7 @@ typedef struct yaml_parser_s { /** The number of tokens fetched from the queue. */ size_t tokens_parsed; - /** Does the tokens queue contain a token ready for dequeueing. */ + /** Does the tokens queue contain a token ready for dequeueing. */ int token_available; /** The indentation levels stack. */ @@ -1452,7 +1452,7 @@ yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event); * @param[in,out] parser A parser object. * @param[out] document An empty document object. * - * @returns @c 1 if the function succeeded, @c 0 on error. + * @returns @c 1 if the function succeeded, @c 0 on error. */ YAML_DECLARE(int) @@ -1495,7 +1495,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. */ @@ -1506,7 +1506,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. */ @@ -1517,7 +1517,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. */ @@ -1526,18 +1526,18 @@ typedef enum yaml_emitter_state_e { YAML_EMIT_END_STATE } yaml_emitter_state_t; - -/* This is needed for C++ */ - -typedef struct yaml_anchors_s { - /** The number of references. */ - int references; - /** The anchor id. */ - int anchor; - /** If the node has been emitted? */ - int serialized; -} yaml_anchors_t; - + +/* This is needed for C++ */ + +typedef struct yaml_anchors_s { + /** The number of references. */ + int references; + /** The anchor id. */ + int anchor; + /** If the node has been emitted? */ + int serialized; +} yaml_anchors_t; + /** * The emitter structure. * @@ -1569,7 +1569,7 @@ typedef struct yaml_emitter_s { /** Write handler. */ yaml_write_handler_t *write_handler; - /** A pointer for passing to the write handler. */ + /** A pointer for passing to the write handler. */ void *write_handler_data; /** Standard (string or file) output data. */ @@ -1763,7 +1763,7 @@ typedef struct yaml_emitter_s { int closed; /** The information associated with the document nodes. */ - yaml_anchors_t *anchors; + yaml_anchors_t *anchors; /** The last assigned anchor id. */ int last_anchor_id; @@ -1867,7 +1867,7 @@ YAML_DECLARE(void) yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical); /** - * Set the indentation increment. + * Set the indentation increment. * * @param[in,out] emitter An emitter object. * @param[in] indent The indentation increment (1 < . < 10). @@ -1954,8 +1954,8 @@ yaml_emitter_close(yaml_emitter_t *emitter); * * The documen object may be generated using the yaml_parser_load() function * or the yaml_document_initialize() function. The emitter takes the - * responsibility for the document object and destroys its content after - * it is emitted. The document object is destroyed even if the function fails. + * responsibility for the document object and destroys its content after + * it is emitted. The document object is destroyed even if the function fails. * * @param[in,out] emitter An emitter object. * @param[in,out] document A document object. diff --git a/contrib/libs/yaml/src/api.c b/contrib/libs/yaml/src/api.c index 16f88bd762..d670f327eb 100644 --- a/contrib/libs/yaml/src/api.c +++ b/contrib/libs/yaml/src/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_char_t *)yaml_realloc((void*)*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,9 +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, SHIM(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) + UNUSED_PARAM(b_end) if (*b_start == *b_pointer) return 1; @@ -118,13 +118,13 @@ yaml_string_join( YAML_DECLARE(int) yaml_stack_extend(void **start, void **top, void **end) { - void *new_start; - - if ((char *)*end - (char *)*start >= INT_MAX / 2) - return 0; - - 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; *top = (char *)new_start + ((char *)*top - (char *)*start); @@ -183,17 +183,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, yaml_token_t*)) + if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE, yaml_token_t*)) goto error; - if (!STACK_INIT(parser, parser->indents, int*)) + if (!STACK_INIT(parser, parser->indents, int*)) goto error; - if (!STACK_INIT(parser, parser->simple_keys, yaml_simple_key_t*)) + if (!STACK_INIT(parser, parser->simple_keys, yaml_simple_key_t*)) goto error; - if (!STACK_INIT(parser, parser->states, yaml_parser_state_t*)) + if (!STACK_INIT(parser, parser->states, yaml_parser_state_t*)) goto error; - if (!STACK_INIT(parser, parser->marks, yaml_mark_t*)) + if (!STACK_INIT(parser, parser->marks, yaml_mark_t*)) goto error; - if (!STACK_INIT(parser, parser->tag_directives, yaml_tag_directive_t*)) + if (!STACK_INIT(parser, parser->tag_directives, yaml_tag_directive_t*)) goto error; return 1; @@ -249,7 +249,7 @@ static int yaml_string_read_handler(void *data, unsigned char *buffer, size_t size, size_t *size_read) { - yaml_parser_t *parser = (yaml_parser_t *)data; + yaml_parser_t *parser = (yaml_parser_t *)data; if (parser->input.string.current == parser->input.string.end) { *size_read = 0; @@ -275,7 +275,7 @@ static int yaml_file_read_handler(void *data, unsigned char *buffer, size_t size, size_t *size_read) { - yaml_parser_t *parser = (yaml_parser_t *)data; + yaml_parser_t *parser = (yaml_parser_t *)data; *size_read = fread(buffer, 1, size, parser->input.file); return !ferror(parser->input.file); @@ -361,13 +361,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, yaml_emitter_state_t*)) + if (!STACK_INIT(emitter, emitter->states, yaml_emitter_state_t*)) goto error; - if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE, yaml_event_t*)) + if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE, yaml_event_t*)) goto error; - if (!STACK_INIT(emitter, emitter->indents, int*)) + if (!STACK_INIT(emitter, emitter->indents, int*)) goto error; - if (!STACK_INIT(emitter, emitter->tag_directives, yaml_tag_directive_t*)) + if (!STACK_INIT(emitter, emitter->tag_directives, yaml_tag_directive_t*)) goto error; return 1; @@ -419,9 +419,9 @@ 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 = (yaml_emitter_t *)data; + yaml_emitter_t *emitter = (yaml_emitter_t *)data; - if (emitter->output.string.size - *emitter->output.string.size_written + if (emitter->output.string.size - *emitter->output.string.size_written < size) { memcpy(emitter->output.string.buffer + *emitter->output.string.size_written, @@ -445,7 +445,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 = (yaml_emitter_t *)data; + yaml_emitter_t *emitter = (yaml_emitter_t *)data; return (fwrite(buffer, 1, size, emitter->output.file) == size); } @@ -623,10 +623,10 @@ yaml_token_delete(yaml_token_t *token) */ static int -yaml_check_utf8(const yaml_char_t *start, size_t length) +yaml_check_utf8(const yaml_char_t *start, size_t length) { - const yaml_char_t *end = start+length; - const yaml_char_t *pointer = start; + const yaml_char_t *end = start+length; + const yaml_char_t *pointer = start; while (pointer < end) { unsigned char octet; @@ -723,7 +723,7 @@ yaml_document_start_event_initialize(yaml_event_t *event, /* Valid tag directives are expected. */ if (version_directive) { - version_directive_copy = YAML_MALLOC_STATIC(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; @@ -731,7 +731,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, yaml_tag_directive_t*)) + 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 ++) { @@ -794,7 +794,7 @@ yaml_document_end_event_initialize(yaml_event_t *event, int implicit) */ YAML_DECLARE(int) -yaml_alias_event_initialize(yaml_event_t *event, const 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; @@ -819,8 +819,8 @@ yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor) YAML_DECLARE(int) yaml_scalar_event_initialize(yaml_event_t *event, - const yaml_char_t *anchor, const yaml_char_t *tag, - const 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) { @@ -849,7 +849,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'; @@ -873,7 +873,7 @@ error: YAML_DECLARE(int) yaml_sequence_start_event_initialize(yaml_event_t *event, - const yaml_char_t *anchor, const 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 }; @@ -928,7 +928,7 @@ yaml_sequence_end_event_initialize(yaml_event_t *event) YAML_DECLARE(int) yaml_mapping_start_event_initialize(yaml_event_t *event, - const yaml_char_t *anchor, const 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 }; @@ -1061,10 +1061,10 @@ yaml_document_initialize(yaml_document_t *document, (tag_directives_start == tag_directives_end)); /* Valid tag directives are expected. */ - if (!STACK_INIT(&context, nodes, yaml_node_t*)) goto error; + if (!STACK_INIT(&context, nodes, yaml_node_t*)) goto error; if (version_directive) { - version_directive_copy = YAML_MALLOC_STATIC(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; @@ -1072,7 +1072,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, yaml_tag_directive_t*)) + 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 ++) { @@ -1193,7 +1193,7 @@ yaml_document_get_root_node(yaml_document_t *document) YAML_DECLARE(int) yaml_document_add_scalar(yaml_document_t *document, - const yaml_char_t *tag, const yaml_char_t *value, int length, + const yaml_char_t *tag, const yaml_char_t *value, int length, yaml_scalar_style_t style) { struct { @@ -1220,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'; @@ -1243,7 +1243,7 @@ error: YAML_DECLARE(int) yaml_document_add_sequence(yaml_document_t *document, - const 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; @@ -1267,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, yaml_node_item_t*)) 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); @@ -1288,7 +1288,7 @@ error: YAML_DECLARE(int) yaml_document_add_mapping(yaml_document_t *document, - const 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; @@ -1312,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, yaml_node_pair_t*)) 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); diff --git a/contrib/libs/yaml/src/config.h b/contrib/libs/yaml/src/config.h index 22a2296e5e..d71932721d 100644 --- a/contrib/libs/yaml/src/config.h +++ b/contrib/libs/yaml/src/config.h @@ -1,82 +1,82 @@ -/* 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 <stdint.h> header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the <stdio.h> header file. */ -#define HAVE_STDIO_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.5" - -/* 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.5" - -/* Define to 1 if all of the C90 standard headers exist (not just the ones - required in a freestanding environment). This macro is provided for - backward compatibility; new code need not use it. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.2.5" - -/* Define the major version number. */ +/* 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 <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdio.h> header file. */ +#define HAVE_STDIO_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.5" + +/* 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.5" + +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.2.5" + +/* 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 5 - -/* Define the version string. */ -#define YAML_VERSION_STRING "0.2.5" - -/* 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 */ + +/* Define the minor version number. */ +#define YAML_VERSION_MINOR 2 + +/* Define the patch version number. */ +#define YAML_VERSION_PATCH 5 + +/* Define the version string. */ +#define YAML_VERSION_STRING "0.2.5" + +/* 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/contrib/libs/yaml/src/dumper.c b/contrib/libs/yaml/src/dumper.c index 1fe940b674..a0b2c2f50f 100644 --- a/contrib/libs/yaml/src/dumper.c +++ b/contrib/libs/yaml/src/dumper.c @@ -131,7 +131,7 @@ yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document) assert(emitter->opened); /* Emitter should be opened. */ - emitter->anchors = (yaml_anchors_t*)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)) @@ -245,9 +245,9 @@ yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index) #define ANCHOR_TEMPLATE_LENGTH 16 static yaml_char_t * -yaml_emitter_generate_anchor(SHIM(yaml_emitter_t *emitter), int anchor_id) +yaml_emitter_generate_anchor(SHIM(yaml_emitter_t *emitter), int anchor_id) { - yaml_char_t *anchor = YAML_MALLOC(ANCHOR_TEMPLATE_LENGTH); + yaml_char_t *anchor = YAML_MALLOC(ANCHOR_TEMPLATE_LENGTH); if (!anchor) return NULL; diff --git a/contrib/libs/yaml/src/emitter.c b/contrib/libs/yaml/src/emitter.c index 609b28a4c6..ed0b323934 100644 --- a/contrib/libs/yaml/src/emitter.c +++ b/contrib/libs/yaml/src/emitter.c @@ -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, - const char *indicator, int need_whitespace, + const char *indicator, int need_whitespace, int is_whitespace, int is_indention); static int @@ -495,7 +495,7 @@ static int yaml_emitter_emit_stream_start(yaml_emitter_t *emitter, yaml_event_t *event) { - emitter->open_ended = 0; + emitter->open_ended = 0; if (event->type == YAML_STREAM_START_EVENT) { if (!emitter->encoding) { @@ -518,7 +518,7 @@ yaml_emitter_emit_stream_start(yaml_emitter_t *emitter, if (emitter->best_width < 0) { emitter->best_width = INT_MAX; } - + if (!emitter->line_break) { emitter->line_break = YAML_LN_BREAK; } @@ -598,24 +598,24 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter, if (!yaml_emitter_write_indent(emitter)) return 0; } - emitter->open_ended = 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 (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; - } + 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; + } 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; @@ -652,25 +652,25 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter, emitter->state = YAML_EMIT_DOCUMENT_CONTENT_STATE; - emitter->open_ended = 0; + emitter->open_ended = 0; return 1; } else if (event->type == YAML_STREAM_END_EVENT) { - /** - * This can happen if a block scalar with trailing empty lines - * is at the end of the stream - */ - if (emitter->open_ended == 2) - { - if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) - return 0; - emitter->open_ended = 0; - if (!yaml_emitter_write_indent(emitter)) - return 0; - } + /** + * This can happen if a block scalar with trailing empty lines + * is at the end of the stream + */ + if (emitter->open_ended == 2) + { + if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) + return 0; + emitter->open_ended = 0; + if (!yaml_emitter_write_indent(emitter)) + return 0; + } if (!yaml_emitter_flush(emitter)) return 0; @@ -712,12 +712,12 @@ yaml_emitter_emit_document_end(yaml_emitter_t *emitter, if (!event->data.document_end.implicit) { if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) return 0; - emitter->open_ended = 0; + emitter->open_ended = 0; if (!yaml_emitter_write_indent(emitter)) return 0; } - else if (!emitter->open_ended) - emitter->open_ended = 1; + else if (!emitter->open_ended) + emitter->open_ended = 1; if (!yaml_emitter_flush(emitter)) return 0; @@ -738,7 +738,7 @@ yaml_emitter_emit_document_end(yaml_emitter_t *emitter, } /* - * + * * Expect a flow item node. */ @@ -1019,12 +1019,12 @@ yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event, */ static int -yaml_emitter_emit_alias(yaml_emitter_t *emitter, SHIM(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; - if (emitter->simple_key_context) - if (!PUT(emitter, ' ')) return 0; + if (emitter->simple_key_context) + if (!PUT(emitter, ' ')) return 0; emitter->state = POP(emitter, emitter->states); return 1; @@ -1106,7 +1106,7 @@ yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event) */ static int -yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter)) +yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter)) { return 0; } @@ -1253,7 +1253,7 @@ yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event) } /* - * Write an anchor. + * Write an anchor. */ static int @@ -1352,10 +1352,10 @@ static int yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter, yaml_version_directive_t version_directive) { - if (version_directive.major != 1 || ( - version_directive.minor != 1 - && version_directive.minor != 2 - )) { + if (version_directive.major != 1 || ( + version_directive.minor != 1 + && version_directive.minor != 2 + )) { return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive"); } @@ -1424,7 +1424,7 @@ yaml_emitter_analyze_anchor(yaml_emitter_t *emitter, { size_t anchor_length; yaml_string_t string; - + anchor_length = strlen((char *)anchor); STRING_ASSIGN(string, anchor, anchor_length); @@ -1515,7 +1515,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, int break_space = 0; int space_break = 0; - int preceded_by_whitespace = 0; + int preceded_by_whitespace = 0; int followed_by_whitespace = 0; int previous_space = 0; int previous_break = 0; @@ -1546,7 +1546,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, flow_indicators = 1; } - preceded_by_whitespace = 1; + preceded_by_whitespace = 1; followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); while (string.pointer != string.end) @@ -1592,7 +1592,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, } } - if (CHECK(string, '#') && preceded_by_whitespace) { + if (CHECK(string, '#') && preceded_by_whitespace) { flow_indicators = 1; block_indicators = 1; } @@ -1641,7 +1641,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, previous_break = 0; } - preceded_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)); @@ -1806,7 +1806,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter) static int yaml_emitter_write_indicator(yaml_emitter_t *emitter, - const char *indicator, int need_whitespace, + const char *indicator, int need_whitespace, int is_whitespace, int is_indention) { size_t indicator_length; @@ -1925,17 +1925,17 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter, STRING_ASSIGN(string, value, length); - /** - * Avoid trailing spaces for empty values in block mode. - * In flow mode, we still want the space to prevent ambiguous things - * like {a:}. - * Currently, the emitter forbids any plain empty scalar in flow mode - * (e.g. it outputs {a: ''} instead), so emitter->flow_level will - * never be true here. - * But if the emitter is ever changed to allow emitting empty values, - * the check for flow_level is already here. - */ - if (!emitter->whitespace && (length || emitter->flow_level)) { + /** + * Avoid trailing spaces for empty values in block mode. + * In flow mode, we still want the space to prevent ambiguous things + * like {a:}. + * Currently, the emitter forbids any plain empty scalar in flow mode + * (e.g. it outputs {a: ''} instead), so emitter->flow_level will + * never be true here. + * But if the emitter is ever changed to allow emitting empty values, + * the check for flow_level is already here. + */ + if (!emitter->whitespace && (length || emitter->flow_level)) { if (!PUT(emitter, ' ')) return 0; } @@ -2035,9 +2035,9 @@ yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter, } } - if (breaks) - if (!yaml_emitter_write_indent(emitter)) return 0; - + if (breaks) + if (!yaml_emitter_write_indent(emitter)) return 0; + if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0)) return 0; @@ -2208,7 +2208,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter, yaml_string_t string) { char indent_hint[2]; - const char *chomp_hint = NULL; + const char *chomp_hint = NULL; if (IS_SPACE(string) || IS_BREAK(string)) { @@ -2237,7 +2237,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter, else if (string.start == string.pointer) { chomp_hint = "+"; - emitter->open_ended = 2; + emitter->open_ended = 2; } else { @@ -2247,7 +2247,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter, if (IS_BREAK(string)) { chomp_hint = "+"; - emitter->open_ended = 2; + emitter->open_ended = 2; } } } diff --git a/contrib/libs/yaml/src/loader.c b/contrib/libs/yaml/src/loader.c index dea8ac428c..9d1a34a1c1 100644 --- a/contrib/libs/yaml/src/loader.c +++ b/contrib/libs/yaml/src/loader.c @@ -38,47 +38,47 @@ static void yaml_parser_delete_aliases(yaml_parser_t *parser); /* - * Document loading context. - */ -struct loader_ctx { - int *start; - int *end; - int *top; -}; - -/* + * Document loading context. + */ +struct loader_ctx { + int *start; + int *end; + int *top; +}; + +/* * Composer functions. */ -static int -yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx); +static int +yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx); static int -yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *event); +yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *event); static int -yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx); +yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx); static int -yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx); +yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx); static int -yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx); +yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx); static int -yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx); +yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx); static int -yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx); - -static int -yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx); +yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx); +static int +yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx); + /* * Load the next document of the stream. */ @@ -92,7 +92,7 @@ yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document) assert(document); /* Non-NULL document object is expected. */ memset(document, 0, sizeof(yaml_document_t)); - if (!STACK_INIT(parser, document->nodes, yaml_node_t*)) + if (!STACK_INIT(parser, document->nodes, yaml_node_t*)) goto error; if (!parser->stream_start_produced) { @@ -110,7 +110,7 @@ yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document) return 1; } - if (!STACK_INIT(parser, parser->aliases, yaml_alias_data_t*)) + if (!STACK_INIT(parser, parser->aliases, yaml_alias_data_t*)) goto error; parser->document = document; @@ -182,78 +182,78 @@ yaml_parser_delete_aliases(yaml_parser_t *parser) */ static int -yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *event) +yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *event) { - struct loader_ctx ctx = { NULL, NULL, NULL }; + struct loader_ctx ctx = { NULL, NULL, NULL }; - assert(event->type == YAML_DOCUMENT_START_EVENT); + assert(event->type == YAML_DOCUMENT_START_EVENT); /* DOCUMENT-START is expected. */ parser->document->version_directive - = event->data.document_start.version_directive; + = event->data.document_start.version_directive; parser->document->tag_directives.start - = event->data.document_start.tag_directives.start; + = event->data.document_start.tag_directives.start; parser->document->tag_directives.end - = event->data.document_start.tag_directives.end; + = event->data.document_start.tag_directives.end; parser->document->start_implicit - = event->data.document_start.implicit; - parser->document->start_mark = event->start_mark; + = event->data.document_start.implicit; + parser->document->start_mark = event->start_mark; - if (!STACK_INIT(parser, ctx, int*)) return 0; - if (!yaml_parser_load_nodes(parser, &ctx)) { - STACK_DEL(parser, ctx); - return 0; - } - STACK_DEL(parser, ctx); + if (!STACK_INIT(parser, ctx, int*)) return 0; + if (!yaml_parser_load_nodes(parser, &ctx)) { + STACK_DEL(parser, ctx); + return 0; + } + STACK_DEL(parser, ctx); return 1; } /* - * Compose a node tree. + * Compose a node tree. */ static int -yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx) +yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx) { - yaml_event_t event; - - do { - if (!yaml_parser_parse(parser, &event)) return 0; - - switch (event.type) { - case YAML_ALIAS_EVENT: - if (!yaml_parser_load_alias(parser, &event, ctx)) return 0; - break; - case YAML_SCALAR_EVENT: - if (!yaml_parser_load_scalar(parser, &event, ctx)) return 0; - break; - case YAML_SEQUENCE_START_EVENT: - if (!yaml_parser_load_sequence(parser, &event, ctx)) return 0; - break; - case YAML_SEQUENCE_END_EVENT: - if (!yaml_parser_load_sequence_end(parser, &event, ctx)) - return 0; - break; - case YAML_MAPPING_START_EVENT: - if (!yaml_parser_load_mapping(parser, &event, ctx)) return 0; - break; - case YAML_MAPPING_END_EVENT: - if (!yaml_parser_load_mapping_end(parser, &event, ctx)) - return 0; - break; - default: - assert(0); /* Could not happen. */ - return 0; - case YAML_DOCUMENT_END_EVENT: - break; - } - } while (event.type != YAML_DOCUMENT_END_EVENT); - - parser->document->end_implicit = event.data.document_end.implicit; - parser->document->end_mark = event.end_mark; - - return 1; + yaml_event_t event; + + do { + if (!yaml_parser_parse(parser, &event)) return 0; + + switch (event.type) { + case YAML_ALIAS_EVENT: + if (!yaml_parser_load_alias(parser, &event, ctx)) return 0; + break; + case YAML_SCALAR_EVENT: + if (!yaml_parser_load_scalar(parser, &event, ctx)) return 0; + break; + case YAML_SEQUENCE_START_EVENT: + if (!yaml_parser_load_sequence(parser, &event, ctx)) return 0; + break; + case YAML_SEQUENCE_END_EVENT: + if (!yaml_parser_load_sequence_end(parser, &event, ctx)) + return 0; + break; + case YAML_MAPPING_START_EVENT: + if (!yaml_parser_load_mapping(parser, &event, ctx)) return 0; + break; + case YAML_MAPPING_END_EVENT: + if (!yaml_parser_load_mapping_end(parser, &event, ctx)) + return 0; + break; + default: + assert(0); /* Could not happen. */ + return 0; + case YAML_DOCUMENT_END_EVENT: + break; + } + } while (event.type != YAML_DOCUMENT_END_EVENT); + + parser->document->end_implicit = event.data.document_end.implicit; + parser->document->end_mark = event.end_mark; + + return 1; } /* @@ -278,8 +278,8 @@ yaml_parser_register_anchor(yaml_parser_t *parser, if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) { yaml_free(anchor); return yaml_parser_set_composer_error_context(parser, - "found duplicate anchor; first occurrence", - alias_data->mark, "second occurrence", data.mark); + "found duplicate anchor; first occurrence", + alias_data->mark, "second occurrence", data.mark); } } @@ -292,79 +292,79 @@ yaml_parser_register_anchor(yaml_parser_t *parser, } /* - * Compose node into its parent in the stree. - */ - -static int -yaml_parser_load_node_add(yaml_parser_t *parser, struct loader_ctx *ctx, - int index) -{ - struct yaml_node_s *parent; - int parent_index; - - if (STACK_EMPTY(parser, *ctx)) { - /* This is the root node, there's no tree to add it to. */ - return 1; - } - - parent_index = *((*ctx).top - 1); - parent = &parser->document->nodes.start[parent_index-1]; - - switch (parent->type) { - case YAML_SEQUENCE_NODE: - if (!STACK_LIMIT(parser, parent->data.sequence.items, INT_MAX-1)) - return 0; - if (!PUSH(parser, parent->data.sequence.items, index)) - return 0; - break; - case YAML_MAPPING_NODE: { - yaml_node_pair_t pair; - if (!STACK_EMPTY(parser, parent->data.mapping.pairs)) { - yaml_node_pair_t *p = parent->data.mapping.pairs.top - 1; - if (p->key != 0 && p->value == 0) { - p->value = index; - break; - } - } - - pair.key = index; - pair.value = 0; - if (!STACK_LIMIT(parser, parent->data.mapping.pairs, INT_MAX-1)) - return 0; - if (!PUSH(parser, parent->data.mapping.pairs, pair)) - return 0; - - break; - } - default: - assert(0); /* Could not happen. */ - return 0; - } - return 1; -} - -/* + * Compose node into its parent in the stree. + */ + +static int +yaml_parser_load_node_add(yaml_parser_t *parser, struct loader_ctx *ctx, + int index) +{ + struct yaml_node_s *parent; + int parent_index; + + if (STACK_EMPTY(parser, *ctx)) { + /* This is the root node, there's no tree to add it to. */ + return 1; + } + + parent_index = *((*ctx).top - 1); + parent = &parser->document->nodes.start[parent_index-1]; + + switch (parent->type) { + case YAML_SEQUENCE_NODE: + if (!STACK_LIMIT(parser, parent->data.sequence.items, INT_MAX-1)) + return 0; + if (!PUSH(parser, parent->data.sequence.items, index)) + return 0; + break; + case YAML_MAPPING_NODE: { + yaml_node_pair_t pair; + if (!STACK_EMPTY(parser, parent->data.mapping.pairs)) { + yaml_node_pair_t *p = parent->data.mapping.pairs.top - 1; + if (p->key != 0 && p->value == 0) { + p->value = index; + break; + } + } + + pair.key = index; + pair.value = 0; + if (!STACK_LIMIT(parser, parent->data.mapping.pairs, INT_MAX-1)) + return 0; + if (!PUSH(parser, parent->data.mapping.pairs, pair)) + return 0; + + break; + } + default: + assert(0); /* Could not happen. */ + return 0; + } + return 1; +} + +/* * Compose a node corresponding to an alias. */ static int -yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx) +yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx) { - yaml_char_t *anchor = event->data.alias.anchor; + yaml_char_t *anchor = event->data.alias.anchor; yaml_alias_data_t *alias_data; for (alias_data = parser->aliases.start; alias_data != parser->aliases.top; alias_data ++) { if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) { yaml_free(anchor); - return yaml_parser_load_node_add(parser, ctx, alias_data->index); + return yaml_parser_load_node_add(parser, ctx, alias_data->index); } } yaml_free(anchor); return yaml_parser_set_composer_error(parser, "found undefined alias", - event->start_mark); + event->start_mark); } /* @@ -372,12 +372,12 @@ yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *event, */ static int -yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx) +yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx) { yaml_node_t node; int index; - yaml_char_t *tag = event->data.scalar.tag; + yaml_char_t *tag = event->data.scalar.tag; if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; @@ -387,23 +387,23 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *event, if (!tag) goto error; } - SCALAR_NODE_INIT(node, tag, event->data.scalar.value, - event->data.scalar.length, event->data.scalar.style, - event->start_mark, event->end_mark); + SCALAR_NODE_INIT(node, tag, event->data.scalar.value, + event->data.scalar.length, event->data.scalar.style, + event->start_mark, event->end_mark); if (!PUSH(parser, parser->document->nodes, node)) goto error; index = parser->document->nodes.top - parser->document->nodes.start; if (!yaml_parser_register_anchor(parser, index, - event->data.scalar.anchor)) return 0; + event->data.scalar.anchor)) return 0; - return yaml_parser_load_node_add(parser, ctx, index); + return yaml_parser_load_node_add(parser, ctx, index); error: yaml_free(tag); - yaml_free(event->data.scalar.anchor); - yaml_free(event->data.scalar.value); + yaml_free(event->data.scalar.anchor); + yaml_free(event->data.scalar.value); return 0; } @@ -412,8 +412,8 @@ error: */ static int -yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx) +yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx) { yaml_node_t node; struct { @@ -421,8 +421,8 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event, yaml_node_item_t *end; yaml_node_item_t *top; } items = { NULL, NULL, NULL }; - int index; - yaml_char_t *tag = event->data.sequence_start.tag; + int index; + yaml_char_t *tag = event->data.sequence_start.tag; if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; @@ -432,56 +432,56 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event, if (!tag) goto error; } - if (!STACK_INIT(parser, items, yaml_node_item_t*)) goto error; + if (!STACK_INIT(parser, items, yaml_node_item_t*)) goto error; SEQUENCE_NODE_INIT(node, tag, items.start, items.end, - event->data.sequence_start.style, - event->start_mark, event->end_mark); + event->data.sequence_start.style, + event->start_mark, event->end_mark); if (!PUSH(parser, parser->document->nodes, node)) goto error; index = parser->document->nodes.top - parser->document->nodes.start; if (!yaml_parser_register_anchor(parser, index, - event->data.sequence_start.anchor)) return 0; + event->data.sequence_start.anchor)) return 0; - if (!yaml_parser_load_node_add(parser, ctx, index)) return 0; + if (!yaml_parser_load_node_add(parser, ctx, index)) return 0; - if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0; - if (!PUSH(parser, *ctx, index)) return 0; + if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0; + if (!PUSH(parser, *ctx, index)) return 0; - return 1; + return 1; error: yaml_free(tag); - yaml_free(event->data.sequence_start.anchor); + yaml_free(event->data.sequence_start.anchor); return 0; } -static int -yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx) -{ - int index; - - assert(((*ctx).top - (*ctx).start) > 0); - - index = *((*ctx).top - 1); - assert(parser->document->nodes.start[index-1].type == YAML_SEQUENCE_NODE); - parser->document->nodes.start[index-1].end_mark = event->end_mark; - - (void)POP(parser, *ctx); - - return 1; -} - +static int +yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx) +{ + int index; + + assert(((*ctx).top - (*ctx).start) > 0); + + index = *((*ctx).top - 1); + assert(parser->document->nodes.start[index-1].type == YAML_SEQUENCE_NODE); + parser->document->nodes.start[index-1].end_mark = event->end_mark; + + (void)POP(parser, *ctx); + + return 1; +} + /* * Compose a mapping node. */ static int -yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx) +yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx) { yaml_node_t node; struct { @@ -490,7 +490,7 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event, yaml_node_pair_t *top; } pairs = { NULL, NULL, NULL }; int index; - yaml_char_t *tag = event->data.mapping_start.tag; + yaml_char_t *tag = event->data.mapping_start.tag; if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; @@ -500,45 +500,45 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event, if (!tag) goto error; } - if (!STACK_INIT(parser, pairs, yaml_node_pair_t*)) goto error; + if (!STACK_INIT(parser, pairs, yaml_node_pair_t*)) goto error; MAPPING_NODE_INIT(node, tag, pairs.start, pairs.end, - event->data.mapping_start.style, - event->start_mark, event->end_mark); + event->data.mapping_start.style, + event->start_mark, event->end_mark); if (!PUSH(parser, parser->document->nodes, node)) goto error; index = parser->document->nodes.top - parser->document->nodes.start; if (!yaml_parser_register_anchor(parser, index, - event->data.mapping_start.anchor)) return 0; + event->data.mapping_start.anchor)) return 0; - if (!yaml_parser_load_node_add(parser, ctx, index)) return 0; + if (!yaml_parser_load_node_add(parser, ctx, index)) return 0; - if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0; - if (!PUSH(parser, *ctx, index)) return 0; + if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0; + if (!PUSH(parser, *ctx, index)) return 0; - return 1; + return 1; error: yaml_free(tag); - yaml_free(event->data.mapping_start.anchor); + yaml_free(event->data.mapping_start.anchor); return 0; } -static int -yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event, - struct loader_ctx *ctx) -{ - int index; - - assert(((*ctx).top - (*ctx).start) > 0); - - index = *((*ctx).top - 1); - assert(parser->document->nodes.start[index-1].type == YAML_MAPPING_NODE); - parser->document->nodes.start[index-1].end_mark = event->end_mark; - - (void)POP(parser, *ctx); - - return 1; -}
\ No newline at end of file +static int +yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event, + struct loader_ctx *ctx) +{ + int index; + + assert(((*ctx).top - (*ctx).start) > 0); + + index = *((*ctx).top - 1); + assert(parser->document->nodes.start[index-1].type == YAML_MAPPING_NODE); + parser->document->nodes.start[index-1].end_mark = event->end_mark; + + (void)POP(parser, *ctx); + + return 1; +}
\ No newline at end of file diff --git a/contrib/libs/yaml/src/parser.c b/contrib/libs/yaml/src/parser.c index ec2f8d3e05..605cc5ee01 100644 --- a/contrib/libs/yaml/src/parser.c +++ b/contrib/libs/yaml/src/parser.c @@ -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; @@ -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); - (void)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; @@ -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); - (void)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; @@ -994,7 +994,7 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser, } parser->state = POP(parser, parser->states); - (void)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; @@ -1154,7 +1154,7 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, } parser->state = POP(parser, parser->states); - (void)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, yaml_tag_directive_t*)) + if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*)) goto error; token = PEEK_TOKEN(parser); @@ -1261,15 +1261,15 @@ yaml_parser_process_directives(yaml_parser_t *parser, goto error; } if (token->data.version_directive.major != 1 - || ( - token->data.version_directive.minor != 1 - && token->data.version_directive.minor != 2 - )) { + || ( + token->data.version_directive.minor != 1 + && token->data.version_directive.minor != 2 + )) { yaml_parser_set_parser_error(parser, "found incompatible YAML document", token->start_mark); goto error; } - version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t); + version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t); if (!version_directive) { parser->error = YAML_MEMORY_ERROR; goto error; @@ -1294,7 +1294,7 @@ yaml_parser_process_directives(yaml_parser_t *parser, token = PEEK_TOKEN(parser); if (!token) goto error; } - + for (default_tag_directive = default_tag_directives; default_tag_directive->handle; default_tag_directive++) { if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1, @@ -1319,8 +1319,8 @@ yaml_parser_process_directives(yaml_parser_t *parser, STACK_DEL(parser, tag_directives); } - if (!version_directive_ref) - yaml_free(version_directive); + if (!version_directive_ref) + yaml_free(version_directive); return 1; error: diff --git a/contrib/libs/yaml/src/reader.c b/contrib/libs/yaml/src/reader.c index f3ac54c251..7169d5accd 100644 --- a/contrib/libs/yaml/src/reader.c +++ b/contrib/libs/yaml/src/reader.c @@ -52,7 +52,7 @@ yaml_parser_determine_encoding(yaml_parser_t *parser) { /* Ensure that we had enough bytes in the raw buffer. */ - while (!parser->eof + while (!parser->eof && parser->raw_buffer.last - parser->raw_buffer.pointer < 3) { if (!yaml_parser_update_raw_buffer(parser)) { return 0; @@ -295,7 +295,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length) parser->offset, value); break; - + case YAML_UTF16LE_ENCODING: case YAML_UTF16BE_ENCODING: @@ -318,7 +318,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length) * * The following formulas are used for decoding * and encoding characters using surrogate pairs: - * + * * U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF) * U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF) * W1 = 110110yyyyyyyyyy @@ -460,10 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length) } - if (parser->offset >= MAX_FILE_SIZE) { + if (parser->offset >= MAX_FILE_SIZE) { return yaml_parser_set_reader_error(parser, "input is too long", - parser->offset, -1); - } + parser->offset, -1); + } return 1; } diff --git a/contrib/libs/yaml/src/scanner.c b/contrib/libs/yaml/src/scanner.c index c6b4987656..551b69476d 100644 --- a/contrib/libs/yaml/src/scanner.c +++ b/contrib/libs/yaml/src/scanner.c @@ -38,8 +38,8 @@ * BLOCK-END # Indentation decrease. * FLOW-SEQUENCE-START # '[' * FLOW-SEQUENCE-END # ']' - * FLOW-MAPPING-START # '{' - * FLOW-MAPPING-END # '}' + * FLOW-MAPPING-START # '{' + * FLOW-MAPPING-END # '}' * BLOCK-ENTRY # '-' * FLOW-ENTRY # ',' * KEY # '?' or nothing (simple keys). @@ -70,7 +70,7 @@ * %TAG !yaml! tag:yaml.org,2002: * --- * - * The corresponding sequence of tokens: + * The corresponding sequence of tokens: * * STREAM-START(utf-8) * VERSION-DIRECTIVE(1,1) @@ -348,7 +348,7 @@ * SCALAR("another value",plain) * KEY * SCALAR("a mapping",plain) - * VALUE + * VALUE * BLOCK-MAPPING-START * KEY * SCALAR("key 1",plain) @@ -712,7 +712,7 @@ yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive, yaml_mark_t start_mark, yaml_char_t **handle); static int -yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive, +yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive, yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri); static int @@ -763,7 +763,7 @@ yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token) } /* Fetch the next token from the queue. */ - + *token = DEQUEUE(parser, parser->tokens); parser->token_available = 0; parser->tokens_parsed ++; @@ -1115,7 +1115,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser) yaml_simple_key_t simple_key; simple_key.possible = 1; simple_key.required = required; - simple_key.token_number = + simple_key.token_number = parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head); simple_key.mark = parser->mark; @@ -1189,7 +1189,7 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser) { if (parser->flow_level) { parser->flow_level --; - (void)POP(parser, parser->simple_keys); + (void)POP(parser, parser->simple_keys); } return 1; @@ -1199,7 +1199,7 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser) * Push the current indentation level to the stack and set the new level * the current column is greater than the indentation level. In this case, * append or insert the specified token into the token queue. - * + * */ static int @@ -1250,7 +1250,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column, /* * Pop indentation levels from the indents stack until the current level - * becomes less or equal to the column. For each indentation level, append + * becomes less or equal to the column. For each indentation level, append * the BLOCK-END token. */ @@ -1265,7 +1265,7 @@ yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column) if (parser->flow_level) return 1; - /* Loop through the indentation levels in the stack. */ + /* Loop through the indentation levels in the stack. */ while (parser->indent > column) { @@ -1637,7 +1637,7 @@ yaml_parser_fetch_key(yaml_parser_t *parser) if (!parser->flow_level) { - /* Check if we are allowed to start a new key (not necessary 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, @@ -1937,7 +1937,7 @@ yaml_parser_scan_to_next_token(yaml_parser_t *parser) * * - in the flow context; * - in the block context, but not at the beginning of the line or - * after '-', '?', or ':' (complex value). + * after '-', '?', or ':' (complex value). */ if (!CACHE(parser, 1)) return 0; @@ -2052,7 +2052,7 @@ yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token) else { yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "found unknown directive name"); + start_mark, "found unknown directive name"); goto error; } @@ -2293,7 +2293,7 @@ yaml_parser_scan_tag_directive_value(yaml_parser_t *parser, /* Scan a prefix. */ - if (!yaml_parser_scan_tag_uri(parser, 1, 1, NULL, start_mark, &prefix_value)) + if (!yaml_parser_scan_tag_uri(parser, 1, 1, NULL, start_mark, &prefix_value)) goto error; /* Expect a whitespace or line break. */ @@ -2400,7 +2400,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'; @@ -2411,7 +2411,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token) /* Consume the tag value. */ - if (!yaml_parser_scan_tag_uri(parser, 1, 0, NULL, start_mark, &suffix)) + if (!yaml_parser_scan_tag_uri(parser, 1, 0, NULL, start_mark, &suffix)) goto error; /* Check for '>' and eat it. */ @@ -2439,20 +2439,20 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token) { /* Scan the suffix now. */ - if (!yaml_parser_scan_tag_uri(parser, 0, 0, NULL, start_mark, &suffix)) + if (!yaml_parser_scan_tag_uri(parser, 0, 0, NULL, start_mark, &suffix)) goto error; } else { /* It wasn't a handle after all. Scan the rest of the tag. */ - if (!yaml_parser_scan_tag_uri(parser, 0, 0, handle, start_mark, &suffix)) + if (!yaml_parser_scan_tag_uri(parser, 0, 0, handle, start_mark, &suffix)) goto error; /* Set the handle to '!'. */ yaml_free(handle); - handle = YAML_MALLOC(2); + handle = YAML_MALLOC(2); if (!handle) goto error; handle[0] = '!'; handle[1] = '\0'; @@ -2475,11 +2475,11 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token) if (!CACHE(parser, 1)) goto error; if (!IS_BLANKZ(parser->buffer)) { - if (!parser->flow_level || !CHECK(parser->buffer, ',') ) { - yaml_parser_set_scanner_error(parser, "while scanning a tag", - start_mark, "did not find expected whitespace or line break"); - goto error; - } + if (!parser->flow_level || !CHECK(parser->buffer, ',') ) { + yaml_parser_set_scanner_error(parser, "while scanning a tag", + start_mark, "did not find expected whitespace or line break"); + goto error; + } } end_mark = parser->mark; @@ -2568,7 +2568,7 @@ error: */ static int -yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive, +yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive, yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri) { size_t length = head ? strlen((char *)head) : 0; @@ -2604,11 +2604,11 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive, * The set of characters that may appear in URI is as follows: * * '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&', - * '=', '+', '$', '.', '!', '~', '*', '\'', '(', ')', '%'. - * - * If we are inside a verbatim tag <...> (parameter uri_char is true) - * then also the following flow indicators are allowed: - * ',', '[', ']' + * '=', '+', '$', '.', '!', '~', '*', '\'', '(', ')', '%'. + * + * If we are inside a verbatim tag <...> (parameter uri_char is true) + * then also the following flow indicators are allowed: + * ',', '[', ']' */ while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';') @@ -2616,22 +2616,22 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive, || CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@') || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=') || CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$') - || CHECK(parser->buffer, '.') || CHECK(parser->buffer, '%') + || CHECK(parser->buffer, '.') || CHECK(parser->buffer, '%') || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~') || CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'') || CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')') - || (uri_char && ( - CHECK(parser->buffer, ',') - || CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']') - ) - )) + || (uri_char && ( + CHECK(parser->buffer, ',') + || CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']') + ) + )) { /* Check if it is a URI-escape sequence. */ if (CHECK(parser->buffer, '%')) { - if (!STRING_EXTEND(parser, string)) - goto error; - + if (!STRING_EXTEND(parser, string)) + goto error; + if (!yaml_parser_scan_uri_escapes(parser, directive, start_mark, &string)) goto error; } @@ -2782,15 +2782,15 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, if (IS_DIGIT(parser->buffer)) { - /* Check that the indentation is greater than 0. */ + /* Check that the indentation is greater than 0. */ if (CHECK(parser->buffer, '0')) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an indentation indicator equal to 0"); + start_mark, "found an indentation indicator equal to 0"); goto error; } - /* Get the indentation level and eat the indicator. */ + /* Get the indentation level and eat the indicator. */ increment = AS_DIGIT(parser->buffer); @@ -2804,7 +2804,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, { if (CHECK(parser->buffer, '0')) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an indentation indicator equal to 0"); + start_mark, "found an indentation indicator equal to 0"); goto error; } @@ -2854,7 +2854,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, end_mark = parser->mark; - /* Set the indentation level if it was specified. */ + /* Set the indentation level if it was specified. */ if (increment) { indent = parser->indent >= 0 ? parser->indent+increment : increment; @@ -2869,7 +2869,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. @@ -2920,7 +2920,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, if (!READ_LINE(parser, leading_break)) goto error; - /* Eat the following indentation spaces and line breaks. */ + /* Eat the following indentation spaces and line breaks. */ if (!yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark)) goto error; @@ -2955,8 +2955,8 @@ error: } /* - * Scan indentation spaces and line breaks for a block scalar. Determine the - * indentation level if needed. + * Scan indentation spaces and line breaks for a block scalar. Determine the + * indentation level if needed. */ static int @@ -2968,11 +2968,11 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, *end_mark = parser->mark; - /* Eat the indentation spaces and line breaks. */ + /* Eat the indentation spaces and line breaks. */ while (1) { - /* Eat the indentation spaces. */ + /* Eat the indentation spaces. */ if (!CACHE(parser, 1)) return 0; @@ -2985,12 +2985,12 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, if ((int)parser->mark.column > max_indent) max_indent = (int)parser->mark.column; - /* Check for a tab character messing the indentation. */ + /* Check for a tab character messing the indentation. */ if ((!*indent || (int)parser->mark.column < *indent) && IS_TAB(parser->buffer)) { return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found a tab character where an indentation space is expected"); + start_mark, "found a tab character where an indentation space is expected"); } /* Have we found a non-empty line? */ @@ -3014,7 +3014,7 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, *indent = 1; } - return 1; + return 1; } /* @@ -3169,8 +3169,8 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token, *(string.pointer++) = '"'; break; - case '/': - *(string.pointer++) = '/'; + case '/': + *(string.pointer++) = '/'; break; case '\\': @@ -3287,11 +3287,11 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token, /* Check if we are at the end of the scalar. */ - /* Fix for crash unitialized value crash - * Credit for the bug and input is to OSS Fuzz - * Credit for the fix to Alex Gaynor - */ - if (!CACHE(parser, 1)) goto error; + /* Fix for crash unitialized value crash + * Credit for the bug and input is to OSS Fuzz + * Credit for the fix to Alex Gaynor + */ + if (!CACHE(parser, 1)) goto error; if (CHECK(parser->buffer, single ? '\'' : '"')) break; @@ -3439,22 +3439,22 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) while (!IS_BLANKZ(parser->buffer)) { - /* 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 - */ + /* 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, ':') - && ( - 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) - ) - ) { + && ( + 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; @@ -3464,8 +3464,8 @@ 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, '}')))) break; @@ -3527,12 +3527,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) { if (IS_BLANK(parser->buffer)) { - /* Check for tab characters that abuse indentation. */ + /* Check for tab characters that abuse indentation. */ if (leading_blanks && (int)parser->mark.column < indent && IS_TAB(parser->buffer)) { yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", - start_mark, "found a tab character that violates indentation"); + start_mark, "found a tab character that violates indentation"); goto error; } @@ -3565,7 +3565,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) if (!CACHE(parser, 1)) goto error; } - /* Check indentation level. */ + /* Check indentation level. */ if (!parser->flow_level && (int)parser->mark.column < indent) break; diff --git a/contrib/libs/yaml/src/writer.c b/contrib/libs/yaml/src/writer.c index 5d57f392f1..b90019f5cb 100644 --- a/contrib/libs/yaml/src/writer.c +++ b/contrib/libs/yaml/src/writer.c @@ -74,7 +74,7 @@ yaml_emitter_flush(yaml_emitter_t *emitter) unsigned int value; size_t k; - /* + /* * See the "reader.c" code for more details on UTF-8 encoding. Note * that we assume that the buffer contains a valid UTF-8 sequence. */ diff --git a/contrib/libs/yaml/src/yaml_private.h b/contrib/libs/yaml/src/yaml_private.h index b3351c4165..dd83d8dcf9 100644 --- a/contrib/libs/yaml/src/yaml_private.h +++ b/contrib/libs/yaml/src/yaml_private.h @@ -1,6 +1,6 @@ -#if HAVE_CONFIG_H +#if HAVE_CONFIG_H #include "config.h" -#endif +#endif #include <yaml.h> @@ -67,17 +67,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 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. */ @@ -90,7 +90,7 @@ yaml_parser_fetch_more_tokens(yaml_parser_t *parser); */ #define BUFFER_INIT(context,buffer,size) \ - (((buffer).start = (yaml_char_t *)yaml_malloc(size)) ? \ + (((buffer).start = (yaml_char_t *)yaml_malloc(size)) ? \ ((buffer).last = (buffer).pointer = (buffer).start, \ (buffer).end = (buffer).start+(size), \ 1) : \ @@ -130,7 +130,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)), \ @@ -143,12 +143,12 @@ yaml_string_join( (string).start = (string).pointer = (string).end = 0) #define STRING_EXTEND(context,string) \ - ((((string).pointer+5 < (string).end) \ + ((((string).pointer+5 < (string).end) \ || yaml_string_extend(&(string).start, \ - &(string).pointer, &(string).end)) ? \ - 1 : \ - ((context)->error = YAML_MEMORY_ERROR, \ - 0)) + &(string).pointer, &(string).end)) ? \ + 1 : \ + ((context)->error = YAML_MEMORY_ERROR, \ + 0)) #define CLEAR(context,string) \ ((string).pointer = (string).start, \ @@ -171,14 +171,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 @@ -420,10 +420,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,type) \ - (((stack).start = (type)yaml_malloc(INITIAL_STACK_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+INITIAL_STACK_SIZE, \ + (stack).end = (stack).start+INITIAL_STACK_SIZE, \ 1) : \ ((context)->error = YAML_MEMORY_ERROR, \ 0)) @@ -453,8 +453,8 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end); #define POP(context,stack) \ (*(--(stack).top)) -#define QUEUE_INIT(context,queue,size,type) \ - (((queue).start = (type)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) : \ @@ -658,27 +658,27 @@ yaml_queue_extend(void **start, void **head, void **tail, void **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) +/* 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) diff --git a/contrib/libs/yaml/ya.make b/contrib/libs/yaml/ya.make index 547a2b2a63..d408b1e2ea 100644 --- a/contrib/libs/yaml/ya.make +++ b/contrib/libs/yaml/ya.make @@ -1,5 +1,5 @@ -# Generated by devtools/yamaker from nixpkgs 21.11. - +# Generated by devtools/yamaker from nixpkgs 21.11. + LIBRARY() OWNER( @@ -7,27 +7,27 @@ OWNER( g:cpp-contrib ) -VERSION(0.2.5) +VERSION(0.2.5) ORIGINAL_SOURCE(https://github.com/yaml/libyaml/archive/0.2.5.tar.gz) -LICENSE(MIT) - -LICENSE_TEXTS(.yandex_meta/licenses.list.txt) - +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + ADDINCL( GLOBAL contrib/libs/yaml/include - contrib/libs/yaml/src + contrib/libs/yaml/src ) NO_COMPILER_WARNINGS() -NO_RUNTIME() - -CFLAGS( - -DHAVE_CONFIG_H -) - +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H +) + SRCS( src/api.c src/dumper.c |