Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Jan 11, 2021
2 parents c6a7b6f + 1f354ff commit bfa72d1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ rvm:
- 2.5.7
- 2.6.3
- 2.6.5
- 2.7.0
- 2.7.2
#- ruby-head
#- 3.0.0

install: gem install test-unit

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All changes to the Ox gem are documented here. Releases follow semantic versioni

## [Unreleased]

## [2.14.1] - 2021-01-11

### Fixed

- In Ruby 3.0 Range objects are frozen. This version allows Ranges to be created on load.

## [2.14.0] - 2020-12-15

### Added
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ A fast XML parser and Object marshaller as a Ruby gem.

*RubyGems* *repo*: https://rubygems.org/gems/ox

## Follow @oxgem on Twitter

[Follow @peterohler on Twitter](http://twitter.com/#!/peterohler) for announcements and news about the Ox gem.

## Support

[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).
Expand Down Expand Up @@ -79,7 +75,7 @@ callbacks. Unlike Nokogiri and LibXML, Ox can be tuned to use only the SAX
callbacks that are of interest to the caller. (See the perf_sax.rb file for an
example.)

Ox is compatible with Ruby 1.8.7, 1.9.3, 2.1.2, 2.2.0 and RBX.
Ox is compatible with Ruby 2.3, 2.4, 2.5, 2.6, 2.7, 3.0.

### Object Dump Sample:

Expand Down
2 changes: 1 addition & 1 deletion ext/ox/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
out->w_start(out, &e);

for (i = 0; i < cnt; i++) {
VALUE v = RSTRUCT_GET(obj, i);
VALUE v = RSTRUCT_GET(obj, (int)(i));
dump_obj(rb_intern(ulong2str(i, num_buf + sizeof(num_buf) - 1)), v, d2, out);
}
out->w_end(out, &e);
Expand Down
39 changes: 21 additions & 18 deletions ext/ox/obj_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ static void fill_indent(PInfo pi, char *buf, size_t size);


struct _parseCallbacks _ox_obj_callbacks = {
instruct, /* instruct, */
0, /* add_doctype, */
0, /* add_comment, */
0, /* add_cdata, */
instruct, // instruct,
0, // add_doctype,
0, // add_comment,
0, // add_cdata,
add_text,
add_element,
end_element,
Expand Down Expand Up @@ -128,7 +128,7 @@ resolve_classname(VALUE mod, const char *class_name, Effort effort, VALUE base_c
break;
case StrictEffort:
default:
/* raise an error if name is not defined */
// raise an error if name is not defined
clas = rb_const_get_at(mod, ci);
break;
}
Expand Down Expand Up @@ -183,7 +183,7 @@ parse_ulong(const char *s, PInfo pi) {
return ULONG2NUM(n);
}

/* 2010-07-09T10:47:45.895826162+09:00 */
// 2010-07-09T10:47:45.895826162+09:00
inline static VALUE
parse_time(const char *text, VALUE clas) {
VALUE t;
Expand Down Expand Up @@ -559,7 +559,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
printf("%s%s\n", indent, buf);
}
}
if (helper_stack_empty(&pi->helpers)) { /* top level object */
if (helper_stack_empty(&pi->helpers)) { // top level object
if (0 != (id = get_id_from_attrs(pi, attrs))) {
pi->circ_array = circ_array_new();
}
Expand All @@ -580,7 +580,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
h->obj = Qfalse;
break;
case StringCode:
/* h->obj will be replaced by add_text if it is called */
// h->obj will be replaced by add_text if it is called
h->obj = ox_empty_string;
if (0 != pi->circ_array) {
pi->id = get_id_from_attrs(pi, attrs);
Expand All @@ -597,8 +597,8 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
case ComplexCode:
case DateCode:
case TimeCode:
case RationalCode: /* sub elements read next */
/* value will be read in the following add_text */
case RationalCode: // sub elements read next
// value will be read in the following add_text
h->obj = Qundef;
break;
case String64Code:
Expand All @@ -620,7 +620,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
}
break;
case RangeCode:
h->obj = rb_range_new(ox_zero_fixnum, ox_zero_fixnum, Qfalse);
h->obj = rb_ary_new_from_args(3, Qnil, Qnil, Qfalse);
break;
case RawCode:
if (hasChildren) {
Expand Down Expand Up @@ -700,12 +700,15 @@ end_element(PInfo pi, const char *ename) {
Helper ph = helper_stack_peek(&pi->helpers);

if (ox_empty_string == h->obj) {
/* special catch for empty strings */
// special catch for empty strings
h->obj = rb_str_new2("");
}
if (Qundef == h->obj) {
} else if (Qundef == h->obj) {
set_error(&pi->err, "Invalid element for object mode", pi->str, pi->s);
return;
} else if (RangeCode == h->type) { // Expect an array of 3 elements.
const VALUE *ap = RARRAY_PTR(h->obj);

h->obj = rb_range_new(*ap, *(ap + 1), Qtrue == *(ap + 2));
}
pi->obj = h->obj;
if (0 != ph) {
Expand Down Expand Up @@ -740,11 +743,11 @@ end_element(PInfo pi, const char *ename) {
break;
case RangeCode:
if (ox_beg_id == h->var) {
RSTRUCT_SET(ph->obj, 0, h->obj);
rb_ary_store(ph->obj, 0, h->obj);
} else if (ox_end_id == h->var) {
RSTRUCT_SET(ph->obj, 1, h->obj);
rb_ary_store(ph->obj, 1, h->obj);
} else if (ox_excl_id == h->var) {
RSTRUCT_SET(ph->obj, 2, h->obj);
rb_ary_store(ph->obj, 2, h->obj);
} else {
set_error(&pi->err, "Invalid range attribute", pi->str, pi->s);
return;
Expand Down Expand Up @@ -903,7 +906,7 @@ parse_xsd_time(const char *text, VALUE clas) {
#endif
}

/* debug functions */
// debug functions
static void
fill_indent(PInfo pi, char *buf, size_t size) {
size_t cnt;
Expand Down
2 changes: 1 addition & 1 deletion lib/ox/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

module Ox
# Current version of the module.
VERSION = '2.14.0'
VERSION = '2.14.1'
end

0 comments on commit bfa72d1

Please sign in to comment.