ox 2.13.2 → 2.13.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b9169ce6c85abf39460754b0c28af8a286c55c5f3a76e61f9a8e6de823d991c
4
- data.tar.gz: 7f9a4a3f8a27fe0e44e116fb76e8b754f76bec0de43e1fec4c12c42780f68a7a
3
+ metadata.gz: 4121ea0bb75760d8b57c9904bf884c44455e1d2613b3826b3765004b006c65a0
4
+ data.tar.gz: cb5fbf251430612e4c46feca429a0b8d0e60fee8191a250ec540d709966ca20d
5
5
  SHA512:
6
- metadata.gz: 7903498e8e8f64232ffc168959b7f8d4ffdcfdbb7bd93407a7d35d575ad3f25dc20ce598c942e38dc8d7dd433d84e6957db48721b5c737fa0dc5f0144bd6556e
7
- data.tar.gz: ccb0187833dd6c33ba0dfa4a486d9deb4d1f0628ff3ede133f2d85f365c96a8ec98a52af72d364d8f8a3beb46de4ac077af404ffe8e019978ef039bf60762128
6
+ metadata.gz: 66995249fcc36e945629c09fe93bac6702b03e644d8fe310068f74f5dd1db47e65f98a86a7390f4cdefe865aa1976239caf283b393d725b1f6aae0cdc6a4d71c
7
+ data.tar.gz: 447fa33cc0ac30e78e56823f83b1be8d09dedc7763cb0fb820366c20cfe86ce9aafd6649fd3d0bcc8f90885f60325dae756ec32b44786cd482f9f0f7fb98a7ca
@@ -4,6 +4,12 @@ All changes to the Ox gem are documented here. Releases follow semantic versioni
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [2.13.3] - 2020-09-03
8
+
9
+ ### Changed
10
+
11
+ - mkmf have macros used instead of ad-hoc determinations.
12
+
7
13
  ## [2.13.2] - 2020-02-05
8
14
 
9
15
  Skip and missed sequence
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
  A fast XML parser and Object marshaller as a Ruby gem.
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/ohler55/ox.svg?branch=master)](http://travis-ci.org/ohler55/ox) [![TideLift](https://tidelift.com/badges/github/ohler55/ox)](https://tidelift.com/subscription/pkg/rubygems-ox?utm_source=rubygems-ox&utm_medium=referral&utm_campaign=readme)
5
+ [![Financial Contributors on Open Collective](https://opencollective.com/ohler/all/badge.svg?label=financial+contributors)](https://opencollective.com/ohler)
5
6
 
6
7
  ## Installation
7
8
  gem install ox
@@ -323,3 +324,33 @@ Ox supports circular references where attributes of one Object can refer to
323
324
  an Object that refers back to the first Object. When this option is used an
324
325
  Object ID is added to each XML Object element as the value of the 'a'
325
326
  attribute.
327
+
328
+ ## Contributors
329
+
330
+ ### Code Contributors
331
+
332
+ This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
333
+ <a href="https://github.com/ohler55/ox/graphs/contributors"><img src="https://opencollective.com/ohler/contributors.svg?width=890&button=false" /></a>
334
+
335
+ ### Financial Contributors
336
+
337
+ Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/ohler/contribute)]
338
+
339
+ #### Individuals
340
+
341
+ <a href="https://opencollective.com/ohler"><img src="https://opencollective.com/ohler/individuals.svg?width=890"></a>
342
+
343
+ #### Organizations
344
+
345
+ Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/ohler/contribute)]
346
+
347
+ <a href="https://opencollective.com/ohler/organization/0/website"><img src="https://opencollective.com/ohler/organization/0/avatar.svg"></a>
348
+ <a href="https://opencollective.com/ohler/organization/1/website"><img src="https://opencollective.com/ohler/organization/1/avatar.svg"></a>
349
+ <a href="https://opencollective.com/ohler/organization/2/website"><img src="https://opencollective.com/ohler/organization/2/avatar.svg"></a>
350
+ <a href="https://opencollective.com/ohler/organization/3/website"><img src="https://opencollective.com/ohler/organization/3/avatar.svg"></a>
351
+ <a href="https://opencollective.com/ohler/organization/4/website"><img src="https://opencollective.com/ohler/organization/4/avatar.svg"></a>
352
+ <a href="https://opencollective.com/ohler/organization/5/website"><img src="https://opencollective.com/ohler/organization/5/avatar.svg"></a>
353
+ <a href="https://opencollective.com/ohler/organization/6/website"><img src="https://opencollective.com/ohler/organization/6/avatar.svg"></a>
354
+ <a href="https://opencollective.com/ohler/organization/7/website"><img src="https://opencollective.com/ohler/organization/7/avatar.svg"></a>
355
+ <a href="https://opencollective.com/ohler/organization/8/website"><img src="https://opencollective.com/ohler/organization/8/avatar.svg"></a>
356
+ <a href="https://opencollective.com/ohler/organization/9/website"><img src="https://opencollective.com/ohler/organization/9/avatar.svg"></a>
@@ -8,6 +8,10 @@
8
8
  #include <stdio.h>
