ox 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ox might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/ext/ox/cache.c +1 -1
- data/ext/ox/cache.h +1 -1
- data/ext/ox/sax.c +75 -11
- data/ext/ox/sax.h +1 -47
- data/lib/ox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67efa2e182b17f740fb607db83a0a19e8cac6f69
|
4
|
+
data.tar.gz: 35a96cea460c51f6c511a9e7f7947246db358e6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e3fd93e060d88ad134b884be891563a168af3fd8847851aa8d12906ed8c4dd6757a4fd66a287883a5872281651a826b49e5da82ec03827d55bd2a2f3a9e9d87
|
7
|
+
data.tar.gz: d580345b51fb658223c25f15da6d0fa70ae79580984f1d275c8c6a6948e8a388af3412c5d3f8623224f082bbf33da88a6b4820cded7be16c37152e331ce5633a
|
data/README.md
CHANGED
@@ -34,14 +34,16 @@ A fast XML parser and Object marshaller as a Ruby gem.
|
|
34
34
|
|
35
35
|
## Release Notes
|
36
36
|
|
37
|
-
### Current Release 2.1.
|
37
|
+
### Current Release 2.1.5
|
38
38
|
|
39
|
-
- Fixed
|
40
|
-
|
39
|
+
- Fixed symbol intern problem with Ruby 2.2.0. Symbols are not dynamic unless
|
40
|
+
rb_intern(). There does not seem to be a way to force symbols created with
|
41
|
+
encoding to be pinned.
|
41
42
|
|
42
|
-
### Release 2.1.
|
43
|
+
### Release 2.1.4
|
43
44
|
|
44
|
-
-
|
45
|
+
- Fixed bug where the parser always started at the first position in a stringio
|
46
|
+
instead of the current position.
|
45
47
|
|
46
48
|
## Description
|
47
49
|
|
data/ext/ox/cache.c
CHANGED
@@ -67,7 +67,7 @@ ox_cache_new(Cache *cache) {
|
|
67
67
|
}
|
68
68
|
|
69
69
|
VALUE
|
70
|
-
ox_cache_get(Cache cache, const char *key, VALUE **slot, char **keyp) {
|
70
|
+
ox_cache_get(Cache cache, const char *key, VALUE **slot, const char **keyp) {
|
71
71
|
unsigned char *k = (unsigned char*)key;
|
72
72
|
Cache *cp;
|
73
73
|
|
data/ext/ox/cache.h
CHANGED
@@ -37,7 +37,7 @@ typedef struct _Cache *Cache;
|
|
37
37
|
|
38
38
|
extern void ox_cache_new(Cache *cache);
|
39
39
|
|
40
|
-
extern VALUE ox_cache_get(Cache cache, const char *key, VALUE **slot, char **keyp);
|
40
|
+
extern VALUE ox_cache_get(Cache cache, const char *key, VALUE **slot, const char **keyp);
|
41
41
|
|
42
42
|
extern void ox_cache_print(Cache cache);
|
43
43
|
|
data/ext/ox/sax.c
CHANGED
@@ -91,6 +91,71 @@ static VALUE protect_parse(VALUE drp) {
|
|
91
91
|
return Qnil;
|
92
92
|
}
|
93
93
|
|
94
|
+
#if HAS_ENCODING_SUPPORT || HAS_PRIVATE_ENCODING
|
95
|
+
static int
|
96
|
+
strIsAscii(const char *s) {
|
97
|
+
for (; '\0' != *s; s++) {
|
98
|
+
if (*s < ' ' || '~' < *s) {
|
99
|
+
return 0;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
return 1;
|
103
|
+
}
|
104
|
+
#endif
|
105
|
+
|
106
|
+
VALUE
|
107
|
+
str2sym(SaxDrive dr, const char *str, const char **strp) {
|
108
|
+
VALUE *slot;
|
109
|
+
VALUE sym;
|
110
|
+
|
111
|
+
if (dr->options.symbolize) {
|
112
|
+
if (Qundef == (sym = ox_cache_get(ox_symbol_cache, str, &slot, strp))) {
|
113
|
+
#if HAS_ENCODING_SUPPORT
|
114
|
+
if (0 != dr->encoding && !strIsAscii(str)) {
|
115
|
+
VALUE rstr = rb_str_new2(str);
|
116
|
+
|
117
|
+
// TBD if sym can be pinned down then use this all the time
|
118
|
+
rb_enc_associate(rstr, dr->encoding);
|
119
|
+
sym = rb_funcall(rstr, ox_to_sym_id, 0);
|
120
|
+
*slot = Qundef;
|
121
|
+
} else {
|
122
|
+
sym = ID2SYM(rb_intern(str));
|
123
|
+
*slot = sym;
|
124
|
+
}
|
125
|
+
#elif HAS_PRIVATE_ENCODING
|
126
|
+
if (Qnil != dr->encoding && !strIsAscii(str)) {
|
127
|
+
VALUE rstr = rb_str_new2(str);
|
128
|
+
|
129
|
+
rb_funcall(rstr, ox_force_encoding_id, 1, dr->encoding);
|
130
|
+
sym = rb_funcall(rstr, ox_to_sym_id, 0);
|
131
|
+
*slot = Qundef;
|
132
|
+
} else {
|
133
|
+
sym = ID2SYM(rb_intern(str));
|
134
|
+
*slot = sym;
|
135
|
+
}
|
136
|
+
#else
|
137
|
+
sym = ID2SYM(rb_intern(str));
|
138
|
+
*slot = sym;
|
139
|
+
#endif
|
140
|
+
}
|
141
|
+
} else {
|
142
|
+
sym = rb_str_new2(str);
|
143
|
+
#if HAS_ENCODING_SUPPORT
|
144
|
+
if (0 != dr->encoding) {
|
145
|
+
rb_enc_associate(sym, dr->encoding);
|
146
|
+
}
|
147
|
+
#elif HAS_PRIVATE_ENCODING
|
148
|
+
if (Qnil != dr->encoding) {
|
149
|
+
rb_funcall(sym, ox_force_encoding_id, 1, dr->encoding);
|
150
|
+
}
|
151
|
+
#endif
|
152
|
+
if (0 != strp) {
|
153
|
+
*strp = StringValuePtr(sym);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
return sym;
|
157
|
+
}
|
158
|
+
|
94
159
|
void
|
95
160
|
ox_sax_parse(VALUE handler, VALUE io, SaxOptions options) {
|
96
161
|
struct _SaxDrive dr;
|
@@ -708,14 +773,14 @@ read_comment(SaxDrive dr) {
|
|
708
773
|
*/
|
709
774
|
static char
|
710
775
|
read_element_start(SaxDrive dr) {
|
711
|
-
char
|
712
|
-
VALUE
|
713
|
-
char
|
714
|
-
int
|
715
|
-
int
|
716
|
-
int
|
717
|
-
Hint
|
718
|
-
int
|
776
|
+
const char *ename = 0;
|
777
|
+
volatile VALUE name = Qnil;
|
778
|
+
char c;
|
779
|
+
int closed;
|
780
|
+
int line = dr->buf.line;
|
781
|
+
int col = dr->buf.col - 1;
|
782
|
+
Hint h = 0;
|
783
|
+
int stackless = 0;
|
719
784
|
|
720
785
|
if ('\0' == (c = read_name_token(dr))) {
|
721
786
|
return '\0';
|
@@ -850,19 +915,18 @@ read_element_end(SaxDrive dr) {
|
|
850
915
|
|
851
916
|
if (0 == match) {
|
852
917
|
// Not found so open and close element.
|
853
|
-
char *ename = 0;
|
854
918
|
Hint h = ox_hint_find(dr->hints, dr->buf.str);
|
855
919
|
|
856
920
|
if (0 != h && h->empty) {
|
857
921
|
// Just close normally
|
858
|
-
name = str2sym(dr, dr->buf.str,
|
922
|
+
name = str2sym(dr, dr->buf.str, 0);
|
859
923
|
snprintf(msg, sizeof(msg) - 1, "%selement '%s' should not have a separate close element", EL_MISMATCH, dr->buf.str);
|
860
924
|
ox_sax_drive_error_at(dr, msg, line, col);
|
861
925
|
return c;
|
862
926
|
} else {
|
863
927
|
snprintf(msg, sizeof(msg) - 1, "%selement '%s' closed but not opened", EL_MISMATCH, dr->buf.str);
|
864
928
|
ox_sax_drive_error_at(dr, msg, line, col);
|
865
|
-
name = str2sym(dr, dr->buf.str,
|
929
|
+
name = str2sym(dr, dr->buf.str, 0);
|
866
930
|
if (dr->has.start_element) {
|
867
931
|
VALUE args[1];
|
868
932
|
|
data/ext/ox/sax.h
CHANGED
@@ -70,52 +70,6 @@ extern int ox_sax_collapse_special(SaxDrive dr, char *str, int line, int col);
|
|
70
70
|
|
71
71
|
extern VALUE ox_sax_value_class;
|
72
72
|
|
73
|
-
|
74
|
-
str2sym(SaxDrive dr, const char *str, char **strp) {
|
75
|
-
VALUE *slot;
|
76
|
-
VALUE sym;
|
77
|
-
|
78
|
-
if (dr->options.symbolize) {
|
79
|
-
if (Qundef == (sym = ox_cache_get(ox_symbol_cache, str, &slot, strp))) {
|
80
|
-
#if HAS_ENCODING_SUPPORT
|
81
|
-
if (0 != dr->encoding) {
|
82
|
-
VALUE rstr = rb_str_new2(str);
|
83
|
-
|
84
|
-
rb_enc_associate(rstr, dr->encoding);
|
85
|
-
sym = rb_funcall(rstr, ox_to_sym_id, 0);
|
86
|
-
} else {
|
87
|
-
sym = ID2SYM(rb_intern(str));
|
88
|
-
}
|
89
|
-
#elif HAS_PRIVATE_ENCODING
|
90
|
-
if (Qnil != dr->encoding) {
|
91
|
-
VALUE rstr = rb_str_new2(str);
|
92
|
-
|
93
|
-
rb_funcall(rstr, ox_force_encoding_id, 1, dr->encoding);
|
94
|
-
sym = rb_funcall(rstr, ox_to_sym_id, 0);
|
95
|
-
} else {
|
96
|
-
sym = ID2SYM(rb_intern(str));
|
97
|
-
}
|
98
|
-
#else
|
99
|
-
sym = ID2SYM(rb_intern(str));
|
100
|
-
#endif
|
101
|
-
*slot = sym;
|
102
|
-
}
|
103
|
-
} else {
|
104
|
-
sym = rb_str_new2(str);
|
105
|
-
#if HAS_ENCODING_SUPPORT
|
106
|
-
if (0 != dr->encoding) {
|
107
|
-
rb_enc_associate(sym, dr->encoding);
|
108
|
-
}
|
109
|
-
#elif HAS_PRIVATE_ENCODING
|
110
|
-
if (Qnil != dr->encoding) {
|
111
|
-
rb_funcall(sym, ox_force_encoding_id, 1, dr->encoding);
|
112
|
-
}
|
113
|
-
#endif
|
114
|
-
if (0 != strp) {
|
115
|
-
*strp = StringValuePtr(sym);
|
116
|
-
}
|
117
|
-
}
|
118
|
-
return sym;
|
119
|
-
}
|
73
|
+
extern VALUE str2sym(SaxDrive dr, const char *str, const char **strp);
|
120
74
|
|
121
75
|
#endif /* __OX_SAX_H__ */
|
data/lib/ox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "A fast XML parser and object serializer that uses only standard C lib.\n
|
14
14
|
\ \nOptimized XML (Ox), as the name implies was written to provide speed
|