psych 2.0.12 → 5.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +24 -0
  3. data/{ext/psych/yaml/LICENSE → LICENSE} +9 -7
  4. data/README.md +80 -0
  5. data/ext/psych/depend +14 -0
  6. data/ext/psych/extconf.rb +43 -28
  7. data/ext/psych/psych.c +6 -4
  8. data/ext/psych/psych.h +0 -3
  9. data/ext/psych/psych_emitter.c +165 -132
  10. data/ext/psych/psych_parser.c +298 -331
  11. data/ext/psych/psych_to_ruby.c +0 -5
  12. data/ext/psych/psych_yaml_tree.c +0 -13
  13. data/lib/psych/class_loader.rb +11 -8
  14. data/lib/psych/coder.rb +1 -0
  15. data/lib/psych/core_ext.rb +3 -19
  16. data/lib/psych/exception.rb +17 -2
  17. data/lib/psych/handler.rb +8 -2
  18. data/lib/psych/handlers/document_stream.rb +2 -1
  19. data/lib/psych/handlers/recorder.rb +2 -1
  20. data/lib/psych/json/ruby_events.rb +1 -0
  21. data/lib/psych/json/stream.rb +3 -2
  22. data/lib/psych/json/tree_builder.rb +2 -1
  23. data/lib/psych/json/yaml_events.rb +1 -0
  24. data/lib/psych/nodes/alias.rb +3 -0
  25. data/lib/psych/nodes/document.rb +3 -0
  26. data/lib/psych/nodes/mapping.rb +3 -0
  27. data/lib/psych/nodes/node.rb +25 -5
  28. data/lib/psych/nodes/scalar.rb +4 -1
  29. data/lib/psych/nodes/sequence.rb +3 -0
  30. data/lib/psych/nodes/stream.rb +3 -0
  31. data/lib/psych/nodes.rb +8 -7
  32. data/lib/psych/omap.rb +1 -0
  33. data/lib/psych/parser.rb +14 -0
  34. data/lib/psych/scalar_scanner.rb +41 -49
  35. data/lib/psych/set.rb +1 -0
  36. data/lib/psych/stream.rb +1 -0
  37. data/lib/psych/streaming.rb +1 -0
  38. data/lib/psych/syntax_error.rb +2 -1
  39. data/lib/psych/tree_builder.rb +48 -7
  40. data/lib/psych/versions.rb +10 -0
  41. data/lib/psych/visitors/depth_first.rb +1 -0
  42. data/lib/psych/visitors/emitter.rb +1 -0
  43. data/lib/psych/visitors/json_tree.rb +2 -1
  44. data/lib/psych/visitors/to_ruby.rb +64 -33
  45. data/lib/psych/visitors/visitor.rb +18 -3
  46. data/lib/psych/visitors/yaml_tree.rb +128 -149
  47. data/lib/psych/visitors.rb +7 -6
  48. data/lib/psych/y.rb +1 -0
  49. data/lib/psych.rb +360 -95
  50. metadata +36 -169
  51. data/.autotest +0 -18
  52. data/.gemtest +0 -0
  53. data/.travis.yml +0 -11
  54. data/CHANGELOG.rdoc +0 -562
  55. data/Manifest.txt +0 -112
  56. data/README.rdoc +0 -71
  57. data/Rakefile +0 -74
  58. data/ext/psych/yaml/api.c +0 -1415
  59. data/ext/psych/yaml/config.h +0 -10
  60. data/ext/psych/yaml/dumper.c +0 -394
  61. data/ext/psych/yaml/emitter.c +0 -2329
  62. data/ext/psych/yaml/loader.c +0 -459
  63. data/ext/psych/yaml/parser.c +0 -1370
  64. data/ext/psych/yaml/reader.c +0 -469
  65. data/ext/psych/yaml/scanner.c +0 -3583
  66. data/ext/psych/yaml/writer.c +0 -141
  67. data/ext/psych/yaml/yaml.h +0 -1971
  68. data/ext/psych/yaml/yaml_private.h +0 -664
  69. data/lib/psych/deprecated.rb +0 -85
  70. data/test/psych/handlers/test_recorder.rb +0 -25
  71. data/test/psych/helper.rb +0 -114
  72. data/test/psych/json/test_stream.rb +0 -109
  73. data/test/psych/nodes/test_enumerable.rb +0 -43
  74. data/test/psych/test_alias_and_anchor.rb +0 -96
  75. data/test/psych/test_array.rb +0 -57
  76. data/test/psych/test_boolean.rb +0 -36
  77. data/test/psych/test_class.rb +0 -36
  78. data/test/psych/test_coder.rb +0 -184
  79. data/test/psych/test_date_time.rb +0 -38
  80. data/test/psych/test_deprecated.rb +0 -214
  81. data/test/psych/test_document.rb +0 -46
  82. data/test/psych/test_emitter.rb +0 -93
  83. data/test/psych/test_encoding.rb +0 -259
  84. data/test/psych/test_exception.rb +0 -157
  85. data/test/psych/test_hash.rb +0 -94
  86. data/test/psych/test_json_tree.rb +0 -65
  87. data/test/psych/test_marshalable.rb +0 -54
  88. data/test/psych/test_merge_keys.rb +0 -180
  89. data/test/psych/test_nil.rb +0 -18
  90. data/test/psych/test_null.rb +0 -19
  91. data/test/psych/test_numeric.rb +0 -45
  92. data/test/psych/test_object.rb +0 -44
  93. data/test/psych/test_object_references.rb +0 -71
  94. data/test/psych/test_omap.rb +0 -75
  95. data/test/psych/test_parser.rb +0 -339
  96. data/test/psych/test_psych.rb +0 -168
  97. data/test/psych/test_safe_load.rb +0 -97
  98. data/test/psych/test_scalar.rb +0 -11
  99. data/test/psych/test_scalar_scanner.rb +0 -106
  100. data/test/psych/test_serialize_subclasses.rb +0 -38
  101. data/test/psych/test_set.rb +0 -49
  102. data/test/psych/test_stream.rb +0 -93
  103. data/test/psych/test_string.rb +0 -226
  104. data/test/psych/test_struct.rb +0 -49
  105. data/test/psych/test_symbol.rb +0 -25
  106. data/test/psych/test_tainted.rb +0 -130
  107. data/test/psych/test_to_yaml_properties.rb +0 -63
  108. data/test/psych/test_tree_builder.rb +0 -79
  109. data/test/psych/test_yaml.rb +0 -1288
  110. data/test/psych/test_yamldbm.rb +0 -193
  111. data/test/psych/test_yamlstore.rb +0 -85
  112. data/test/psych/visitors/test_depth_first.rb +0 -49
  113. data/test/psych/visitors/test_emitter.rb +0 -144
  114. data/test/psych/visitors/test_to_ruby.rb +0 -326
  115. data/test/psych/visitors/test_yaml_tree.rb +0 -173
