ox 2.10.0 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -2
- data/ext/ox/attr.h +10 -10
- data/ext/ox/base64.h +3 -3
- data/ext/ox/buf.h +10 -10
- data/ext/ox/builder.c +7 -7
- data/ext/ox/cache.c +6 -6
- data/ext/ox/cache.h +4 -4
- data/ext/ox/cache8.c +5 -5
- data/ext/ox/cache8.h +4 -4
- data/ext/ox/dump.c +25 -25
- data/ext/ox/encode.h +26 -0
- data/ext/ox/err.h +4 -4
- data/ext/ox/gen_load.c +5 -5
- data/ext/ox/hash_load.c +3 -3
- data/ext/ox/helper.h +10 -10
- data/ext/ox/obj_load.c +18 -18
- data/ext/ox/ox.c +36 -36
- data/ext/ox/ox.h +12 -12
- data/ext/ox/parse.c +15 -15
- data/ext/ox/sax.c +6 -6
- data/ext/ox/sax.h +9 -9
- data/ext/ox/sax_as.c +4 -4
- data/ext/ox/sax_buf.h +7 -7
- data/ext/ox/sax_has.h +4 -4
- data/ext/ox/sax_hint.c +6 -6
- data/ext/ox/sax_hint.h +5 -5
- data/ext/ox/sax_stack.h +10 -10
- data/ext/ox/special.h +3 -3
- data/ext/ox/type.h +3 -3
- data/lib/ox/element.rb +117 -1
- data/lib/ox/version.rb +1 -1
- metadata +4 -4
data/ext/ox/encode.h
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
/* encode.h
|
2
|
+
* Copyright (c) 2011, Peter Ohler
|
3
|
+
* All rights reserved.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#ifndef __OX_ENCODE_H__
|
7
|
+
#define __OX_ENCODE_H__
|
8
|
+
|
9
|
+
#include "ruby.h"
|
10
|
+
#if HAS_ENCODING_SUPPORT
|
11
|
+
#include "ruby/encoding.h"
|
12
|
+
#endif
|
13
|
+
|
14
|
+
static inline VALUE
|
15
|
+
ox_encode(VALUE rstr) {
|
16
|
+
#if HAS_ENCODING_SUPPORT
|
17
|
+
rb_enc_associate(rstr, ox_utf8_encoding);
|
18
|
+
#else
|
19
|
+
if (Qnil != ox_utf8_encoding) {
|
20
|
+
rstr = rb_funcall(ox_utf8_encoding, ox_iconv_id, 1, rstr);
|
21
|
+
}
|
22
|
+
#endif
|
23
|
+
return rstr;
|
24
|
+
}
|
25
|
+
|
26
|
+
#endif /* __OX_ENCODE_H__ */
|
data/ext/ox/err.h
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
* All rights reserved.
|
4
4
|
*/
|
5
5
|
|
6
|
-
#ifndef
|
7
|
-
#define
|
6
|
+
#ifndef OX_ERR_H
|
7
|
+
#define OX_ERR_H
|
8
8
|
|
9
9
|
#include "ruby.h"
|
10
10
|
|
11
11
|
#define set_error(err, msg, xml, current) _ox_err_set_with_location(err, msg, xml, current, __FILE__, __LINE__)
|
12
12
|
|
13
|
-
typedef struct
|
13
|
+
typedef struct _err {
|
14
14
|
VALUE clas;
|
15
15
|
char msg[128];
|
16
16
|
} *Err;
|
@@ -33,4 +33,4 @@ err_has(Err e) {
|
|
33
33
|
return (Qnil != e->clas);
|
34
34
|
}
|
35
35
|
|
36
|
-
#endif /*
|
36
|
+
#endif /* OX_ERR_H */
|
data/ext/ox/gen_load.c
CHANGED
@@ -26,7 +26,7 @@ static void add_instruct(PInfo pi, const char *name, Attr attrs, const char *con
|
|
26
26
|
|
27
27
|
extern ParseCallbacks ox_obj_callbacks;
|
28
28
|
|
29
|
-
struct
|
29
|
+
struct _parseCallbacks _ox_gen_callbacks = {
|
30
30
|
instruct, /* instruct, */
|
31
31
|
add_doctype,
|
32
32
|
add_comment,
|
@@ -39,7 +39,7 @@ struct _ParseCallbacks _ox_gen_callbacks = {
|
|
39
39
|
|
40
40
|
ParseCallbacks ox_gen_callbacks = &_ox_gen_callbacks;
|
41
41
|
|
42
|
-
struct
|
42
|
+
struct _parseCallbacks _ox_limited_callbacks = {
|
43
43
|
0,
|
44
44
|
0,
|
45
45
|
0,
|
@@ -52,7 +52,7 @@ struct _ParseCallbacks _ox_limited_callbacks = {
|
|
52
52
|
|
53
53
|
ParseCallbacks ox_limited_callbacks = &_ox_limited_callbacks;
|
54
54
|
|
55
|
-
struct
|
55
|
+
struct _parseCallbacks _ox_nomode_callbacks = {
|
56
56
|
nomode_instruct,
|
57
57
|
add_doctype,
|
58
58
|
add_comment,
|
@@ -310,7 +310,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
310
310
|
rb_ivar_set(e, ox_at_value_id, s);
|
311
311
|
if (0 != attrs->name) {
|
312
312
|
volatile VALUE ah = rb_hash_new();
|
313
|
-
|
313
|
+
|
314
314
|
for (; 0 != attrs->name; attrs++) {
|
315
315
|
volatile VALUE sym;
|
316
316
|
|
@@ -424,7 +424,7 @@ add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
|
|
424
424
|
rb_ivar_set(inst, ox_at_content_id, c);
|
425
425
|
} else if (0 != attrs->name) {
|
426
426
|
volatile VALUE ah = rb_hash_new();
|
427
|
-
|
427
|
+
|
428
428
|
for (; 0 != attrs->name; attrs++) {
|
429
429
|
volatile VALUE sym;
|
430
430
|
VALUE *slot;
|
data/ext/ox/hash_load.c
CHANGED
@@ -69,7 +69,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
69
69
|
volatile VALUE key;
|
70
70
|
volatile VALUE val;
|
71
71
|
volatile VALUE a;
|
72
|
-
|
72
|
+
|
73
73
|
for (; 0 != attrs->name; attrs++) {
|
74
74
|
if (Qnil != pi->options->attr_key_mod) {
|
75
75
|
key = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
|
@@ -201,7 +201,7 @@ finish(PInfo pi) {
|
|
201
201
|
}
|
202
202
|
}
|
203
203
|
|
204
|
-
struct
|
204
|
+
struct _parseCallbacks _ox_hash_callbacks = {
|
205
205
|
NULL,
|
206
206
|
NULL,
|
207
207
|
NULL,
|
@@ -214,7 +214,7 @@ struct _ParseCallbacks _ox_hash_callbacks = {
|
|
214
214
|
|
215
215
|
ParseCallbacks ox_hash_callbacks = &_ox_hash_callbacks;
|
216
216
|
|
217
|
-
struct
|
217
|
+
struct _parseCallbacks _ox_hash_no_attrs_callbacks = {
|
218
218
|
NULL,
|
219
219
|
NULL,
|
220
220
|
NULL,
|
data/ext/ox/helper.h
CHANGED
@@ -3,21 +3,21 @@
|
|
3
3
|
* All rights reserved.
|
4
4
|
*/
|
5
5
|
|
6
|
-
#ifndef
|
7
|
-
#define
|
6
|
+
#ifndef OX_HELPER_H
|
7
|
+
#define OX_HELPER_H
|
8
8
|
|
9
9
|
#include "type.h"
|
10
10
|
|
11
11
|
#define HELPER_STACK_INC 16
|
12
12
|
|
13
|
-
typedef struct
|
13
|
+
typedef struct _helper {
|
14
14
|
ID var; /* Object var ID */
|
15
15
|
VALUE obj; /* object created or Qundef if not appropriate */
|
16
16
|
Type type; /* type of object in obj */
|
17
17
|
} *Helper;
|
18
18
|
|
19
|
-
typedef struct
|
20
|
-
struct
|
19
|
+
typedef struct _helperStack {
|
20
|
+
struct _helper base[HELPER_STACK_INC];
|
21
21
|
Helper head; /* current stack */
|
22
22
|
Helper end; /* stack end */
|
23
23
|
Helper tail; /* pointer to one past last element name on stack */
|
@@ -26,7 +26,7 @@ typedef struct _HelperStack {
|
|
26
26
|
inline static void
|
27
27
|
helper_stack_init(HelperStack stack) {
|
28
28
|
stack->head = stack->base;
|
29
|
-
stack->end = stack->base + sizeof(stack->base) / sizeof(struct
|
29
|
+
stack->end = stack->base + sizeof(stack->base) / sizeof(struct _helper);
|
30
30
|
stack->tail = stack->head;
|
31
31
|
}
|
32
32
|
|
@@ -55,10 +55,10 @@ helper_stack_push(HelperStack stack, ID var, VALUE obj, Type type) {
|
|
55
55
|
size_t toff = stack->tail - stack->head;
|
56
56
|
|
57
57
|
if (stack->base == stack->head) {
|
58
|
-
stack->head = ALLOC_N(struct
|
59
|
-
memcpy(stack->head, stack->base, sizeof(struct
|
58
|
+
stack->head = ALLOC_N(struct _helper, len + HELPER_STACK_INC);
|
59
|
+
memcpy(stack->head, stack->base, sizeof(struct _helper) * len);
|
60
60
|
} else {
|
61
|
-
REALLOC_N(stack->head, struct
|
61
|
+
REALLOC_N(stack->head, struct _helper, len + HELPER_STACK_INC);
|
62
62
|
}
|
63
63
|
stack->tail = stack->head + toff;
|
64
64
|
stack->end = stack->head + len + HELPER_STACK_INC;
|
@@ -88,4 +88,4 @@ helper_stack_pop(HelperStack stack) {
|
|
88
88
|
return 0;
|
89
89
|
}
|
90
90
|
|
91
|
-
#endif /*
|
91
|
+
#endif /* OX_HELPER_H */
|
data/ext/ox/obj_load.c
CHANGED
@@ -38,7 +38,7 @@ static void debug_stack(PInfo pi, const char *comment);
|
|
38
38
|
static void fill_indent(PInfo pi, char *buf, size_t size);
|
39
39
|
|
40
40
|
|
41
|
-
struct
|
41
|
+
struct _parseCallbacks _ox_obj_callbacks = {
|
42
42
|
instruct, /* instruct, */
|
43
43
|
0, /* add_doctype, */
|
44
44
|
0, /* add_comment, */
|
@@ -57,7 +57,7 @@ extern ParseCallbacks ox_gen_callbacks;
|
|
57
57
|
inline static VALUE
|
58
58
|
str2sym(const char *str, void *encoding) {
|
59
59
|
VALUE sym;
|
60
|
-
|
60
|
+
|
61
61
|
#ifdef HAVE_RUBY_ENCODING_H
|
62
62
|
if (0 != encoding) {
|
63
63
|
VALUE rstr = rb_str_new2(str);
|
@@ -85,7 +85,7 @@ name2var(const char *name, void *encoding) {
|
|
85
85
|
if (0 != encoding) {
|
86
86
|
volatile VALUE rstr = rb_str_new2(name);
|
87
87
|
volatile VALUE sym;
|
88
|
-
|
88
|
+
|
89
89
|
rb_enc_associate(rstr, (rb_encoding*)encoding);
|
90
90
|
sym = rb_funcall(rstr, ox_to_sym_id, 0);
|
91
91
|
// Needed for Ruby 2.2 to get around the GC of symbols
|
@@ -135,7 +135,7 @@ resolve_classname(VALUE mod, const char *class_name, Effort effort, VALUE base_c
|
|
135
135
|
inline static VALUE
|
136
136
|
classname2obj(const char *name, PInfo pi, VALUE base_class) {
|
137
137
|
VALUE clas = classname2class(name, pi, base_class);
|
138
|
-
|
138
|
+
|
139
139
|
if (Qundef == clas) {
|
140
140
|
return Qnil;
|
141
141
|
} else {
|
@@ -204,7 +204,7 @@ static VALUE
|
|
204
204
|
classname2class(const char *name, PInfo pi, VALUE base_class) {
|
205
205
|
VALUE *slot;
|
206
206
|
VALUE clas;
|
207
|
-
|
207
|
+
|
208
208
|
if (Qundef == (clas = ox_cache_get(ox_class_cache, name, &slot, 0))) {
|
209
209
|
char class_name[1024];
|
210
210
|
char *s;
|
@@ -284,7 +284,7 @@ get_id_from_attrs(PInfo pi, Attr a) {
|
|
284
284
|
unsigned long id = 0;
|
285
285
|
const char *text = a->value;
|
286
286
|
char c;
|
287
|
-
|
287
|
+
|
288
288
|
for (; '\0' != *text; text++) {
|
289
289
|
c = *text;
|
290
290
|
if ('0' <= c && c <= '9') {
|
@@ -303,12 +303,12 @@ get_id_from_attrs(PInfo pi, Attr a) {
|
|
303
303
|
static CircArray
|
304
304
|
circ_array_new() {
|
305
305
|
CircArray ca;
|
306
|
-
|
307
|
-
ca = ALLOC(struct
|
306
|
+
|
307
|
+
ca = ALLOC(struct _circArray);
|
308
308
|
ca->objs = ca->obj_array;
|
309
309
|
ca->size = sizeof(ca->obj_array) / sizeof(VALUE);
|
310
310
|
ca->cnt = 0;
|
311
|
-
|
311
|
+
|
312
312
|
return ca;
|
313
313
|
}
|
314
314
|
|
@@ -361,7 +361,7 @@ static VALUE
|
|
361
361
|
parse_regexp(const char *text) {
|
362
362
|
const char *te;
|
363
363
|
int options = 0;
|
364
|
-
|
364
|
+
|
365
365
|
te = text + strlen(text) - 1;
|
366
366
|
#if HAS_ONIG
|
367
367
|
for (; text < te && '/' != *te; te--) {
|
@@ -491,7 +491,7 @@ add_text(PInfo pi, char *text, int closed) {
|
|
491
491
|
unsigned long str_size = b64_orig_size(text);
|
492
492
|
VALUE v;
|
493
493
|
char *str = ALLOCA_N(char, str_size + 1);
|
494
|
-
|
494
|
+
|
495
495
|
from_base64(text, (uchar*)str);
|
496
496
|
v = rb_str_new(str, str_size);
|
497
497
|
#if HAS_ENCODING_SUPPORT
|
@@ -515,7 +515,7 @@ add_text(PInfo pi, char *text, int closed) {
|
|
515
515
|
VALUE *slot;
|
516
516
|
unsigned long str_size = b64_orig_size(text);
|
517
517
|
char *str = ALLOCA_N(char, str_size + 1);
|
518
|
-
|
518
|
+
|
519
519
|
from_base64(text, (uchar*)str);
|
520
520
|
if (Qundef == (sym = ox_cache_get(ox_symbol_cache, str, &slot, 0))) {
|
521
521
|
sym = str2sym(str, (void*)pi->options->rb_enc);
|
@@ -533,7 +533,7 @@ add_text(PInfo pi, char *text, int closed) {
|
|
533
533
|
} else {
|
534
534
|
unsigned long str_size = b64_orig_size(text);
|
535
535
|
char *str = ALLOCA_N(char, str_size + 1);
|
536
|
-
|
536
|
+
|
537
537
|
from_base64(text, (uchar*)str);
|
538
538
|
h->obj = parse_regexp(str);
|
539
539
|
}
|
@@ -709,7 +709,7 @@ static void
|
|
709
709
|
end_element(PInfo pi, const char *ename) {
|
710
710
|
if (TRACE <= pi->options->trace) {
|
711
711
|
char indent[128];
|
712
|
-
|
712
|
+
|
713
713
|
if (DEBUG <= pi->options->trace) {
|
714
714
|
char buf[1024];
|
715
715
|
|
@@ -853,7 +853,7 @@ parse_double_time(const char *text, VALUE clas) {
|
|
853
853
|
long v2 = 0;
|
854
854
|
const char *dot = 0;
|
855
855
|
char c;
|
856
|
-
|
856
|
+
|
857
857
|
for (; '.' != *text; text++) {
|
858
858
|
c = *text;
|
859
859
|
if (c < '0' || '9' < c) {
|
@@ -879,7 +879,7 @@ parse_double_time(const char *text, VALUE clas) {
|
|
879
879
|
#endif
|
880
880
|
}
|
881
881
|
|
882
|
-
typedef struct
|
882
|
+
typedef struct _tp {
|
883
883
|
int cnt;
|
884
884
|
char end;
|
885
885
|
char alt;
|
@@ -892,7 +892,7 @@ parse_xsd_time(const char *text, VALUE clas) {
|
|
892
892
|
long v;
|
893
893
|
int i;
|
894
894
|
char c;
|
895
|
-
struct
|
895
|
+
struct _tp tpa[10] = { { 4, '-', '-' },
|
896
896
|
{ 2, '-', '-' },
|
897
897
|
{ 2, 'T', 'T' },
|
898
898
|
{ 2, ':', ':' },
|
@@ -971,7 +971,7 @@ debug_stack(PInfo pi, const char *comment) {
|
|
971
971
|
if (0 != h->var) {
|
972
972
|
if (HashCode == h->type) {
|
973
973
|
VALUE v;
|
974
|
-
|
974
|
+
|
975
975
|
v = rb_funcall2(h->var, rb_intern("to_s"), 0, 0);
|
976
976
|
key = StringValuePtr(v);
|
977
977
|
} else if (ObjectCode == (h - 1)->type || ExceptionCode == (h - 1)->type || RangeCode == (h - 1)->type || StructCode == (h - 1)->type) {
|
data/ext/ox/ox.c
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
#define SMALL_XML 4096
|
19
19
|
#define WITH_CACHE_TESTS 0
|
20
20
|
|
21
|
-
typedef struct
|
21
|
+
typedef struct _yesNoOpt {
|
22
22
|
VALUE sym;
|
23
23
|
char *attr;
|
24
24
|
} *YesNoOpt;
|
@@ -160,7 +160,7 @@ VALUE ox_utf8_encoding = Qnil;
|
|
160
160
|
void *ox_utf8_encoding = 0;
|
161
161
|
#endif
|
162
162
|
|
163
|
-
struct
|
163
|
+
struct _options ox_default_options = {
|
164
164
|
{ '\0' }, // encoding
|
165
165
|
{ '\0' }, // margin
|
166
166
|
2, // indent
|
@@ -255,7 +255,7 @@ hints_to_overlay(Hints hints) {
|
|
255
255
|
Hint h;
|
256
256
|
int i;
|
257
257
|
VALUE ov;
|
258
|
-
|
258
|
+
|
259
259
|
for (i = hints->size, h = hints->hints; 0 < i; i--, h++) {
|
260
260
|
switch (h->overlay) {
|
261
261
|
case InactiveOverlay: ov = inactive_sym; break;
|
@@ -267,7 +267,7 @@ hints_to_overlay(Hints hints) {
|
|
267
267
|
default: ov = active_sym; break;
|
268
268
|
}
|
269
269
|
rb_hash_aset(overlay, rb_str_new2(h->name), ov);
|
270
|
-
}
|
270
|
+
}
|
271
271
|
return overlay;
|
272
272
|
}
|
273
273
|
|
@@ -300,7 +300,7 @@ hints_to_overlay(Hints hints) {
|
|
300
300
|
* - _:block_ - block this and all children callbacks
|
301
301
|
* - _:off_ - block this element and it's children unless the child element is active
|
302
302
|
* - _:abort_ - abort the html processing and return
|
303
|
-
*
|
303
|
+
*
|
304
304
|
* *return* [Hash] all current option settings.
|
305
305
|
*
|
306
306
|
* Note that an indent of less than zero will result in a tight one line output
|
@@ -373,7 +373,7 @@ static int
|
|
373
373
|
set_overlay(VALUE key, VALUE value, VALUE ctx) {
|
374
374
|
Hints hints = (Hints)ctx;
|
375
375
|
Hint hint;
|
376
|
-
|
376
|
+
|
377
377
|
if (NULL != (hint = ox_hint_find(hints, StringValuePtr(key)))) {
|
378
378
|
if (active_sym == value) {
|
379
379
|
hint->overlay = ActiveOverlay;
|
@@ -444,7 +444,7 @@ sax_html_overlay(VALUE self) {
|
|
444
444
|
*/
|
445
445
|
static VALUE
|
446
446
|
set_def_opts(VALUE self, VALUE opts) {
|
447
|
-
struct
|
447
|
+
struct _yesNoOpt ynos[] = {
|
448
448
|
{ with_xml_sym, &ox_default_options.with_xml },
|
449
449
|
{ with_dtd_sym, &ox_default_options.with_dtd },
|
450
450
|
{ with_instruct_sym, &ox_default_options.with_instruct },
|
@@ -456,7 +456,7 @@ set_def_opts(VALUE self, VALUE opts) {
|
|
456
456
|
};
|
457
457
|
YesNoOpt o;
|
458
458
|
VALUE v;
|
459
|
-
|
459
|
+
|
460
460
|
Check_Type(opts, T_HASH);
|
461
461
|
|
462
462
|
v = rb_hash_aref(opts, ox_encoding_sym);
|
@@ -625,7 +625,7 @@ set_def_opts(VALUE self, VALUE opts) {
|
|
625
625
|
}
|
626
626
|
ox_default_options.element_key_mod = rb_hash_lookup2(opts, element_key_mod_sym, ox_default_options.element_key_mod);
|
627
627
|
ox_default_options.attr_key_mod = rb_hash_lookup2(opts, attr_key_mod_sym, ox_default_options.attr_key_mod);
|
628
|
-
|
628
|
+
|
629
629
|
return Qnil;
|
630
630
|
}
|
631
631
|
|
@@ -644,8 +644,8 @@ to_obj(VALUE self, VALUE ruby_xml) {
|
|
644
644
|
char *xml, *x;
|
645
645
|
size_t len;
|
646
646
|
VALUE obj;
|
647
|
-
struct
|
648
|
-
struct
|
647
|
+
struct _options options = ox_default_options;
|
648
|
+
struct _err err;
|
649
649
|
|
650
650
|
err_init(&err);
|
651
651
|
Check_Type(ruby_xml, T_STRING);
|
@@ -688,8 +688,8 @@ to_gen(VALUE self, VALUE ruby_xml) {
|
|
688
688
|
char *xml, *x;
|
689
689
|
size_t len;
|
690
690
|
VALUE obj;
|
691
|
-
struct
|
692
|
-
struct
|
691
|
+
struct _options options = ox_default_options;
|
692
|
+
struct _err err;
|
693
693
|
|
694
694
|
err_init(&err);
|
695
695
|
Check_Type(ruby_xml, T_STRING);
|
@@ -715,12 +715,12 @@ to_gen(VALUE self, VALUE ruby_xml) {
|
|
715
715
|
static VALUE
|
716
716
|
load(char *xml, size_t len, int argc, VALUE *argv, VALUE self, VALUE encoding, Err err) {
|
717
717
|
VALUE obj;
|
718
|
-
struct
|
718
|
+
struct _options options = ox_default_options;
|
719
719
|
|
720
720
|
if (1 == argc && rb_cHash == rb_obj_class(*argv)) {
|
721
721
|
VALUE h = *argv;
|
722
722
|
VALUE v;
|
723
|
-
|
723
|
+
|
724
724
|
if (Qnil != (v = rb_hash_lookup(h, mode_sym))) {
|
725
725
|
if (object_sym == v) {
|
726
726
|
options.mode = ObjMode;
|
@@ -916,7 +916,7 @@ load_str(int argc, VALUE *argv, VALUE self) {
|
|
916
916
|
size_t len;
|
917
917
|
VALUE obj;
|
918
918
|
VALUE encoding;
|
919
|
-
struct
|
919
|
+
struct _err err;
|
920
920
|
|
921
921
|
err_init(&err);
|
922
922
|
Check_Type(*argv, T_STRING);
|
@@ -979,7 +979,7 @@ load_file(int argc, VALUE *argv, VALUE self) {
|
|
979
979
|
FILE *f;
|
980
980
|
size_t len;
|
981
981
|
VALUE obj;
|
982
|
-
struct
|
982
|
+
struct _err err;
|
983
983
|
|
984
984
|
err_init(&err);
|
985
985
|
Check_Type(*argv, T_STRING);
|
@@ -1027,7 +1027,7 @@ load_file(int argc, VALUE *argv, VALUE self) {
|
|
1027
1027
|
*/
|
1028
1028
|
static VALUE
|
1029
1029
|
sax_parse(int argc, VALUE *argv, VALUE self) {
|
1030
|
-
struct
|
1030
|
+
struct _saxOptions options;
|
1031
1031
|
|
1032
1032
|
options.symbolize = (No != ox_default_options.sym_keys);
|
1033
1033
|
options.convert_special = ox_default_options.convert_special;
|
@@ -1035,14 +1035,14 @@ sax_parse(int argc, VALUE *argv, VALUE self) {
|
|
1035
1035
|
options.skip = ox_default_options.skip;
|
1036
1036
|
options.hints = NULL;
|
1037
1037
|
strcpy(options.strip_ns, ox_default_options.strip_ns);
|
1038
|
-
|
1038
|
+
|
1039
1039
|
if (argc < 2) {
|
1040
1040
|
rb_raise(ox_parse_error_class, "Wrong number of arguments to sax_parse.\n");
|
1041
1041
|
}
|
1042
1042
|
if (3 <= argc && rb_cHash == rb_obj_class(argv[2])) {
|
1043
1043
|
VALUE h = argv[2];
|
1044
1044
|
VALUE v;
|
1045
|
-
|
1045
|
+
|
1046
1046
|
if (Qnil != (v = rb_hash_lookup(h, convert_special_sym))) {
|
1047
1047
|
options.convert_special = (Qtrue == v);
|
1048
1048
|
}
|
@@ -1108,9 +1108,9 @@ sax_parse(int argc, VALUE *argv, VALUE self) {
|
|
1108
1108
|
*/
|
1109
1109
|
static VALUE
|
1110
1110
|
sax_html(int argc, VALUE *argv, VALUE self) {
|
1111
|
-
struct
|
1111
|
+
struct _saxOptions options;
|
1112
1112
|
bool free_hints = false;
|
1113
|
-
|
1113
|
+
|
1114
1114
|
options.symbolize = (No != ox_default_options.sym_keys);
|
1115
1115
|
options.convert_special = ox_default_options.convert_special;
|
1116
1116
|
options.smart = true;
|
@@ -1120,14 +1120,14 @@ sax_html(int argc, VALUE *argv, VALUE self) {
|
|
1120
1120
|
options.hints = ox_hints_html();
|
1121
1121
|
}
|
1122
1122
|
*options.strip_ns = '\0';
|
1123
|
-
|
1123
|
+
|
1124
1124
|
if (argc < 2) {
|
1125
1125
|
rb_raise(ox_parse_error_class, "Wrong number of arguments to sax_html.\n");
|
1126
1126
|
}
|
1127
1127
|
if (3 <= argc && rb_cHash == rb_obj_class(argv[2])) {
|
1128
1128
|
volatile VALUE h = argv[2];
|
1129
1129
|
volatile VALUE v;
|
1130
|
-
|
1130
|
+
|
1131
1131
|
if (Qnil != (v = rb_hash_lookup(h, convert_special_sym))) {
|
1132
1132
|
options.convert_special = (Qtrue == v);
|
1133
1133
|
}
|
@@ -1147,7 +1147,7 @@ sax_html(int argc, VALUE *argv, VALUE self) {
|
|
1147
1147
|
}
|
1148
1148
|
if (Qnil != (v = rb_hash_lookup(h, overlay_sym))) {
|
1149
1149
|
int cnt;
|
1150
|
-
|
1150
|
+
|
1151
1151
|
Check_Type(v, T_HASH);
|
1152
1152
|
cnt = (int)RHASH_SIZE(v);
|
1153
1153
|
if (0 == cnt) {
|
@@ -1168,7 +1168,7 @@ sax_html(int argc, VALUE *argv, VALUE self) {
|
|
1168
1168
|
|
1169
1169
|
static void
|
1170
1170
|
parse_dump_options(VALUE ropts, Options copts) {
|
1171
|
-
struct
|
1171
|
+
struct _yesNoOpt ynos[] = {
|
1172
1172
|
{ with_xml_sym, &copts->with_xml },
|
1173
1173
|
{ with_dtd_sym, &copts->with_dtd },
|
1174
1174
|
{ with_instruct_sym, &copts->with_instruct },
|
@@ -1177,10 +1177,10 @@ parse_dump_options(VALUE ropts, Options copts) {
|
|
1177
1177
|
{ Qnil, 0 }
|
1178
1178
|
};
|
1179
1179
|
YesNoOpt o;
|
1180
|
-
|
1180
|
+
|
1181
1181
|
if (rb_cHash == rb_obj_class(ropts)) {
|
1182
1182
|
VALUE v;
|
1183
|
-
|
1183
|
+
|
1184
1184
|
if (Qnil != (v = rb_hash_lookup(ropts, ox_indent_sym))) {
|
1185
1185
|
#ifdef RUBY_INTEGER_UNIFICATION
|
1186
1186
|
if (rb_cInteger != rb_obj_class(v) && T_FIXNUM != rb_type(v)) {
|
@@ -1251,7 +1251,7 @@ parse_dump_options(VALUE ropts, Options copts) {
|
|
1251
1251
|
copts->margin[sizeof(copts->margin) - 1] = '\0';
|
1252
1252
|
copts->margin_len = (char)slen;
|
1253
1253
|
}
|
1254
|
-
|
1254
|
+
|
1255
1255
|
for (o = ynos; 0 != o->attr; o++) {
|
1256
1256
|
if (Qnil != (v = rb_hash_lookup(ropts, o->sym))) {
|
1257
1257
|
VALUE c = rb_obj_class(v);
|
@@ -1286,9 +1286,9 @@ parse_dump_options(VALUE ropts, Options copts) {
|
|
1286
1286
|
static VALUE
|
1287
1287
|
dump(int argc, VALUE *argv, VALUE self) {
|
1288
1288
|
char *xml;
|
1289
|
-
struct
|
1289
|
+
struct _options copts = ox_default_options;
|
1290
1290
|
VALUE rstr;
|
1291
|
-
|
1291
|
+
|
1292
1292
|
if (2 == argc) {
|
1293
1293
|
parse_dump_options(argv[1], &copts);
|
1294
1294
|
}
|
@@ -1328,8 +1328,8 @@ dump(int argc, VALUE *argv, VALUE self) {
|
|
1328
1328
|
*/
|
1329
1329
|
static VALUE
|
1330
1330
|
to_file(int argc, VALUE *argv, VALUE self) {
|
1331
|
-
struct
|
1332
|
-
|
1331
|
+
struct _options copts = ox_default_options;
|
1332
|
+
|
1333
1333
|
if (3 == argc) {
|
1334
1334
|
parse_dump_options(argv[2], &copts);
|
1335
1335
|
}
|
@@ -1376,9 +1376,9 @@ void Init_ox() {
|
|
1376
1376
|
rb_define_module_function(Ox, "to_file", to_file, -1);
|
1377
1377
|
|
1378
1378
|
rb_define_module_function(Ox, "sax_html_overlay", sax_html_overlay, 0);
|
1379
|
-
|
1379
|
+
|
1380
1380
|
ox_init_builder(Ox);
|
1381
|
-
|
1381
|
+
|
1382
1382
|
rb_require("time");
|
1383
1383
|
rb_require("date");
|
1384
1384
|
rb_require("bigdecimal");
|
@@ -1529,7 +1529,7 @@ void Init_ox() {
|
|
1529
1529
|
rb_define _module_function(Ox, "cache_test", cache_test, 0);
|
1530
1530
|
rb_define _module_function(Ox, "cache8_test", cache8_test, 0);
|
1531
1531
|
#endif
|
1532
|
-
|
1532
|
+
|
1533
1533
|
#if HAS_ENCODING_SUPPORT
|
1534
1534
|
ox_utf8_encoding = rb_enc_find("UTF-8");
|
1535
1535
|
#elif HAS_PRIVATE_ENCODING
|