oj 2.1.7 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of oj might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70957d2247e339a9ad73f19ad36df9da6979848b
4
- data.tar.gz: b2bdcf86cf0920e464560066b7054c997656b53c
3
+ metadata.gz: 2acd85015af30a88c50ae38253f4595c701a6e6e
4
+ data.tar.gz: 226adba1e99b118b6c3fd6e3a1d4663a9168c94c
5
5
  SHA512:
6
- metadata.gz: d4ec5a8db9aa7fd4d9c3721ccbd09f7aa357583d4a8c75f071ee007356b9371164ab75dd2ea897117cb332cf9d6158f47e0c8338aacb3b77c389e0ca08c099a6
7
- data.tar.gz: 5849f4c725ee2db364c41a034aead4e1c547ae53bb090db10e6bbb65013a19812cd024586fcba1f0d58285ded793a5f5c4675103f095cd57f184ba36beca6fe8
6
+ metadata.gz: d13abbe27c0f818011a68e456d88cedb0b648641f543aa09eab20f9a43fdfd368899b51d99c732eb23ab1b405285a0f68203bd85e705f1fbbbf5d3e2c03e9bac
7
+ data.tar.gz: 526a83f70809d99e54ce21c0f1905cf0a19ceb35216aad41aa4138071af8e611f2c744ce8b4fbb22f20113b46db90d8bca57ded64a10da0729112c6812fadb22
data/README.md CHANGED
@@ -20,13 +20,15 @@ Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announceme
20
20
 