@@ -1,6 +1,14 @@
1
1
  #include <psych.h>
2
2
 
3
+ #if !defined(RARRAY_CONST_PTR)
4
+ #define RARRAY_CONST_PTR(s) (const VALUE *)RARRAY_PTR(s)
5
+ #endif
6
+ #if !defined(RARRAY_AREF)
7
+ #define RARRAY_AREF(a, i) RARRAY_CONST_PTR(a)[i]
8
+ #endif
9
+
3
10
  VALUE cPsychEmitter;
11
+ static ID id_io;
4
12
  static ID id_write;
5
13
  static ID id_line_width;
6
14
  static ID id_indentation;
@@ -9,13 +17,13 @@ static ID id_canonical;
9
17
  static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
10
18
  {
11
19
  if(!yaml_emitter_emit(emitter, event))
12
- rb_raise(rb_eRuntimeError, "%s", emitter->problem);
20
+ rb_raise(rb_eRuntimeError, "%s", emitter->problem);
13
21
  }
14
22
 
15
23
  static int writer(void *ctx, unsigned char *buffer, size_t size)
16
24
  {
17
- VALUE io = (VALUE)ctx;
18
- VALUE str = rb_str_new((const char *)buffer, (long)size);
25
+ VALUE self = (VALUE)ctx, io = rb_attr_get(self, id_io);
26
+ VALUE str = rb_enc_str_new((const char *)buffer, (long)size, rb_utf8_encoding());
19
27
  VALUE wrote = rb_funcall(io, id_write, 1, str);
20
28
  return (int)NUM2INT(wrote);
21
29
  }