9
9
  #include <string.h>
10
10
 
11
+ #include "ruby.h"
12
+ #if HAVE_RB_ENC_ASSOCIATE
13
+ #include "ruby/encoding.h"
14
+ #endif
11
15
  #include "ox.h"
12
16
  #include "buf.h"
13
17
  #include "err.h"
@@ -331,7 +335,7 @@ to_s(Builder b) {
331
335
  rstr = rb_str_new(b->buf.head, buf_len(&b->buf));
332
336
 
333
337
  if ('\0' != *b->encoding) {
334
- #if HAS_ENCODING_SUPPORT
338
+ #if HAVE_RB_ENC_ASSOCIATE
335
339
  rb_enc_associate(rstr, rb_enc_find(b->encoding));
336
340
  #endif
337
341
  }
@@ -455,17 +455,14 @@ static void
455
455
  dump_time_thin(Out out, VALUE obj) {
456
456
  char buf[64];
457
457
  char *b = buf + sizeof(buf) - 1;
458
- #if HAS_RB_TIME_TIMESPEC
458
+ #if HAVE_RB_TIME_TIMESPEC
459
459
  struct timespec ts = rb_time_timespec(obj);
460
460
  time_t sec = ts.tv_sec;
461
461
  long nsec = ts.tv_nsec;
462
462
  #else
463
463
  time_t sec = NUM2LONG(rb_funcall2(obj, ox_tv_sec_id, 0, 0));
464
- #if HAS_NANO_TIME
465
464
  long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_nsec_id, 0, 0));
466
- #else
467
- long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_usec_id, 0, 0)) * 1000;
468
- #endif
465
+ //long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_usec_id, 0, 0)) * 1000;
469
466
  #endif
470
467
  char *dot = b - 10;
471
468
  long size;
@@ -520,11 +517,8 @@ dump_time_xsd(Out out, VALUE obj) {
520
517
  long nsec = ts.tv_nsec;
521
518
  #else
522
519
  time_t sec = NUM2LONG(rb_funcall2(obj, ox_tv_sec_id, 0, 0));
523
- #if HAS_NANO_TIME
524
520
  long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_nsec_id, 0, 0));
525
- #else
526
- long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_usec_id, 0, 0)) * 1000;
527
- #endif
521
+ //long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_usec_id, 0, 0)) * 1000;
528
522
  #endif
529
523
  int tzhour, tzmin;
530
524
  char tzsign = '+';
@@ -809,7 +803,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
809
803
  }
810
804
  case T_STRUCT:
