ox 2.13.2 → 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 +6 -0
- data/README.md +31 -0
- data/ext/ox/builder.c +5 -1
- data/ext/ox/dump.c +6 -18
- data/ext/ox/extconf.rb +12 -34
- data/ext/ox/gen_load.c +18 -96
- data/ext/ox/hash_load.c +2 -10
- data/ext/ox/obj_load.c +8 -45
- data/ext/ox/ox.c +34 -46
- data/ext/ox/ox.h +6 -15
- data/ext/ox/parse.c +1 -20
- data/ext/ox/sax.c +21 -91
- data/ext/ox/sax.h +1 -3
- data/ext/ox/sax_as.c +2 -6
- data/ext/ox/sax_buf.c +1 -1
- data/lib/ox/version.rb +1 -1
- metadata +2 -2
data/ext/ox/hash_load.c
CHANGED
@@ -79,14 +79,10 @@ add_text(PInfo pi, char *text, int closed) {
|
|
79
79
|
volatile VALUE s = rb_str_new2(text);
|
80
80
|
volatile VALUE a;
|
81
81
|
|
82
|
-
#if
|
82
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
83
83
|
if (0 != pi->options->rb_enc) {
|
84
84
|
rb_enc_associate(s, pi->options->rb_enc);
|
85
85
|
}
|
86
|
-
#elif HAS_PRIVATE_ENCODING
|
87
|
-
if (Qnil != pi->options->rb_enc) {
|
88
|
-
rb_funcall(s, ox_force_encoding_id, 1, pi->options->rb_enc);
|
89
|
-
}
|
90
86
|
#endif
|
91
87
|
switch (parent->type) {
|
92
88
|
case NoCode:
|
@@ -126,14 +122,10 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
126
122
|
key = rb_str_new2(attrs->name);
|
127
123
|
}
|
128
124
|
val = rb_str_new2(attrs->value);
|
129
|
-
#if
|
125
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
130
126
|
if (0 != pi->options->rb_enc) {
|
131
127
|
rb_enc_associate(val, pi->options->rb_enc);
|
132
128
|
}
|
133
|
-
#elif HAS_PRIVATE_ENCODING
|
134
|
-
if (Qnil != pi->options->rb_enc) {
|
135
|
-
rb_funcall(val, ox_force_encoding_id, 1, pi->options->rb_enc);
|
136
|
-
}
|
137
129
|
#endif
|
138
130
|
rb_hash_aset(h, key, val);
|
139
131
|
}
|
data/ext/ox/obj_load.c
CHANGED
@@ -11,6 +11,9 @@
|
|
11
11
|
#include <time.h>
|
12
12
|
|
13
13
|
#include "ruby.h"
|
14
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
15
|
+
#include "ruby/encoding.h"
|
16
|
+
#endif
|
14
17
|
#include "base64.h"
|
15
18
|
#include "ox.h"
|
16
19
|
|
@@ -143,7 +146,6 @@ classname2obj(const char *name, PInfo pi, VALUE base_class) {
|
|
143
146
|
}
|
144
147
|
}
|
145
148
|
|
146
|
-
#if HAS_RSTRUCT
|
147
149
|
inline static VALUE
|
148
150
|
structname2obj(const char *name) {
|
149
151
|
VALUE ost;
|
@@ -159,16 +161,12 @@ structname2obj(const char *name) {
|
|
159
161
|
}
|
160
162
|
}
|
161
163
|
ost = rb_const_get(ox_struct_class, rb_intern(s));
|
162
|
-
|
163
|
-
#if HAS_ENCODING_SUPPORT
|
164
|
-
return rb_struct_alloc_noinit(ost);
|
165
|
-
#elif HAS_PRIVATE_ENCODING
|
164
|
+
#if HAVE_RB_STRUCT_ALLOC_NOINIT
|
166
165
|
return rb_struct_alloc_noinit(ost);
|
167
166
|
#else
|
168
167
|
return rb_struct_new(ost);
|
169
168
|
#endif
|
170
169
|
}
|
171
|
-
#endif
|
172
170
|
|
173
171
|
inline static VALUE
|
174
172
|
parse_ulong(const char *s, PInfo pi) {
|
@@ -255,7 +253,6 @@ get_obj_from_attrs(Attr a, PInfo pi, VALUE base_class) {
|
|
255
253
|
return Qundef;
|
256
254
|
}
|
257
255
|
|
258
|
-
#if HAS_RSTRUCT
|
259
256
|
static VALUE
|
260
257
|
get_struct_from_attrs(Attr a) {
|
261
258
|
for (; 0 != a->name; a++) {
|
@@ -265,7 +262,6 @@ get_struct_from_attrs(Attr a) {
|
|
265
262
|
}
|
266
263
|
return Qundef;
|
267
264
|
}
|
268
|
-
#endif
|
269
265
|
|
270
266
|
static VALUE
|
271
267
|
get_class_from_attrs(Attr a, PInfo pi, VALUE base_class) {
|
@@ -363,7 +359,7 @@ parse_regexp(const char *text) {
|
|
363
359
|
int options = 0;
|
364
360
|
|
365
361
|
te = text + strlen(text) - 1;
|
366
|
-
#
|
362
|
+
#ifdef ONIG_OPTION_IGNORECASE
|
367
363
|
for (; text < te && '/' != *te; te--) {
|
368
364
|
switch (*te) {
|
369
365
|
case 'i': options |= ONIG_OPTION_IGNORECASE; break;
|
@@ -379,18 +375,12 @@ parse_regexp(const char *text) {
|
|
379
375
|
static void
|
380
376
|
instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
|
381
377
|
if (0 == strcmp("xml", target)) {
|
382
|
-
#if
|
378
|
+
#if HAVE_RB_ENC_FIND
|
383
379
|
for (; 0 != attrs->name; attrs++) {
|
384
380
|
if (0 == strcmp("encoding", attrs->name)) {
|
385
381
|
pi->options->rb_enc = rb_enc_find(attrs->value);
|
386
382
|
}
|
387
383
|
}
|
388
|
-
#elif HAS_PRIVATE_ENCODING
|
389
|
-
for (; 0 != attrs->name; attrs++) {
|
390
|
-
if (0 == strcmp("encoding", attrs->name)) {
|
391
|
-
pi->options->rb_enc = rb_str_new2(attrs->value);
|
392
|
-
}
|
393
|
-
}
|
394
384
|
#endif
|
395
385
|
}
|
396
386
|
}
|
@@ -417,14 +407,10 @@ add_text(PInfo pi, char *text, int closed) {
|
|
417
407
|
case NoCode:
|
418
408
|
case StringCode:
|
419
409
|
h->obj = rb_str_new2(text);
|
420
|
-
#if
|
410
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
421
411
|
if (0 != pi->options->rb_enc) {
|
422
412
|
rb_enc_associate(h->obj, pi->options->rb_enc);
|
423
413
|
}
|
424
|
-
#elif HAS_PRIVATE_ENCODING
|
425
|
-
if (Qnil != pi->options->rb_enc) {
|
426
|
-
rb_funcall(h->obj, ox_force_encoding_id, 1, pi->options->rb_enc);
|
427
|
-
}
|
428
414
|
#endif
|
429
415
|
if (0 != pi->circ_array) {
|
430
416
|
circ_array_set(pi->circ_array, h->obj, (unsigned long)pi->id);
|
@@ -494,14 +480,10 @@ add_text(PInfo pi, char *text, int closed) {
|
|
494
480
|
|
495
481
|
from_base64(text, (uchar*)str);
|
496
482
|
v = rb_str_new(str, str_size);
|
497
|
-
#if
|
483
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
498
484
|
if (0 != pi->options->rb_enc) {
|
499
485
|
rb_enc_associate(v, pi->options->rb_enc);
|
500
486
|
}
|
501
|
-
#elif HAS_PRIVATE_ENCODING
|
502
|
-
if (0 != pi->options->rb_enc) {
|
503
|
-
rb_funcall(v, ox_force_encoding_id, 1, pi->options->rb_enc);
|
504
|
-
}
|
505
487
|
#endif
|
506
488
|
if (0 != pi->circ_array) {
|
507
489
|
circ_array_set(pi->circ_array, v, (unsigned long)h->obj);
|
@@ -542,11 +524,7 @@ add_text(PInfo pi, char *text, int closed) {
|
|
542
524
|
h->obj = rb_cstr_to_inum(text, 10, 1);
|
543
525
|
break;
|
544
526
|
case BigDecimalCode:
|
545
|
-
#if HAS_BIGDECIMAL
|
546
527
|
h->obj = rb_funcall(rb_cObject, ox_bigdecimal_id, 1, rb_str_new2(text));
|
547
|
-
#else
|
548
|
-
h->obj = Qnil;
|
549
|
-
#endif
|
550
528
|
break;
|
551
529
|
default:
|
552
530
|
h->obj = Qnil;
|
@@ -670,15 +648,10 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
670
648
|
}
|
671
649
|
break;
|
672
650
|
case StructCode:
|
673
|
-
#if HAS_RSTRUCT
|
674
651
|
h->obj = get_struct_from_attrs(attrs);
|
675
652
|
if (0 != pi->circ_array) {
|
676
653
|
circ_array_set(pi->circ_array, h->obj, get_id_from_attrs(pi, attrs));
|
677
654
|
}
|
678
|
-
#else
|
679
|
-
set_error(&pi->err, "Ruby structs not supported with this verion of Ruby", pi->str, pi->s);
|
680
|
-
return;
|
681
|
-
#endif
|
682
655
|
break;
|
683
656
|
case ClassCode:
|
684
657
|
if (Qundef == (h->obj = get_class_from_attrs(attrs, pi, ox_bag_clas))) {
|
@@ -750,23 +723,17 @@ end_element(PInfo pi, const char *ename) {
|
|
750
723
|
}
|
751
724
|
break;
|
752
725
|
case StructCode:
|
753
|
-
#if HAS_RSTRUCT
|
754
726
|
if (0 == h->var) {
|
755
727
|
set_error(&pi->err, "Invalid element for object mode", pi->str, pi->s);
|
756
728
|
return;
|
757
729
|
}
|
758
730
|
rb_struct_aset(ph->obj, h->var, h->obj);
|
759
|
-
#else
|
760
|
-
set_error(&pi->err, "Ruby structs not supported with this verion of Ruby", pi->str, pi->s);
|
761
|
-
return;
|
762
|
-
#endif
|
763
731
|
break;
|
764
732
|
case HashCode:
|
765
733
|
// put back h
|
766
734
|
helper_stack_push(&pi->helpers, h->var, h->obj, KeyCode);
|
767
735
|
break;
|
768
736
|
case RangeCode:
|
769
|
-
#if HAS_RSTRUCT
|
770
737
|
if (ox_beg_id == h->var) {
|
771
738
|
RSTRUCT_SET(ph->obj, 0, h->obj);
|
772
739
|
} else if (ox_end_id == h->var) {
|
@@ -777,10 +744,6 @@ end_element(PInfo pi, const char *ename) {
|
|
777
744
|
set_error(&pi->err, "Invalid range attribute", pi->str, pi->s);
|
778
745
|
return;
|
779
746
|
}
|
780
|
-
#else
|
781
|
-
set_error(&pi->err, "Ruby structs not supported with this verion of Ruby", pi->str, pi->s);
|
782
|
-
return;
|
783
|
-
#endif
|
784
747
|
break;
|
785
748
|
case KeyCode:
|
786
749
|
{
|
data/ext/ox/ox.c
CHANGED
@@ -154,10 +154,8 @@ static VALUE element_key_mod_sym;
|
|
154
154
|
static ID encoding_id;
|
155
155
|
static ID has_key_id;
|
156
156
|
|
157
|
-
#if
|
157
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
158
158
|
rb_encoding *ox_utf8_encoding = 0;
|
159
|
-
#elif HAS_PRIVATE_ENCODING
|
160
|
-
VALUE ox_utf8_encoding = Qnil;
|
161
159
|
#else
|
162
160
|
void *ox_utf8_encoding = 0;
|
163
161
|
#endif
|
@@ -186,11 +184,7 @@ struct _options ox_default_options = {
|
|
186
184
|
NULL, // html_hints
|
187
185
|
Qnil, // attr_key_mod;
|
188
186
|
Qnil, // element_key_mod;
|
189
|
-
#if HAS_PRIVATE_ENCODING
|
190
|
-
Qnil // rb_enc
|
191
|
-
#else
|
192
187
|
0 // rb_enc
|
193
|
-
#endif
|
194
188
|
};
|
195
189
|
|
196
190
|
extern ParseCallbacks ox_obj_callbacks;
|
@@ -470,11 +464,8 @@ set_def_opts(VALUE self, VALUE opts) {
|
|
470
464
|
} else {
|
471
465
|
Check_Type(v, T_STRING);
|
472
466
|
strncpy(ox_default_options.encoding, StringValuePtr(v), sizeof(ox_default_options.encoding) - 1);
|
473
|
-
#if
|
467
|
+
#if HAVE_RB_ENC_FIND
|
474
468
|
ox_default_options.rb_enc = rb_enc_find(ox_default_options.encoding);
|
475
|
-
#elif HAS_PRIVATE_ENCODING
|
476
|
-
ox_default_options.rb_enc = rb_str_new2(ox_default_options.encoding);
|
477
|
-
rb_gc_register_address(&ox_default_options.rb_enc);
|
478
469
|
#endif
|
479
470
|
}
|
480
471
|
|
@@ -674,14 +665,14 @@ to_obj(VALUE self, VALUE ruby_xml) {
|
|
674
665
|
xml = ALLOCA_N(char, len);
|
675
666
|
}
|
676
667
|
memcpy(xml, x, len);
|
677
|
-
#
|
668
|
+
#ifdef RB_GC_GUARD
|
678
669
|
rb_gc_disable();
|
679
670
|
#endif
|
680
671
|
obj = ox_parse(xml, len - 1, ox_obj_callbacks, 0, &options, &err);
|
681
672
|
if (SMALL_XML < len) {
|
682
673
|
xfree(xml);
|
683
674
|
}
|
684
|
-
#
|
675
|
+
#ifdef RB_GC_GUARD
|
685
676
|
RB_GC_GUARD(obj);
|
686
677
|
rb_gc_enable();
|
687
678
|
#endif
|
@@ -848,7 +839,7 @@ load(char *xml, size_t len, int argc, VALUE *argv, VALUE self, VALUE encoding, E
|
|
848
839
|
options.margin_len = strlen(options.margin);
|
849
840
|
}
|
850
841
|
}
|
851
|
-
#if
|
842
|
+
#if HAVE_RB_ENC_FIND
|
852
843
|
if ('\0' == *options.encoding) {
|
853
844
|
if (Qnil != encoding) {
|
854
845
|
options.rb_enc = rb_enc_from_index(rb_enc_get_index(encoding));
|
@@ -858,26 +849,15 @@ load(char *xml, size_t len, int argc, VALUE *argv, VALUE self, VALUE encoding, E
|
|
858
849
|
} else if (0 == options.rb_enc) {
|
859
850
|
options.rb_enc = rb_enc_find(options.encoding);
|
860
851
|
}
|
861
|
-
#elif HAS_PRIVATE_ENCODING
|
862
|
-
if ('\0' == *options.encoding) {
|
863
|
-
if (Qnil != encoding) {
|
864
|
-
options.rb_enc = encoding;
|
865
|
-
} else {
|
866
|
-
options.rb_enc = Qnil;
|
867
|
-
}
|
868
|
-
} else if (0 == options.rb_enc) {
|
869
|
-
options.rb_enc = rb_str_new2(options.encoding);
|
870
|
-
rb_gc_register_address(&options.rb_enc);
|
871
|
-
}
|
872
852
|
#endif
|
873
853
|
xml = defuse_bom(xml, &options);
|
874
854
|
switch (options.mode) {
|
875
855
|
case ObjMode:
|
876
|
-
#
|
856
|
+
#ifdef RB_GC_GUARD
|
877
857
|
rb_gc_disable();
|
878
858
|
#endif
|
879
859
|
obj = ox_parse(xml, len, ox_obj_callbacks, 0, &options, err);
|
880
|
-
#
|
860
|
+
#ifdef RB_GC_GUARD
|
881
861
|
RB_GC_GUARD(obj);
|
882
862
|
rb_gc_enable();
|
883
863
|
#endif
|
@@ -946,14 +926,8 @@ load_str(int argc, VALUE *argv, VALUE self) {
|
|
946
926
|
} else {
|
947
927
|
xml = ALLOCA_N(char, len);
|
948
928
|
}
|
949
|
-
#if
|
950
|
-
#ifdef MACRUBY_RUBY
|
951
|
-
encoding = rb_funcall(*argv, encoding_id, 0);
|
952
|
-
#else
|
929
|
+
#if HAVE_RB_OBJ_ENCODING
|
953
930
|
encoding = rb_obj_encoding(*argv);
|
954
|
-
#endif
|
955
|
-
#elif HAS_PRIVATE_ENCODING
|
956
|
-
encoding = rb_funcall(*argv, encoding_id, 0);
|
957
931
|
#else
|
958
932
|
encoding = Qnil;
|
959
933
|
#endif
|
@@ -1319,21 +1293,38 @@ dump(int argc, VALUE *argv, VALUE self) {
|
|
1319
1293
|
rb_raise(rb_eNoMemError, "Not enough memory.\n");
|
1320
1294
|
}
|
1321
1295
|
rstr = rb_str_new2(xml);
|
1322
|
-
#if
|
1296
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
1323
1297
|
if ('\0' != *copts.encoding) {
|
1324
1298
|
rb_enc_associate(rstr, rb_enc_find(copts.encoding));
|
1325
1299
|
}
|
1326
|
-
#elif HAS_PRIVATE_ENCODING
|
1327
|
-
if ('\0' != *copts.encoding) {
|
1328
|
-
rb_funcall(rstr, ox_force_encoding_id, 1, rb_str_new2(copts.encoding));
|
1329
|
-
}
|
1330
1300
|
#endif
|
1331
1301
|
xfree(xml);
|
1332
1302
|
|
1333
1303
|
return rstr;
|
1334
1304
|
}
|
1335
1305
|
|
1336
|
-
/* call-seq:
|
1306
|
+
/* call-seq: to_xml(obj, options) => xml-string
|
1307
|
+
*
|
1308
|
+
* Dumps an Object (obj) to a string.
|
1309
|
+
* - +obj+ [Object] Object to serialize as an XML document String
|
1310
|
+
* - +options+ [Hash] formating options
|
1311
|
+
* - *:indent* [Fixnum] format expected
|
1312
|
+
* - *:no_empty* [true|false] if true don't output empty elements
|
1313
|
+
* - *:xsd_date* [true|false] use XSD date format if true, default: false
|
1314
|
+
* - *:circular* [true|false] allow circular references, default: false
|
1315
|
+
* - *:strict|:tolerant]* [ :effort effort to use when an undumpable object (e.g., IO) is encountered, default: :strict
|
1316
|
+
* - _:strict_ - raise an NotImplementedError if an undumpable object is encountered
|
1317
|
+
* - _:tolerant_ - replaces undumplable objects with nil
|
1318
|
+
*
|
1319
|
+
* Note that an indent of less than zero will result in a tight one line output
|
1320
|
+
* unless the text in the XML fields contain new line characters.
|
1321
|
+
*/
|
1322
|
+
static VALUE
|
1323
|
+
to_xml(int argc, VALUE *argv, VALUE self) {
|
1324
|
+
return dump(argc, argv, self);
|
1325
|
+
}
|
1326
|
+
|
1327
|
+
/* call-seq: to_file(file_path, obj, options) => Object
|
1337
1328
|
*
|
1338
1329
|
* Dumps an Object to the specified file.
|
1339
1330
|
* - +file_path+ [String] file path to write the XML document to
|
@@ -1392,7 +1383,7 @@ void Init_ox() {
|
|
1392
1383
|
rb_define_module_function(Ox, "sax_parse", sax_parse, -1);
|
1393
1384
|
rb_define_module_function(Ox, "sax_html", sax_html, -1);
|
1394
1385
|
|
1395
|
-
rb_define_module_function(Ox, "to_xml",
|
1386
|
+
rb_define_module_function(Ox, "to_xml", to_xml, -1);
|
1396
1387
|
rb_define_module_function(Ox, "dump", dump, -1);
|
1397
1388
|
|
1398
1389
|
rb_define_module_function(Ox, "load_file", load_file, -1);
|
@@ -1555,11 +1546,8 @@ void Init_ox() {
|
|
1555
1546
|
rb_define _module_function(Ox, "cache8_test", cache8_test, 0);
|
1556
1547
|
#endif
|
1557
1548
|
|
1558
|
-
#if
|
1549
|
+
#if HAVE_RB_ENC_FIND
|
1559
1550
|
ox_utf8_encoding = rb_enc_find("UTF-8");
|
1560
|
-
#elif HAS_PRIVATE_ENCODING
|
1561
|
-
ox_utf8_encoding = rb_str_new2("UTF-8");
|
1562
|
-
rb_gc_register_address(&ox_utf8_encoding);
|
1563
1551
|
#endif
|
1564
1552
|
}
|
1565
1553
|
|
@@ -1580,7 +1568,7 @@ _ox_raise_error(const char *msg, const char *xml, const char *current, const cha
|
|
1580
1568
|
xline++;
|
1581
1569
|
}
|
1582
1570
|
}
|
1583
|
-
#
|
1571
|
+
#ifdef RB_GC_GUARD
|
1584
1572
|
rb_gc_enable();
|
1585
1573
|
#endif
|
1586
1574
|
rb_raise(ox_parse_error_class, "%s at line %d, column %d [%s:%d]\n", msg, xline, col, file, line);
|
data/ext/ox/ox.h
CHANGED
@@ -16,20 +16,15 @@ extern "C" {
|
|
16
16
|
#define RSTRING_NOT_MODIFIED
|
17
17
|
|
18
18
|
#include "ruby.h"
|
19
|
-
#if
|
19
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
20
20
|
#include "ruby/encoding.h"
|
21
21
|
#endif
|
22
22
|
|
23
|
-
#
|
24
|
-
#
|
25
|
-
enum st_retval {ST_CONTINUE = 0, ST_STOP = 1, ST_DELETE = 2, ST_CHECK};
|
23
|
+
#if HAVE_RUBY_ST_H
|
24
|
+
#include "ruby/st.h"
|
26
25
|
#else
|
27
|
-
|
28
|
-
/* Only on travis, local is where it is for all others. Seems to vary depending on the travis machine picked up. */
|
26
|
+
// Only on travis, local is where it is for all others. Seems to vary depending on the travis machine picked up.
|
29
27
|
#include "st.h"
|
30
|
-
#else
|
31
|
-
#include "ruby/st.h"
|
32
|
-
#endif
|
33
28
|
#endif
|
34
29
|
|
35
30
|
#include "cache.h"
|
@@ -146,10 +141,8 @@ typedef struct _options {
|
|
146
141
|
struct _hints *html_hints; // html hints
|
147
142
|
VALUE attr_key_mod;
|
148
143
|
VALUE element_key_mod;
|
149
|
-
#if
|
144
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
150
145
|
rb_encoding *rb_enc;
|
151
|
-
#elif HAS_PRIVATE_ENCODING
|
152
|
-
VALUE rb_enc;
|
153
146
|
#else
|
154
147
|
void *rb_enc;
|
155
148
|
#endif
|
@@ -236,10 +229,8 @@ extern ID ox_tv_nsec_id;
|
|
236
229
|
extern ID ox_tv_usec_id;
|
237
230
|
extern ID ox_value_id;
|
238
231
|
|
239
|
-
#if
|
232
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
240
233
|
extern rb_encoding *ox_utf8_encoding;
|
241
|
-
#elif HAS_PRIVATE_ENCODING
|
242
|
-
extern VALUE ox_utf8_encoding;
|
243
234
|
#else
|
244
235
|
extern void *ox_utf8_encoding;
|
245
236
|
#endif
|
data/ext/ox/parse.c
CHANGED
@@ -441,7 +441,6 @@ read_element(PInfo pi) {
|
|
441
441
|
// empty element, no attributes and no children
|
442
442
|
pi->s++;
|
443
443
|
if ('>' != *pi->s) {
|
444
|
-
/*printf("*** '%s' ***\n", pi->s); */
|
445
444
|
attr_stack_cleanup(&attrs);
|
446
445
|
set_error(&pi->err, "invalid format, element not closed", pi->str, pi->s);
|
447
446
|
return 0;
|
@@ -479,8 +478,8 @@ read_element(PInfo pi) {
|
|
479
478
|
pi->s++;
|
480
479
|
pi->pcb->add_element(pi, ename, attrs.head, hasChildren);
|
481
480
|
pi->pcb->end_element(pi, ename);
|
482
|
-
|
483
481
|
attr_stack_cleanup(&attrs);
|
482
|
+
|
484
483
|
return 0;
|
485
484
|
case '>':
|
486
485
|
/* has either children or a value */
|
@@ -1033,18 +1032,9 @@ read_coded_chars(PInfo pi, char *text) {
|
|
1033
1032
|
} else {
|
1034
1033
|
if (u <= 0x000000000000007FULL) {
|
1035
1034
|
*text++ = (char)u;
|
1036
|
-
#if HAS_PRIVATE_ENCODING
|
1037
|
-
} else if (ox_utf8_encoding == pi->options->rb_enc ||
|
1038
|
-
0 == strcasecmp(rb_str_ptr(rb_String(ox_utf8_encoding)), rb_str_ptr(rb_String(pi->options->rb_enc)))) {
|
1039
|
-
#else
|
1040
1035
|
} else if (ox_utf8_encoding == pi->options->rb_enc) {
|
1041
|
-
#endif
|
1042
1036
|
text = ox_ucs_to_utf8_chars(text, u);
|
1043
|
-
#if HAS_PRIVATE_ENCODING
|
1044
|
-
} else if (Qnil == pi->options->rb_enc) {
|
1045
|
-
#else
|
1046
1037
|
} else if (0 == pi->options->rb_enc) {
|
1047
|
-
#endif
|
1048
1038
|
pi->options->rb_enc = ox_utf8_encoding;
|
1049
1039
|
text = ox_ucs_to_utf8_chars(text, u);
|
1050
1040
|
} else if (TolerantEffort == pi->options->effort) {
|
@@ -1110,19 +1100,10 @@ collapse_special(PInfo pi, char *str) {
|
|
1110
1100
|
}
|
1111
1101
|
if (u <= 0x000000000000007FULL) {
|
1112
1102
|
*b++ = (char)u;
|
1113
|
-
#if HAS_PRIVATE_ENCODING
|
1114
|
-
} else if (ox_utf8_encoding == pi->options->rb_enc ||
|
1115
|
-
0 == strcasecmp(rb_str_ptr(rb_String(ox_utf8_encoding)), rb_str_ptr(rb_String(pi->options->rb_enc)))) {
|
1116
|
-
#else
|
1117
1103
|
} else if (ox_utf8_encoding == pi->options->rb_enc) {
|
1118
|
-
#endif
|
1119
1104
|
b = ox_ucs_to_utf8_chars(b, u);
|
1120
1105
|
/* TBD support UTF-16 */
|
1121
|
-
#if HAS_PRIVATE_ENCODING
|
1122
|
-
} else if (Qnil == pi->options->rb_enc) {
|
1123
|
-
#else
|
1124
1106
|
} else if (0 == pi->options->rb_enc) {
|
1125
|
-
#endif
|
1126
1107
|
pi->options->rb_enc = ox_utf8_encoding;
|
1127
1108
|
b = ox_ucs_to_utf8_chars(b, u);
|
1128
1109
|
} else {
|