This commit is contained in:
gfx 2010-09-15 13:16:13 +09:00
parent d36543b204
commit c694f1a4a9

View File

@ -204,7 +204,7 @@ STATIC_INLINE int template_callback_raw(unpack_user* u PERL_UNUSED_DECL, const c
#include "msgpack/unpack_template.h" #include "msgpack/unpack_template.h"
STATIC_INLINE SV* _msgpack_unpack(SV* data, int limit) { STATIC_INLINE SV* _msgpack_unpack(SV* data, size_t limit PERL_UNUSED_DECL) {
msgpack_unpack_t mp; msgpack_unpack_t mp;
dTHX; dTHX;
unpack_user u = {0, &PL_sv_undef, false}; unpack_user u = {0, &PL_sv_undef, false};
@ -252,14 +252,20 @@ XS(xs_unpack_limit) {
XS(xs_unpack) { XS(xs_unpack) {
dXSARGS; dXSARGS;
SV* const data = ST(1);
size_t limit;
if (items != 2) { if (items == 2) {
Perl_croak(aTHX_ "Usage: Data::MessagePack->unpack('datadata')"); limit = sv_len(data);
}
else if(items == 3) {
limit = SvUVx(ST(2));
}
else {
Perl_croak(aTHX_ "Usage: Data::MessagePack->unpack('data' [, $limit])");
} }
{ ST(0) = _msgpack_unpack(data, limit);
ST(0) = _msgpack_unpack(ST(1), sv_len(ST(1)));
}
XSRETURN(1); XSRETURN(1);
} }