diff options
author | John Shahid <jvshahid@gmail.com> | 2012-11-23 03:19:08 -0500 |
---|---|---|
committer | John Shahid <jvshahid@gmail.com> | 2012-11-23 03:21:50 -0500 |
commit | bdb8e000a7e12e74313d349a4e9b1f7e8b385778 (patch) | |
tree | f24db3a564bcbd34833ea3fb85dba484fd3499b8 | |
parent | 00333cd538abd9a963a5b2baca186489dc335d98 (diff) | |
download | json-bdb8e000a7e12e74313d349a4e9b1f7e8b385778.tar.gz |
fix some bugs in the C versions of State::configure and add the alias in the Java version.
-rw-r--r-- | ext/json/ext/generator/generator.c | 10 | ||||
-rw-r--r-- | java/src/json/ext/GeneratorState.java | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index ad7dfe3..2c7fa61 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -522,7 +522,7 @@ static VALUE cState_configure(VALUE self, VALUE opts) unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); - state->indent = fstrndup(RSTRING_PTR(tmp), len); + state->indent = fstrndup(RSTRING_PTR(tmp), len + 1); state->indent_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_space)); @@ -530,7 +530,7 @@ static VALUE cState_configure(VALUE self, VALUE opts) unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); - state->space = fstrndup(RSTRING_PTR(tmp), len); + state->space = fstrndup(RSTRING_PTR(tmp), len + 1); state->space_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_space_before)); @@ -538,7 +538,7 @@ static VALUE cState_configure(VALUE self, VALUE opts) unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); - state->space_before = fstrndup(RSTRING_PTR(tmp), len); + state->space_before = fstrndup(RSTRING_PTR(tmp), len + 1); state->space_before_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_array_nl)); @@ -546,7 +546,7 @@ static VALUE cState_configure(VALUE self, VALUE opts) unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); - state->array_nl = fstrndup(RSTRING_PTR(tmp), len); + state->array_nl = fstrndup(RSTRING_PTR(tmp), len + 1); state->array_nl_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_object_nl)); @@ -554,7 +554,7 @@ static VALUE cState_configure(VALUE self, VALUE opts) unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); - state->object_nl = fstrndup(RSTRING_PTR(tmp), len); + state->object_nl = fstrndup(RSTRING_PTR(tmp), len + 1); state->object_nl_len = len; } tmp = ID2SYM(i_max_nesting); diff --git a/java/src/json/ext/GeneratorState.java b/java/src/json/ext/GeneratorState.java index 14d5431..58904ee 100644 --- a/java/src/json/ext/GeneratorState.java +++ b/java/src/json/ext/GeneratorState.java @@ -445,7 +445,7 @@ public class GeneratorState extends RubyObject { * @param vOpts The options hash * @return The receiver */ - @JRubyMethod + @JRubyMethod(alias = "merge") public IRubyObject configure(ThreadContext context, IRubyObject vOpts) { OptionsReader opts = new OptionsReader(context, vOpts); |