diff --git a/configure.in b/configure.in index 63762b0c..3a67081b 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(msgpack/unpack_template.h) -AM_INIT_AUTOMAKE(msgpack, 0.2.1) +AM_INIT_AUTOMAKE(msgpack, 0.2.2) AC_CONFIG_HEADER(config.h) AC_PROG_LIBTOOL diff --git a/msgpack/unpack_define.h b/msgpack/unpack_define.h index 1d9db19f..f6398410 100644 --- a/msgpack/unpack_define.h +++ b/msgpack/unpack_define.h @@ -22,8 +22,10 @@ #include #include #include -#include #include +#ifndef __WIN32__ +#include +#endif #ifdef __cplusplus extern "C" { diff --git a/ruby/gem/lib/msgpack/version.rb b/ruby/gem/lib/msgpack/version.rb index 229c7462..488e0b2d 100644 --- a/ruby/gem/lib/msgpack/version.rb +++ b/ruby/gem/lib/msgpack/version.rb @@ -2,7 +2,7 @@ module MessagePack module VERSION #:nodoc: MAJOR = 0 MINOR = 2 - TINY = 1 + TINY = 2 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/ruby/msgpack.gemspec b/ruby/msgpack.gemspec new file mode 100755 index 00000000..db2fcd52 --- /dev/null +++ b/ruby/msgpack.gemspec @@ -0,0 +1,11 @@ +Gem::Specification.new do |s| + s.platform = Gem::Platform::CURRENT + s.name = "msgpack" + s.version = "0.2.2" + s.summary = "MessagePack" + s.author = "FURUHASHI Sadayuki" + s.email = "frsyuki _at_ users.sourceforge.jp" + s.homepage = "https://launchpad.net/msgpack/" + s.require_paths = ["lib", "ext"] + s.files = ["lib/**/*", "ext/**/*"].map {|g| Dir.glob(g) }.flatten +end diff --git a/ruby/unpack.c b/ruby/unpack.c index 8ab425c6..df722469 100644 --- a/ruby/unpack.c +++ b/ruby/unpack.c @@ -21,6 +21,7 @@ typedef struct { int finished; + VALUE origstr; } msgpack_unpack_context; @@ -104,7 +105,7 @@ static inline void template_callback_map_item(msgpack_unpack_context* x, VALUE* { rb_hash_aset(*c, k, v); } static inline VALUE template_callback_raw(msgpack_unpack_context* x, const char* b, const char* p, unsigned int l) -{ return rb_str_new(p, l); } +{ return l == 0 ? rb_str_new(0,0) : rb_str_substr(x->origstr, p - b, l); } #include "msgpack/unpack_template.h" @@ -152,8 +153,9 @@ static VALUE MessagePack_Unpacker_alloc(VALUE klass) static VALUE MessagePack_Unpacker_reset(VALUE self) { UNPACKER(self, mp); - mp->user.finished = 0; msgpack_unpacker_init(mp); + msgpack_unpack_context ctx = {0, Qnil}; + mp->user = ctx; return self; } @@ -179,7 +181,9 @@ static VALUE MessagePack_Unpacker_execute_impl(VALUE args) rb_raise(eUnpackError, "offset is bigger than data buffer size."); } + mp->user.origstr = data; ret = msgpack_unpacker_execute(mp, dptr, (size_t)dlen, &from); + mp->user.origstr = Qnil; if(ret < 0) { rb_raise(eUnpackError, "parse error."); @@ -239,7 +243,9 @@ static VALUE MessagePack_unpack_impl(VALUE args) long dlen = RSTRING_LEN(data); int ret; + mp->user.origstr = data; ret = msgpack_unpacker_execute(mp, dptr, (size_t)dlen, &from); + mp->user.origstr = Qnil; if(ret < 0) { rb_raise(eUnpackError, "parse error."); @@ -268,6 +274,9 @@ static VALUE MessagePack_unpack(VALUE self, VALUE data) CHECK_STRING_TYPE(data); msgpack_unpacker mp; msgpack_unpacker_init(&mp); + msgpack_unpack_context ctx = {0, Qnil}; + mp.user = ctx; + rb_gc_disable(); VALUE args[2] = {(VALUE)&mp, data}; VALUE ret = rb_rescue(MessagePack_unpack_impl, (VALUE)args,