psych 3.3.2 → 5.2.2

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +24 -0
  3. data/README.md +6 -5
  4. data/ext/psych/depend +13 -1
  5. data/ext/psych/extconf.rb +40 -30
  6. data/ext/psych/psych.c +1 -1
  7. data/ext/psych/psych_emitter.c +155 -120
  8. data/ext/psych/psych_parser.c +267 -281
  9. data/lib/psych/class_loader.rb +5 -5
  10. data/lib/psych/core_ext.rb +1 -1
  11. data/lib/psych/exception.rb +16 -2
  12. data/lib/psych/handlers/document_stream.rb +1 -1
  13. data/lib/psych/handlers/recorder.rb +1 -1
  14. data/lib/psych/json/stream.rb +2 -2
  15. data/lib/psych/json/tree_builder.rb +1 -1
  16. data/lib/psych/nodes/node.rb +5 -5
  17. data/lib/psych/nodes.rb +7 -7
  18. data/lib/psych/parser.rb +13 -0
  19. data/lib/psych/scalar_scanner.rb +24 -19
  20. data/lib/psych/syntax_error.rb +1 -1
  21. data/lib/psych/tree_builder.rb +3 -3
  22. data/lib/psych/versions.rb +2 -2
  23. data/lib/psych/visitors/json_tree.rb +1 -1
  24. data/lib/psych/visitors/to_ruby.rb +12 -11
  25. data/lib/psych/visitors/yaml_tree.rb +71 -27
  26. data/lib/psych/visitors.rb +6 -6
  27. data/lib/psych.rb +204 -106
  28. metadata +37 -25
  29. data/.gitignore +0 -16
  30. data/Gemfile +0 -9
  31. data/Mavenfile +0 -7
  32. data/Rakefile +0 -41
  33. data/bin/console +0 -7
  34. data/bin/setup +0 -6
  35. data/ext/psych/yaml/LICENSE +0 -19
  36. data/ext/psych/yaml/api.c +0 -1393
  37. data/ext/psych/yaml/config.h +0 -80
  38. data/ext/psych/yaml/dumper.c +0 -394
  39. data/ext/psych/yaml/emitter.c +0 -2358
  40. data/ext/psych/yaml/loader.c +0 -544
  41. data/ext/psych/yaml/parser.c +0 -1375
  42. data/ext/psych/yaml/reader.c +0 -469
  43. data/ext/psych/yaml/scanner.c +0 -3598
  44. data/ext/psych/yaml/writer.c +0 -141
  45. data/ext/psych/yaml/yaml.h +0 -1985
  46. data/ext/psych/yaml/yaml_private.h +0 -688
  47. data/psych.gemspec +0 -67
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 816fda8fc436476e4117450ad248554d12b2d41c25439e457c171583b0ad3e6a
4
- data.tar.gz: 83ce5b7ccd045a76f430d7a13b30c356d05be0014d753945f412ab0e939fe0da
3
+ metadata.gz: e81adcfc8e167dbe8951e4b32794238a09003e57e75cc9e7f807d90c20aee917
4
+ data.tar.gz: 98cab7d17c5f91abbd84c95b089e71b4928b9554d5a8b154841c1d6d96c63f69
5
5
  SHA512:
6
- metadata.gz: 855d085016ed2c1f30bc3a3433247ad34ce06220d3871b7a92b922d89fde0a645471b8512f41b9d43812de407dcfaf01b23458475dfc1e0c37b9bbb6ff8d91f6
7
- data.tar.gz: 1191a34c8cf1c82687fbf94a25fdcce854c585718ef69aaedf97eb5a2cc1b07225ec44769a00b58124f67d58e33f138f657ea2233094f76bad1d2479d7a1b400
6
+ metadata.gz: 9297958a815fe84220641506bc65e17133d2c551cc34d50d0261f95e51d7a19e706b06bb98b59bbde587825f9256f0579a68d250346134f2f766a79c93fa1288
7
+ data.tar.gz: a86c4526fb081f9b18cc13e6f8326c3335e80913013f448bf9ef0d0f741af7d1bdc52392014076fe3b709427e47ae42dce7f4ffe0e896de82c8d3d218e23cfb0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,24 @@
1
+ ## How to contribute to Psych
2
+
3
+ Full details [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute)
4
+
5
+ #### **Did you find a bug?**
6
+
7
+ * **Do not open an issue if the bug is a security vulnerability
8
+ in Psych**, instead refer to our [security policy](https://www.ruby-lang.org/en/security/) and email [here](security@ruby-lang.org).
9
+
10
+ * **Ensure the bug was not already reported** by searching on ruby-core, the ruby github repo and on Psych's github repo. More info [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReport)
11
+
12
+ * If you're unable to find an open issue addressing the problem, [open a new one](https://bugs.ruby-lang.org/). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
13
+
14
+ #### **Did you write a patch that fixes a bug?**
15
+
16
+ * Open a new GitHub pull request with the patch for small fixes. Anything larger look [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute); submit a Feature.
17
+
18
+ * Ensure you clearly describe the problem and solution. Include the relevant ticket/issue number if applicable.
19
+
20
+ Psych is a volunteer effort. We encourage you to pitch in and [join the team](https://github.com/ruby/psych/contributors)!
21
+
22
+ Thanks! :heart: :heart: :heart:
23
+
24
+ The Psych Team
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Psych
2
2
 
3
3
  * https://github.com/ruby/psych
4
+ * https://docs.ruby-lang.org/en/master/Psych.html
4
5
 
5
6
  ## Description
6
7
 
@@ -32,6 +33,11 @@ If you want a newer gem release of Psych, you can use rubygems:
32
33
 
33
34
  gem install psych
34
35
 
36
+
37
+ Psych supported the static build with specific version of libyaml sources. You can build psych with libyaml-0.2.5 like this.
38
+
39
+ gem install psych -- --with-libyaml-source-dir=/path/to/libyaml-0.2.5
40
+
35
41
  In order to use the gem release in your app, and not the stdlib version,
36
42
  you'll need the following:
37
43
 
@@ -44,11 +50,6 @@ Or if you use Bundler add this to your `Gemfile`:
44
50
 
45
51
  JRuby ships with a pure Java implementation of Psych.
46
52
 
47
- If you're on Rubinius, Psych is available in 1.9 mode, please refer to the
48
- Language Modes section of the [Rubinius
49
- README](https://github.com/rubinius/rubinius#readme) for more information on
50
- building and 1.9 mode.
51
-
52
53
  ## License
53
54
 
54
55
  Copyright 2009 Aaron Patterson, et al.
data/ext/psych/depend CHANGED
@@ -1,4 +1,16 @@
1
- $(OBJS): $(YAML_H)
1
+ $(TARGET_SO): $(LIBYAML)
2
+
3
+ libyaml $(LIBYAML):
4
+ cd libyaml && $(MAKE)
5
+ $(AR) $(ARFLAGS) $(LIBYAML) $(LIBYAML_OBJDIR)/*.$(OBJEXT)
6
+ $(RANLIB) $(LIBYAML)
7
+
8
+ clean-so::
9
+ -cd libyaml && $(MAKE) clean
10
+
11
+ distclean-so::
12
+ -cd libyaml && $(MAKE) distclean
13
+ -$(Q)$(RMDIRS) libyaml/* libyaml
2
14
 
3
15
  $(OBJS): $(HDRS) $(ruby_headers) \
4
16
  $(hdrdir)/ruby/encoding.h \
data/ext/psych/extconf.rb CHANGED
@@ -1,43 +1,53 @@
1
1
  # -*- coding: us-ascii -*-
2
2
  # frozen_string_literal: true
3
3
  require 'mkmf'
4
- require 'fileutils'
5
4
 
6
- # :stopdoc:
7
-
8
- dir_config 'libyaml'
9
-
10
- if enable_config("bundled-libyaml", false) || !(find_header('yaml.h') && find_library('yaml', 'yaml_get_version'))
11
- # Embed libyaml since we could not find it.
12
-
13
- $VPATH << "$(srcdir)/yaml"
14
- $INCFLAGS << " -I$(srcdir)/yaml"
15
-
16
- $srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}.sort
5
+ if $mswin or $mingw or $cygwin
6
+ $CPPFLAGS << " -DYAML_DECLARE_STATIC"
7
+ end
17
8
 
18
- header = 'yaml/yaml.h'
19
- header = "{$(VPATH)}#{header}" if $nmake
20
- if have_macro("_WIN32")
21
- $CPPFLAGS << " -DYAML_DECLARE_STATIC -DHAVE_CONFIG_H"
9
+ yaml_source = with_config("libyaml-source-dir")
10
+ if yaml_source
11
+ yaml_source = yaml_source.gsub(/\$\((\w+)\)|\$\{(\w+)\}/) {ENV[$1||$2]}
12
+ yaml_source = yaml_source.chomp("/")
13
+ yaml_configure = "#{File.expand_path(yaml_source)}/configure"
14
+ unless File.exist?(yaml_configure)
15
+ raise "Configure script not found in #{yaml_source.quote}"
22
16
  end
23
17
 
24
- have_header 'dlfcn.h'
25
- have_header 'inttypes.h'
26
- have_header 'memory.h'
27
- have_header 'stdint.h'
28
- have_header 'stdlib.h'
29
- have_header 'strings.h'
30
- have_header 'string.h'
31
- have_header 'sys/stat.h'
32
- have_header 'sys/types.h'
33
- have_header 'unistd.h'
34
-
35
- find_header 'yaml.h'
36
- have_header 'config.h'
18
+ puts("Configuring libyaml source in #{yaml_source.quote}")
19
+ yaml = "libyaml"
20
+ Dir.mkdir(yaml) unless File.directory?(yaml)
21
+ shared = $enable_shared || !$static
22
+ args = [
23
+ yaml_configure,
24
+ "--enable-#{shared ? 'shared' : 'static'}",
25
+ "--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-').sub(/arm64/, 'arm')}",
26
+ "CC=#{RbConfig::CONFIG['CC']}",
27
+ *(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
28
+ ]
29
+ puts(args.quote.join(' '))
30
+ unless system(*args, chdir: yaml)
31
+ raise "failed to configure libyaml"
32
+ end
33
+ inc = yaml_source.start_with?("#$srcdir/") ? "$(srcdir)#{yaml_source[$srcdir.size..-1]}" : yaml_source
34
+ $INCFLAGS << " -I#{yaml}/include -I#{inc}/include"
35
+ puts("INCFLAGS=#$INCFLAGS")
36
+ libyaml = "libyaml.#$LIBEXT"
37
+ $cleanfiles << libyaml
38
+ $LOCAL_LIBS.prepend("$(LIBYAML) ")
39
+ else # default to pre-installed libyaml
40
+ pkg_config('yaml-0.1')
41
+ dir_config('libyaml')
42
+ find_header('yaml.h') or abort "yaml.h not found"
43
+ find_library('yaml', 'yaml_get_version') or abort "libyaml not found"
37
44
  end
38
45
 
39
46
  create_makefile 'psych' do |mk|
40
- mk << "YAML_H = #{header}".strip << "\n"
47
+ mk << "LIBYAML = #{libyaml}".strip << "\n"
48
+ mk << "LIBYAML_OBJDIR = libyaml/src#{shared ? '/.libs' : ''}\n"
49
+ mk << "OBJEXT = #$OBJEXT"
50
+ mk << "RANLIB = #{config_string('RANLIB') || config_string('NULLCMD')}\n"
41
51
  end
42
52
 
43
53
  # :startdoc:
data/ext/psych/psych.c CHANGED
@@ -23,7 +23,7 @@ VALUE mPsych;
23
23
  void Init_psych(void)
24
24
  {
25
25
  #ifdef HAVE_RB_EXT_RACTOR_SAFE
26
- RB_EXT_RACTOR_SAFE(true);
26
+ RB_EXT_RACTOR_SAFE(true);
27
27
  #endif
28
28
  mPsych = rb_define_module("Psych");
29
29
 
@@ -17,7 +17,7 @@ static ID id_canonical;
17
17
  static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
18
18
  {
19
19
  if(!yaml_emitter_emit(emitter, event))
20
- rb_raise(rb_eRuntimeError, "%s", emitter->problem);
20
+ rb_raise(rb_eRuntimeError, "%s", emitter->problem);
21
21
  }
22
22
 
23
23
  static int writer(void *ctx, unsigned char *buffer, size_t size)
@@ -82,13 +82,13 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
82
82
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
83
83
 
84
84
  if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
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);
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);
88
88
 
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);
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);
92
92
  }
93
93
 
94
94
  rb_ivar_set(self, id_io, io);
@@ -136,84 +136,118 @@ static VALUE end_stream(VALUE self)
136
136
  return self;
137
137
  }
138
138
 
139
- /* call-seq: emitter.start_document(version, tags, implicit)
140
- *
141
- * Start a document emission with YAML +version+, +tags+, and an +implicit+
142
- * start.
143
- *
144
- * See Psych::Handler#start_document
145
- */
146
- 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)
147
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
+
148
156
  yaml_emitter_t * emitter;
149
- yaml_tag_directive_t * head = NULL;
150
157
  yaml_tag_directive_t * tail = NULL;
151
158
  yaml_event_t event;
152
159
  yaml_version_directive_t version_directive;
153
160
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
154
161
 
155
-
156
162
  Check_Type(version, T_ARRAY);
157
163
 
158
164
  if(RARRAY_LEN(version) > 0) {
159
- VALUE major = rb_ary_entry(version, (long)0);
160
- 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);
161
167
 
162
- version_directive.major = NUM2INT(major);
163
- version_directive.minor = NUM2INT(minor);
168
+ version_directive.major = NUM2INT(major);
169
+ version_directive.minor = NUM2INT(minor);
164
170
  }
165
171
 
166
172
  if(RTEST(tags)) {
167
- long i = 0;
168
- long len;
169
- rb_encoding * encoding = rb_utf8_encoding();
170
-
171
- Check_Type(tags, T_ARRAY);
172
-
173
- len = RARRAY_LEN(tags);
174
- head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
175
- tail = head;
176
-
177
- for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
178
- VALUE tuple = RARRAY_AREF(tags, i);
179
- VALUE name;
180
- VALUE value;
181
-
182
- Check_Type(tuple, T_ARRAY);
183
-
184
- if(RARRAY_LEN(tuple) < 2) {
185
- xfree(head);
186
- rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
187
- }
188
- name = RARRAY_AREF(tuple, 0);
189
- value = RARRAY_AREF(tuple, 1);
190
- StringValue(name);
191
- StringValue(value);
192
- name = rb_str_export_to_enc(name, encoding);
193
- value = rb_str_export_to_enc(value, encoding);
194
-
195
- tail->handle = (yaml_char_t *)StringValueCStr(name);
196
- tail->prefix = (yaml_char_t *)StringValueCStr(value);
197
-
198
- tail++;
199
- }
173
+ long i = 0;
174
+ long len;
175
+ rb_encoding * encoding = rb_utf8_encoding();
176
+
177
+ Check_Type(tags, T_ARRAY);
178
+
179
+ len = RARRAY_LEN(tags);
180
+ data->head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
181
+ tail = data->head;
182
+
183
+ for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
184
+ VALUE tuple = RARRAY_AREF(tags, i);
185
+ VALUE name;
186
+ VALUE value;
187
+
188
+ Check_Type(tuple, T_ARRAY);
189
+
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);
200
+
201
+ tail->handle = (yaml_char_t *)StringValueCStr(name);
202
+ tail->prefix = (yaml_char_t *)StringValueCStr(value);
203
+
204
+ tail++;
205
+ }
200
206
  }
