ox 2.11.0 → 2.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/README.md +55 -7
- data/ext/ox/builder.c +13 -7
- data/ext/ox/dump.c +31 -25
- 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 +8 -45
- data/ext/ox/ox.c +59 -48
- data/ext/ox/ox.h +33 -38
- 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 -8
- data/ext/ox/encode.h +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4121ea0bb75760d8b57c9904bf884c44455e1d2613b3826b3765004b006c65a0
|
4
|
+
data.tar.gz: cb5fbf251430612e4c46feca429a0b8d0e60fee8191a250ec540d709966ca20d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66995249fcc36e945629c09fe93bac6702b03e644d8fe310068f74f5dd1db47e65f98a86a7390f4cdefe865aa1976239caf283b393d725b1f6aae0cdc6a4d71c
|
7
|
+
data.tar.gz: 447fa33cc0ac30e78e56823f83b1be8d09dedc7763cb0fb820366c20cfe86ce9aafd6649fd3d0bcc8f90885f60325dae756ec32b44786cd482f9f0f7fb98a7ca
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,52 @@ 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
|
+
|
13
|
+
## [2.13.2] - 2020-02-05
|
14
|
+
|
15
|
+
Skip and missed sequence
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- Add ' sequence.
|
20
|
+
|
21
|
+
- `:skip_off` no longer misses spaces between elements.
|
22
|
+
|
23
|
+
## [2.13.1] - 2020-01-30
|
24
|
+
|
25
|
+
HTML Sequences
|
26
|
+
|
27
|
+
### Added
|
28
|
+
|
29
|
+
- All HTML 4 sequence are now supported.
|
30
|
+
|
31
|
+
## [2.13.0] - 2020-01-25
|
32
|
+
|
33
|
+
HTML Escape Sequences
|
34
|
+
|
35
|
+
### Added
|
36
|
+
|
37
|
+
- All HTML 4 escape sequences are now parsed.
|
38
|
+
|
39
|
+
## [2.12.1] - 2020-01-05
|
40
|
+
|
41
|
+
Ruby 2.7.0
|
42
|
+
|
43
|
+
### Fixed
|
44
|
+
|
45
|
+
- Updated for Ruby 2.7.0. More strict type checking. Function signature changes, and `Object#taint` deprecated.
|
46
|
+
|
47
|
+
## [2.12.0] - 2019-12-18
|
48
|
+
|
49
|
+
### Added
|
50
|
+
|
51
|
+
- Add `no_empty` option to not allow <xyz/> and use <xyz></xyz> instead.
|
52
|
+
|
7
53
|
## [2.11.0] - 2019-06-14
|
8
54
|
|
9
55
|
### Changed
|
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
|
@@ -22,7 +23,7 @@ A fast XML parser and Object marshaller as a Ruby gem.
|
|
22
23
|
|
23
24
|
## Support
|
24
25
|
|
25
|
-
[Get supported Ox with a Tidelift Subscription.](https://tidelift.com/subscription/pkg/rubygems-ox?utm_source=rubygems-ox&utm_medium=referral&utm_campaign=readme)
|
26
|
+
[Get supported Ox with a Tidelift Subscription.](https://tidelift.com/subscription/pkg/rubygems-ox?utm_source=rubygems-ox&utm_medium=referral&utm_campaign=readme) Security updates are [supported](https://tidelift.com/security).
|
26
27
|
|
27
28
|
## Links of Interest
|
28
29
|
|
@@ -108,7 +109,13 @@ obj2 = Ox.parse_obj(xml)
|
|
108
109
|
```ruby
|
109
110
|
require 'ox'
|
110
111
|
|
111
|
-
doc = Ox::Document.new
|
112
|
+
doc = Ox::Document.new
|
113
|
+
|
114
|
+
instruct = Ox::Instruct.new(:xml)
|
115
|
+
instruct[:version] = '1.0'
|
116
|
+
instruct[:encoding] = 'UTF-8'
|
117
|
+
instruct[:standalone] = 'yes'
|
118
|
+
doc << instruct
|
112
119
|
|
113
120
|
top = Ox::Element.new('top')
|
114
121
|
top[:name] = 'sample'
|
@@ -120,20 +127,31 @@ top << mid
|
|
120
127
|
|
121
128
|
bot = Ox::Element.new('bottom')
|
122
129
|
bot[:name] = 'third'
|
130
|
+
bot << 'text at bottom'
|
123
131
|
mid << bot
|
124
132
|
|
133
|
+
other_elements = Ox::Element.new('otherElements')
|
134
|
+
other_elements << Ox::CData.new('<sender>John Smith</sender>')
|
135
|
+
other_elements << Ox::Comment.new('Director\'s commentary')
|
136
|
+
# other_elements << Ox::DocType.new('content')
|
137
|
+
other_elements << Ox::Raw.new('<warning>Be carefull with this! Direct inject into XML!</warning>')
|
138
|
+
top << other_elements
|
139
|
+
|
140
|
+
|
125
141
|
xml = Ox.dump(doc)
|
126
142
|
|
127
143
|
# xml =
|
144
|
+
# <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
128
145
|
# <top name="sample">
|
129
146
|
# <middle name="second">
|
130
|
-
# <bottom name="third"
|
147
|
+
# <bottom name="third">text at bottom</bottom>
|
131
148
|
# </middle>
|
149
|
+
# <otherElements>
|
150
|
+
# <![CDATA[<sender>John Smith</sender>]]>
|
151
|
+
# <!-- Director's commentary -->
|
152
|
+
# <warning>Be carefull with this! Direct inject into XML!</warning>
|
153
|
+
# </otherElements>
|
132
154
|
# </top>
|
133
|
-
|
134
|
-
doc2 = Ox.parse(xml)
|
135
|
-
puts "Same? #{doc == doc2}"
|
136
|
-
# true
|
137
155
|
```
|
138
156
|
|
139
157
|
### HTML Parsing:
|
@@ -306,3 +324,33 @@ Ox supports circular references where attributes of one Object can refer to
|
|
306
324
|
an Object that refers back to the first Object. When this option is used an
|
307
325
|
Object ID is added to each XML Object element as the value of the 'a'
|
308
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
|
|
@@ -301,7 +301,14 @@ dump_start(Out out, Element e) {
|
|
301
301
|
fill_attr(out, 'i', s, end - s);
|
302
302
|
}
|
303
303
|
if (e->closed) {
|
304
|
-
|
304
|
+
if (out->opts->no_empty) {
|
305
|
+
*out->cur++ = '>';
|
306
|
+
*out->cur++ = '<';
|
307
|
+
*out->cur++ = '/';
|
308
|
+
*out->cur++ = e->type;
|
309
|
+
} else {
|
310
|
+
*out->cur++ = '/';
|
311
|
+
}
|
305
312
|
}
|
306
313
|
*out->cur++ = '>';
|
307
314
|
*out->cur = '\0';
|
@@ -448,17 +455,14 @@ static void
|
|
448
455
|
dump_time_thin(Out out, VALUE obj) {
|
449
456
|
char buf[64];
|
450
457
|
char *b = buf + sizeof(buf) - 1;
|
451
|
-
#if
|
458
|
+
#if HAVE_RB_TIME_TIMESPEC
|
452
459
|
struct timespec ts = rb_time_timespec(obj);
|
453
460
|
time_t sec = ts.tv_sec;
|
454
461
|
long nsec = ts.tv_nsec;
|
455
462
|
#else
|
456
463
|
time_t sec = NUM2LONG(rb_funcall2(obj, ox_tv_sec_id, 0, 0));
|
457
|
-
#if HAS_NANO_TIME
|
458
464
|
long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_nsec_id, 0, 0));
|
459
|
-
|
460
|
-
long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_usec_id, 0, 0)) * 1000;
|
461
|
-
#endif
|
465
|
+
//long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_usec_id, 0, 0)) * 1000;
|
462
466
|
#endif
|
463
467
|
char *dot = b - 10;
|
464
468
|
long size;
|
@@ -513,11 +517,8 @@ dump_time_xsd(Out out, VALUE obj) {
|
|
513
517
|
long nsec = ts.tv_nsec;
|
514
518
|
#else
|
515
519
|
time_t sec = NUM2LONG(rb_funcall2(obj, ox_tv_sec_id, 0, 0));
|
516
|
-
#if HAS_NANO_TIME
|
517
520
|
long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_nsec_id, 0, 0));
|
518
|
-
|
519
|
-
long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_usec_id, 0, 0)) * 1000;
|
520
|
-
#endif
|
521
|
+
//long nsec = NUM2LONG(rb_funcall2(obj, ox_tv_usec_id, 0, 0)) * 1000;
|
521
522
|
#endif
|
522
523
|
int tzhour, tzmin;
|
523
524
|
char tzsign = '+';
|
@@ -802,7 +803,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
|
|
802
803
|
}
|
803
804
|
case T_STRUCT:
|
804
805
|
{
|
805
|
-
#
|
806
|
+
#ifdef RSTRUCT_GET
|
806
807
|
VALUE clas;
|
807
808
|
|
808
809
|
if (0 != out->circ_cache && check_circular(out, obj, &e)) {
|
@@ -824,7 +825,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
|
|
824
825
|
} else {
|
825
826
|
char num_buf[16];
|
826
827
|
int d2 = depth + 1;
|
827
|
-
#
|
828
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
828
829
|
long i;
|
829
830
|
long cnt = NUM2LONG(rb_struct_size(obj));
|
830
831
|
#else // UNIFY_FIXNUM_AND_INTEGER
|
@@ -870,7 +871,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
|
|
870
871
|
dump_gen_element(obj, depth + 1, out);
|
871
872
|
out->w_end(out, &e);
|
872
873
|
} else { /* Object */
|
873
|
-
#if
|
874
|
+
#if HAVE_RB_IVAR_FOREACH
|
874
875
|
e.type = (Qtrue == rb_obj_is_kind_of(obj, rb_eException)) ? ExceptionCode : ObjectCode;
|
875
876
|
cnt = (int)rb_ivar_count(obj);
|
876
877
|
e.closed = (0 >= cnt);
|
@@ -998,7 +999,9 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
|
|
998
999
|
}
|
999
1000
|
|
1000
1001
|
static int
|
1001
|
-
dump_var(ID key, VALUE value,
|
1002
|
+
dump_var(ID key, VALUE value, VALUE ov) {
|
1003
|
+
Out out = (Out)ov;
|
1004
|
+
|
1002
1005
|
if (T_DATA == rb_type(value) && key == ox_mesg_id) {
|
1003
1006
|
/* There is a secret recipe that keeps Exception mesg attributes as a
|
1004
1007
|
* T_DATA until it is needed. The safe way around this hack is to call
|
@@ -1015,7 +1018,9 @@ dump_var(ID key, VALUE value, Out out) {
|
|
1015
1018
|
}
|
1016
1019
|
|
1017
1020
|
static int
|
1018
|
-
dump_hash(VALUE key, VALUE value,
|
1021
|
+
dump_hash(VALUE key, VALUE value, VALUE ov) {
|
1022
|
+
Out out = (Out)ov;
|
1023
|
+
|
1019
1024
|
dump_obj(0, key, out->depth, out);
|
1020
1025
|
dump_obj(0, value, out->depth, out);
|
1021
1026
|
|
@@ -1105,6 +1110,11 @@ dump_gen_element(VALUE obj, int depth, Out out) {
|
|
1105
1110
|
*out->cur++ = '<';
|
1106
1111
|
*out->cur++ = '/';
|
1107
1112
|
fill_value(out, name, nlen);
|
1113
|
+
} else if (out->opts->no_empty) {
|
1114
|
+
*out->cur++ = '>';
|
1115
|
+
*out->cur++ = '<';
|
1116
|
+
*out->cur++ = '/';
|
1117
|
+
fill_value(out, name, nlen);
|
1108
1118
|
} else {
|
1109
1119
|
*out->cur++ = '/';
|
1110
1120
|
}
|
@@ -1186,16 +1196,13 @@ dump_gen_nodes(VALUE obj, int depth, Out out) {
|
|
1186
1196
|
}
|
1187
1197
|
|
1188
1198
|
static int
|
1189
|
-
dump_gen_attr(VALUE key, VALUE value,
|
1199
|
+
dump_gen_attr(VALUE key, VALUE value, VALUE ov) {
|
1200
|
+
Out out = (Out)ov;
|
1201
|
+
|
1190
1202
|
const char *ks;
|
1191
1203
|
size_t klen;
|
1192
1204
|
size_t size;
|
1193
1205
|
|
1194
|
-
#if HAS_PRIVATE_ENCODING
|
1195
|
-
// There seems to be a bug in jruby for converting symbols to strings and preserving the encoding. This is a work
|
1196
|
-
// around.
|
1197
|
-
ks = rb_str_ptr(rb_String(key));
|
1198
|
-
#else
|
1199
1206
|
switch (rb_type(key)) {
|
1200
1207
|
case T_SYMBOL:
|
1201
1208
|
ks = rb_id2name(SYM2ID(key));
|
@@ -1208,7 +1215,6 @@ dump_gen_attr(VALUE key, VALUE value, Out out) {
|
|
1208
1215
|
ks = StringValuePtr(key);
|
1209
1216
|
break;
|
1210
1217
|
}
|
1211
|
-
#endif
|
1212
1218
|
klen = strlen(ks);
|
1213
1219
|
value = rb_String(value);
|
1214
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}
|