oj 3.11.3 → 3.11.4
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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/ext/oj/buf.h +34 -38
- data/ext/oj/cache8.c +59 -62
- data/ext/oj/cache8.h +8 -7
- data/ext/oj/circarray.c +33 -35
- data/ext/oj/circarray.h +11 -9
- data/ext/oj/code.c +170 -174
- data/ext/oj/code.h +21 -20
- data/ext/oj/compat.c +159 -166
- data/ext/oj/custom.c +802 -851
- data/ext/oj/dump.c +766 -778
- data/ext/oj/dump.h +49 -51
- data/ext/oj/dump_compat.c +1 -0
- data/ext/oj/dump_leaf.c +116 -157
- data/ext/oj/dump_object.c +609 -628
- data/ext/oj/dump_strict.c +318 -327
- data/ext/oj/encode.h +3 -4
- data/ext/oj/err.c +39 -25
- data/ext/oj/err.h +24 -15
- data/ext/oj/extconf.rb +2 -1
- data/ext/oj/fast.c +1008 -1038
- data/ext/oj/hash.c +62 -66
- data/ext/oj/hash.h +7 -6
- data/ext/oj/hash_test.c +450 -443
- data/ext/oj/mimic_json.c +405 -401
- data/ext/oj/object.c +559 -528
- data/ext/oj/odd.c +123 -128
- data/ext/oj/odd.h +27 -25
- data/ext/oj/oj.c +1121 -921
- data/ext/oj/oj.h +286 -298
- data/ext/oj/parse.c +938 -930
- data/ext/oj/parse.h +70 -69
- data/ext/oj/rails.c +836 -839
- data/ext/oj/rails.h +7 -7
- data/ext/oj/reader.c +135 -140
- data/ext/oj/reader.h +66 -79
- data/ext/oj/resolve.c +43 -43
- data/ext/oj/resolve.h +3 -2
- data/ext/oj/rxclass.c +67 -68
- data/ext/oj/rxclass.h +12 -10
- data/ext/oj/saj.c +451 -479
- data/ext/oj/scp.c +93 -103
- data/ext/oj/sparse.c +770 -730
- data/ext/oj/stream_writer.c +120 -149
- data/ext/oj/strict.c +71 -86
- data/ext/oj/string_writer.c +198 -243
- data/ext/oj/trace.c +29 -33
- data/ext/oj/trace.h +14 -11
- data/ext/oj/util.c +103 -103
- data/ext/oj/util.h +3 -2
- data/ext/oj/val_stack.c +47 -47
- data/ext/oj/val_stack.h +79 -86
- data/ext/oj/wab.c +291 -309
- data/lib/oj/bag.rb +1 -0
- data/lib/oj/mimic.rb +0 -12
- data/lib/oj/version.rb +1 -1
- data/test/activerecord/result_test.rb +7 -2
- data/test/foo.rb +35 -32
- data/test/test_scp.rb +1 -1
- metadata +2 -2
data/ext/oj/dump.h
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
// Copyright (c) 2011 Peter Ohler. All rights reserved.
|
2
|
+
// Licensed under the MIT License. See LICENSE file in the project root for license details.
|
2
3
|
|
3
4
|
#ifndef OJ_DUMP_H
|
4
5
|
#define OJ_DUMP_H
|
@@ -12,80 +13,77 @@
|
|
12
13
|
// Extra padding at end of buffer.
|
13
14
|
#define BUFFER_EXTRA 64
|
14
15
|
|
15
|
-
extern void
|
16
|
-
extern void
|
17
|
-
extern void
|
18
|
-
extern void
|
19
|
-
extern void
|
20
|
-
extern void
|
21
|
-
extern void
|
22
|
-
extern void
|
23
|
-
extern void
|
16
|
+
extern void oj_dump_nil(VALUE obj, int depth, Out out, bool as_ok);
|
17
|
+
extern void oj_dump_true(VALUE obj, int depth, Out out, bool as_ok);
|
18
|
+
extern void oj_dump_false(VALUE obj, int depth, Out out, bool as_ok);
|
19
|
+
extern void oj_dump_fixnum(VALUE obj, int depth, Out out, bool as_ok);
|
20
|
+
extern void oj_dump_bignum(VALUE obj, int depth, Out out, bool as_ok);
|
21
|
+
extern void oj_dump_float(VALUE obj, int depth, Out out, bool as_ok);
|
22
|
+
extern void oj_dump_str(VALUE obj, int depth, Out out, bool as_ok);
|
23
|
+
extern void oj_dump_sym(VALUE obj, int depth, Out out, bool as_ok);
|
24
|
+
extern void oj_dump_class(VALUE obj, int depth, Out out, bool as_ok);
|
24
25
|
|
25
|
-
extern void
|
26
|
-
extern void
|
27
|
-
extern void
|
28
|
-
extern void
|
29
|
-
extern void
|
30
|
-
extern void
|
26
|
+
extern void oj_dump_raw(const char *str, size_t cnt, Out out);
|
27
|
+
extern void oj_dump_cstr(const char *str, size_t cnt, bool is_sym, bool escape1, Out out);
|
28
|
+
extern void oj_dump_ruby_time(VALUE obj, Out out);
|
29
|
+
extern void oj_dump_xml_time(VALUE obj, Out out);
|
30
|
+
extern void oj_dump_time(VALUE obj, Out out, int withZone);
|
31
|
+
extern void oj_dump_obj_to_s(VALUE obj, Out out);
|
31
32
|
|
32
|
-
extern const char*
|
33
|
+
extern const char *oj_nan_str(VALUE obj, int opt, int mode, bool plus, int *lenp);
|
33
34
|
|
34
|
-
extern void
|
35
|
-
extern long
|
35
|
+
extern void oj_grow_out(Out out, size_t len);
|
36
|
+
extern long oj_check_circular(VALUE obj, Out out);
|
36
37
|
|
37
|
-
extern void
|
38
|
-
extern void
|
39
|
-
extern void
|
40
|
-
extern void
|
41
|
-
extern void
|
42
|
-
extern void
|
43
|
-
extern void
|
38
|
+
extern void oj_dump_strict_val(VALUE obj, int depth, Out out);
|
39
|
+
extern void oj_dump_null_val(VALUE obj, int depth, Out out);
|
40
|
+
extern void oj_dump_obj_val(VALUE obj, int depth, Out out);
|
41
|
+
extern void oj_dump_compat_val(VALUE obj, int depth, Out out, bool as_ok);
|
42
|
+
extern void oj_dump_rails_val(VALUE obj, int depth, Out out);
|
43
|
+
extern void oj_dump_custom_val(VALUE obj, int depth, Out out, bool as_ok);
|
44
|
+
extern void oj_dump_wab_val(VALUE obj, int depth, Out out);
|
44
45
|
|
45
|
-
extern void
|
46
|
+
extern void oj_dump_raw_json(VALUE obj, int depth, Out out);
|
46
47
|
|
47
|
-
extern VALUE
|
48
|
-
extern VALUE
|
48
|
+
extern VALUE oj_add_to_json(int argc, VALUE *argv, VALUE self);
|
49
|
+
extern VALUE oj_remove_to_json(int argc, VALUE *argv, VALUE self);
|
49
50
|
|
50
|
-
extern int
|
51
|
+
extern int oj_dump_float_printf(char *buf, size_t blen, VALUE obj, double d, const char *format);
|
51
52
|
|
52
|
-
extern bool
|
53
|
-
extern time_t
|
53
|
+
extern bool oj_dump_ignore(Options opts, VALUE obj);
|
54
|
+
extern time_t oj_sec_from_time_hard_way(VALUE obj);
|
54
55
|
|
55
|
-
inline static void
|
56
|
-
assure_size(Out out, size_t len) {
|
56
|
+
inline static void assure_size(Out out, size_t len) {
|
57
57
|
if (out->end - out->cur <= (long)len) {
|
58
|
-
|
58
|
+
oj_grow_out(out, len);
|
59
59
|
}
|
60
60
|
}
|
61
61
|
|
62
|
-
inline static void
|
63
|
-
fill_indent(Out out, int cnt) {
|
62
|
+
inline static void fill_indent(Out out, int cnt) {
|
64
63
|
if (0 < out->indent) {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
cnt *= out->indent;
|
65
|
+
*out->cur++ = '\n';
|
66
|
+
for (; 0 < cnt; cnt--) {
|
67
|
+
*out->cur++ = ' ';
|
68
|
+
}
|
70
69
|
}
|
71
70
|
}
|
72
71
|
|
73
|
-
inline static void
|
74
|
-
|
75
|
-
char
|
76
|
-
char *b = buf + sizeof(buf) - 1;
|
72
|
+
inline static void dump_ulong(unsigned long num, Out out) {
|
73
|
+
char buf[32];
|
74
|
+
char *b = buf + sizeof(buf) - 1;
|
77
75
|
|
78
76
|
*b-- = '\0';
|
79
77
|
if (0 < num) {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
for (; 0 < num; num /= 10, b--) {
|
79
|
+
*b = (num % 10) + '0';
|
80
|
+
}
|
81
|
+
b++;
|
84
82
|
} else {
|
85
|
-
|
83
|
+
*b = '0';
|
86
84
|
}
|
87
85
|
for (; '\0' != *b; b++) {
|
88
|
-
|
86
|
+
*out->cur++ = *b;
|
89
87
|
}
|
90
88
|
*out->cur = '\0';
|
91
89
|
}
|
data/ext/oj/dump_compat.c
CHANGED
data/ext/oj/dump_leaf.c
CHANGED
@@ -1,249 +1,208 @@
|
|
1
1
|
// Copyright (c) 2012, 2017 Peter Ohler. All rights reserved.
|
2
|
+
// Licensed under the MIT License. See LICENSE file in the project root for license details.
|
2
3
|
|
3
4
|
#include <errno.h>
|
4
5
|
|
5
|
-
#include "oj.h"
|
6
6
|
#include "dump.h"
|
7
|
+
#include "oj.h"
|
7
8
|
|
8
|
-
static void
|
9
|
+
static void dump_leaf(Leaf leaf, int depth, Out out);
|
9
10
|
|
10
|
-
static void
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
char *buf;
|
11
|
+
static void grow(Out out, size_t len) {
|
12
|
+
size_t size = out->end - out->buf;
|
13
|
+
long pos = out->cur - out->buf;
|
14
|
+
char * buf;
|
15
15
|
|
16
16
|
size *= 2;
|
17
17
|
if (size <= len * 2 + pos) {
|
18
|
-
|
18
|
+
size += len;
|
19
19
|
}
|
20
20
|
if (out->allocated) {
|
21
|
-
|
21
|
+
buf = REALLOC_N(out->buf, char, (size + BUFFER_EXTRA));
|
22
22
|
} else {
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
buf = ALLOC_N(char, (size + BUFFER_EXTRA));
|
24
|
+
out->allocated = true;
|
25
|
+
memcpy(buf, out->buf, out->end - out->buf + BUFFER_EXTRA);
|
26
26
|
}
|
27
27
|
if (0 == buf) {
|
28
|
-
|
28
|
+
rb_raise(rb_eNoMemError, "Failed to create string. [%d:%s]\n", ENOSPC, strerror(ENOSPC));
|
29
29
|
}
|
30
30
|
out->buf = buf;
|
31
31
|
out->end = buf + size;
|
32
32
|
out->cur = out->buf + pos;
|
33
33
|
}
|
34
34
|
|
35
|
-
|
36
|
-
inline static void
|
37
|
-
dump_chars(const char *s, size_t size, Out out) {
|
35
|
+
inline static void dump_chars(const char *s, size_t size, Out out) {
|
38
36
|
if (out->end - out->cur <= (long)size) {
|
39
|
-
|
37
|
+
grow(out, size);
|
40
38
|
}
|
41
39
|
memcpy(out->cur, s, size);
|
42
40
|
out->cur += size;
|
43
41
|
*out->cur = '\0';
|
44
42
|
}
|
45
43
|
|
46
|
-
static void
|
47
|
-
dump_leaf_str(Leaf leaf, Out out) {
|
44
|
+
static void dump_leaf_str(Leaf leaf, Out out) {
|
48
45
|
switch (leaf->value_type) {
|
49
|
-
case STR_VAL:
|
50
|
-
oj_dump_cstr(leaf->str, strlen(leaf->str), 0, 0, out);
|
51
|
-
break;
|
46
|
+
case STR_VAL: oj_dump_cstr(leaf->str, strlen(leaf->str), 0, 0, out); break;
|
52
47
|
case RUBY_VAL:
|
53
|
-
|
54
|
-
|
48
|
+
oj_dump_cstr(rb_string_value_cstr(&leaf->value), (int)RSTRING_LEN(leaf->value), 0, 0, out);
|
49
|
+
break;
|
55
50
|
case COL_VAL:
|
56
|
-
default:
|
57
|
-
rb_raise(rb_eTypeError, "Unexpected value type %02x.\n", leaf->value_type);
|
58
|
-
break;
|
51
|
+
default: rb_raise(rb_eTypeError, "Unexpected value type %02x.\n", leaf->value_type); break;
|
59
52
|
}
|
60
53
|
}
|
61
54
|
|
62
|
-
static void
|
63
|
-
dump_leaf_fixnum(Leaf leaf, Out out) {
|
55
|
+
static void dump_leaf_fixnum(Leaf leaf, Out out) {
|
64
56
|
switch (leaf->value_type) {
|
65
|
-
case STR_VAL:
|
66
|
-
dump_chars(leaf->str, strlen(leaf->str), out);
|
67
|
-
break;
|
57
|
+
case STR_VAL: dump_chars(leaf->str, strlen(leaf->str), out); break;
|
68
58
|
case RUBY_VAL:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
59
|
+
if (T_BIGNUM == rb_type(leaf->value)) {
|
60
|
+
oj_dump_bignum(leaf->value, 0, out, false);
|
61
|
+
} else {
|
62
|
+
oj_dump_fixnum(leaf->value, 0, out, false);
|
63
|
+
}
|
64
|
+
break;
|
75
65
|
case COL_VAL:
|
76
|
-
default:
|
77
|
-
rb_raise(rb_eTypeError, "Unexpected value type %02x.\n", leaf->value_type);
|
78
|
-
break;
|
66
|
+
default: rb_raise(rb_eTypeError, "Unexpected value type %02x.\n", leaf->value_type); break;
|
79
67
|
}
|
80
68
|
}
|
81
69
|
|
82
|
-
static void
|
83
|
-
dump_leaf_float(Leaf leaf, Out out) {
|
70
|
+
static void dump_leaf_float(Leaf leaf, Out out) {
|
84
71
|
switch (leaf->value_type) {
|
85
|
-
case STR_VAL:
|
86
|
-
|
87
|
-
break;
|
88
|
-
case RUBY_VAL:
|
89
|
-
oj_dump_float(leaf->value, 0, out, false);
|
90
|
-
break;
|
72
|
+
case STR_VAL: dump_chars(leaf->str, strlen(leaf->str), out); break;
|
73
|
+
case RUBY_VAL: oj_dump_float(leaf->value, 0, out, false); break;
|
91
74
|
case COL_VAL:
|
92
|
-
default:
|
93
|
-
rb_raise(rb_eTypeError, "Unexpected value type %02x.\n", leaf->value_type);
|
94
|
-
break;
|
75
|
+
default: rb_raise(rb_eTypeError, "Unexpected value type %02x.\n", leaf->value_type); break;
|
95
76
|
}
|
96
77
|
}
|
97
78
|
|
98
|
-
static void
|
99
|
-
|
100
|
-
|
101
|
-
int d2 = depth + 1;
|
79
|
+
static void dump_leaf_array(Leaf leaf, int depth, Out out) {
|
80
|
+
size_t size;
|
81
|
+
int d2 = depth + 1;
|
102
82
|
|
103
83
|
size = 2;
|
104
84
|
if (out->end - out->cur <= (long)size) {
|
105
|
-
|
85
|
+
grow(out, size);
|
106
86
|
}
|
107
87
|
*out->cur++ = '[';
|
108
88
|
if (0 == leaf->elements) {
|
109
|
-
|
89
|
+
*out->cur++ = ']';
|
110
90
|
} else {
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
91
|
+
Leaf first = leaf->elements->next;
|
92
|
+
Leaf e = first;
|
93
|
+
|
94
|
+
size = d2 * out->indent + 2;
|
95
|
+
do {
|
96
|
+
if (out->end - out->cur <= (long)size) {
|
97
|
+
grow(out, size);
|
98
|
+
}
|
99
|
+
fill_indent(out, d2);
|
100
|
+
dump_leaf(e, d2, out);
|
101
|
+
if (e->next != first) {
|
102
|
+
*out->cur++ = ',';
|
103
|
+
}
|
104
|
+
e = e->next;
|
105
|
+
} while (e != first);
|
106
|
+
size = depth * out->indent + 1;
|
107
|
+
if (out->end - out->cur <= (long)size) {
|
108
|
+
grow(out, size);
|
109
|
+
}
|
110
|
+
fill_indent(out, depth);
|
111
|
+
*out->cur++ = ']';
|
132
112
|
}
|
133
113
|
*out->cur = '\0';
|
134
114
|
}
|
135
115
|
|
136
|
-
static void
|
137
|
-
|
138
|
-
|
139
|
-
int d2 = depth + 1;
|
116
|
+
static void dump_leaf_hash(Leaf leaf, int depth, Out out) {
|
117
|
+
size_t size;
|
118
|
+
int d2 = depth + 1;
|
140
119
|
|
141
120
|
size = 2;
|
142
121
|
if (out->end - out->cur <= (long)size) {
|
143
|
-
|
122
|
+
grow(out, size);
|
144
123
|
}
|
145
124
|
*out->cur++ = '{';
|
146
125
|
if (0 == leaf->elements) {
|
147
|
-
|
126
|
+
*out->cur++ = '}';
|
148
127
|
} else {
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
128
|
+
Leaf first = leaf->elements->next;
|
129
|
+
Leaf e = first;
|
130
|
+
|
131
|
+
size = d2 * out->indent + 2;
|
132
|
+
do {
|
133
|
+
if (out->end - out->cur <= (long)size) {
|
134
|
+
grow(out, size);
|
135
|
+
}
|
136
|
+
fill_indent(out, d2);
|
137
|
+
oj_dump_cstr(e->key, strlen(e->key), 0, 0, out);
|
138
|
+
*out->cur++ = ':';
|
139
|
+
dump_leaf(e, d2, out);
|
140
|
+
if (e->next != first) {
|
141
|
+
*out->cur++ = ',';
|
142
|
+
}
|
143
|
+
e = e->next;
|
144
|
+
} while (e != first);
|
145
|
+
size = depth * out->indent + 1;
|
146
|
+
if (out->end - out->cur <= (long)size) {
|
147
|
+
grow(out, size);
|
148
|
+
}
|
149
|
+
fill_indent(out, depth);
|
150
|
+
*out->cur++ = '}';
|
172
151
|
}
|
173
152
|
*out->cur = '\0';
|
174
153
|
}
|
175
154
|
|
176
|
-
static void
|
177
|
-
dump_leaf(Leaf leaf, int depth, Out out) {
|
155
|
+
static void dump_leaf(Leaf leaf, int depth, Out out) {
|
178
156
|
switch (leaf->rtype) {
|
179
|
-
case T_NIL:
|
180
|
-
|
181
|
-
|
182
|
-
case
|
183
|
-
|
184
|
-
|
185
|
-
case
|
186
|
-
|
187
|
-
|
188
|
-
case T_STRING:
|
189
|
-
dump_leaf_str(leaf, out);
|
190
|
-
break;
|
191
|
-
case T_FIXNUM:
|
192
|
-
dump_leaf_fixnum(leaf, out);
|
193
|
-
break;
|
194
|
-
case T_FLOAT:
|
195
|
-
dump_leaf_float(leaf, out);
|
196
|
-
break;
|
197
|
-
case T_ARRAY:
|
198
|
-
dump_leaf_array(leaf, depth, out);
|
199
|
-
break;
|
200
|
-
case T_HASH:
|
201
|
-
dump_leaf_hash(leaf, depth, out);
|
202
|
-
break;
|
203
|
-
default:
|
204
|
-
rb_raise(rb_eTypeError, "Unexpected type %02x.\n", leaf->rtype);
|
205
|
-
break;
|
157
|
+
case T_NIL: oj_dump_nil(Qnil, 0, out, false); break;
|
158
|
+
case T_TRUE: oj_dump_true(Qtrue, 0, out, false); break;
|
159
|
+
case T_FALSE: oj_dump_false(Qfalse, 0, out, false); break;
|
160
|
+
case T_STRING: dump_leaf_str(leaf, out); break;
|
161
|
+
case T_FIXNUM: dump_leaf_fixnum(leaf, out); break;
|
162
|
+
case T_FLOAT: dump_leaf_float(leaf, out); break;
|
163
|
+
case T_ARRAY: dump_leaf_array(leaf, depth, out); break;
|
164
|
+
case T_HASH: dump_leaf_hash(leaf, depth, out); break;
|
165
|
+
default: rb_raise(rb_eTypeError, "Unexpected type %02x.\n", leaf->rtype); break;
|
206
166
|
}
|
207
167
|
}
|
208
168
|
|
209
|
-
void
|
210
|
-
oj_dump_leaf_to_json(Leaf leaf, Options copts, Out out) {
|
169
|
+
void oj_dump_leaf_to_json(Leaf leaf, Options copts, Out out) {
|
211
170
|
if (0 == out->buf) {
|
212
|
-
|
213
|
-
|
214
|
-
|
171
|
+
out->buf = ALLOC_N(char, 4096);
|
172
|
+
out->end = out->buf + 4095 -
|
173
|
+
BUFFER_EXTRA; // 1 less than end plus extra for possible errors
|
174
|
+
out->allocated = true;
|
215
175
|
}
|
216
|
-
out->cur
|
176
|
+
out->cur = out->buf;
|
217
177
|
out->circ_cnt = 0;
|
218
|
-
out->opts
|
178
|
+
out->opts = copts;
|
219
179
|
out->hash_cnt = 0;
|
220
|
-
out->indent
|
180
|
+
out->indent = copts->indent;
|
221
181
|
dump_leaf(leaf, 0, out);
|
222
182
|
}
|
223
183
|
|
224
|
-
void
|
225
|
-
|
226
|
-
char buf[4096];
|
184
|
+
void oj_write_leaf_to_file(Leaf leaf, const char *path, Options copts) {
|
185
|
+
char buf[4096];
|
227
186
|
struct _out out;
|
228
|
-
size_t
|
229
|
-
FILE
|
187
|
+
size_t size;
|
188
|
+
FILE * f;
|
230
189
|
|
231
|
-
out.buf
|
232
|
-
out.end
|
190
|
+
out.buf = buf;
|
191
|
+
out.end = buf + sizeof(buf) - BUFFER_EXTRA;
|
233
192
|
out.allocated = false;
|
234
|
-
out.omit_nil
|
193
|
+
out.omit_nil = copts->dump_opts.omit_nil;
|
235
194
|
oj_dump_leaf_to_json(leaf, copts, &out);
|
236
195
|
size = out.cur - out.buf;
|
237
196
|
if (0 == (f = fopen(path, "w"))) {
|
238
|
-
|
197
|
+
rb_raise(rb_eIOError, "%s\n", strerror(errno));
|
239
198
|
}
|
240
199
|
if (size != fwrite(out.buf, 1, size, f)) {
|
241
|
-
|
200
|
+
int err = ferror(f);
|
242
201
|
|
243
|
-
|
202
|
+
rb_raise(rb_eIOError, "Write failed. [%d:%s]\n", err, strerror(err));
|
244
203
|
}
|
245
204
|
if (out.allocated) {
|
246
|
-
|
205
|
+
xfree(out.buf);
|
247
206
|
}
|
248
207
|
fclose(f);
|
249
208
|
}
|