21
21
  [![Build Status](https://secure.travis-ci.org/ohler55/oj.png?branch=master)](http://travis-ci.org/ohler55/oj)
22
22
 
23
- ### Current Release 2.1.7
23
+ ### Current Release 2.2.0
24
24
 
25
- - Added support for NaN and -NaN to address issue #102. This is not according to the JSON spec but seems to be expected.
25
+ - All 1.8.x versions of Ruby now have require 'rational' called.
26
26
 
27
- - Added require for rational if the Ruby version is 1.8.7 to address issue #104.
27
+ - Removed the temporary GC disable and implemented mark strategy instead.
28
28
 
29
- - Added Rails re-call of Oj.dump in the to_json() method which caused loops with Rational objects to fix issue #108 and #105.
29
+ - Added new character encoding mode to support the Rails 4 escape characters of &, <, and > as xss_safe mode. The :encoding option replaces the :ascii_only option.
30
+
31
+ - Change parsing of NaN to not use math.h which on older systems does not define NAN.
30
32
 
31
33
  [Older release notes](http://www.ohler.com/dev/oj_misc/release_notes.html).
32
34
 
@@ -96,6 +96,7 @@ static void dump_odd(VALUE obj, Odd odd, VALUE clas, int depth, Out out);
96
96
 
97
97
  static void grow(Out out, size_t len);
98
98
  static size_t hibit_friendly_size(const uint8_t *str, size_t len);
99
+ static size_t xss_friendly_size(const uint8_t *str, size_t len);
99
100
  static size_t ascii_friendly_size(const uint8_t *str, size_t len);
100
101
 
101
102
  static void dump_leaf(Leaf leaf, int depth, Out out);
@@ -134,6 +135,16 @@ static char ascii_friendly_chars[256] = "\
134
135
  33333333333333333333333333333333\
135
136
  33333333333333333333333333333333";
136
137
 
138
+ static char xss_friendly_chars[256] = "\
139
+ 66666666222622666666666666666666\
140
+ 11211161111111121111111111116161\
141
+ 11111111111111111111111111112111\
142
+ 11111111111111111111111111111116\
143
+ 33333333333333333333333333333333\
144
+ 33333333333333333333333333333333\
145
+ 33333333333333333333333333333333\
146
+ 33333333333333333333333333333333";
147
+
137
148
  inline static size_t
138
149
  hibit_friendly_size(const uint8_t *str, size_t len) {
139
150
  size_t size = 0;
@@ -154,6 +165,16 @@ ascii_friendly_size(const uint8_t *str, size_t len) {
154
165
  return size - len * (size_t)'0';
155
166
  }
156
167
 
168
+ inline static size_t
169
+ xss_friendly_size(const uint8_t *str, size_t len) {
170
+ size_t size = 0;
171
+
172
+ for (; 0 < len; str++, len--) {
173
+ size += xss_friendly_chars[*str];
174
+ }
175
+ return size - len * (size_t)'0';
176
+ }
177
+
157
178
  inline static void
158
179
  fill_indent(Out out, int cnt) {
159
180
  if (0 < out->indent) {
@@ -401,13 +422,13 @@ dump_fixnum(VALUE obj, Out out) {
401
422
 
402
423
  static void
403
424
  dump_bignum(VALUE obj, Out out) {
404
- VALUE rs = rb_big2str(obj, 10);
405
- int cnt = (int)RSTRING_LEN(rs);
425
+ volatile VALUE rs = rb_big2str(obj, 10);
426
+ int cnt = (int)RSTRING_LEN(rs);
406
427
 
407
428
  if (out->end - out->cur <= (long)cnt) {
408
429
  grow(out, cnt);
409
430
  }
410
- memcpy(out->cur, StringValuePtr(rs), cnt);
431
+ memcpy(out->cur, rb_string_value_cstr((VALUE*)&rs), cnt);
411
432
  out->cur += cnt;
412
433
  *out->cur = '\0';
413
434
  }
@@ -455,10 +476,17 @@ dump_cstr(const char *str, size_t cnt, int is_sym, int escape1, Out out) {
455
476
  size_t size;
456
477
  char *cmap;
457
478
 
458
- if (Yes == out->opts->ascii_only) {
479
+ switch (out->opts->escape_mode) {
480
+ case ASCIIEsc:
459
481
  cmap = ascii_friendly_chars;
460
482
  size = ascii_friendly_size((uint8_t*)str, cnt);
461
- } else {
483
+ break;
484
+ case XSSEsc:
485
+ cmap = xss_friendly_chars;
486
+ size = xss_friendly_size((uint8_t*)str, cnt);
487
+ break;
488
+ case JSONEsc:
489
+ default:
462
490
  cmap = hibit_friendly_chars;
463
491
  size = hibit_friendly_size((uint8_t*)str, cnt);
464
492
  }
@@ -528,12 +556,12 @@ dump_cstr(const char *str, size_t cnt, int is_sym, int escape1, Out out) {
528
556
 
529
557
  static void
530
558
  dump_str_comp(VALUE obj, Out out) {
531
- dump_cstr(StringValuePtr(obj), RSTRING_LEN(obj), 0, 0, out);
559
+ dump_cstr(rb_string_value_cstr((VALUE*)&obj), RSTRING_LEN(obj), 0, 0, out);
532
560
  }
533
561
 
534
562
  static void
535
563
  dump_str_obj(VALUE obj, Out out) {
536
- const char *s = StringValuePtr(obj);
564
+ const char *s = rb_string_value_cstr((VALUE*)&obj);
537
565
  size_t len = RSTRING_LEN(obj);
538
566
  char s1 = s[1];
539
567
 
@@ -583,20 +611,14 @@ dump_class_obj(VALUE obj, Out out) {
583
611
 
584
612
  static void
585
613
  dump_array(VALUE a, int depth, Out out) {
586
- VALUE *np;
587
614
  size_t size;
588
- int cnt;
615
+ int i, cnt;
589
616
  int d2 = depth + 1;
590
617
  long id = check_circular(a, out);
591
618
 
592
619
  if (id < 0) {
593
620
  return;
594
621
  }
595
-
596
- #if HAS_GC_GUARD
597
- RB_GC_GUARD(a);
598
- #endif
599
- np = RARRAY_PTR(a);
600
622
  cnt = (int)RARRAY_LEN(a);
601
623
  *out->cur++ = '[';
602
624
  if (0 < id) {
@@ -626,7 +648,8 @@ dump_array(VALUE a, int depth, Out out) {
626
648
  } else {
627
649
  size = d2 * out->opts->dump_opts->indent_size + out->opts->dump_opts->array_size + 1;
628
650
  }
629
- for (; 0 < cnt; cnt--, np++) {
651
+ cnt--;
652
+ for (i = 0; i <= cnt; i++) {
630
653
  if (out->end - out->cur <= (long)size) {
631
654
  grow(out, size);
632
655
  }
@@ -645,8 +668,8 @@ dump_array(VALUE a, int depth, Out out) {
645
668
  }
646
669
  }
647
670
  }
648
- dump_val(*np, d2, out);
649
- if (1 < cnt) {
671
+ dump_val(rb_ary_entry(a, i), d2, out);
672
+ if (i < cnt) {
650
673
  *out->cur++ = ',';
651
674
  }
652
675
  }
@@ -1000,9 +1023,9 @@ dump_time(VALUE obj, Out out) {
1000
1023
 
1001
1024
  static void
1002
1025
  dump_ruby_time(VALUE obj, Out out) {
1003
- VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1026
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1004
1027
 
1005
- dump_cstr(StringValuePtr(rstr), RSTRING_LEN(rstr), 0, 0, out);
1028
+ dump_cstr(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), 0, 0, out);
1006
1029
  }
1007
1030
 
1008
1031
  static void
@@ -1098,9 +1121,9 @@ dump_data_strict(VALUE obj, Out out) {
1098
1121
  VALUE clas = rb_obj_class(obj);
1099
1122
 
1100
1123
  if (oj_bigdecimal_class == clas) {
1101
- VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1124
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1102
1125
 
1103
- dump_raw(StringValuePtr(rstr), RSTRING_LEN(rstr), out);
1126
+ dump_raw(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), out);
1104
1127
  } else {
1105
1128
  raise_strict(obj);
1106
1129
  }
@@ -1111,9 +1134,9 @@ dump_data_null(VALUE obj, Out out) {
1111
1134
  VALUE clas = rb_obj_class(obj);
1112
1135
 
1113
1136
  if (oj_bigdecimal_class == clas) {
1114
- VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1137
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1115
1138
 
1116
- dump_raw(StringValuePtr(rstr), RSTRING_LEN(rstr), out);
1139
+ dump_raw(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), out);
1117
1140
  } else {
1118
1141
  dump_nil(out);
1119
1142
  }
@@ -1121,10 +1144,10 @@ dump_data_null(VALUE obj, Out out) {
1121
1144
 
1122
1145
  static void
1123
1146
  dump_data_comp(VALUE obj, int depth, Out out) {
1124
- VALUE o2;
1147
+ volatile VALUE o2;
1125
1148
 
1126
1149
  if (rb_respond_to(obj, oj_to_hash_id)) {
1127
- VALUE h = rb_funcall(obj, oj_to_hash_id, 0);
1150
+ volatile VALUE h = rb_funcall(obj, oj_to_hash_id, 0);
1128
1151
 
1129
1152
  if (T_HASH != rb_type(h)) {
1130
1153
  rb_raise(rb_eTypeError, "%s.to_hash() did not return a Hash.\n", rb_class2name(rb_obj_class(obj)));
@@ -1133,14 +1156,14 @@ dump_data_comp(VALUE obj, int depth, Out out) {
1133
1156
  } else if (rb_respond_to(obj, oj_as_json_id) && obj != (o2 = rb_funcall(obj, oj_as_json_id, 0))) {
1134
1157
  dump_val(o2, depth, out);
1135
1158
  } else if (rb_respond_to(obj, oj_to_json_id) && (!oj_rails_hack || last_obj != obj)) {
1136
- VALUE rs;
1159
+ volatile VALUE rs;
1137
1160
  const char *s;
1138
1161
  int len;
1139
1162
 
1140
1163
  last_obj = obj;
1141
1164
  rs = rb_funcall(obj, oj_to_json_id, 0);
1142
1165
  last_obj = Qundef;
1143
- s = StringValuePtr(rs);
1166
+ s = rb_string_value_cstr((VALUE*)&rs);
1144
1167
  len = (int)RSTRING_LEN(rs);
1145
1168
 
1146
1169
  if (out->end - out->cur <= len + 1) {
@@ -1160,18 +1183,17 @@ dump_data_comp(VALUE obj, int depth, Out out) {
1160
1183
  default: dump_time(obj, out); break;
1161
1184
  }
1162
1185
  } else if (oj_bigdecimal_class == clas) {
1163
- VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1186
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1164
1187
 
1165
1188
  if (Yes == out->opts->bigdec_as_num) {
1166
- dump_raw(StringValuePtr(rstr), RSTRING_LEN(rstr), out);
1189
+ dump_raw(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), out);
1167
1190
  } else {
1168
- dump_cstr(StringValuePtr(rstr), RSTRING_LEN(rstr), 0, 0, out);
1191
+ dump_cstr(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), 0, 0, out);
1169
1192
  }
1170
1193
  } else {
1171
- VALUE rstr;
1194
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1172
1195
 
1173
- rstr = rb_funcall(obj, oj_to_s_id, 0);
1174
- dump_cstr(StringValuePtr(rstr), RSTRING_LEN(rstr), 0, 0, out);
1196
+ dump_cstr(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), 0, 0, out);
1175
1197
  }
1176
1198
  }
1177
1199
  }
@@ -1198,12 +1220,12 @@ dump_data_obj(VALUE obj, int depth, Out out) {
1198
1220
 
1199
1221
  if (0 == odd) {
1200
1222
  if (oj_bigdecimal_class == clas) {
1201
- VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1223
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1202
1224
 
1203
1225
  if (Yes == out->opts->bigdec_as_num) {
1204
- dump_raw(StringValuePtr(rstr), RSTRING_LEN(rstr), out);
1226
+ dump_raw(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), out);
1205
1227
  } else {
1206
- dump_cstr(StringValuePtr(rstr), RSTRING_LEN(rstr), 0, 0, out);
1228
+ dump_cstr(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), 0, 0, out);
1207
1229
  }
1208
1230
  } else {
1209
1231
  dump_nil(out);
@@ -1216,27 +1238,26 @@ dump_data_obj(VALUE obj, int depth, Out out) {
1216
1238
 
1217
1239
  static void
1218
1240
  dump_obj_comp(VALUE obj, int depth, Out out) {
1219
- #if HAS_GC_GUARD
1220
- RB_GC_GUARD(obj);
1221
- #endif
1222
1241
  if (rb_respond_to(obj, oj_to_hash_id)) {
1223
- VALUE h = rb_funcall(obj, oj_to_hash_id, 0);
1242
+ volatile VALUE h = rb_funcall(obj, oj_to_hash_id, 0);
1224
1243
 
1225
1244
  if (T_HASH != rb_type(h)) {
1226
1245
  rb_raise(rb_eTypeError, "%s.to_hash() did not return a Hash.\n", rb_class2name(rb_obj_class(obj)));
1227
1246
  }
1228
1247
  dump_hash(h, depth, out->opts->mode, out);
1229
1248
  } else if (rb_respond_to(obj, oj_as_json_id)) {
1230
- dump_val(rb_funcall(obj, oj_as_json_id, 0), depth, out);
1249
+ volatile VALUE js = rb_funcall(obj, oj_as_json_id, 0);
1250
+
1251
+ dump_val(js, depth, out);
1231
1252
  } else if (rb_respond_to(obj, oj_to_json_id) && (!oj_rails_hack || last_obj != obj)) {
1232
- VALUE rs;
1253
+ volatile VALUE rs;
1233
1254
  const char *s;
1234
1255
  int len;
1235
1256
 
1236
1257
  last_obj = obj;
1237
1258
  rs = rb_funcall(obj, oj_to_json_id, 0);
1238
1259
  last_obj = Qundef;
1239
- s = StringValuePtr(rs);
1260
+ s = rb_string_value_cstr((VALUE*)&rs);
1240
1261
  len = (int)RSTRING_LEN(rs);
1241
1262
 
1242
1263
  if (out->end - out->cur <= len + 1) {
@@ -1249,17 +1270,17 @@ dump_obj_comp(VALUE obj, int depth, Out out) {
1249
1270
  VALUE clas = rb_obj_class(obj);
1250
1271
 
1251
1272
  if (oj_bigdecimal_class == clas) {
1252
- VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1273
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1253
1274
 
1254
1275
  if (Yes == out->opts->bigdec_as_num) {
1255
- dump_raw(StringValuePtr(rstr), RSTRING_LEN(rstr), out);
1276
+ dump_raw(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), out);
1256
1277
  } else {
1257
- dump_cstr(StringValuePtr(rstr), RSTRING_LEN(rstr), 0, 0, out);
1278
+ dump_cstr(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), 0, 0, out);
1258
1279
  }
1259
1280
  } else if (oj_datetime_class == clas || oj_date_class == clas) {
1260
- VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1281
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1261
1282
 
1262
- dump_cstr(StringValuePtr(rstr), RSTRING_LEN(rstr), 0, 0, out);
1283
+ dump_cstr(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), 0, 0, out);
1263
1284
  } else {
1264
1285
  Odd odd = oj_get_odd(clas);
1265
1286
 
@@ -1283,9 +1304,9 @@ dump_obj_obj(VALUE obj, int depth, Out out) {
1283
1304
 
1284
1305
  if (0 == odd) {
1285
1306
  if (oj_bigdecimal_class == clas) {
1286
- VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1307
+ volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
1287
1308
 
1288
- dump_raw(StringValuePtr(rstr), RSTRING_LEN(rstr), out);
1309
+ dump_raw(rb_string_value_cstr((VALUE*)&rstr), RSTRING_LEN(rstr), out);
1289
1310
  } else {
1290
1311
  dump_obj_attrs(obj, clas, id, depth, out);
1291
1312
  }
@@ -1375,7 +1396,7 @@ dump_obj_attrs(VALUE obj, VALUE clas, slot_t id, int depth, Out out) {
1375
1396
  #if HAS_IVAR_HELPERS
1376
1397
  cnt = (int)rb_ivar_count(obj);
1377
1398
  #else
1378
- VALUE vars = rb_funcall2(obj, oj_instance_variables_id, 0, 0);
1399
+ volatile VALUE vars = rb_funcall2(obj, oj_instance_variables_id, 0, 0);
1379
1400
  VALUE *np = RARRAY_PTR(vars);
1380
1401
  ID vid;
1381
1402
  const char *attr;
@@ -1424,6 +1445,8 @@ dump_obj_attrs(VALUE obj, VALUE clas, slot_t id, int depth, Out out) {
1424
1445
  #endif
1425
1446
  #if HAS_EXCEPTION_MAGIC
1426
1447
  if (Qtrue == rb_obj_is_kind_of(obj, rb_eException)) {
1448
+ volatile VALUE rv;
1449
+
1427
1450
  if (',' != *(out->cur - 1)) {
1428
1451
  *out->cur++ = ',';
1429
1452
  }
@@ -1434,7 +1457,8 @@ dump_obj_attrs(VALUE obj, VALUE clas, slot_t id, int depth, Out out) {
1434
1457
  fill_indent(out, d2);
1435
1458
  dump_cstr("~mesg", 5, 0, 0, out);
1436
1459
  *out->cur++ = ':';
1437
- dump_val(rb_funcall2(obj, rb_intern("message"), 0, 0), d2, out);
1460
+ rv = rb_funcall2(obj, rb_intern("message"), 0, 0);
1461
+ dump_val(rv, d2, out);
1438
1462
  if (out->end - out->cur <= 2) {
1439
1463
  grow(out, 2);
1440
1464
  }
@@ -1446,7 +1470,8 @@ dump_obj_attrs(VALUE obj, VALUE clas, slot_t id, int depth, Out out) {
1446
1470
  fill_indent(out, d2);
1447
1471
  dump_cstr("~bt", 3, 0, 0, out);
1448
1472
  *out->cur++ = ':';
1449
- dump_val(rb_funcall2(obj, rb_intern("backtrace"), 0, 0), d2, out);
1473
+ rv = rb_funcall2(obj, rb_intern("backtrace"), 0, 0);
1474
+ dump_val(rv, d2, out);
1450
1475
  if (out->end - out->cur <= 2) {
1451
1476
  grow(out, 2);
1452
1477
  }
@@ -1463,17 +1488,19 @@ dump_obj_attrs(VALUE obj, VALUE clas, slot_t id, int depth, Out out) {
1463
1488
  static void
1464
1489
  dump_struct_comp(VALUE obj, int depth, Out out) {
1465
1490
  if (rb_respond_to(obj, oj_to_hash_id)) {
1466
- VALUE h = rb_funcall(obj, oj_to_hash_id, 0);
1491
+ volatile VALUE h = rb_funcall(obj, oj_to_hash_id, 0);
1467
1492
 
1468
1493
  if (T_HASH != rb_type(h)) {
1469
1494
  rb_raise(rb_eTypeError, "%s.to_hash() did not return a Hash.\n", rb_class2name(rb_obj_class(obj)));
1470
1495
  }
1471
1496
  dump_hash(h, depth, out->opts->mode, out);
1472
1497
  } else if (rb_respond_to(obj, oj_to_json_id)) {
1473
- VALUE rs = rb_funcall(obj, oj_to_json_id, 0);
1474
- const char *s = StringValuePtr(rs);
1475
- int len = (int)RSTRING_LEN(rs);
1498
+ volatile VALUE rs = rb_funcall(obj, oj_to_json_id, 0);
1499
+ const char *s;
1500
+ int len;
1476
1501
 
1502
+ s = rb_string_value_cstr((VALUE*)&rs);
1503
+ len = (int)RSTRING_LEN(rs);
1477
1504
  if (out->end - out->cur <= len) {
1478
1505
  grow(out, len);
1479
1506
  }
@@ -1530,11 +1557,11 @@ dump_struct_obj(VALUE obj, int depth, Out out) {
1530
1557
 
1531
1558
  static void
1532
1559
  dump_odd(VALUE obj, Odd odd, VALUE clas, int depth, Out out) {
1533
- ID *idp;
1534
- VALUE v;
1535
- const char *name;
1536
- size_t size;
1537
- int d2 = depth + 1;
1560
+ ID *idp;
1561
+ volatile VALUE v;
1562
+ const char *name;
1563
+ size_t size;
1564
+ int d2 = depth + 1;
1538
1565
 
1539
1566
  if (out->end - out->cur <= 2) {
1540
1567
  grow(out, 2);
@@ -1745,18 +1772,18 @@ oj_write_obj_to_stream(VALUE obj, VALUE stream, Options copts) {
1745
1772
  #ifndef JRUBY_RUBY
1746
1773
  #if !IS_WINDOWS
1747
1774
  } else if (rb_respond_to(stream, oj_fileno_id) && Qnil != (s = rb_funcall(stream, oj_fileno_id, 0))) {
1748
- int fd = FIX2INT(s);
1775
+ int fd = FIX2INT(s);
1749
1776
 
1750
- if (size != write(fd, out.buf, size)) {
1751
- if (out.allocated) {
1752
- xfree(out.buf);
1753
- }
1754
- rb_raise(rb_eIOError, "Write failed. [%d:%s]\n", errno, strerror(errno));
1777
+ if (size != write(fd, out.buf, size)) {
1778
+ if (out.allocated) {
1779
+ xfree(out.buf);
1755
1780
  }
1781
+ rb_raise(rb_eIOError, "Write failed. [%d:%s]\n", errno, strerror(errno));
1782
+ }
1756
1783
  #endif
1757
1784
  #endif
1758
1785
  } else if (rb_respond_to(stream, oj_write_id)) {
1759
- s = rb_funcall(stream, oj_write_id, 1, rb_str_new(out.buf, size));
1786
+ rb_funcall(stream, oj_write_id, 1, rb_str_new(out.buf, size));
1760
1787
  } else {
1761
1788
  if (out.allocated) {
1762
1789
  xfree(out.buf);
@@ -1787,7 +1814,7 @@ dump_leaf_str(Leaf leaf, Out out) {
1787
1814
  dump_cstr(leaf->str, strlen(leaf->str), 0, 0, out);
1788
1815
  break;
1789
1816
  case RUBY_VAL:
1790
- dump_cstr(StringValuePtr(leaf->value), RSTRING_LEN(leaf->value), 0, 0, out);
1817
+ dump_cstr(rb_string_value_cstr(&leaf->value), RSTRING_LEN(leaf->value), 0, 0, out);
1791
1818
  break;
1792
1819
  case COL_VAL:
1793
1820
  default:
@@ -28,9 +28,8 @@ dflags = {
28
28
  'HAS_IVAR_HELPERS' => ('ruby' == type && !is_windows && (('1' == version[0] && '9' == version[1]) || '2' <= version[0])) ? 1 : 0,
29
29
  'HAS_EXCEPTION_MAGIC' => ('ruby' == type && ('1' == version[0] && '9' == version[1])) ? 0 : 1,
30
30
  'HAS_PROC_WITH_BLOCK' => ('ruby' == type && (('1' == version[0] && '9' == version[1]) || '2' <= version[0])) ? 1 : 0,
31
- 'HAS_GC_GUARD' => ('jruby' != type && 'rubinius' != type) ? 1 : 0,
32
31
  'HAS_TOP_LEVEL_ST_H' => ('ree' == type || ('ruby' == type && '1' == version[0] && '8' == version[1])) ? 1 : 0,
33
- 'NEEDS_RATIONAL' => ('ruby' == type && '1' == version[0] && '8' == version[1]) ? 1 : 0,
32
+ 'NEEDS_RATIONAL' => ('1' == version[0] && '8' == version[1]) ? 1 : 0,
34
33
  'IS_WINDOWS' => is_windows ? 1 : 0,
35
34
  'SAFE_CACHE' => is_windows ? 0 : 1,
36
35
  }