ox 2.12.0 → 2.13.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/CHANGELOG.md +48 -0
- data/README.md +31 -0
- data/ext/ox/builder.c +13 -7
- data/ext/ox/dump.c +18 -24
- data/ext/ox/extconf.rb +16 -34
- data/ext/ox/gen_load.c +18 -96
- data/ext/ox/hash_load.c +62 -26
- data/ext/ox/obj_load.c +14 -46
- data/ext/ox/ox.c +34 -46
- data/ext/ox/ox.h +10 -16
- data/ext/ox/parse.c +59 -67
- data/ext/ox/sax.c +84 -134
- data/ext/ox/sax.h +2 -4
- data/ext/ox/sax_as.c +2 -6
- data/ext/ox/sax_buf.c +1 -1
- data/ext/ox/special.c +346 -0
- data/ext/ox/special.h +1 -0
- data/lib/ox/element.rb +1 -0
- data/lib/ox/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 455a3e6630c8cf482656e024c14c609cfcc5441d201dd6b6f7649a283309bf87
|
4
|
+
data.tar.gz: e6240807c3f21f2915d044b56bc05433730a39315b10a50c3698adcc5640cf1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ddfd3e2a3e80338a1f5d4cf36b9b0ea28b721f24d7d6bc8c3b1a27c2c026484596274b105b4da602e4070627411297295807eebbf83cc923863d4494e0c0c32
|
7
|
+
data.tar.gz: af3b468beb6e48aa6046b3829ee186433be56d308dd3bb06b19068eefd4a315c004353aaa245a95fdc42d315e817d7cca4f3d309b745fb782c5e77bbd463e427
|
data/CHANGELOG.md
CHANGED
@@ -4,8 +4,56 @@ All changes to the Ox gem are documented here. Releases follow semantic versioni
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [2.13.4] - 2020-09-11
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- Fixed one crash that occurred when a corrupted object encoded string was provided.
|
12
|
+
|
13
|
+
## [2.13.3] - 2020-09-03
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- mkmf have macros used instead of ad-hoc determinations.
|
18
|
+
|
19
|
+
## [2.13.2] - 2020-02-05
|
20
|
+
|
21
|
+
Skip and missed sequence
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
|
25
|
+
- Add ' sequence.
|
26
|
+
|
27
|
+
- `:skip_off` no longer misses spaces between elements.
|
28
|
+
|
29
|
+
## [2.13.1] - 2020-01-30
|
30
|
+
|
31
|
+
HTML Sequences
|
32
|
+
|
33
|
+
### Added
|
34
|
+
|
35
|
+
- All HTML 4 sequence are now supported.
|
36
|
+
|
37
|
+
## [2.13.0] - 2020-01-25
|
38
|
+
|
39
|
+
HTML Escape Sequences
|
40
|
+
|
41
|
+
### Added
|
42
|
+
|
43
|
+
- All HTML 4 escape sequences are now parsed.
|
44
|
+
|
45
|
+
## [2.12.1] - 2020-01-05
|
46
|
+
|
47
|
+
Ruby 2.7.0
|
48
|
+
|
49
|
+
### Fixed
|
50
|
+
|
51
|
+
- Updated for Ruby 2.7.0. More strict type checking. Function signature changes, and `Object#taint` deprecated.
|
52
|
+
|
7
53
|
## [2.12.0] - 2019-12-18
|
8
54
|
|
55
|
+
### Added
|
56
|
+
|
9
57
|
- Add `no_empty` option to not allow <xyz/> and use <xyz></xyz> instead.
|
10
58
|
|
11
59
|
## [2.11.0] - 2019-06-14
|
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
|
[](http://travis-ci.org/ohler55/ox) [](https://tidelift.com/subscription/pkg/rubygems-ox?utm_source=rubygems-ox&utm_medium=referral&utm_campaign=readme)
|
5
|
+
[](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>
|
data/ext/ox/builder.c
CHANGED
@@ -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"
|
@@ -17,7 +21,7 @@
|
|
17
21
|
typedef struct _element {
|
18
22
|
char *name;
|
19
23
|
char buf[64];
|
20
|
-
|
24
|
+
long len;
|
21
25
|
bool has_child;
|
22
26
|
bool non_text_child;
|
23
27
|
} *Element;
|
@@ -124,7 +128,7 @@ append_string(Builder b, const char *str, size_t size, const char *table, bool s
|
|
124
128
|
char buf[256];
|
125
129
|
char *end = buf + sizeof(buf) - 1;
|
126
130
|
char *bp = buf;
|
127
|
-
|
131
|
+
size_t i = size;
|
128
132
|
int fcnt;
|
129
133
|
|
130
134
|
for (; '\0' != *str && 0 < i; i--, str++) {
|
@@ -183,7 +187,7 @@ append_string(Builder b, const char *str, size_t size, const char *table, bool s
|
|
183
187
|
static void
|
184
188
|
append_sym_str(Builder b, VALUE v) {
|
185
189
|
const char *s;
|
186
|
-
|
190
|
+
long len;
|
187
191
|
|
188
192
|
switch (rb_type(v)) {
|
189
193
|
case T_STRING:
|
@@ -219,7 +223,9 @@ i_am_a_child(Builder b, bool is_text) {
|
|
219
223
|
}
|
220
224
|
|
221
225
|
static int
|
222
|
-
append_attr(VALUE key, VALUE value,
|
226
|
+
append_attr(VALUE key, VALUE value, VALUE bv) {
|
227
|
+
Builder b = (Builder)bv;
|
228
|
+
|
223
229
|
buf_append(&b->buf, ' ');
|
224
230
|
b->col++;
|
225
231
|
b->pos++;
|
@@ -329,7 +335,7 @@ to_s(Builder b) {
|
|
329
335
|
rstr = rb_str_new(b->buf.head, buf_len(&b->buf));
|
330
336
|
|
331
337
|
if ('\0' != *b->encoding) {
|
332
|
-
#if
|
338
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
333
339
|
rb_enc_associate(rstr, rb_enc_find(b->encoding));
|
334
340
|
#endif
|
335
341
|
}
|
@@ -600,7 +606,7 @@ builder_element(int argc, VALUE *argv, VALUE self) {
|
|
600
606
|
Builder b = (Builder)DATA_PTR(self);
|
601
607
|
Element e;
|
602
608
|
const char *name;
|
603
|
-
|
609
|
+
long len;
|
604
610
|
|
605
611
|
if (1 > argc) {
|
606
612
|
rb_raise(ox_arg_error_class, "missing element name");
|
@@ -662,7 +668,7 @@ static VALUE
|
|
662
668
|
builder_void_element(int argc, VALUE *argv, VALUE self) {
|
663
669
|
Builder b = (Builder)DATA_PTR(self);
|
664
670
|
const char *name;
|
665
|
-
|
671
|
+
long len;
|
666
672
|
|
667
673
|
if (1 > argc) {
|
668
674
|
rb_raise(ox_arg_error_class, "missing element name");
|
data/ext/ox/dump.c
CHANGED
@@ -54,7 +54,7 @@ static void dump_obj(ID aid, VALUE obj, int depth, Out out);
|
|
54
54
|
static void dump_gen_doc(VALUE obj, int depth, Out out);
|
55
55
|
static void dump_gen_element(VALUE obj, int depth, Out out);
|
56
56
|
static void dump_gen_instruct(VALUE obj, int depth, Out out);
|
57
|
-
static int dump_gen_attr(VALUE key, VALUE value,
|
57
|
+
static int dump_gen_attr(VALUE key, VALUE value, VALUE ov);
|
58
58
|
static int dump_gen_nodes(VALUE obj, int depth, Out out);
|
59
59
|
static void dump_gen_val_node(VALUE obj, int depth,
|
60
60
|
const char *pre, size_t plen,
|
@@ -67,12 +67,12 @@ static void grow(Out out, size_t len);
|
|
67
67
|
|
68
68
|
static void dump_value(Out out, const char *value, size_t size);
|
69
69
|
static void dump_str_value(Out out, const char *value, size_t size, const char *table);
|
70
|
-
static int dump_var(ID key, VALUE value,
|
70
|
+
static int dump_var(ID key, VALUE value, VALUE ov);
|
71
71
|
static void dump_num(Out out, VALUE obj);
|
72
72
|
static void dump_date(Out out, VALUE obj);
|
73
73
|
static void dump_time_thin(Out out, VALUE obj);
|
74
74
|
static void dump_time_xsd(Out out, VALUE obj);
|
75
|
-
static int dump_hash(VALUE key, VALUE value,
|
75
|
+
static int dump_hash(VALUE key, VALUE value, VALUE ov);
|
76
76
|
|
77
77
|
static int is_xml_friendly(const uchar *str, int len, const char *table);
|
78
78
|
|
@@ -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
|
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
|
-
|
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
|
-
|
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
|
-
#
|
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
|
-
#
|
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
|
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);
|
@@ -1005,7 +999,9 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
|
|
1005
999
|
}
|
1006
1000
|
|
1007
1001
|
static int
|
1008
|
-
dump_var(ID key, VALUE value,
|
1002
|
+
dump_var(ID key, VALUE value, VALUE ov) {
|
1003
|
+
Out out = (Out)ov;
|
1004
|
+
|
1009
1005
|
if (T_DATA == rb_type(value) && key == ox_mesg_id) {
|
1010
1006
|
/* There is a secret recipe that keeps Exception mesg attributes as a
|
1011
1007
|
* T_DATA until it is needed. The safe way around this hack is to call
|
@@ -1022,7 +1018,9 @@ dump_var(ID key, VALUE value, Out out) {
|
|
1022
1018
|
}
|
1023
1019
|
|
1024
1020
|
static int
|
1025
|
-
dump_hash(VALUE key, VALUE value,
|
1021
|
+
dump_hash(VALUE key, VALUE value, VALUE ov) {
|
1022
|
+
Out out = (Out)ov;
|
1023
|
+
|
1026
1024
|
dump_obj(0, key, out->depth, out);
|
1027
1025
|
dump_obj(0, value, out->depth, out);
|
1028
1026
|
|
@@ -1198,16 +1196,13 @@ dump_gen_nodes(VALUE obj, int depth, Out out) {
|
|
1198
1196
|
}
|
1199
1197
|
|
1200
1198
|
static int
|
1201
|
-
dump_gen_attr(VALUE key, VALUE value,
|
1199
|
+
dump_gen_attr(VALUE key, VALUE value, VALUE ov) {
|
1200
|
+
Out out = (Out)ov;
|
1201
|
+
|
1202
1202
|
const char *ks;
|
1203
1203
|
size_t klen;
|
1204
1204
|
size_t size;
|
1205
1205
|
|
1206
|
-
#if HAS_PRIVATE_ENCODING
|
1207
|
-
// There seems to be a bug in jruby for converting symbols to strings and preserving the encoding. This is a work
|
1208
|
-
// around.
|
1209
|
-
ks = rb_str_ptr(rb_String(key));
|
1210
|
-
#else
|
1211
1206
|
switch (rb_type(key)) {
|
1212
1207
|
case T_SYMBOL:
|
1213
1208
|
ks = rb_id2name(SYM2ID(key));
|
@@ -1220,7 +1215,6 @@ dump_gen_attr(VALUE key, VALUE value, Out out) {
|
|
1220
1215
|
ks = StringValuePtr(key);
|
1221
1216
|
break;
|
1222
1217
|
}
|
1223
|
-
#endif
|
1224
1218
|
klen = strlen(ks);
|
1225
1219
|
value = rb_String(value);
|
1226
1220
|
size = 4 + klen + RSTRING_LEN(value);
|
data/ext/ox/extconf.rb
CHANGED
@@ -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}"
|
@@ -62,6 +28,22 @@ dflags.each do |k,v|
|
|
62
28
|
end
|
63
29
|
$CPPFLAGS += ' -Wall'
|
64
30
|
#puts "*** $CPPFLAGS: #{$CPPFLAGS}"
|
31
|
+
CONFIG['warnflags'].slice!(/ -Wsuggest-attribute=format/)
|
32
|
+
CONFIG['warnflags'].slice!(/ -Wdeclaration-after-statement/)
|
33
|
+
CONFIG['warnflags'].slice!(/ -Wmissing-noreturn/)
|
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
|
+
|
65
47
|
create_makefile(extension_name)
|
66
48
|
|
67
49
|
%x{make clean}
|
data/ext/ox/gen_load.c
CHANGED
@@ -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
|
-
#
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
}
|