psych 3.0.3 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +3 -6
- data/Rakefile +2 -16
- data/ext/psych/depend +2 -0
- data/ext/psych/extconf.rb +6 -2
- data/ext/psych/psych.c +6 -3
- data/ext/psych/psych_parser.c +20 -33
- data/ext/psych/psych_yaml_tree.c +0 -12
- data/ext/psych/yaml/api.c +48 -47
- data/ext/psych/yaml/config.h +77 -7
- data/ext/psych/yaml/dumper.c +3 -3
- data/ext/psych/yaml/emitter.c +48 -19
- data/ext/psych/yaml/loader.c +210 -110
- data/ext/psych/yaml/parser.c +11 -6
- data/ext/psych/yaml/reader.c +3 -3
- data/ext/psych/yaml/scanner.c +52 -28
- data/ext/psych/yaml/yaml.h +42 -28
- data/ext/psych/yaml/yaml_private.h +46 -20
- data/lib/psych.rb +171 -77
- data/lib/psych/class_loader.rb +6 -4
- data/lib/psych/handler.rb +1 -1
- data/lib/psych/nodes/node.rb +2 -2
- data/lib/psych/scalar_scanner.rb +23 -36
- data/lib/psych/versions.rb +4 -3
- data/lib/psych/visitors/to_ruby.rb +50 -17
- data/lib/psych/visitors/visitor.rb +17 -3
- data/lib/psych/visitors/yaml_tree.rb +30 -42
- data/psych.gemspec +18 -14
- metadata +10 -55
- data/.travis.yml +0 -20
- data/CHANGELOG.rdoc +0 -576
data/ext/psych/yaml/parser.c
CHANGED
@@ -605,7 +605,7 @@ yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
|
|
605
605
|
if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) {
|
606
606
|
size_t prefix_len = strlen((char *)tag_directive->prefix);
|
607
607
|
size_t suffix_len = strlen((char *)tag_suffix);
|
608
|
-
tag =
|
608
|
+
tag = YAML_MALLOC(prefix_len+suffix_len+1);
|
609
609
|
if (!tag) {
|
610
610
|
parser->error = YAML_MEMORY_ERROR;
|
611
611
|
goto error;
|
@@ -685,7 +685,7 @@ yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
|
|
685
685
|
return 1;
|
686
686
|
}
|
687
687
|
else if (anchor || tag) {
|
688
|
-
yaml_char_t *value =
|
688
|
+
yaml_char_t *value = YAML_MALLOC(1);
|
689
689
|
if (!value) {
|
690
690
|
parser->error = YAML_MEMORY_ERROR;
|
691
691
|
goto error;
|
@@ -1208,7 +1208,7 @@ yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event,
|
|
1208
1208
|
{
|
1209
1209
|
yaml_char_t *value;
|
1210
1210
|
|
1211
|
-
value =
|
1211
|
+
value = YAML_MALLOC(1);
|
1212
1212
|
if (!value) {
|
1213
1213
|
parser->error = YAML_MEMORY_ERROR;
|
1214
1214
|
return 0;
|
@@ -1245,7 +1245,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|
1245
1245
|
} tag_directives = { NULL, NULL, NULL };
|
1246
1246
|
yaml_token_t *token;
|
1247
1247
|
|
1248
|
-
if (!STACK_INIT(parser, tag_directives,
|
1248
|
+
if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
|
1249
1249
|
goto error;
|
1250
1250
|
|
1251
1251
|
token = PEEK_TOKEN(parser);
|
@@ -1261,12 +1261,15 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|
1261
1261
|
goto error;
|
1262
1262
|
}
|
1263
1263
|
if (token->data.version_directive.major != 1
|
1264
|
-
||
|
1264
|
+
|| (
|
1265
|
+
token->data.version_directive.minor != 1
|
1266
|
+
&& token->data.version_directive.minor != 2
|
1267
|
+
)) {
|
1265
1268
|
yaml_parser_set_parser_error(parser,
|
1266
1269
|
"found incompatible YAML document", token->start_mark);
|
1267
1270
|
goto error;
|
1268
1271
|
}
|
1269
|
-
version_directive =
|
1272
|
+
version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t);
|
1270
1273
|
if (!version_directive) {
|
1271
1274
|
parser->error = YAML_MEMORY_ERROR;
|
1272
1275
|
goto error;
|
@@ -1316,6 +1319,8 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|
1316
1319
|
STACK_DEL(parser, tag_directives);
|
1317
1320
|
}
|
1318
1321
|
|
1322
|
+
if (!version_directive_ref)
|
1323
|
+
yaml_free(version_directive);
|
1319
1324
|
return 1;
|
1320
1325
|
|
1321
1326
|
error:
|
data/ext/psych/yaml/reader.c
CHANGED
@@ -460,10 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
|
460
460
|
|
461
461
|
}
|
462
462
|
|
463
|
-
if (parser->offset >=
|
463
|
+
if (parser->offset >= MAX_FILE_SIZE) {
|
464
464
|
return yaml_parser_set_reader_error(parser, "input is too long",
|
465
|
-
|
465
|
+
parser->offset, -1);
|
466
|
+
}
|
466
467
|
|
467
468
|
return 1;
|
468
469
|
}
|
469
|
-
|
data/ext/psych/yaml/scanner.c
CHANGED
@@ -38,8 +38,8 @@
|
|
38
38
|
* BLOCK-END # Indentation decrease.
|
39
39
|
* FLOW-SEQUENCE-START # '['
|
40
40
|
* FLOW-SEQUENCE-END # ']'
|
41
|
-
*
|
42
|
-
*
|
41
|
+
* FLOW-MAPPING-START # '{'
|
42
|
+
* FLOW-MAPPING-END # '}'
|
43
43
|
* BLOCK-ENTRY # '-'
|
44
44
|
* FLOW-ENTRY # ','
|
45
45
|
* KEY # '?' or nothing (simple keys).
|
@@ -348,6 +348,7 @@
|
|
348
348
|
* SCALAR("another value",plain)
|
349
349
|
* KEY
|
350
350
|
* SCALAR("a mapping",plain)
|
351
|
+
* VALUE
|
351
352
|
* BLOCK-MAPPING-START
|
352
353
|
* KEY
|
353
354
|
* SCALAR("key 1",plain)
|
@@ -711,7 +712,7 @@ yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
|
|
711
712
|
yaml_mark_t start_mark, yaml_char_t **handle);
|
712
713
|
|
713
714
|
static int
|
714
|
-
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
|
715
|
+
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive,
|
715
716
|
yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri);
|
716
717
|
|
717
718
|
static int
|
@@ -1188,7 +1189,7 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
|
|
1188
1189
|
{
|
1189
1190
|
if (parser->flow_level) {
|
1190
1191
|
parser->flow_level --;
|
1191
|
-
|
1192
|
+
(void)POP(parser, parser->simple_keys);
|
1192
1193
|
}
|
1193
1194
|
|
1194
1195
|
return 1;
|
@@ -1227,7 +1228,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
|
|
1227
1228
|
return 0;
|
1228
1229
|
}
|
1229
1230
|
|
1230
|
-
parser->indent = column;
|
1231
|
+
parser->indent = (int)column;
|
1231
1232
|
|
1232
1233
|
/* Create a token and insert it into the queue. */
|
1233
1234
|
|
@@ -2292,7 +2293,7 @@ yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
|
|
2292
2293
|
|
2293
2294
|
/* Scan a prefix. */
|
2294
2295
|
|
2295
|
-
if (!yaml_parser_scan_tag_uri(parser, 1, NULL, start_mark, &prefix_value))
|
2296
|
+
if (!yaml_parser_scan_tag_uri(parser, 1, 1, NULL, start_mark, &prefix_value))
|
2296
2297
|
goto error;
|
2297
2298
|
|
2298
2299
|
/* Expect a whitespace or line break. */
|
@@ -2399,7 +2400,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
|
|
2399
2400
|
{
|
2400
2401
|
/* Set the handle to '' */
|
2401
2402
|
|
2402
|
-
handle =
|
2403
|
+
handle = YAML_MALLOC(1);
|
2403
2404
|
if (!handle) goto error;
|
2404
2405
|
handle[0] = '\0';
|
2405
2406
|
|
@@ -2410,7 +2411,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
|
|
2410
2411
|
|
2411
2412
|
/* Consume the tag value. */
|
2412
2413
|
|
2413
|
-
if (!yaml_parser_scan_tag_uri(parser, 0, NULL, start_mark, &suffix))
|
2414
|
+
if (!yaml_parser_scan_tag_uri(parser, 1, 0, NULL, start_mark, &suffix))
|
2414
2415
|
goto error;
|
2415
2416
|
|
2416
2417
|
/* Check for '>' and eat it. */
|
@@ -2438,20 +2439,20 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
|
|
2438
2439
|
{
|
2439
2440
|
/* Scan the suffix now. */
|
2440
2441
|
|
2441
|
-
if (!yaml_parser_scan_tag_uri(parser, 0, NULL, start_mark, &suffix))
|
2442
|
+
if (!yaml_parser_scan_tag_uri(parser, 0, 0, NULL, start_mark, &suffix))
|
2442
2443
|
goto error;
|
2443
2444
|
}
|
2444
2445
|
else
|
2445
2446
|
{
|
2446
2447
|
/* It wasn't a handle after all. Scan the rest of the tag. */
|
2447
2448
|
|
2448
|
-
if (!yaml_parser_scan_tag_uri(parser, 0, handle, start_mark, &suffix))
|
2449
|
+
if (!yaml_parser_scan_tag_uri(parser, 0, 0, handle, start_mark, &suffix))
|
2449
2450
|
goto error;
|
2450
2451
|
|
2451
2452
|
/* Set the handle to '!'. */
|
2452
2453
|
|
2453
2454
|
yaml_free(handle);
|
2454
|
-
handle =
|
2455
|
+
handle = YAML_MALLOC(2);
|
2455
2456
|
if (!handle) goto error;
|
2456
2457
|
handle[0] = '!';
|
2457
2458
|
handle[1] = '\0';
|
@@ -2474,9 +2475,11 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
|
|
2474
2475
|
if (!CACHE(parser, 1)) goto error;
|
2475
2476
|
|
2476
2477
|
if (!IS_BLANKZ(parser->buffer)) {
|
2477
|
-
|
2478
|
-
|
2479
|
-
|
2478
|
+
if (!parser->flow_level || !CHECK(parser->buffer, ',') ) {
|
2479
|
+
yaml_parser_set_scanner_error(parser, "while scanning a tag",
|
2480
|
+
start_mark, "did not find expected whitespace or line break");
|
2481
|
+
goto error;
|
2482
|
+
}
|
2480
2483
|
}
|
2481
2484
|
|
2482
2485
|
end_mark = parser->mark;
|
@@ -2565,7 +2568,7 @@ error:
|
|
2565
2568
|
*/
|
2566
2569
|
|
2567
2570
|
static int
|
2568
|
-
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
|
2571
|
+
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive,
|
2569
2572
|
yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri)
|
2570
2573
|
{
|
2571
2574
|
size_t length = head ? strlen((char *)head) : 0;
|
@@ -2601,8 +2604,11 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
|
|
2601
2604
|
* The set of characters that may appear in URI is as follows:
|
2602
2605
|
*
|
2603
2606
|
* '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',
|
2604
|
-
* '=', '+', '$', '
|
2605
|
-
*
|
2607
|
+
* '=', '+', '$', '.', '!', '~', '*', '\'', '(', ')', '%'.
|
2608
|
+
*
|
2609
|
+
* If we are inside a verbatim tag <...> (parameter uri_char is true)
|
2610
|
+
* then also the following flow indicators are allowed:
|
2611
|
+
* ',', '[', ']'
|
2606
2612
|
*/
|
2607
2613
|
|
2608
2614
|
while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';')
|
@@ -2610,12 +2616,15 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
|
|
2610
2616
|
|| CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@')
|
2611
2617
|
|| CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=')
|
2612
2618
|
|| CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$')
|
2613
|
-
|| CHECK(parser->buffer, '
|
2619
|
+
|| CHECK(parser->buffer, '.') || CHECK(parser->buffer, '%')
|
2614
2620
|
|| CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
|
2615
2621
|
|| CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
|
2616
2622
|
|| CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
|
2617
|
-
||
|
2618
|
-
|
2623
|
+
|| (uri_char && (
|
2624
|
+
CHECK(parser->buffer, ',')
|
2625
|
+
|| CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
|
2626
|
+
)
|
2627
|
+
))
|
2619
2628
|
{
|
2620
2629
|
/* Check if it is a URI-escape sequence. */
|
2621
2630
|
|
@@ -2860,7 +2869,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
2860
2869
|
|
2861
2870
|
if (!CACHE(parser, 1)) goto error;
|
2862
2871
|
|
2863
|
-
while ((int)parser->mark.column == indent && !IS_Z(parser->buffer))
|
2872
|
+
while ((int)parser->mark.column == indent && !(IS_Z(parser->buffer)))
|
2864
2873
|
{
|
2865
2874
|
/*
|
2866
2875
|
* We are at the beginning of a non-empty line.
|
@@ -3160,8 +3169,8 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
3160
3169
|
*(string.pointer++) = '"';
|
3161
3170
|
break;
|
3162
3171
|
|
3163
|
-
case '
|
3164
|
-
*(string.pointer++) = '
|
3172
|
+
case '/':
|
3173
|
+
*(string.pointer++) = '/';
|
3165
3174
|
break;
|
3166
3175
|
|
3167
3176
|
case '\\':
|
@@ -3278,6 +3287,11 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
3278
3287
|
|
3279
3288
|
/* Check if we are at the end of the scalar. */
|
3280
3289
|
|
3290
|
+
/* Fix for crash unitialized value crash
|
3291
|
+
* Credit for the bug and input is to OSS Fuzz
|
3292
|
+
* Credit for the fix to Alex Gaynor
|
3293
|
+
*/
|
3294
|
+
if (!CACHE(parser, 1)) goto error;
|
3281
3295
|
if (CHECK(parser->buffer, single ? '\'' : '"'))
|
3282
3296
|
break;
|
3283
3297
|
|
@@ -3425,11 +3439,22 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
3425
3439
|
|
3426
3440
|
while (!IS_BLANKZ(parser->buffer))
|
3427
3441
|
{
|
3428
|
-
/* Check for
|
3442
|
+
/* Check for "x:" + one of ',?[]{}' in the flow context. TODO: Fix the test "spec-08-13".
|
3443
|
+
* This is not completely according to the spec
|
3444
|
+
* See http://yaml.org/spec/1.1/#id907281 9.1.3. Plain
|
3445
|
+
*/
|
3429
3446
|
|
3430
3447
|
if (parser->flow_level
|
3431
3448
|
&& CHECK(parser->buffer, ':')
|
3432
|
-
&&
|
3449
|
+
&& (
|
3450
|
+
CHECK_AT(parser->buffer, ',', 1)
|
3451
|
+
|| CHECK_AT(parser->buffer, '?', 1)
|
3452
|
+
|| CHECK_AT(parser->buffer, '[', 1)
|
3453
|
+
|| CHECK_AT(parser->buffer, ']', 1)
|
3454
|
+
|| CHECK_AT(parser->buffer, '{', 1)
|
3455
|
+
|| CHECK_AT(parser->buffer, '}', 1)
|
3456
|
+
)
|
3457
|
+
) {
|
3433
3458
|
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
|
3434
3459
|
start_mark, "found unexpected ':'");
|
3435
3460
|
goto error;
|
@@ -3439,8 +3464,8 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
3439
3464
|
|
3440
3465
|
if ((CHECK(parser->buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1))
|
3441
3466
|
|| (parser->flow_level &&
|
3442
|
-
(CHECK(parser->buffer, ',')
|
3443
|
-
|| CHECK(parser->buffer, '
|
3467
|
+
(CHECK(parser->buffer, ',')
|
3468
|
+
|| CHECK(parser->buffer, '[')
|
3444
3469
|
|| CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
|
3445
3470
|
|| CHECK(parser->buffer, '}'))))
|
3446
3471
|
break;
|
@@ -3571,4 +3596,3 @@ error:
|
|
3571
3596
|
|
3572
3597
|
return 0;
|
3573
3598
|
}
|
3574
|
-
|
data/ext/psych/yaml/yaml.h
CHANGED
@@ -26,7 +26,9 @@ extern "C" {
|
|
26
26
|
|
27
27
|
/** The public API declaration. */
|
28
28
|
|
29
|
-
#
|
29
|
+
#if defined(__MINGW32__)
|
30
|
+
# define YAML_DECLARE(type) type
|
31
|
+
#elif defined(_WIN32)
|
30
32
|
# if defined(YAML_DECLARE_STATIC)
|
31
33
|
# define YAML_DECLARE(type) type
|
32
34
|
# elif defined(YAML_DECLARE_EXPORT)
|
@@ -230,7 +232,7 @@ typedef enum yaml_token_type_e {
|
|
230
232
|
|
231
233
|
/** A BLOCK-SEQUENCE-START token. */
|
232
234
|
YAML_BLOCK_SEQUENCE_START_TOKEN,
|
233
|
-
/** A BLOCK-
|
235
|
+
/** A BLOCK-MAPPING-START token. */
|
234
236
|
YAML_BLOCK_MAPPING_START_TOKEN,
|
235
237
|
/** A BLOCK-END token. */
|
236
238
|
YAML_BLOCK_END_TOKEN,
|
@@ -550,7 +552,7 @@ yaml_document_end_event_initialize(yaml_event_t *event, int implicit);
|
|
550
552
|
*/
|
551
553
|
|
552
554
|
YAML_DECLARE(int)
|
553
|
-
yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor);
|
555
|
+
yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor);
|
554
556
|
|
555
557
|
/**
|
556
558
|
* Create a SCALAR event.
|
@@ -576,8 +578,8 @@ yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor);
|
|
576
578
|
|
577
579
|
YAML_DECLARE(int)
|
578
580
|
yaml_scalar_event_initialize(yaml_event_t *event,
|
579
|
-
yaml_char_t *anchor, yaml_char_t *tag,
|
580
|
-
yaml_char_t *value, int length,
|
581
|
+
const yaml_char_t *anchor, const yaml_char_t *tag,
|
582
|
+
const yaml_char_t *value, int length,
|
581
583
|
int plain_implicit, int quoted_implicit,
|
582
584
|
yaml_scalar_style_t style);
|
583
585
|
|
@@ -599,7 +601,7 @@ yaml_scalar_event_initialize(yaml_event_t *event,
|
|
599
601
|
|
600
602
|
YAML_DECLARE(int)
|
601
603
|
yaml_sequence_start_event_initialize(yaml_event_t *event,
|
602
|
-
yaml_char_t *anchor, yaml_char_t *tag, int implicit,
|
604
|
+
const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
|
603
605
|
yaml_sequence_style_t style);
|
604
606
|
|
605
607
|
/**
|
@@ -631,7 +633,7 @@ yaml_sequence_end_event_initialize(yaml_event_t *event);
|
|
631
633
|
|
632
634
|
YAML_DECLARE(int)
|
633
635
|
yaml_mapping_start_event_initialize(yaml_event_t *event,
|
634
|
-
yaml_char_t *anchor, yaml_char_t *tag, int implicit,
|
636
|
+
const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
|
635
637
|
yaml_mapping_style_t style);
|
636
638
|
|
637
639
|
/**
|
@@ -663,7 +665,7 @@ yaml_event_delete(yaml_event_t *event);
|
|
663
665
|
|
664
666
|
/** The tag @c !!null with the only possible value: @c null. */
|
665
667
|
#define YAML_NULL_TAG "tag:yaml.org,2002:null"
|
666
|
-
/** The tag @c !!bool with the values: @c true and @c
|
668
|
+
/** The tag @c !!bool with the values: @c true and @c false. */
|
667
669
|
#define YAML_BOOL_TAG "tag:yaml.org,2002:bool"
|
668
670
|
/** The tag @c !!str for string values. */
|
669
671
|
#define YAML_STR_TAG "tag:yaml.org,2002:str"
|
@@ -894,7 +896,7 @@ yaml_document_get_root_node(yaml_document_t *document);
|
|
894
896
|
|
895
897
|
YAML_DECLARE(int)
|
896
898
|
yaml_document_add_scalar(yaml_document_t *document,
|
897
|
-
yaml_char_t *tag, yaml_char_t *value, int length,
|
899
|
+
const yaml_char_t *tag, const yaml_char_t *value, int length,
|
898
900
|
yaml_scalar_style_t style);
|
899
901
|
|
900
902
|
/**
|
@@ -911,7 +913,7 @@ yaml_document_add_scalar(yaml_document_t *document,
|
|
911
913
|
|
912
914
|
YAML_DECLARE(int)
|
913
915
|
yaml_document_add_sequence(yaml_document_t *document,
|
914
|
-
yaml_char_t *tag, yaml_sequence_style_t style);
|
916
|
+
const yaml_char_t *tag, yaml_sequence_style_t style);
|
915
917
|
|
916
918
|
/**
|
917
919
|
* Create a MAPPING node and attach it to the document.
|
@@ -927,7 +929,7 @@ yaml_document_add_sequence(yaml_document_t *document,
|
|
927
929
|
|
928
930
|
YAML_DECLARE(int)
|
929
931
|
yaml_document_add_mapping(yaml_document_t *document,
|
930
|
-
yaml_char_t *tag, yaml_mapping_style_t style);
|
932
|
+
const yaml_char_t *tag, yaml_mapping_style_t style);
|
931
933
|
|
932
934
|
/**
|
933
935
|
* Add an item to a SEQUENCE node.
|
@@ -935,7 +937,7 @@ yaml_document_add_mapping(yaml_document_t *document,
|
|
935
937
|
* @param[in,out] document A document object.
|
936
938
|
* @param[in] sequence The sequence node id.
|
937
939
|
* @param[in] item The item node id.
|
938
|
-
*
|
940
|
+
*
|
939
941
|
* @returns @c 1 if the function succeeded, @c 0 on error.
|
940
942
|
*/
|
941
943
|
|
@@ -950,7 +952,7 @@ yaml_document_append_sequence_item(yaml_document_t *document,
|
|
950
952
|
* @param[in] mapping The mapping node id.
|
951
953
|
* @param[in] key The key node id.
|
952
954
|
* @param[in] value The value node id.
|
953
|
-
*
|
955
|
+
*
|
954
956
|
* @returns @c 1 if the function succeeded, @c 0 on error.
|
955
957
|
*/
|
956
958
|
|
@@ -1018,6 +1020,7 @@ typedef enum yaml_parser_state_e {
|
|
1018
1020
|
YAML_PARSE_DOCUMENT_CONTENT_STATE,
|
1019
1021
|
/** Expect DOCUMENT-END. */
|
1020
1022
|
YAML_PARSE_DOCUMENT_END_STATE,
|
1023
|
+
|
1021
1024
|
/** Expect a block node. */
|
1022
1025
|
YAML_PARSE_BLOCK_NODE_STATE,
|
1023
1026
|
/** Expect a block node or indentless sequence. */
|
@@ -1028,6 +1031,7 @@ typedef enum yaml_parser_state_e {
|
|
1028
1031
|
YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE,
|
1029
1032
|
/** Expect an entry of a block sequence. */
|
1030
1033
|
YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE,
|
1034
|
+
|
1031
1035
|
/** Expect an entry of an indentless sequence. */
|
1032
1036
|
YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE,
|
1033
1037
|
/** Expect the first key of a block mapping. */
|
@@ -1038,6 +1042,7 @@ typedef enum yaml_parser_state_e {
|
|
1038
1042
|
YAML_PARSE_BLOCK_MAPPING_VALUE_STATE,
|
1039
1043
|
/** Expect the first entry of a flow sequence. */
|
1040
1044
|
YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE,
|
1045
|
+
|
1041
1046
|
/** Expect an entry of a flow sequence. */
|
1042
1047
|
YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE,
|
1043
1048
|
/** Expect a key of an ordered mapping. */
|
@@ -1049,6 +1054,7 @@ typedef enum yaml_parser_state_e {
|
|
1049
1054
|
/** Expect the first key of a flow mapping. */
|
1050
1055
|
YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE,
|
1051
1056
|
/** Expect a key of a flow mapping. */
|
1057
|
+
|
1052
1058
|
YAML_PARSE_FLOW_MAPPING_KEY_STATE,
|
1053
1059
|
/** Expect a value of a flow mapping. */
|
1054
1060
|
YAML_PARSE_FLOW_MAPPING_VALUE_STATE,
|
@@ -1089,7 +1095,7 @@ typedef struct yaml_parser_s {
|
|
1089
1095
|
yaml_error_type_t error;
|
1090
1096
|
/** Error description. */
|
1091
1097
|
const char *problem;
|
1092
|
-
/** The byte about which the problem
|
1098
|
+
/** The byte about which the problem occured. */
|
1093
1099
|
size_t problem_offset;
|
1094
1100
|
/** The problematic value (@c -1 is none). */
|
1095
1101
|
int problem_value;
|
@@ -1203,7 +1209,7 @@ typedef struct yaml_parser_s {
|
|
1203
1209
|
/** The number of tokens fetched from the queue. */
|
1204
1210
|
size_t tokens_parsed;
|
1205
1211
|
|
1206
|
-
|
1212
|
+
/** Does the tokens queue contain a token ready for dequeueing. */
|
1207
1213
|
int token_available;
|
1208
1214
|
|
1209
1215
|
/** The indentation levels stack. */
|
@@ -1444,7 +1450,7 @@ yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
|
|
1444
1450
|
* @param[in,out] parser A parser object.
|
1445
1451
|
* @param[out] document An empty document object.
|
1446
1452
|
*
|
1447
|
-
* @
|
1453
|
+
* @returns @c 1 if the function succeeded, @c 0 on error.
|
1448
1454
|
*/
|
1449
1455
|
|
1450
1456
|
YAML_DECLARE(int)
|
@@ -1487,6 +1493,7 @@ typedef enum yaml_emitter_state_e {
|
|
1487
1493
|
YAML_EMIT_DOCUMENT_CONTENT_STATE,
|
1488
1494
|
/** Expect DOCUMENT-END. */
|
1489
1495
|
YAML_EMIT_DOCUMENT_END_STATE,
|
1496
|
+
|
1490
1497
|
/** Expect the first item of a flow sequence. */
|
1491
1498
|
YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE,
|
1492
1499
|
/** Expect an item of a flow sequence. */
|
@@ -1497,6 +1504,7 @@ typedef enum yaml_emitter_state_e {
|
|
1497
1504
|
YAML_EMIT_FLOW_MAPPING_KEY_STATE,
|
1498
1505
|
/** Expect a value for a simple key of a flow mapping. */
|
1499
1506
|
YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE,
|
1507
|
+
|
1500
1508
|
/** Expect a value of a flow mapping. */
|
1501
1509
|
YAML_EMIT_FLOW_MAPPING_VALUE_STATE,
|
1502
1510
|
/** Expect the first item of a block sequence. */
|
@@ -1507,6 +1515,7 @@ typedef enum yaml_emitter_state_e {
|
|
1507
1515
|
YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE,
|
1508
1516
|
/** Expect the key of a block mapping. */
|
1509
1517
|
YAML_EMIT_BLOCK_MAPPING_KEY_STATE,
|
1518
|
+
|
1510
1519
|
/** Expect a value for a simple key of a block mapping. */
|
1511
1520
|
YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE,
|
1512
1521
|
/** Expect a value of a block mapping. */
|
@@ -1515,6 +1524,18 @@ typedef enum yaml_emitter_state_e {
|
|
1515
1524
|
YAML_EMIT_END_STATE
|
1516
1525
|
} yaml_emitter_state_t;
|
1517
1526
|
|
1527
|
+
|
1528
|
+
/* This is needed for C++ */
|
1529
|
+
|
1530
|
+
typedef struct yaml_anchors_s {
|
1531
|
+
/** The number of references. */
|
1532
|
+
int references;
|
1533
|
+
/** The anchor id. */
|
1534
|
+
int anchor;
|
1535
|
+
/** If the node has been emitted? */
|
1536
|
+
int serialized;
|
1537
|
+
} yaml_anchors_t;
|
1538
|
+
|
1518
1539
|
/**
|
1519
1540
|
* The emitter structure.
|
1520
1541
|
*
|
@@ -1546,7 +1567,7 @@ typedef struct yaml_emitter_s {
|
|
1546
1567
|
/** Write handler. */
|
1547
1568
|
yaml_write_handler_t *write_handler;
|
1548
1569
|
|
1549
|
-
/** A pointer for passing to the
|
1570
|
+
/** A pointer for passing to the write handler. */
|
1550
1571
|
void *write_handler_data;
|
1551
1572
|
|
1552
1573
|
/** Standard (string or file) output data. */
|
@@ -1713,7 +1734,7 @@ typedef struct yaml_emitter_s {
|
|
1713
1734
|
size_t length;
|
1714
1735
|
/** Does the scalar contain line breaks? */
|
1715
1736
|
int multiline;
|
1716
|
-
/** Can the scalar be
|
1737
|
+
/** Can the scalar be expressed in the flow plain style? */
|
1717
1738
|
int flow_plain_allowed;
|
1718
1739
|
/** Can the scalar be expressed in the block plain style? */
|
1719
1740
|
int block_plain_allowed;
|
@@ -1740,14 +1761,7 @@ typedef struct yaml_emitter_s {
|
|
1740
1761
|
int closed;
|
1741
1762
|
|
1742
1763
|
/** The information associated with the document nodes. */
|
1743
|
-
|
1744
|
-
/** The number of references. */
|
1745
|
-
int references;
|
1746
|
-
/** The anchor id. */
|
1747
|
-
int anchor;
|
1748
|
-
/** If the node has been emitted? */
|
1749
|
-
int serialized;
|
1750
|
-
} *anchors;
|
1764
|
+
yaml_anchors_t *anchors;
|
1751
1765
|
|
1752
1766
|
/** The last assigned anchor id. */
|
1753
1767
|
int last_anchor_id;
|
@@ -1938,8 +1952,8 @@ yaml_emitter_close(yaml_emitter_t *emitter);
|
|
1938
1952
|
*
|
1939
1953
|
* The documen object may be generated using the yaml_parser_load() function
|
1940
1954
|
* or the yaml_document_initialize() function. The emitter takes the
|
1941
|
-
* responsibility for the document object and
|
1942
|
-
* it is emitted. The document object is
|
1955
|
+
* responsibility for the document object and destroys its content after
|
1956
|
+
* it is emitted. The document object is destroyed even if the function fails.
|
1943
1957
|
*
|
1944
1958
|
* @param[in,out] emitter An emitter object.
|
1945
1959
|
* @param[in,out] document A document object.
|