mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-21 06:11:18 +01:00
perl: clean up
This commit is contained in:
parent
c790735b9f
commit
92b346efa7
@ -1,6 +1,5 @@
|
||||
#define NEED_newRV_noinc
|
||||
#define NEED_sv_2pv_flags
|
||||
#define NEED_my_snprintf
|
||||
#include "xshelper.h"
|
||||
|
||||
#define MY_CXT_KEY "Data::MessagePack::_unpack_guts" XS_VERSION
|
||||
@ -121,7 +120,8 @@ STATIC_INLINE int template_callback_IV(unpack_user* u PERL_UNUSED_DECL, IV const
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char* str_from_uint64(char* buf_end, uint64_t v)
|
||||
/* workaround win32 problems (my_snprintf(%llu) returns incorrect values ) */
|
||||
static char* str_from_uint64(char* buf_end, uint64_t v)
|
||||
{
|
||||
char *p = buf_end;
|
||||
*--p = '\0';
|
||||
@ -131,9 +131,8 @@ static const char* str_from_uint64(char* buf_end, uint64_t v)
|
||||
return p;
|
||||
}
|
||||
|
||||
static const char* str_from_int64(char* buf_end, int64_t v)
|
||||
{
|
||||
int minus = v < 0;
|
||||
static const char* str_from_int64(char* buf_end, int64_t const v) {
|
||||
bool const minus = v < 0;
|
||||
char* p = str_from_uint64(buf_end, minus ? -v : v);
|
||||
if (minus)
|
||||
*--p = '-';
|
||||
@ -144,13 +143,8 @@ static int template_callback_uint64(unpack_user* u PERL_UNUSED_DECL, uint64_t co
|
||||
{
|
||||
dTHX;
|
||||
char tbuf[64];
|
||||
#if 1 /* workaround for win32-32bit (my_snprintf(%llu) returns are incorrect) */
|
||||
char* s = str_from_uint64(tbuf + sizeof(tbuf), d);
|
||||
const char* const s = str_from_uint64(tbuf + sizeof(tbuf), d);
|
||||
*o = newSVpvn(s, tbuf + sizeof(tbuf) - 1 - s);
|
||||
#else
|
||||
STRLEN const len = my_snprintf(tbuf, sizeof(tbuf), "%llu", d);
|
||||
*o = newSVpvn(tbuf, len);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -158,13 +152,8 @@ static int template_callback_int64(unpack_user* u PERL_UNUSED_DECL, int64_t cons
|
||||
{
|
||||
dTHX;
|
||||
char tbuf[64];
|
||||
#if 1 /* workaround for win32-32bit (my_snprintf(%lld) returns are incorrect) */
|
||||
char* s = str_from_int64(tbuf + sizeof(tbuf), d);
|
||||
const char* const s = str_from_int64(tbuf + sizeof(tbuf), d);
|
||||
*o = newSVpvn(s, tbuf + sizeof(tbuf) - 1 - s);
|
||||
#else
|
||||
STRLEN const len = my_snprintf(tbuf, sizeof(tbuf), "%lld", d);
|
||||
*o = newSVpvn(tbuf, len);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user