@@ -50,14 +58,13 @@ static const rb_data_type_t psych_emitter_type = {
50
58
  static VALUE allocate(VALUE klass)
51
59
  {
52
60
  yaml_emitter_t * emitter;
53
-
54
- emitter = xmalloc(sizeof(yaml_emitter_t));
61
+ VALUE obj = TypedData_Make_Struct(klass, yaml_emitter_t, &psych_emitter_type, emitter);
55
62
 
56
63
  yaml_emitter_initialize(emitter);
57
64
  yaml_emitter_set_unicode(emitter, 1);
58
65
  yaml_emitter_set_indent(emitter, 2);
59
66
 
60
- return TypedData_Wrap_Struct(klass, &psych_emitter_type, emitter);
67
+ return obj;
61
68
  }
62
69
 
63
70
  /* call-seq: Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS)
@@ -75,16 +82,17 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
75
82
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
76
83
 
77
84
  if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
78
- line_width = rb_funcall(options, id_line_width, 0);
79
- indent = rb_funcall(options, id_indentation, 0);
80
- canonical = rb_funcall(options, id_canonical, 0);
85
+ line_width = rb_funcall(options, id_line_width, 0);
86
+ indent = rb_funcall(options, id_indentation, 0);
87
+ canonical = rb_funcall(options, id_canonical, 0);
81
88
 
82
- yaml_emitter_set_width(emitter, NUM2INT(line_width));
83
- yaml_emitter_set_indent(emitter, NUM2INT(indent));
84
- yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
89
+ yaml_emitter_set_width(emitter, NUM2INT(line_width));
90
+ yaml_emitter_set_indent(emitter, NUM2INT(indent));
91
+ yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
85
92
  }
86
93
 
87
- yaml_emitter_set_output(emitter, writer, (void *)io);
94
+ rb_ivar_set(self, id_io, io);
95
+ yaml_emitter_set_output(emitter, writer, (void *)self);
88
96
 
89
97
  return self;
90
98
  }
@@ -128,84 +136,118 @@ static VALUE end_stream(VALUE self)
128
136
  return self;
129
137
  }
130
138
 
131
- /* call-seq: emitter.start_document(version, tags, implicit)
132
- *
133
- * Start a document emission with YAML +version+, +tags+, and an +implicit+
134
- * start.
135
- *
136
- * See Psych::Handler#start_document
137
- */
138
- static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
139
+ struct start_document_data {
140
+ VALUE self;
141
+ VALUE version;
142
+ VALUE tags;
143
+ VALUE imp;
144
+
145
+ yaml_tag_directive_t * head;
146
+ };
147
+
148
+ static VALUE start_document_try(VALUE d)
139
149
  {
150
+ struct start_document_data * data = (struct start_document_data *)d;
151
+ VALUE self = data->self;
152
+ VALUE version = data->version;
153
+ VALUE tags = data->tags;
154
+ VALUE imp = data->imp;
155
+
140
156
  yaml_emitter_t * emitter;
141
- yaml_tag_directive_t * head = NULL;
142
157
  yaml_tag_directive_t * tail = NULL;
143
158
  yaml_event_t event;
144
159
  yaml_version_directive_t version_directive;
145
160
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
146
161
 
147
-
148
162
  Check_Type(version, T_ARRAY);
149
163
 
150
164
  if(RARRAY_LEN(version) > 0) {
151
- VALUE major = rb_ary_entry(version, (long)0);
152
- VALUE minor = rb_ary_entry(version, (long)1);
165
+ VALUE major = rb_ary_entry(version, (long)0);
166
+ VALUE minor = rb_ary_entry(version, (long)1);
153
167
 
154
- version_directive.major = NUM2INT(major);
155
- version_directive.minor = NUM2INT(minor);
168
+ version_directive.major = NUM2INT(major);
169
+ version_directive.minor = NUM2INT(minor);
156
170
  }
157
171
 
158
172
  if(RTEST(tags)) {
159
- int i = 0;
160
- #ifdef HAVE_RUBY_ENCODING_H
161
- rb_encoding * encoding = rb_utf8_encoding();
162
- #endif
173
+ long i = 0;
174
+ long len;
175
+ rb_encoding * encoding = rb_utf8_encoding();
163
176
 
164
- Check_Type(tags, T_ARRAY);
177
+ Check_Type(tags, T_ARRAY);
165
178
 
166
- head = xcalloc((size_t)RARRAY_LEN(tags), sizeof(yaml_tag_directive_t));
167
- tail = head;
179
+ len = RARRAY_LEN(tags);
180
+ data->head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
181
+ tail = data->head;
168
182
 
169
- for(i = 0; i < RARRAY_LEN(tags); i++) {
170
- VALUE tuple = RARRAY_PTR(tags)[i];
171
- VALUE name;
172
- VALUE value;
183
+ for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
184
+ VALUE tuple = RARRAY_AREF(tags, i);
185
+ VALUE name;
186
+ VALUE value;
173
187
 
174
- Check_Type(tuple, T_ARRAY);
188
+ Check_Type(tuple, T_ARRAY);
175
189
 
176
- if(RARRAY_LEN(tuple) < 2) {
177
- xfree(head);
178
- rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
179
- }
180
- name = RARRAY_PTR(tuple)[0];
181
- value = RARRAY_PTR(tuple)[1];
182
- #ifdef HAVE_RUBY_ENCODING_H
183
- name = rb_str_export_to_enc(name, encoding);
184
- value = rb_str_export_to_enc(value, encoding);
185
- #endif
190
+ if(RARRAY_LEN(tuple) < 2) {
191
+ rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
192
+ }
193
+
194
+ name = RARRAY_AREF(tuple, 0);
195
+ value = RARRAY_AREF(tuple, 1);
196
+ StringValue(name);
197
+ StringValue(value);
198
+ name = rb_str_export_to_enc(name, encoding);
199
+ value = rb_str_export_to_enc(value, encoding);
186
200
 
187
- tail->handle = (yaml_char_t *)StringValuePtr(name);
188
- tail->prefix = (yaml_char_t *)StringValuePtr(value);
201
+ tail->handle = (yaml_char_t *)StringValueCStr(name);
202
+ tail->prefix = (yaml_char_t *)StringValueCStr(value);
189
203
 
190
- tail++;
191
- }
204
+ tail++;
205
+ }
192
206
  }
193
207
 
194
208
  yaml_document_start_event_initialize(
195
- &event,
196
- (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
197
- head,
198
- tail,
199
- imp ? 1 : 0
200
- );
209
+ &event,
210
+ (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
211
+ data->head,
212
+ tail,
213
+ imp ? 1 : 0
214
+ );
201
215
 
202
216
  emit(emitter, &event);
203
217
 
204
- if(head) xfree(head);
205
-
206
218
  return self;
207
219
  }
208
220
 
221
+ static VALUE start_document_ensure(VALUE d)
222
+ {
223
+ struct start_document_data * data = (struct start_document_data *)d;
224
+
225
+ xfree(data->head);
226
+
227
+ return Qnil;
228
+ }
229
+
230
+ /* call-seq: emitter.start_document(version, tags, implicit)
231
+ *
232
+ * Start a document emission with YAML +version+, +tags+, and an +implicit+
233
+ * start.
234
+ *
235
+ * See Psych::Handler#start_document
236
+ */
237
+ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
238
+ {
239
+ struct start_document_data data = {
240
+ .self = self,
241
+ .version = version,
242
+ .tags = tags,
243
+ .imp = imp,
244
+
245
+ .head = NULL,
246
+ };
247
+
248
+ return rb_ensure(start_document_try, (VALUE)&data, start_document_ensure, (VALUE)&data);
249
+ }
250
+
209
251
  /* call-seq: emitter.end_document(implicit)
210
252
  *
211
253
  * End a document emission with an +implicit+ ending.
@@ -233,49 +275,46 @@ static VALUE end_document(VALUE self, VALUE imp)
233
275
  * See Psych::Handler#scalar
234
276
  */
235
277
  static VALUE scalar(
236
- VALUE self,
237
- VALUE value,
238
- VALUE anchor,
239
- VALUE tag,
240
- VALUE plain,
241
- VALUE quoted,
242
- VALUE style
243
- ) {
278
+ VALUE self,
279
+ VALUE value,
280
+ VALUE anchor,
281
+ VALUE tag,
282
+ VALUE plain,
283
+ VALUE quoted,
284
+ VALUE style
285
+ ) {
244
286
  yaml_emitter_t * emitter;
245
287
  yaml_event_t event;
246
- #ifdef HAVE_RUBY_ENCODING_H
247
288
  rb_encoding *encoding;
248
- #endif
249
289
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
250
290
 
251
291
  Check_Type(value, T_STRING);
252
292
 
253
- #ifdef HAVE_RUBY_ENCODING_H
254
293
  encoding = rb_utf8_encoding();
255
294
 
256
295
  value = rb_str_export_to_enc(value, encoding);
257
296
 
258
297
  if(!NIL_P(anchor)) {
259
- Check_Type(anchor, T_STRING);
260
- anchor = rb_str_export_to_enc(anchor, encoding);
298
+ Check_Type(anchor, T_STRING);
299
+ anchor = rb_str_export_to_enc(anchor, encoding);
261
300
  }
262
301
 
263
302
  if(!NIL_P(tag)) {
264
- Check_Type(tag, T_STRING);
265
- tag = rb_str_export_to_enc(tag, encoding);
303
+ Check_Type(tag, T_STRING);
304
+ tag = rb_str_export_to_enc(tag, encoding);
266
305
  }
267
- #endif
268
306
 
307
+ const char *value_ptr = StringValuePtr(value);
269
308
  yaml_scalar_event_initialize(
270
- &event,
271
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
272
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
273
- (yaml_char_t*)StringValuePtr(value),
274
- (int)RSTRING_LEN(value),
275
- plain ? 1 : 0,
276
- quoted ? 1 : 0,
277
- (yaml_scalar_style_t)NUM2INT(style)
278
- );
309
+ &event,
310
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
311
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
312
+ (yaml_char_t*)value_ptr,
313
+ (int)RSTRING_LEN(value),
314
+ plain ? 1 : 0,
315
+ quoted ? 1 : 0,
316
+ (yaml_scalar_style_t)NUM2INT(style)
317
+ );
279
318
 
280
319
  emit(emitter, &event);
281
320
 
@@ -290,38 +329,36 @@ static VALUE scalar(
290
329
  * See Psych::Handler#start_sequence
291
330
  */
292
331
  static VALUE start_sequence(
293
- VALUE self,
294
- VALUE anchor,
295
- VALUE tag,
296
- VALUE implicit,
297
- VALUE style
298
- ) {
332
+ VALUE self,
333
+ VALUE anchor,
334
+ VALUE tag,
335
+ VALUE implicit,
336
+ VALUE style
337
+ ) {
299
338
  yaml_emitter_t * emitter;
300
339
  yaml_event_t event;
301
340
 
302
- #ifdef HAVE_RUBY_ENCODING_H
303
341
  rb_encoding * encoding = rb_utf8_encoding();
304
342
 
305
343
  if(!NIL_P(anchor)) {
306
- Check_Type(anchor, T_STRING);
307
- anchor = rb_str_export_to_enc(anchor, encoding);
344
+ Check_Type(anchor, T_STRING);
345
+ anchor = rb_str_export_to_enc(anchor, encoding);
308
346
  }
309
347
 
310
348
  if(!NIL_P(tag)) {
311
- Check_Type(tag, T_STRING);
312
- tag = rb_str_export_to_enc(tag, encoding);
349
+ Check_Type(tag, T_STRING);
350
+ tag = rb_str_export_to_enc(tag, encoding);
313
351
  }
314
- #endif
315
352
 
316
353
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
317
354
 
318
355
  yaml_sequence_start_event_initialize(
319
- &event,
320
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
321
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
322
- implicit ? 1 : 0,
323
- (yaml_sequence_style_t)NUM2INT(style)
324
- );
356
+ &event,
357
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
358
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
359
+ implicit ? 1 : 0,
360
+ (yaml_sequence_style_t)NUM2INT(style)
361
+ );
325
362
 
326
363
  emit(emitter, &event);
327
364
 
@@ -355,40 +392,37 @@ static VALUE end_sequence(VALUE self)
355
392
  * See Psych::Handler#start_mapping
356
393
  */
357
394
  static VALUE start_mapping(
358
- VALUE self,
359
- VALUE anchor,
360
- VALUE tag,
361
- VALUE implicit,
362
- VALUE style
363
- ) {
395
+ VALUE self,
396
+ VALUE anchor,
397
+ VALUE tag,
398
+ VALUE implicit,
399
+ VALUE style
400
+ ) {
364
401
  yaml_emitter_t * emitter;
365
402
  yaml_event_t event;
366
- #ifdef HAVE_RUBY_ENCODING_H
367
403
  rb_encoding *encoding;
368
- #endif
404
+
369
405
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
370
406
 
371
- #ifdef HAVE_RUBY_ENCODING_H
372
407
  encoding = rb_utf8_encoding();
373
408
 
374
409
  if(!NIL_P(anchor)) {
375
- Check_Type(anchor, T_STRING);
376
- anchor = rb_str_export_to_enc(anchor, encoding);
410
+ Check_Type(anchor, T_STRING);
411
+ anchor = rb_str_export_to_enc(anchor, encoding);
377
412
  }
378
413
 
379
414
  if(!NIL_P(tag)) {
380
- Check_Type(tag, T_STRING);
381
- tag = rb_str_export_to_enc(tag, encoding);
415
+ Check_Type(tag, T_STRING);
416
+ tag = rb_str_export_to_enc(tag, encoding);
382
417
  }
383
- #endif
384
418
 
385
419
  yaml_mapping_start_event_initialize(
386
- &event,
387
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
388
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
389
- implicit ? 1 : 0,
390
- (yaml_mapping_style_t)NUM2INT(style)
391
- );
420
+ &event,
421
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
422
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
423
+ implicit ? 1 : 0,
424
+ (yaml_mapping_style_t)NUM2INT(style)
425
+ );
392
426
 
393
427
  emit(emitter, &event);
394
428
 
@@ -426,17 +460,15 @@ static VALUE alias(VALUE self, VALUE anchor)
426
460
  yaml_event_t event;
427
461
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
428
462
 
429
- #ifdef HAVE_RUBY_ENCODING_H
430
463
  if(!NIL_P(anchor)) {
431
- Check_Type(anchor, T_STRING);
432
- anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
464
+ Check_Type(anchor, T_STRING);
465
+ anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
433
466
  }
434
- #endif
435
467
 
436
468
  yaml_alias_event_initialize(
437
- &event,
438
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor))
439
- );
469
+ &event,
470
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
471
+ );
440
472
 
441
473
  emit(emitter, &event);
442
474
 
@@ -524,6 +556,7 @@ static VALUE set_line_width(VALUE self, VALUE width)
524
556
 
525
557
  void Init_psych_emitter(void)
526
558
  {
559
+ #undef rb_intern
527
560
  VALUE psych = rb_define_module("Psych");
528
561
  VALUE handler = rb_define_class_under(psych, "Handler", rb_cObject);
529
562
  cPsychEmitter = rb_define_class_under(psych, "Emitter", handler);
@@ -548,9 +581,9 @@ void Init_psych_emitter(void)
548
581
  rb_define_method(cPsychEmitter, "line_width", line_width, 0);
549
582
  rb_define_method(cPsychEmitter, "line_width=", set_line_width, 1);
550
583
 
584
+ id_io = rb_intern("io");
551
585
  id_write = rb_intern("write");
552
586
  id_line_width = rb_intern("line_width");
553
587
  id_indentation = rb_intern("indentation");
554
588
  id_canonical = rb_intern("canonical");
555
589
  }
556
- /* vim: set noet sws=4 sw=4: */