psych-shopifork 2.0.3 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.rdoc +17 -0
- data/ext/psych/yaml/api.c +39 -16
- data/ext/psych/yaml/config.h +4 -5
- data/ext/psych/yaml/emitter.c +8 -8
- data/ext/psych/yaml/loader.c +18 -3
- data/ext/psych/yaml/parser.c +5 -9
- data/ext/psych/yaml/reader.c +3 -3
- data/ext/psych/yaml/scanner.c +12 -9
- data/ext/psych/yaml/writer.c +1 -1
- data/ext/psych/yaml/yaml_private.h +12 -5
- data/lib/psych.rb +1 -1
- data/lib/psych/visitors/to_ruby.rb +2 -0
- data/lib/psych/visitors/yaml_tree.rb +5 -0
- data/test/psych/test_encoding.rb +5 -0
- data/test/psych/test_string.rb +1 -1
- data/test/psych/test_yaml.rb +1 -2
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e2f3338b6772bcae59dd47d00176c3dfa5c6f31
|
4
|
+
data.tar.gz: 82e508c6a44a897d3859f4e9119f996ba65c300a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d6c099340d0d0a38e29c7fdfffeb088fa35f342785b98f89814ad5fe781ecb51db37cd934f11eb9cab548c5af97989cbc60237988b0e3a6b4cd52415634a08
|
7
|
+
data.tar.gz: 70690a0824b6bba21d3e65dbd4cbeb97ef7d27c72d1fc617faf279d87d8556bc205532b7da132a0186f0444821a60dd1ad6fdfbdef88c5425bf7e4850fa4f11c
|
data/.travis.yml
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
2014-03-27 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
2
|
+
|
3
|
+
* ext/psych/yaml/scanner.c: merge libyaml 0.1.6
|
4
|
+
* ext/psych/yaml/yaml_private.h: ditto
|
5
|
+
|
6
|
+
Sat Mar 1 11:08:00 2014 Aaron Patterson <aaron@tenderlovemaking.com>
|
7
|
+
|
8
|
+
* ext/psych/lib/psych/visitors/yaml_tree.rb: support dumping Encoding
|
9
|
+
objects.
|
10
|
+
|
11
|
+
* ext/psych/lib/psych/visitors/to_ruby.rb: support loading Encoding
|
12
|
+
objects.
|
13
|
+
|
14
|
+
* test/psych/test_encoding.rb: add test
|
15
|
+
|
16
|
+
* ext/psych/lib/psych.rb: add version
|
17
|
+
|
1
18
|
Wed Feb 5 10:11:36 2014 Zachary Scott <e@zzak.io>
|
2
19
|
|
3
20
|
* ext/psych/yaml/config.h: bump libyaml to 0.1.5
|
data/ext/psych/yaml/api.c
CHANGED
@@ -395,7 +395,7 @@ yaml_emitter_delete(yaml_emitter_t *emitter)
|
|
395
395
|
}
|
396
396
|
QUEUE_DEL(emitter, emitter->events);
|
397
397
|
STACK_DEL(emitter, emitter->indents);
|
398
|
-
while (!STACK_EMPTY(
|
398
|
+
while (!STACK_EMPTY(emitter, emitter->tag_directives)) {
|
399
399
|
yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives);
|
400
400
|
yaml_free(tag_directive.handle);
|
401
401
|
yaml_free(tag_directive.prefix);
|
@@ -822,6 +822,7 @@ yaml_scalar_event_initialize(yaml_event_t *event,
|
|
822
822
|
yaml_char_t *anchor_copy = NULL;
|
823
823
|
yaml_char_t *tag_copy = NULL;
|
824
824
|
yaml_char_t *value_copy = NULL;
|
825
|
+
size_t value_length;
|
825
826
|
|
826
827
|
assert(event); /* Non-NULL event object is expected. */
|
827
828
|
assert(value); /* Non-NULL anchor is expected. */
|
@@ -839,16 +840,19 @@ yaml_scalar_event_initialize(yaml_event_t *event,
|
|
839
840
|
}
|
840
841
|
|
841
842
|
if (length < 0) {
|
842
|
-
|
843
|
+
value_length = strlen((char *)value);
|
844
|
+
}
|
845
|
+
else {
|
846
|
+
value_length = (size_t)length;
|
843
847
|
}
|
844
848
|
|
845
|
-
if (!yaml_check_utf8(value,
|
846
|
-
value_copy = yaml_malloc(
|
849
|
+
if (!yaml_check_utf8(value, value_length)) goto error;
|
850
|
+
value_copy = yaml_malloc(value_length+1);
|
847
851
|
if (!value_copy) goto error;
|
848
|
-
memcpy(value_copy, value,
|
849
|
-
value_copy[
|
852
|
+
memcpy(value_copy, value, value_length);
|
853
|
+
value_copy[value_length] = '\0';
|
850
854
|
|
851
|
-
SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy,
|
855
|
+
SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, value_length,
|
852
856
|
plain_implicit, quoted_implicit, style, mark, mark);
|
853
857
|
|
854
858
|
return 1;
|
@@ -1202,6 +1206,8 @@ yaml_document_add_scalar(yaml_document_t *document,
|
|
1202
1206
|
yaml_char_t *tag_copy = NULL;
|
1203
1207
|
yaml_char_t *value_copy = NULL;
|
1204
1208
|
yaml_node_t node;
|
1209
|
+
size_t value_length;
|
1210
|
+
ptrdiff_t ret;
|
1205
1211
|
|
1206
1212
|
assert(document); /* Non-NULL document object is expected. */
|
1207
1213
|
assert(value); /* Non-NULL value is expected. */
|
@@ -1215,19 +1221,26 @@ yaml_document_add_scalar(yaml_document_t *document,
|
|
1215
1221
|
if (!tag_copy) goto error;
|
1216
1222
|
|
1217
1223
|
if (length < 0) {
|
1218
|
-
|
1224
|
+
value_length = strlen((char *)value);
|
1225
|
+
}
|
1226
|
+
else {
|
1227
|
+
value_length = (size_t)length;
|
1219
1228
|
}
|
1220
1229
|
|
1221
|
-
if (!yaml_check_utf8(value,
|
1222
|
-
value_copy = yaml_malloc(
|
1230
|
+
if (!yaml_check_utf8(value, value_length)) goto error;
|
1231
|
+
value_copy = yaml_malloc(value_length+1);
|
1223
1232
|
if (!value_copy) goto error;
|
1224
|
-
memcpy(value_copy, value,
|
1225
|
-
value_copy[
|
1233
|
+
memcpy(value_copy, value, value_length);
|
1234
|
+
value_copy[value_length] = '\0';
|
1226
1235
|
|
1227
|
-
SCALAR_NODE_INIT(node, tag_copy, value_copy,
|
1236
|
+
SCALAR_NODE_INIT(node, tag_copy, value_copy, value_length, style, mark, mark);
|
1228
1237
|
if (!PUSH(&context, document->nodes, node)) goto error;
|
1229
1238
|
|
1230
|
-
|
1239
|
+
ret = document->nodes.top - document->nodes.start;
|
1240
|
+
#if PTRDIFF_MAX > INT_MAX
|
1241
|
+
if (ret > INT_MAX) goto error;
|
1242
|
+
#endif
|
1243
|
+
return (int)ret;
|
1231
1244
|
|
1232
1245
|
error:
|
1233
1246
|
yaml_free(tag_copy);
|
@@ -1255,6 +1268,7 @@ yaml_document_add_sequence(yaml_document_t *document,
|
|
1255
1268
|
yaml_node_item_t *top;
|
1256
1269
|
} items = { NULL, NULL, NULL };
|
1257
1270
|
yaml_node_t node;
|
1271
|
+
ptrdiff_t ret;
|
1258
1272
|
|
1259
1273
|
assert(document); /* Non-NULL document object is expected. */
|
1260
1274
|
|
@@ -1272,7 +1286,11 @@ yaml_document_add_sequence(yaml_document_t *document,
|
|
1272
1286
|
style, mark, mark);
|
1273
1287
|
if (!PUSH(&context, document->nodes, node)) goto error;
|
1274
1288
|
|
1275
|
-
|
1289
|
+
ret = document->nodes.top - document->nodes.start;
|
1290
|
+
#if PTRDIFF_MAX > INT_MAX
|
1291
|
+
if (ret > INT_MAX) goto error;
|
1292
|
+
#endif
|
1293
|
+
return (int)ret;
|
1276
1294
|
|
1277
1295
|
error:
|
1278
1296
|
STACK_DEL(&context, items);
|
@@ -1300,6 +1318,7 @@ yaml_document_add_mapping(yaml_document_t *document,
|
|
1300
1318
|
yaml_node_pair_t *top;
|
1301
1319
|
} pairs = { NULL, NULL, NULL };
|
1302
1320
|
yaml_node_t node;
|
1321
|
+
ptrdiff_t ret;
|
1303
1322
|
|
1304
1323
|
assert(document); /* Non-NULL document object is expected. */
|
1305
1324
|
|
@@ -1317,7 +1336,11 @@ yaml_document_add_mapping(yaml_document_t *document,
|
|
1317
1336
|
style, mark, mark);
|
1318
1337
|
if (!PUSH(&context, document->nodes, node)) goto error;
|
1319
1338
|
|
1320
|
-
|
1339
|
+
ret = document->nodes.top - document->nodes.start;
|
1340
|
+
#if PTRDIFF_MAX > INT_MAX
|
1341
|
+
if (ret > INT_MAX) goto error;
|
1342
|
+
#endif
|
1343
|
+
return (int)ret;
|
1321
1344
|
|
1322
1345
|
error:
|
1323
1346
|
STACK_DEL(&context, pairs);
|
data/ext/psych/yaml/config.h
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
|
2
1
|
#define PACKAGE_NAME "yaml"
|
3
2
|
#define PACKAGE_TARNAME "yaml"
|
4
|
-
#define PACKAGE_VERSION "0.1.
|
5
|
-
#define PACKAGE_STRING "yaml 0.1.
|
3
|
+
#define PACKAGE_VERSION "0.1.6"
|
4
|
+
#define PACKAGE_STRING "yaml 0.1.6"
|
6
5
|
#define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component libyaml"
|
7
6
|
#define PACKAGE_URL ""
|
8
7
|
#define YAML_VERSION_MAJOR 0
|
9
8
|
#define YAML_VERSION_MINOR 1
|
10
|
-
#define YAML_VERSION_PATCH
|
11
|
-
#define YAML_VERSION_STRING "0.1.
|
9
|
+
#define YAML_VERSION_PATCH 6
|
10
|
+
#define YAML_VERSION_STRING "0.1.6"
|
data/ext/psych/yaml/emitter.c
CHANGED
@@ -53,7 +53,7 @@
|
|
53
53
|
#define WRITE_BREAK(emitter,string) \
|
54
54
|
(FLUSH(emitter) \
|
55
55
|
&& (CHECK(string,'\n') ? \
|
56
|
-
(PUT_BREAK(emitter),
|
56
|
+
((void)PUT_BREAK(emitter), \
|
57
57
|
string.pointer ++, \
|
58
58
|
1) : \
|
59
59
|
(COPY(emitter->buffer,string), \
|
@@ -221,7 +221,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter);
|
|
221
221
|
|
222
222
|
static int
|
223
223
|
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
|
224
|
-
char *indicator, int need_whitespace,
|
224
|
+
const char *indicator, int need_whitespace,
|
225
225
|
int is_whitespace, int is_indention);
|
226
226
|
|
227
227
|
static int
|
@@ -517,7 +517,7 @@ yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
|
|
517
517
|
if (emitter->best_width < 0) {
|
518
518
|
emitter->best_width = INT_MAX;
|
519
519
|
}
|
520
|
-
|
520
|
+
|
521
521
|
if (!emitter->line_break) {
|
522
522
|
emitter->line_break = YAML_LN_BREAK;
|
523
523
|
}
|
@@ -607,7 +607,7 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
|
|
607
607
|
if (!yaml_emitter_write_indent(emitter))
|
608
608
|
return 0;
|
609
609
|
}
|
610
|
-
|
610
|
+
|
611
611
|
if (event->data.document_start.tag_directives.start
|
612
612
|
!= event->data.document_start.tag_directives.end) {
|
613
613
|
implicit = 0;
|
@@ -721,7 +721,7 @@ yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
|
|
721
721
|
}
|
722
722
|
|
723
723
|
/*
|
724
|
-
*
|
724
|
+
*
|
725
725
|
* Expect a flow item node.
|
726
726
|
*/
|
727
727
|
|
@@ -1402,7 +1402,7 @@ yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
|
|
1402
1402
|
{
|
1403
1403
|
size_t anchor_length;
|
1404
1404
|
yaml_string_t string;
|
1405
|
-
|
1405
|
+
|
1406
1406
|
anchor_length = strlen((char *)anchor);
|
1407
1407
|
STRING_ASSIGN(string, anchor, anchor_length);
|
1408
1408
|
|
@@ -1784,7 +1784,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter)
|
|
1784
1784
|
|
1785
1785
|
static int
|
1786
1786
|
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
|
1787
|
-
char *indicator, int need_whitespace,
|
1787
|
+
const char *indicator, int need_whitespace,
|
1788
1788
|
int is_whitespace, int is_indention)
|
1789
1789
|
{
|
1790
1790
|
size_t indicator_length;
|
@@ -2184,7 +2184,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
|
|
2184
2184
|
yaml_string_t string)
|
2185
2185
|
{
|
2186
2186
|
char indent_hint[2];
|
2187
|
-
char *chomp_hint = NULL;
|
2187
|
+
const char *chomp_hint = NULL;
|
2188
2188
|
|
2189
2189
|
if (IS_SPACE(string) || IS_BREAK(string))
|
2190
2190
|
{
|
data/ext/psych/yaml/loader.c
CHANGED
@@ -283,6 +283,7 @@ static int
|
|
283
283
|
yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
|
284
284
|
{
|
285
285
|
yaml_node_t node;
|
286
|
+
ptrdiff_t node_index;
|
286
287
|
int index;
|
287
288
|
yaml_char_t *tag = first_event->data.scalar.tag;
|
288
289
|
|
@@ -300,7 +301,11 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
300
301
|
|
301
302
|
if (!PUSH(parser, parser->document->nodes, node)) goto error;
|
302
303
|
|
303
|
-
|
304
|
+
node_index = parser->document->nodes.top - parser->document->nodes.start;
|
305
|
+
#if PTRDIFF_MAX > INT_MAX
|
306
|
+
if (node_index > INT_MAX) goto error;
|
307
|
+
#endif
|
308
|
+
index = (int)node_index;
|
304
309
|
|
305
310
|
if (!yaml_parser_register_anchor(parser, index,
|
306
311
|
first_event->data.scalar.anchor)) return 0;
|
@@ -329,6 +334,7 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
329
334
|
yaml_node_item_t *top;
|
330
335
|
} items = { NULL, NULL, NULL };
|
331
336
|
int index, item_index;
|
337
|
+
ptrdiff_t node_index;
|
332
338
|
yaml_char_t *tag = first_event->data.sequence_start.tag;
|
333
339
|
|
334
340
|
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
|
@@ -347,7 +353,11 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
347
353
|
|
348
354
|
if (!PUSH(parser, parser->document->nodes, node)) goto error;
|
349
355
|
|
350
|
-
|
356
|
+
node_index = parser->document->nodes.top - parser->document->nodes.start;
|
357
|
+
#if PTRDIFF_MAX > INT_MAX
|
358
|
+
if (node_index > INT_MAX) goto error;
|
359
|
+
#endif
|
360
|
+
index = (int)node_index;
|
351
361
|
|
352
362
|
if (!yaml_parser_register_anchor(parser, index,
|
353
363
|
first_event->data.sequence_start.anchor)) return 0;
|
@@ -391,6 +401,7 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
391
401
|
yaml_node_pair_t *top;
|
392
402
|
} pairs = { NULL, NULL, NULL };
|
393
403
|
int index;
|
404
|
+
ptrdiff_t node_index;
|
394
405
|
yaml_node_pair_t pair;
|
395
406
|
yaml_char_t *tag = first_event->data.mapping_start.tag;
|
396
407
|
|
@@ -410,7 +421,11 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
410
421
|
|
411
422
|
if (!PUSH(parser, parser->document->nodes, node)) goto error;
|
412
423
|
|
413
|
-
|
424
|
+
node_index = parser->document->nodes.top - parser->document->nodes.start;
|
425
|
+
#if PTRDIFF_MAX > INT_MAX
|
426
|
+
if (node_index > INT_MAX) goto error;
|
427
|
+
#endif
|
428
|
+
index = (int)node_index;
|
414
429
|
|
415
430
|
if (!yaml_parser_register_anchor(parser, index,
|
416
431
|
first_event->data.mapping_start.anchor)) return 0;
|
data/ext/psych/yaml/parser.c
CHANGED
@@ -759,9 +759,8 @@ yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
|
|
759
759
|
|
760
760
|
else if (token->type == YAML_BLOCK_END_TOKEN)
|
761
761
|
{
|
762
|
-
yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
|
763
762
|
parser->state = POP(parser, parser->states);
|
764
|
-
|
763
|
+
(void)POP(parser, parser->marks);
|
765
764
|
SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
766
765
|
SKIP_TOKEN(parser);
|
767
766
|
return 1;
|
@@ -869,9 +868,8 @@ yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
|
|
869
868
|
|
870
869
|
else if (token->type == YAML_BLOCK_END_TOKEN)
|
871
870
|
{
|
872
|
-
yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
|
873
871
|
parser->state = POP(parser, parser->states);
|
874
|
-
|
872
|
+
(void)POP(parser, parser->marks);
|
875
873
|
MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
876
874
|
SKIP_TOKEN(parser);
|
877
875
|
return 1;
|
@@ -952,7 +950,6 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
|
|
952
950
|
yaml_event_t *event, int first)
|
953
951
|
{
|
954
952
|
yaml_token_t *token;
|
955
|
-
yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
|
956
953
|
|
957
954
|
if (first) {
|
958
955
|
token = PEEK_TOKEN(parser);
|
@@ -997,7 +994,7 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
|
|
997
994
|
}
|
998
995
|
|
999
996
|
parser->state = POP(parser, parser->states);
|
1000
|
-
|
997
|
+
(void)POP(parser, parser->marks);
|
1001
998
|
SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
1002
999
|
SKIP_TOKEN(parser);
|
1003
1000
|
return 1;
|
@@ -1104,7 +1101,6 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
|
|
1104
1101
|
yaml_event_t *event, int first)
|
1105
1102
|
{
|
1106
1103
|
yaml_token_t *token;
|
1107
|
-
yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
|
1108
1104
|
|
1109
1105
|
if (first) {
|
1110
1106
|
token = PEEK_TOKEN(parser);
|
@@ -1158,7 +1154,7 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
|
|
1158
1154
|
}
|
1159
1155
|
|
1160
1156
|
parser->state = POP(parser, parser->states);
|
1161
|
-
|
1157
|
+
(void)POP(parser, parser->marks);
|
1162
1158
|
MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
1163
1159
|
SKIP_TOKEN(parser);
|
1164
1160
|
return 1;
|
@@ -1295,7 +1291,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|
1295
1291
|
token = PEEK_TOKEN(parser);
|
1296
1292
|
if (!token) goto error;
|
1297
1293
|
}
|
1298
|
-
|
1294
|
+
|
1299
1295
|
for (default_tag_directive = default_tag_directives;
|
1300
1296
|
default_tag_directive->handle; default_tag_directive++) {
|
1301
1297
|
if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
|
data/ext/psych/yaml/reader.c
CHANGED
@@ -52,7 +52,7 @@ yaml_parser_determine_encoding(yaml_parser_t *parser)
|
|
52
52
|
{
|
53
53
|
/* Ensure that we had enough bytes in the raw buffer. */
|
54
54
|
|
55
|
-
while (!parser->eof
|
55
|
+
while (!parser->eof
|
56
56
|
&& parser->raw_buffer.last - parser->raw_buffer.pointer < 3) {
|
57
57
|
if (!yaml_parser_update_raw_buffer(parser)) {
|
58
58
|
return 0;
|
@@ -295,7 +295,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
|
295
295
|
parser->offset, value);
|
296
296
|
|
297
297
|
break;
|
298
|
-
|
298
|
+
|
299
299
|
case YAML_UTF16LE_ENCODING:
|
300
300
|
case YAML_UTF16BE_ENCODING:
|
301
301
|
|
@@ -318,7 +318,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
|
318
318
|
*
|
319
319
|
* The following formulas are used for decoding
|
320
320
|
* and encoding characters using surrogate pairs:
|
321
|
-
*
|
321
|
+
*
|
322
322
|
* U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF)
|
323
323
|
* U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF)
|
324
324
|
* W1 = 110110yyyyyyyyyy
|
data/ext/psych/yaml/scanner.c
CHANGED
@@ -762,7 +762,7 @@ yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
|
|
762
762
|
}
|
763
763
|
|
764
764
|
/* Fetch the next token from the queue. */
|
765
|
-
|
765
|
+
|
766
766
|
*token = DEQUEUE(parser, parser->tokens);
|
767
767
|
parser->token_available = 0;
|
768
768
|
parser->tokens_parsed ++;
|
@@ -1121,7 +1121,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
|
|
1121
1121
|
yaml_simple_key_t simple_key;
|
1122
1122
|
simple_key.possible = 1;
|
1123
1123
|
simple_key.required = required;
|
1124
|
-
simple_key.token_number =
|
1124
|
+
simple_key.token_number =
|
1125
1125
|
parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
|
1126
1126
|
simple_key.mark = parser->mark;
|
1127
1127
|
|
@@ -1193,11 +1193,9 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser)
|
|
1193
1193
|
static int
|
1194
1194
|
yaml_parser_decrease_flow_level(yaml_parser_t *parser)
|
1195
1195
|
{
|
1196
|
-
yaml_simple_key_t dummy_key; /* Used to eliminate a compiler warning. */
|
1197
|
-
|
1198
1196
|
if (parser->flow_level) {
|
1199
1197
|
parser->flow_level --;
|
1200
|
-
|
1198
|
+
(void)POP(parser, parser->simple_keys);
|
1201
1199
|
}
|
1202
1200
|
|
1203
1201
|
return 1;
|
@@ -1207,7 +1205,7 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
|
|
1207
1205
|
* Push the current indentation level to the stack and set the new level
|
1208
1206
|
* the current column is greater than the indentation level. In this case,
|
1209
1207
|
* append or insert the specified token into the token queue.
|
1210
|
-
*
|
1208
|
+
*
|
1211
1209
|
*/
|
1212
1210
|
|
1213
1211
|
static int
|
@@ -1231,12 +1229,14 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
|
|
1231
1229
|
if (!PUSH(parser, parser->indents, parser->indent))
|
1232
1230
|
return 0;
|
1233
1231
|
|
1232
|
+
#if PTRDIFF_MAX > INT_MAX
|
1234
1233
|
if (column > INT_MAX) {
|
1235
1234
|
parser->error = YAML_MEMORY_ERROR;
|
1236
1235
|
return 0;
|
1237
1236
|
}
|
1237
|
+
#endif
|
1238
1238
|
|
1239
|
-
parser->indent = column;
|
1239
|
+
parser->indent = (int)column;
|
1240
1240
|
|
1241
1241
|
/* Create a token and insert it into the queue. */
|
1242
1242
|
|
@@ -1945,7 +1945,7 @@ yaml_parser_scan_to_next_token(yaml_parser_t *parser)
|
|
1945
1945
|
*
|
1946
1946
|
* - in the flow context;
|
1947
1947
|
* - in the block context, but not at the beginning of the line or
|
1948
|
-
* after '-', '?', or ':' (complex value).
|
1948
|
+
* after '-', '?', or ':' (complex value).
|
1949
1949
|
*/
|
1950
1950
|
|
1951
1951
|
if (!CACHE(parser, 1)) return 0;
|
@@ -2629,6 +2629,9 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
|
|
2629
2629
|
/* Check if it is a URI-escape sequence. */
|
2630
2630
|
|
2631
2631
|
if (CHECK(parser->buffer, '%')) {
|
2632
|
+
if (!STRING_EXTEND(parser, string))
|
2633
|
+
goto error;
|
2634
|
+
|
2632
2635
|
if (!yaml_parser_scan_uri_escapes(parser,
|
2633
2636
|
directive, start_mark, &string)) goto error;
|
2634
2637
|
}
|
@@ -3011,7 +3014,7 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
|
|
3011
3014
|
*indent = 1;
|
3012
3015
|
}
|
3013
3016
|
|
3014
|
-
return 1;
|
3017
|
+
return 1;
|
3015
3018
|
}
|
3016
3019
|
|
3017
3020
|
/*
|
data/ext/psych/yaml/writer.c
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
#ifdef RUBY_EXTCONF_H
|
2
|
+
#include RUBY_EXTCONF_H
|
3
|
+
#endif
|
1
4
|
|
2
5
|
#if HAVE_CONFIG_H
|
3
6
|
#include <config.h>
|
@@ -143,9 +146,12 @@ yaml_string_join(
|
|
143
146
|
(string).start = (string).pointer = (string).end = 0)
|
144
147
|
|
145
148
|
#define STRING_EXTEND(context,string) \
|
146
|
-
(((string).pointer+5 < (string).end)
|
149
|
+
((((string).pointer+5 < (string).end) \
|
147
150
|
|| yaml_string_extend(&(string).start, \
|
148
|
-
&(string).pointer, &(string).end))
|
151
|
+
&(string).pointer, &(string).end)) ? \
|
152
|
+
1 : \
|
153
|
+
((context)->error = YAML_MEMORY_ERROR, \
|
154
|
+
0))
|
149
155
|
|
150
156
|
#define CLEAR(context,string) \
|
151
157
|
((string).pointer = (string).start, \
|
@@ -239,9 +245,9 @@ yaml_string_join(
|
|
239
245
|
(string).pointer[offset] <= (yaml_char_t) 'f') ? \
|
240
246
|
((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \
|
241
247
|
((string).pointer[offset] - (yaml_char_t) '0'))
|
242
|
-
|
248
|
+
|
243
249
|
#define AS_HEX(string) AS_HEX_AT((string),0)
|
244
|
-
|
250
|
+
|
245
251
|
/*
|
246
252
|
* Check if the character is ASCII.
|
247
253
|
*/
|
@@ -430,7 +436,8 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
|
430
436
|
(stack).start = (stack).top = (stack).end = 0)
|
431
437
|
|
432
438
|
#define STACK_EMPTY(context,stack) \
|
433
|
-
((
|
439
|
+
((void)(context), \
|
440
|
+
((stack).start == (stack).top))
|
434
441
|
|
435
442
|
#define STACK_LIMIT(context,stack,size) \
|
436
443
|
((stack).top - (stack).start < (size) ? \
|
data/lib/psych.rb
CHANGED
@@ -157,6 +157,11 @@ module Psych
|
|
157
157
|
@emitter.end_sequence
|
158
158
|
end
|
159
159
|
|
160
|
+
def visit_Encoding o
|
161
|
+
tag = "!ruby/encoding"
|
162
|
+
@emitter.scalar o.name, nil, tag, false, false, Nodes::Scalar::ANY
|
163
|
+
end
|
164
|
+
|
160
165
|
def visit_Object o
|
161
166
|
tag = Psych.dump_tags[o.class]
|
162
167
|
unless tag
|
data/test/psych/test_encoding.rb
CHANGED
@@ -31,6 +31,11 @@ module Psych
|
|
31
31
|
@emitter = Psych::Emitter.new @buffer
|
32
32
|
end
|
33
33
|
|
34
|
+
def test_dump_load_encoding_object
|
35
|
+
assert_cycle Encoding::US_ASCII
|
36
|
+
assert_cycle Encoding::UTF_8
|
37
|
+
end
|
38
|
+
|
34
39
|
def test_transcode_shiftjis
|
35
40
|
str = "こんにちは!"
|
36
41
|
loaded = Psych.load("--- こんにちは!".encode('SHIFT_JIS'))
|
data/test/psych/test_string.rb
CHANGED
@@ -137,7 +137,7 @@ string: &70121654388580 !ruby/string
|
|
137
137
|
ivar = "on rock and roll"
|
138
138
|
food.instance_variable_set(:@we_built_this_city, ivar)
|
139
139
|
|
140
|
-
|
140
|
+
Psych.load Psych.dump food
|
141
141
|
assert_equal ivar, food.instance_variable_get(:@we_built_this_city)
|
142
142
|
end
|
143
143
|
|
data/test/psych/test_yaml.rb
CHANGED
@@ -250,7 +250,6 @@ EOY
|
|
250
250
|
|
251
251
|
def test_spec_mapping_between_sequences
|
252
252
|
# Complex key #1
|
253
|
-
dj = Date.new( 2001, 7, 23 )
|
254
253
|
assert_parse_only(
|
255
254
|
{ [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
|
256
255
|
[ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ] }, <<EOY
|
@@ -606,7 +605,7 @@ EOY
|
|
606
605
|
def test_spec_domain_prefix
|
607
606
|
customer_proc = proc { |type, val|
|
608
607
|
if Hash === val
|
609
|
-
|
608
|
+
_, _, type = type.split( ':', 3 )
|
610
609
|
val['type'] = "domain #{type}"
|
611
610
|
val
|
612
611
|
else
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych-shopifork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake-compiler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.4.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.4.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hoe
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.10'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.10'
|
55
55
|
description: |-
|
56
56
|
Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
|
57
57
|
for its YAML parsing and emitting capabilities. In addition to wrapping
|
@@ -67,8 +67,9 @@ extra_rdoc_files:
|
|
67
67
|
- Manifest.txt
|
68
68
|
- README.rdoc
|
69
69
|
files:
|
70
|
-
- .autotest
|
71
|
-
- .
|
70
|
+
- ".autotest"
|
71
|
+
- ".gemtest"
|
72
|
+
- ".travis.yml"
|
72
73
|
- CHANGELOG.rdoc
|
73
74
|
- Manifest.txt
|
74
75
|
- README.rdoc
|
@@ -180,30 +181,29 @@ files:
|
|
180
181
|
- test/psych/visitors/test_emitter.rb
|
181
182
|
- test/psych/visitors/test_to_ruby.rb
|
182
183
|
- test/psych/visitors/test_yaml_tree.rb
|
183
|
-
- .gemtest
|
184
184
|
homepage: http://github.com/tenderlove/psych
|
185
185
|
licenses:
|
186
186
|
- MIT
|
187
187
|
metadata: {}
|
188
188
|
post_install_message:
|
189
189
|
rdoc_options:
|
190
|
-
- --main
|
190
|
+
- "--main"
|
191
191
|
- README.rdoc
|
192
192
|
require_paths:
|
193
193
|
- lib
|
194
194
|
required_ruby_version: !ruby/object:Gem::Requirement
|
195
195
|
requirements:
|
196
|
-
- -
|
196
|
+
- - ">="
|
197
197
|
- !ruby/object:Gem::Version
|
198
198
|
version: 1.9.2
|
199
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
200
|
requirements:
|
201
|
-
- -
|
201
|
+
- - ">="
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
|
-
rubyforge_project:
|
206
|
-
rubygems_version: 2.0
|
205
|
+
rubyforge_project:
|
206
|
+
rubygems_version: 2.2.0
|
207
207
|
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: Psych is a YAML parser and emitter
|