811
805
  {
812
- #if HAS_RSTRUCT
806
+ #ifdef RSTRUCT_GET
813
807
  VALUE clas;
814
808
 
815
809
  if (0 != out->circ_cache && check_circular(out, obj, &e)) {
@@ -831,7 +825,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
831
825
  } else {
832
826
  char num_buf[16];
833
827
  int d2 = depth + 1;
834
- #if UNIFY_FIXNUM_AND_BIGNUM
828
+ #ifdef RUBY_INTEGER_UNIFICATION
835
829
  long i;
836
830
  long cnt = NUM2LONG(rb_struct_size(obj));
837
831
  #else // UNIFY_FIXNUM_AND_INTEGER
@@ -877,7 +871,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
877
871
  dump_gen_element(obj, depth + 1, out);
878
872
  out->w_end(out, &e);
879
873
  } else { /* Object */
880
- #if HAS_IVAR_HELPERS
874
+ #if HAVE_RB_IVAR_FOREACH
881
875
  e.type = (Qtrue == rb_obj_is_kind_of(obj, rb_eException)) ? ExceptionCode : ObjectCode;
882
876
  cnt = (int)rb_ivar_count(obj);
883
877
  e.closed = (0 >= cnt);
@@ -1209,11 +1203,6 @@ dump_gen_attr(VALUE key, VALUE value, VALUE ov) {
1209
1203
  size_t klen;
1210
1204
  size_t size;
1211
1205
 
1212
- #if HAS_PRIVATE_ENCODING
1213
- // There seems to be a bug in jruby for converting symbols to strings and preserving the encoding. This is a work
1214
- // around.
1215
- ks = rb_str_ptr(rb_String(key));
1216
- #else
1217
1206
  switch (rb_type(key)) {
1218
1207
  case T_SYMBOL:
1219
1208
  ks = rb_id2name(SYM2ID(key));
@@ -1226,7 +1215,6 @@ dump_gen_attr(VALUE key, VALUE value, VALUE ov) {
1226
1215
  ks = StringValuePtr(key);
1227
1216
  break;
1228
1217
  }
1229
- #endif
1230
1218
  klen = strlen(ks);
1231
1219
  value = rb_String(value);
1232
1220
  size = 4 + klen + RSTRING_LEN(value);
@@ -6,7 +6,6 @@ dir_config(extension_name)
6
6
  parts = RUBY_DESCRIPTION.split(' ')
7
7
  type = parts[0].downcase()
8
8
  type = 'ree' if 'ruby' == type && RUBY_DESCRIPTION.include?('Ruby Enterprise Edition')
9
- is_windows = RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
10
9
  platform = RUBY_PLATFORM
11
10
  version = RUBY_VERSION.split('.')
12
11
  puts ">>>>> Creating Makefile for #{type} version #{RUBY_VERSION} on #{platform} <<<<<"
@@ -18,41 +17,8 @@ dflags = {
18
17
  'RUBY_VERSION_MAJOR' => version[0],
19
18
  'RUBY_VERSION_MINOR' => version[1],
20
19
  'RUBY_VERSION_MICRO' => version[2],
21
- 'HAS_RB_TIME_TIMESPEC' => ('ruby' == type && ('1.9.3' == RUBY_VERSION)) ? 1 : 0,
22
- #'HAS_RB_TIME_TIMESPEC' => ('ruby' == type && ('1.9.3' == RUBY_VERSION || '2' <= version[0])) ? 1 : 0,
23
- 'HAS_TM_GMTOFF' => ('ruby' == type && (('1' == version[0] && '9' == version[1]) || '2' <= version[0]) &&
24
- !(platform.include?('cygwin') || platform.include?('solaris') || platform.include?('linux') || RUBY_PLATFORM =~ /(win|w)32$/)) ? 1 : 0,
25
- 'HAS_ENCODING_SUPPORT' => (('ruby' == type || 'rubinius' == type || 'macruby' == type) &&
26
- (('1' == version[0] && '9' == version[1]) || '2' <= version[0])) ? 1 : 0,
27
- 'HAS_ONIG' => (('ruby' == type || 'jruby' == type || 'rubinius' == type) &&
28
- (('1' == version[0] && '9' == version[1]) || '2' <= version[0])) ? 1 : 0,
29
- 'HAS_PRIVATE_ENCODING' => ('jruby' == type && '1' == version[0] && '9' == version[1]) ? 1 : 0,
30
- 'HAS_NANO_TIME' => ('ruby' == type && ('1' == version[0] && '9' == version[1]) || '2' <= version[0]) ? 1 : 0,
31
- 'HAS_RSTRUCT' => ('ruby' == type || 'ree' == type) ? 1 : 0,
32
- 'HAS_IVAR_HELPERS' => ('ruby' == type && !is_windows && (('1' == version[0] && '9' == version[1]) || '2' <= version[0])) ? 1 : 0,
33
- 'HAS_PROC_WITH_BLOCK' => ('ruby' == type && ('1' == version[0] && '9' == version[1]) || '2' <= version[0]) ? 1 : 0,
34
- 'HAS_GC_GUARD' => ('jruby' != type && 'rubinius' != type) ? 1 : 0,
35
- 'HAS_BIGDECIMAL' => ('jruby' != type) ? 1 : 0,
36
- 'HAS_TOP_LEVEL_ST_H' => ('ree' == type || ('ruby' == type && '1' == version[0] && '8' == version[1])) ? 1 : 0,
37
- 'NEEDS_UIO' => (RUBY_PLATFORM =~ /(win|w)32$/) ? 0 : 1,
38
- 'HAS_DATA_OBJECT_WRAP' => ('ruby' == type && '2' == version[0] && '3' <= version[1]) ? 1 : 0,
39
- 'UNIFY_FIXNUM_AND_BIGNUM' => ('ruby' == type && '2' == version[0] && '4' <= version[1]) ? 1 : 0,
40
20
  }
41
21
 
42
- if RUBY_PLATFORM =~ /(win|w)32$/ || RUBY_PLATFORM =~ /solaris2\.10/
43
- dflags['NEEDS_STPCPY'] = nil
44
- end
45
-
46
- if ['i386-darwin10.0.0', 'x86_64-darwin10.8.0'].include? RUBY_PLATFORM
47
- dflags['NEEDS_STPCPY'] = nil
48
- dflags['HAS_IVAR_HELPERS'] = 0 if ('ruby' == type && '1.9.1' == RUBY_VERSION)
49
- elsif 'x86_64-linux' == RUBY_PLATFORM && '1.9.3' == RUBY_VERSION && '2011-10-30' == RUBY_RELEASE_DATE
50
- begin
51
- dflags['NEEDS_STPCPY'] = nil if `more /etc/issue`.include?('CentOS release 5.4')
52
- rescue Exception
53
- end
54
- end
55
-
56
22
  dflags.each do |k,v|
57
23
  if v.nil?
58
24
  $CPPFLAGS += " -D#{k}"
@@ -66,6 +32,18 @@ CONFIG['warnflags'].slice!(/ -Wsuggest-attribute=format/)
66
32
  CONFIG['warnflags'].slice!(/ -Wdeclaration-after-statement/)
67
33
  CONFIG['warnflags'].slice!(/ -Wmissing-noreturn/)
68
34
 
35
+ have_func('rb_time_timespec')
36
+ have_func('rb_enc_associate')
37
+ have_func('rb_enc_find')
38
+ have_func('rb_struct_alloc_noinit')
39
+ have_func('rb_obj_encoding')
40
+ have_func('rb_ivar_foreach')
41
+
42
+ have_header('ruby/st.h')
43
+ have_header('sys/uio.h')
44
+
45
+ have_struct_member('struct tm', 'tm_gmtoff')
46
+
69
47
  create_makefile(extension_name)
70
48
 
71
49
  %x{make clean}
@@ -10,6 +10,9 @@
10
10
  #include <stdarg.h>
11
11
 
12
12
  #include "ruby.h"
13
+ #if HAVE_RB_ENC_ASSOCIATE
14
+ #include "ruby/encoding.h"
15
+ #endif
13
16
  #include "ox.h"
14
17
 
15
18
  static void instruct(PInfo pi, const char *target, Attr attrs, const char *content);
@@ -72,7 +75,7 @@ create_doc(PInfo pi) {
72
75
 
73
76
  helper_stack_init(&pi->helpers);
74
77
  doc = rb_obj_alloc(ox_document_clas);
75
- #if HAS_GC_GUARD
78
+ #ifdef RB_GC_GUARD
76
79
  RB_GC_GUARD(doc);
77
80
  #endif
78
81
  nodes = rb_ary_new();
@@ -100,7 +103,7 @@ create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
100
103
  sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
101
104
  rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
102
105
  } else if (Yes == pi->options->sym_keys) {
103
- #if HAS_ENCODING_SUPPORT
106
+ #if HAVE_RB_ENC_ASSOCIATE
104
107
  if (0 != pi->options->rb_enc) {
105
108
  VALUE rstr = rb_str_new2(attrs->name);
106
109
 
@@ -109,41 +112,21 @@ create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
109
112
  } else {
110
113
  sym = ID2SYM(rb_intern(attrs->name));
111
114
  }
112
- #elif HAS_PRIVATE_ENCODING
113
- if (Qnil != pi->options->rb_enc) {
114
- VALUE rstr = rb_str_new2(attrs->name);
115
-
116
- rb_funcall(rstr, ox_force_encoding_id, 1, pi->options->rb_enc);
117
- sym = rb_funcall(rstr, ox_to_sym_id, 0);
118
- } else {
119
- sym = ID2SYM(rb_intern(attrs->name));
120
- }
121
- #else
122
115
  sym = ID2SYM(rb_intern(attrs->name));
123
116
  #endif
124
117
  rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
125
118
  } else {
126
119
  volatile VALUE rstr = rb_str_new2(attrs->name);
127
120
 
128
- #if HAS_ENCODING_SUPPORT
121
+ #if HAVE_RB_ENC_ASSOCIATE
129
122
  if (0 != pi->options->rb_enc) {
130
123
  rb_enc_associate(rstr, pi->options->rb_enc);
131
124
  }
132
- #elif HAS_PRIVATE_ENCODING
133
- if (Qnil != pi->options->rb_enc) {
134
- rb_funcall(rstr, ox_force_encoding_id, 1, pi->options->rb_enc);
135
- }
136
- #endif
137
125
  rb_hash_aset(ah, rstr, rb_str_new2(attrs->value));
138
126
  }
139
- #if HAS_ENCODING_SUPPORT
140
127
  if (0 == strcmp("encoding", attrs->name)) {
141
128
  pi->options->rb_enc = rb_enc_find(attrs->value);
142
129
  }
143
- #elif HAS_PRIVATE_ENCODING
144
- if (0 == strcmp("encoding", attrs->name)) {
145
- pi->options->rb_enc = rb_str_new2(attrs->value);
146
- }
147
130
  #endif
148
131
  }
149
132
  nodes = rb_ary_new();
@@ -212,14 +195,10 @@ add_doctype(PInfo pi, const char *docType) {
212
195
  VALUE n = rb_obj_alloc(ox_doctype_clas);
213
196
  VALUE s = rb_str_new2(docType);
214
197
 
215
- #if HAS_ENCODING_SUPPORT
198
+ #if HAVE_RB_ENC_ASSOCIATE
216
199
  if (0 != pi->options->rb_enc) {
217
200
  rb_enc_associate(s, pi->options->rb_enc);
218
201
  }
219
- #elif HAS_PRIVATE_ENCODING
220
- if (Qnil != pi->options->rb_enc) {
221
- rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
222
- }
223
202
  #endif
224
203
  rb_ivar_set(n, ox_at_value_id, s);
225
204
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
@@ -233,14 +212,10 @@ add_comment(PInfo pi, const char *comment) {
233
212
  VALUE n = rb_obj_alloc(ox_comment_clas);
234
213
  VALUE s = rb_str_new2(comment);
235
214
 
236
- #if HAS_ENCODING_SUPPORT
215
+ #if HAVE_RB_ENC_ASSOCIATE
237
216
  if (0 != pi->options->rb_enc) {
238
217
  rb_enc_associate(s, pi->options->rb_enc);
239
218
  }
240
- #elif HAS_PRIVATE_ENCODING
241
- if (Qnil != pi->options->rb_enc) {
242
- rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
243
- }
244
219
  #endif
245
220
  rb_ivar_set(n, ox_at_value_id, s);
246
221
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
@@ -254,14 +229,10 @@ add_cdata(PInfo pi, const char *cdata, size_t len) {
254
229
  VALUE n = rb_obj_alloc(ox_cdata_clas);
255
230
  VALUE s = rb_str_new2(cdata);
256
231
 
257
- #if HAS_ENCODING_SUPPORT
232
+ #if HAVE_RB_ENC_ASSOCIATE
258
233
  if (0 != pi->options->rb_enc) {
259
234
  rb_enc_associate(s, pi->options->rb_enc);
260
235
  }
261
- #elif HAS_PRIVATE_ENCODING
262
- if (Qnil != pi->options->rb_enc) {
263
- rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
264
- }
265
236
  #endif
266
237
  rb_ivar_set(n, ox_at_value_id, s);
267
238
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
@@ -274,14 +245,10 @@ static void
274
245
  add_text(PInfo pi, char *text, int closed) {
275
246
  VALUE s = rb_str_new2(text);
276
247
 
277
- #if HAS_ENCODING_SUPPORT
248
+ #if HAVE_RB_ENC_ASSOCIATE
278
249
  if (0 != pi->options->rb_enc) {
279
250
  rb_enc_associate(s, pi->options->rb_enc);
280
251
  }
281
- #elif HAS_PRIVATE_ENCODING
282
- if (Qnil != pi->options->rb_enc) {
283
- rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
284
- }
285
252
  #endif
286
253
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
287
254
  create_doc(pi);
@@ -297,14 +264,10 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
297
264
  if (Qnil != pi->options->element_key_mod) {
298
265
  s = rb_funcall(pi->options->element_key_mod, ox_call_id, 1, s);
299
266
  }
300
- #if HAS_ENCODING_SUPPORT
267
+ #if HAVE_RB_ENC_ASSOCIATE
301
268
  if (0 != pi->options->rb_enc) {
302
269
  rb_enc_associate(s, pi->options->rb_enc);
303
270
  }
304
- #elif HAS_PRIVATE_ENCODING
305
- if (Qnil != pi->options->rb_enc) {
306
- rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
307
- }
308
271
  #endif
309
272
  e = rb_obj_alloc(ox_element_clas);
310
273
  rb_ivar_set(e, ox_at_value_id, s);
@@ -320,7 +283,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
320
283
  VALUE *slot;
321
284
 
322
285
  if (Qundef == (sym = ox_cache_get(ox_symbol_cache, attrs->name, &slot, 0))) {
323
- #if HAS_ENCODING_SUPPORT
286
+ #if HAVE_RB_ENC_ASSOCIATE
324
287
  if (0 != pi->options->rb_enc) {
325
288
  VALUE rstr = rb_str_new2(attrs->name);
326
289
 
@@ -329,15 +292,6 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
329
292
  } else {
330
293
  sym = ID2SYM(rb_intern(attrs->name));
331
294
  }
332
- #elif HAS_PRIVATE_ENCODING
333
- if (Qnil != pi->options->rb_enc) {
334
- VALUE rstr = rb_str_new2(attrs->name);
335
-
336
- rb_funcall(rstr, ox_force_encoding_id, 1, pi->options->rb_enc);
337
- sym = rb_funcall(rstr, ox_to_sym_id, 0);
338
- } else {
339
- sym = ID2SYM(rb_intern(attrs->name));
340
- }
341
295
  #else
342
296
  sym = ID2SYM(rb_intern(attrs->name));
343
297
  #endif
@@ -348,25 +302,17 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
348
302
  }
349
303
  } else {
350
304
  sym = rb_str_new2(attrs->name);
351
- #if HAS_ENCODING_SUPPORT
305
+ #if HAVE_RB_ENC_ASSOCIATE
352
306
  if (0 != pi->options->rb_enc) {
353
307
  rb_enc_associate(sym, pi->options->rb_enc);
354
308
  }
355
- #elif HAS_PRIVATE_ENCODING
356
- if (Qnil != pi->options->rb_enc) {
357
- rb_funcall(sym, ox_force_encoding_id, 1, pi->options->rb_enc);
358
- }
359
309
  #endif
360
310
  }
361
311
  s = rb_str_new2(attrs->value);
362
- #if HAS_ENCODING_SUPPORT
312
+ #if HAVE_RB_ENC_ASSOCIATE
363
313
  if (0 != pi->options->rb_enc) {
364
314
  rb_enc_associate(s, pi->options->rb_enc);
365
315
  }
366
- #elif HAS_PRIVATE_ENCODING
367
- if (Qnil != pi->options->rb_enc) {
368
- rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
369
- }
370
316
  #endif
371
317
  rb_hash_aset(ah, sym, s);
372
318
  }
@@ -403,20 +349,13 @@ add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
403
349
  if (0 != content) {
404
350
  c = rb_str_new2(content);
405
351
  }
406
- #if HAS_ENCODING_SUPPORT
352
+ #if HAVE_RB_ENC_ASSOCIATE
407
353
  if (0 != pi->options->rb_enc) {
408
354
  rb_enc_associate(s, pi->options->rb_enc);
409
355
  if (0 != content) {
410
356
  rb_enc_associate(c, pi->options->rb_enc);
411
357
  }
412
358
  }
413
- #elif HAS_PRIVATE_ENCODING
414
- if (Qnil != pi->options->rb_enc) {
415
- rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
416
- if (0 != content) {
417
- rb_funcall(c, ox_force_encoding_id, 1, pi->options->rb_enc);
418
- }
419
- }
420
359
  #endif
421
360
  inst = rb_obj_alloc(ox_instruct_clas);
422
361
  rb_ivar_set(inst, ox_at_value_id, s);
@@ -433,7 +372,7 @@ add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
433
372
  sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
434
373
  } else if (Yes == pi->options->sym_keys) {
435
374
  if (Qundef == (sym = ox_cache_get(ox_symbol_cache, attrs->name, &slot, 0))) {
436
- #if HAS_ENCODING_SUPPORT
375
+ #if HAVE_RB_ENC_ASSOCIATE
437
376
  if (0 != pi->options->rb_enc) {
438
377
  VALUE rstr = rb_str_new2(attrs->name);
439
378
 
@@ -442,15 +381,6 @@ add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
442
381
  } else {
443
382
  sym = ID2SYM(rb_intern(attrs->name));
444
383
  }
445
- #elif HAS_PRIVATE_ENCODING
446
- if (Qnil != pi->options->rb_enc) {
447
- VALUE rstr = rb_str_new2(attrs->name);
448
-
449
- rb_funcall(rstr, ox_force_encoding_id, 1, pi->options->rb_enc);
450
- sym = rb_funcall(rstr, ox_to_sym_id, 0);
451
- } else {
452
- sym = ID2SYM(rb_intern(attrs->name));
453
- }
454
384
  #else
455
385
  sym = ID2SYM(rb_intern(attrs->name));
456
386
  #endif
@@ -461,25 +391,17 @@ add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
461
391
  }
462
392
  } else {
463
393
  sym = rb_str_new2(attrs->name);
464
- #if HAS_ENCODING_SUPPORT
394
+ #if HAVE_RB_ENC_ASSOCIATE
465
395
  if (0 != pi->options->rb_enc) {
466
396
  rb_enc_associate(sym, pi->options->rb_enc);
467
397
  }
468
- #elif HAS_PRIVATE_ENCODING
469
- if (Qnil != pi->options->rb_enc) {
470
- rb_funcall(sym, ox_force_encoding_id, 1, pi->options->rb_enc);
471
- }
472
398
  #endif
473
399
  }
474
400
  s = rb_str_new2(attrs->value);
475
- #if HAS_ENCODING_SUPPORT
401
+ #if HAVE_RB_ENC_ASSOCIATE
476
402
  if (0 != pi->options->rb_enc) {
477
403
  rb_enc_associate(s, pi->options->rb_enc);
478
404
  }
479
- #elif HAS_PRIVATE_ENCODING
480
- if (Qnil != pi->options->rb_enc) {
481
- rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
482
- }
483
405
  #endif
484
406
  rb_hash_aset(ah, sym, s);
485
407
  }