201
207
 
202
208
  yaml_document_start_event_initialize(
203
- &event,
204
- (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
205
- head,
206
- tail,
207
- imp ? 1 : 0
208
- );
209
+ &event,
210
+ (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
211
+ data->head,
212
+ tail,
213
+ imp ? 1 : 0
214
+ );
209
215
 
210
216
  emit(emitter, &event);
211
217
 
212
- if(head) xfree(head);
213
-
214
218
  return self;
215
219
  }
216
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
+
217
251
  /* call-seq: emitter.end_document(implicit)
218
252
  *
219
253
  * End a document emission with an +implicit+ ending.
@@ -241,14 +275,14 @@ static VALUE end_document(VALUE self, VALUE imp)
241
275
  * See Psych::Handler#scalar
242
276
  */
243
277
  static VALUE scalar(
244
- VALUE self,
245
- VALUE value,
246
- VALUE anchor,
247
- VALUE tag,
248
- VALUE plain,
249
- VALUE quoted,
250
- VALUE style
251
- ) {
278
+ VALUE self,
279
+ VALUE value,
280
+ VALUE anchor,
281
+ VALUE tag,
282
+ VALUE plain,
283
+ VALUE quoted,
284
+ VALUE style
285
+ ) {
252
286
  yaml_emitter_t * emitter;
253
287
  yaml_event_t event;
254
288
  rb_encoding *encoding;
@@ -261,25 +295,26 @@ static VALUE scalar(
261
295
  value = rb_str_export_to_enc(value, encoding);
262
296
 
263
297
  if(!NIL_P(anchor)) {
264
- Check_Type(anchor, T_STRING);
265
- anchor = rb_str_export_to_enc(anchor, encoding);
298
+ Check_Type(anchor, T_STRING);
299
+ anchor = rb_str_export_to_enc(anchor, encoding);
266
300
  }
267
301
 
268
302
  if(!NIL_P(tag)) {
269
- Check_Type(tag, T_STRING);
270
- tag = rb_str_export_to_enc(tag, encoding);
303
+ Check_Type(tag, T_STRING);
304
+ tag = rb_str_export_to_enc(tag, encoding);
271
305
  }
272
306
 
307
+ const char *value_ptr = StringValuePtr(value);
273
308
  yaml_scalar_event_initialize(
274
- &event,
275
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
276
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
277
- (yaml_char_t*)StringValuePtr(value),
278
- (int)RSTRING_LEN(value),
279
- plain ? 1 : 0,
280
- quoted ? 1 : 0,
281
- (yaml_scalar_style_t)NUM2INT(style)
282
- );
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
+ );
283
318
 
284
319
  emit(emitter, &event);
285
320
 
@@ -294,36 +329,36 @@ static VALUE scalar(
294
329
  * See Psych::Handler#start_sequence
295
330
  */
296
331
  static VALUE start_sequence(
297
- VALUE self,
298
- VALUE anchor,
299
- VALUE tag,
300
- VALUE implicit,
301
- VALUE style
302
- ) {
332
+ VALUE self,
333
+ VALUE anchor,
334
+ VALUE tag,
335
+ VALUE implicit,
336
+ VALUE style
337
+ ) {
303
338
  yaml_emitter_t * emitter;
304
339
  yaml_event_t event;
305
340
 
306
341
  rb_encoding * encoding = rb_utf8_encoding();
307
342
 
308
343
  if(!NIL_P(anchor)) {
309
- Check_Type(anchor, T_STRING);
310
- anchor = rb_str_export_to_enc(anchor, encoding);
344
+ Check_Type(anchor, T_STRING);
345
+ anchor = rb_str_export_to_enc(anchor, encoding);
311
346
  }
312
347
 
313
348
  if(!NIL_P(tag)) {
314
- Check_Type(tag, T_STRING);
315
- tag = rb_str_export_to_enc(tag, encoding);
349
+ Check_Type(tag, T_STRING);
350
+ tag = rb_str_export_to_enc(tag, encoding);
316
351
  }
317
352
 
318
353
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
319
354
 
320
355
  yaml_sequence_start_event_initialize(
321
- &event,
322
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
323
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
324
- implicit ? 1 : 0,
325
- (yaml_sequence_style_t)NUM2INT(style)
326
- );
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
+ );
327
362
 
328
363
  emit(emitter, &event);
329
364
 
@@ -357,12 +392,12 @@ static VALUE end_sequence(VALUE self)
357
392
  * See Psych::Handler#start_mapping
358
393
  */
359
394
  static VALUE start_mapping(
360
- VALUE self,
361
- VALUE anchor,
362
- VALUE tag,
363
- VALUE implicit,
364
- VALUE style
365
- ) {
395
+ VALUE self,
396
+ VALUE anchor,
397
+ VALUE tag,
398
+ VALUE implicit,
399
+ VALUE style
400
+ ) {
366
401
  yaml_emitter_t * emitter;
367
402
  yaml_event_t event;
368
403
  rb_encoding *encoding;
@@ -372,22 +407,22 @@ static VALUE start_mapping(
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
418
 
384
419
  yaml_mapping_start_event_initialize(
385
- &event,
386
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
387
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
388
- implicit ? 1 : 0,
389
- (yaml_mapping_style_t)NUM2INT(style)
390
- );
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
+ );
391
426
 
392
427
  emit(emitter, &event);
393
428
 
@@ -426,14 +461,14 @@ static VALUE alias(VALUE self, VALUE anchor)
426
461
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
427
462
 
428
463
  if(!NIL_P(anchor)) {
429
- Check_Type(anchor, T_STRING);
430
- 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());
431
466
  }
432
467
 
433
468
  yaml_alias_event_initialize(
434
- &event,
435
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
436
- );
469
+ &event,
470
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
471
+ );
437
472
 
438
473
  emit(emitter, &event);
439
474