X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/cd7e75121be11e7979933a8f7a47cd842a685157..1c75beb82e2bc71836b8b226cb4e976792d1967c:/pp_pack.c diff --git a/pp_pack.c b/pp_pack.c index e0e2db1..3cfc03c 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -129,8 +129,10 @@ typedef union { # define OFF32(p) ((char *) (p)) #endif -#define PUSH16(utf8, cur, p) PUSH_BYTES(utf8, cur, OFF16(p), SIZE16) -#define PUSH32(utf8, cur, p) PUSH_BYTES(utf8, cur, OFF32(p), SIZE32) +#define PUSH16(utf8, cur, p, needs_swap) \ + PUSH_BYTES(utf8, cur, OFF16(p), SIZE16, needs_swap) +#define PUSH32(utf8, cur, p, needs_swap) \ + PUSH_BYTES(utf8, cur, OFF32(p), SIZE32, needs_swap) #if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321 /* big-endian */ # define NEEDS_SWAP(d) (TYPE_ENDIANNESS(d) == TYPE_IS_LITTLE_ENDIAN) @@ -138,35 +140,39 @@ typedef union { # define NEEDS_SWAP(d) (TYPE_ENDIANNESS(d) == TYPE_IS_BIG_ENDIAN) #else # error "Unsupported byteorder" - /* Need to add code here to re-instate mixed endian support. */ + /* Need to add code here to re-instate mixed endian support. + NEEDS_SWAP would need to hold a flag indicating which action to + take, and S_reverse_copy and the code in uni_to_bytes would need + logic adding to deal with any mixed-endian transformations needed. + */ #endif /* Only to be used inside a loop (see the break) */ -#define SHIFT_BYTES(utf8, s, strend, buf, len, datumtype) \ +#define SHIFT_BYTES(utf8, s, strend, buf, len, datumtype, needs_swap) \ STMT_START { \ - if (utf8) { \ + if (UNLIKELY(utf8)) { \ if (!uni_to_bytes(aTHX_ &s, strend, \ (char *) (buf), len, datumtype)) break; \ } else { \ - Copy(s, (char *) (buf), len, char); \ + if (UNLIKELY(needs_swap)) \ + S_reverse_copy(s, (char *) (buf), len); \ + else \ + Copy(s, (char *) (buf), len, char); \ s += len; \ } \ - if (needs_swap) { \ - my_swabn((buf), len); \ - } \ } STMT_END -#define SHIFT16(utf8, s, strend, p, datumtype) \ - SHIFT_BYTES(utf8, s, strend, OFF16(p), SIZE16, datumtype) +#define SHIFT16(utf8, s, strend, p, datumtype, needs_swap) \ + SHIFT_BYTES(utf8, s, strend, OFF16(p), SIZE16, datumtype, needs_swap) -#define SHIFT32(utf8, s, strend, p, datumtype) \ - SHIFT_BYTES(utf8, s, strend, OFF32(p), SIZE32, datumtype) +#define SHIFT32(utf8, s, strend, p, datumtype, needs_swap) \ + SHIFT_BYTES(utf8, s, strend, OFF32(p), SIZE32, datumtype, needs_swap) -#define SHIFT_VAR(utf8, s, strend, var, datumtype) \ - SHIFT_BYTES(utf8, s, strend, &(var), sizeof(var), datumtype) +#define SHIFT_VAR(utf8, s, strend, var, datumtype, needs_swap) \ + SHIFT_BYTES(utf8, s, strend, &(var), sizeof(var), datumtype, needs_swap) -#define PUSH_VAR(utf8, aptr, var) \ - PUSH_BYTES(utf8, aptr, &(var), sizeof(var)) +#define PUSH_VAR(utf8, aptr, var, needs_swap) \ + PUSH_BYTES(utf8, aptr, &(var), sizeof(var), needs_swap) /* Avoid stack overflow due to pathological templates. 100 should be plenty. */ #define MAX_SUB_TEMPLATE_LEVEL 100 @@ -235,19 +241,20 @@ S_mul128(pTHX_ SV *sv, U8 m) # define ENDIANNESS_ALLOWED_TYPES "sSiIlLqQjJfFdDpP(" -# define DO_BO_PACK(var) \ - STMT_START { \ - if (needs_swap) { \ - my_swabn(&var, sizeof(var)); \ - } \ - } STMT_END - #define PACK_SIZE_CANNOT_CSUM 0x80 #define PACK_SIZE_UNPREDICTABLE 0x40 /* Not a fixed size element */ #define PACK_SIZE_MASK 0x3F #include "packsizetables.c" +static void +S_reverse_copy(const char *src, char *dest, STRLEN len) +{ + dest += len; + while (len--) + *--dest = *src++; +} + STATIC U8 uni_to_byte(pTHX_ const char **s, const char *end, I32 datumtype) { @@ -283,6 +290,11 @@ uni_to_bytes(pTHX_ const char **s, const char *end, const char *buf, int buf_len int bad = 0; const U32 flags = ckWARN(WARN_UTF8) ? UTF8_CHECK_ONLY : (UTF8_CHECK_ONLY | UTF8_ALLOW_ANY); + const bool needs_swap = NEEDS_SWAP(datumtype); + + if (UNLIKELY(needs_swap)) + buf += buf_len; + for (;buf_len > 0; buf_len--) { if (from >= end) return FALSE; val = utf8n_to_uvchr((U8 *) from, end-from, &retlen, flags); @@ -294,7 +306,10 @@ uni_to_bytes(pTHX_ const char **s, const char *end, const char *buf, int buf_len bad |= 2; val &= 0xff; } - *(U8 *)buf++ = (U8)val; + if (UNLIKELY(needs_swap)) + *(U8 *)--buf = (U8)val; + else + *(U8 *)buf++ = (U8)val; } /* We have enough characters for the buffer. Did we have problems ? */ if (bad) { @@ -336,30 +351,45 @@ next_uni_uu(pTHX_ const char **s, const char *end, I32 *out) } STATIC char * -S_bytes_to_uni(const U8 *start, STRLEN len, char *dest) { - const U8 * const end = start + len; - +S_bytes_to_uni(const U8 *start, STRLEN len, char *dest, const bool needs_swap) { PERL_ARGS_ASSERT_BYTES_TO_UNI; - while (start < end) { - const UV uv = NATIVE_TO_ASCII(*start); - if (UNI_IS_INVARIANT(uv)) - *dest++ = (char)(U8)UTF_TO_NATIVE(uv); - else { - *dest++ = (char)(U8)UTF8_EIGHT_BIT_HI(uv); - *dest++ = (char)(U8)UTF8_EIGHT_BIT_LO(uv); - } - start++; + if (UNLIKELY(needs_swap)) { + const U8 *p = start + len; + while (p-- > start) { + const UV uv = NATIVE_TO_ASCII(*p); + if (UNI_IS_INVARIANT(uv)) + *dest++ = (char)(U8)UTF_TO_NATIVE(uv); + else { + *dest++ = (char)(U8)UTF8_EIGHT_BIT_HI(uv); + *dest++ = (char)(U8)UTF8_EIGHT_BIT_LO(uv); + } + } + } else { + const U8 * const end = start + len; + while (start < end) { + const UV uv = NATIVE_TO_ASCII(*start); + if (UNI_IS_INVARIANT(uv)) + *dest++ = (char)(U8)UTF_TO_NATIVE(uv); + else { + *dest++ = (char)(U8)UTF8_EIGHT_BIT_HI(uv); + *dest++ = (char)(U8)UTF8_EIGHT_BIT_LO(uv); + } + start++; + } } return dest; } -#define PUSH_BYTES(utf8, cur, buf, len) \ +#define PUSH_BYTES(utf8, cur, buf, len, needs_swap) \ STMT_START { \ - if (utf8) \ - (cur) = bytes_to_uni((U8 *) buf, len, (cur)); \ + if (UNLIKELY(utf8)) \ + (cur) = S_bytes_to_uni((U8 *) buf, len, (cur), needs_swap); \ else { \ - Copy(buf, cur, len, char); \ + if (UNLIKELY(needs_swap)) \ + S_reverse_copy((char *)(buf), cur, len); \ + else \ + Copy(buf, cur, len, char); \ (cur) += (len); \ } \ } STMT_END @@ -385,14 +415,14 @@ STMT_START { \ (start) = sv_exp_grow(cat, gl); \ (cur) = (start) + SvCUR(cat); \ } \ - PUSH_BYTES(utf8, cur, buf, glen); \ + PUSH_BYTES(utf8, cur, buf, glen, 0); \ } STMT_END #define PUSH_BYTE(utf8, s, byte) \ STMT_START { \ if (utf8) { \ const U8 au8 = (byte); \ - (s) = bytes_to_uni(&au8, 1, (s)); \ + (s) = S_bytes_to_uni(&au8, 1, (s), 0); \ } else *(U8 *)(s)++ = (byte); \ } STMT_END @@ -1318,7 +1348,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if SHORTSIZE != SIZE16 while (len-- > 0) { short ashort; - SHIFT_VAR(utf8, s, strend, ashort, datumtype); + SHIFT_VAR(utf8, s, strend, ashort, datumtype, needs_swap); if (!checksum) mPUSHi(ashort); else if (checksum > bits_in_uv) @@ -1337,7 +1367,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if U16SIZE > SIZE16 ai16 = 0; #endif - SHIFT16(utf8, s, strend, &ai16, datumtype); + SHIFT16(utf8, s, strend, &ai16, datumtype, needs_swap); #if U16SIZE > SIZE16 if (ai16 > 32767) ai16 -= 65536; @@ -1354,7 +1384,8 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if SHORTSIZE != SIZE16 while (len-- > 0) { unsigned short aushort; - SHIFT_VAR(utf8, s, strend, aushort, datumtype); + SHIFT_VAR(utf8, s, strend, aushort, datumtype, needs_swap, + needs_swap); if (!checksum) mPUSHu(aushort); else if (checksum > bits_in_uv) @@ -1374,7 +1405,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if U16SIZE > SIZE16 au16 = 0; #endif - SHIFT16(utf8, s, strend, &au16, datumtype); + SHIFT16(utf8, s, strend, &au16, datumtype, needs_swap); if (datumtype == 'n') au16 = PerlSock_ntohs(au16); if (datumtype == 'v') @@ -1394,7 +1425,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c # if U16SIZE > SIZE16 ai16 = 0; # endif - SHIFT16(utf8, s, strend, &ai16, datumtype); + SHIFT16(utf8, s, strend, &ai16, datumtype, needs_swap); /* There should never be any byte-swapping here. */ assert(!TYPE_ENDIANNESS(datumtype)); if (datumtype == ('n' | TYPE_IS_SHRIEKING)) @@ -1413,7 +1444,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'i' | TYPE_IS_SHRIEKING: while (len-- > 0) { int aint; - SHIFT_VAR(utf8, s, strend, aint, datumtype); + SHIFT_VAR(utf8, s, strend, aint, datumtype, needs_swap); if (!checksum) mPUSHi(aint); else if (checksum > bits_in_uv) @@ -1426,7 +1457,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'I' | TYPE_IS_SHRIEKING: while (len-- > 0) { unsigned int auint; - SHIFT_VAR(utf8, s, strend, auint, datumtype); + SHIFT_VAR(utf8, s, strend, auint, datumtype, needs_swap); if (!checksum) mPUSHu(auint); else if (checksum > bits_in_uv) @@ -1438,7 +1469,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'j': while (len-- > 0) { IV aiv; - SHIFT_VAR(utf8, s, strend, aiv, datumtype); + SHIFT_VAR(utf8, s, strend, aiv, datumtype, needs_swap); if (!checksum) mPUSHi(aiv); else if (checksum > bits_in_uv) @@ -1450,7 +1481,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'J': while (len-- > 0) { UV auv; - SHIFT_VAR(utf8, s, strend, auv, datumtype); + SHIFT_VAR(utf8, s, strend, auv, datumtype, needs_swap); if (!checksum) mPUSHu(auv); else if (checksum > bits_in_uv) @@ -1463,7 +1494,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if LONGSIZE != SIZE32 while (len-- > 0) { long along; - SHIFT_VAR(utf8, s, strend, along, datumtype); + SHIFT_VAR(utf8, s, strend, along, datumtype, needs_swap); if (!checksum) mPUSHi(along); else if (checksum > bits_in_uv) @@ -1481,7 +1512,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if U32SIZE > SIZE32 ai32 = 0; #endif - SHIFT32(utf8, s, strend, &ai32, datumtype); + SHIFT32(utf8, s, strend, &ai32, datumtype, needs_swap); #if U32SIZE > SIZE32 if (ai32 > 2147483647) ai32 -= 4294967296; #endif @@ -1497,7 +1528,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if LONGSIZE != SIZE32 while (len-- > 0) { unsigned long aulong; - SHIFT_VAR(utf8, s, strend, aulong, datumtype); + SHIFT_VAR(utf8, s, strend, aulong, datumtype, needs_swap); if (!checksum) mPUSHu(aulong); else if (checksum > bits_in_uv) @@ -1517,7 +1548,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if U32SIZE > SIZE32 au32 = 0; #endif - SHIFT32(utf8, s, strend, &au32, datumtype); + SHIFT32(utf8, s, strend, &au32, datumtype, needs_swap); if (datumtype == 'N') au32 = PerlSock_ntohl(au32); if (datumtype == 'V') @@ -1537,7 +1568,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c #if U32SIZE > SIZE32 ai32 = 0; #endif - SHIFT32(utf8, s, strend, &ai32, datumtype); + SHIFT32(utf8, s, strend, &ai32, datumtype, needs_swap); /* There should never be any byte swapping here. */ assert(!TYPE_ENDIANNESS(datumtype)); if (datumtype == ('N' | TYPE_IS_SHRIEKING)) @@ -1555,7 +1586,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'p': while (len-- > 0) { const char *aptr; - SHIFT_VAR(utf8, s, strend, aptr, datumtype); + SHIFT_VAR(utf8, s, strend, aptr, datumtype, needs_swap); /* newSVpv generates undef if aptr is NULL */ mPUSHs(newSVpv(aptr, 0)); } @@ -1608,7 +1639,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c EXTEND(SP, 1); if (s + sizeof(char*) <= strend) { char *aptr; - SHIFT_VAR(utf8, s, strend, aptr, datumtype); + SHIFT_VAR(utf8, s, strend, aptr, datumtype, needs_swap); /* newSVpvn generates undef if aptr is NULL */ PUSHs(newSVpvn_flags(aptr, len, SVs_TEMP)); } @@ -1617,7 +1648,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'q': while (len-- > 0) { Quad_t aquad; - SHIFT_VAR(utf8, s, strend, aquad, datumtype); + SHIFT_VAR(utf8, s, strend, aquad, datumtype, needs_swap); if (!checksum) mPUSHs(aquad >= IV_MIN && aquad <= IV_MAX ? newSViv((IV)aquad) : newSVnv((NV)aquad)); @@ -1630,7 +1661,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'Q': while (len-- > 0) { Uquad_t auquad; - SHIFT_VAR(utf8, s, strend, auquad, datumtype); + SHIFT_VAR(utf8, s, strend, auquad, datumtype, needs_swap); if (!checksum) mPUSHs(auquad <= UV_MAX ? newSVuv((UV)auquad) : newSVnv((NV)auquad)); @@ -1645,7 +1676,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'f': while (len-- > 0) { float afloat; - SHIFT_VAR(utf8, s, strend, afloat, datumtype); + SHIFT_VAR(utf8, s, strend, afloat, datumtype, needs_swap); if (!checksum) mPUSHn(afloat); else @@ -1655,7 +1686,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'd': while (len-- > 0) { double adouble; - SHIFT_VAR(utf8, s, strend, adouble, datumtype); + SHIFT_VAR(utf8, s, strend, adouble, datumtype, needs_swap); if (!checksum) mPUSHn(adouble); else @@ -1665,7 +1696,8 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'F': while (len-- > 0) { NV_bytes anv; - SHIFT_BYTES(utf8, s, strend, anv.bytes, sizeof(anv.bytes), datumtype); + SHIFT_BYTES(utf8, s, strend, anv.bytes, sizeof(anv.bytes), + datumtype, needs_swap); if (!checksum) mPUSHn(anv.nv); else @@ -1676,7 +1708,8 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c case 'D': while (len-- > 0) { ld_bytes aldouble; - SHIFT_BYTES(utf8, s, strend, aldouble.bytes, sizeof(aldouble.bytes), datumtype); + SHIFT_BYTES(utf8, s, strend, aldouble.bytes, + sizeof(aldouble.bytes), datumtype, needs_swap); if (!checksum) mPUSHn(aldouble.ld); else @@ -2628,7 +2661,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) len+(endb-buffer)*UTF8_EXPAND); end = start+SvLEN(cat); } - cur = bytes_to_uni(buffer, endb-buffer, cur); + cur = S_bytes_to_uni(buffer, endb-buffer, cur, 0); } else { if (cur >= end) { *cur = '\0'; @@ -2662,8 +2695,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) # else afloat = (float)anv; # endif - DO_BO_PACK(afloat); - PUSH_VAR(utf8, cur, afloat); + PUSH_VAR(utf8, cur, afloat, needs_swap); } break; case 'd': @@ -2684,8 +2716,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) # else adouble = (double)anv; # endif - DO_BO_PACK(adouble); - PUSH_VAR(utf8, cur, adouble); + PUSH_VAR(utf8, cur, adouble, needs_swap); } break; case 'F': { @@ -2699,8 +2730,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) #else anv.nv = SvNV(fromstr); #endif - DO_BO_PACK(anv); - PUSH_BYTES(utf8, cur, anv.bytes, sizeof(anv.bytes)); + PUSH_BYTES(utf8, cur, anv.bytes, sizeof(anv.bytes), needs_swap); } break; } @@ -2717,8 +2747,8 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) # else aldouble.ld = (long double)SvNV(fromstr); # endif - DO_BO_PACK(aldouble); - PUSH_BYTES(utf8, cur, aldouble.bytes, sizeof(aldouble.bytes)); + PUSH_BYTES(utf8, cur, aldouble.bytes, sizeof(aldouble.bytes), + needs_swap); } break; } @@ -2730,7 +2760,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) fromstr = NEXTFROM; ai16 = (I16)SvIV(fromstr); ai16 = PerlSock_htons(ai16); - PUSH16(utf8, cur, &ai16); + PUSH16(utf8, cur, &ai16, FALSE); } break; case 'v' | TYPE_IS_SHRIEKING: @@ -2740,7 +2770,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) fromstr = NEXTFROM; ai16 = (I16)SvIV(fromstr); ai16 = htovs(ai16); - PUSH16(utf8, cur, &ai16); + PUSH16(utf8, cur, &ai16, FALSE); } break; case 'S' | TYPE_IS_SHRIEKING: @@ -2749,8 +2779,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) unsigned short aushort; fromstr = NEXTFROM; aushort = SvUV(fromstr); - DO_BO_PACK(aushort); - PUSH_VAR(utf8, cur, aushort); + PUSH_VAR(utf8, cur, aushort, needs_swap); } break; #else @@ -2761,8 +2790,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) U16 au16; fromstr = NEXTFROM; au16 = (U16)SvUV(fromstr); - DO_BO_PACK(au16); - PUSH16(utf8, cur, &au16); + PUSH16(utf8, cur, &au16, needs_swap); } break; case 's' | TYPE_IS_SHRIEKING: @@ -2771,8 +2799,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) short ashort; fromstr = NEXTFROM; ashort = SvIV(fromstr); - DO_BO_PACK(ashort); - PUSH_VAR(utf8, cur, ashort); + PUSH_VAR(utf8, cur, ashort, needs_swap); } break; #else @@ -2783,8 +2810,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) I16 ai16; fromstr = NEXTFROM; ai16 = (I16)SvIV(fromstr); - DO_BO_PACK(ai16); - PUSH16(utf8, cur, &ai16); + PUSH16(utf8, cur, &ai16, needs_swap); } break; case 'I': @@ -2793,8 +2819,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) unsigned int auint; fromstr = NEXTFROM; auint = SvUV(fromstr); - DO_BO_PACK(auint); - PUSH_VAR(utf8, cur, auint); + PUSH_VAR(utf8, cur, auint, needs_swap); } break; case 'j': @@ -2802,8 +2827,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) IV aiv; fromstr = NEXTFROM; aiv = SvIV(fromstr); - DO_BO_PACK(aiv); - PUSH_VAR(utf8, cur, aiv); + PUSH_VAR(utf8, cur, aiv, needs_swap); } break; case 'J': @@ -2811,8 +2835,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) UV auv; fromstr = NEXTFROM; auv = SvUV(fromstr); - DO_BO_PACK(auv); - PUSH_VAR(utf8, cur, auv); + PUSH_VAR(utf8, cur, auv, needs_swap); } break; case 'w': @@ -2908,8 +2931,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) int aint; fromstr = NEXTFROM; aint = SvIV(fromstr); - DO_BO_PACK(aint); - PUSH_VAR(utf8, cur, aint); + PUSH_VAR(utf8, cur, aint, needs_swap); } break; case 'N' | TYPE_IS_SHRIEKING: @@ -2919,7 +2941,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) fromstr = NEXTFROM; au32 = SvUV(fromstr); au32 = PerlSock_htonl(au32); - PUSH32(utf8, cur, &au32); + PUSH32(utf8, cur, &au32, FALSE); } break; case 'V' | TYPE_IS_SHRIEKING: @@ -2929,7 +2951,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) fromstr = NEXTFROM; au32 = SvUV(fromstr); au32 = htovl(au32); - PUSH32(utf8, cur, &au32); + PUSH32(utf8, cur, &au32, FALSE); } break; case 'L' | TYPE_IS_SHRIEKING: @@ -2938,8 +2960,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) unsigned long aulong; fromstr = NEXTFROM; aulong = SvUV(fromstr); - DO_BO_PACK(aulong); - PUSH_VAR(utf8, cur, aulong); + PUSH_VAR(utf8, cur, aulong, needs_swap); } break; #else @@ -2950,8 +2971,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) U32 au32; fromstr = NEXTFROM; au32 = SvUV(fromstr); - DO_BO_PACK(au32); - PUSH32(utf8, cur, &au32); + PUSH32(utf8, cur, &au32, needs_swap); } break; case 'l' | TYPE_IS_SHRIEKING: @@ -2960,8 +2980,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) long along; fromstr = NEXTFROM; along = SvIV(fromstr); - DO_BO_PACK(along); - PUSH_VAR(utf8, cur, along); + PUSH_VAR(utf8, cur, along, needs_swap); } break; #else @@ -2972,8 +2991,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) I32 ai32; fromstr = NEXTFROM; ai32 = SvIV(fromstr); - DO_BO_PACK(ai32); - PUSH32(utf8, cur, &ai32); + PUSH32(utf8, cur, &ai32, needs_swap); } break; #ifdef HAS_QUAD @@ -2982,8 +3000,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) Uquad_t auquad; fromstr = NEXTFROM; auquad = (Uquad_t) SvUV(fromstr); - DO_BO_PACK(auquad); - PUSH_VAR(utf8, cur, auquad); + PUSH_VAR(utf8, cur, auquad, needs_swap); } break; case 'q': @@ -2991,8 +3008,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) Quad_t aquad; fromstr = NEXTFROM; aquad = (Quad_t)SvIV(fromstr); - DO_BO_PACK(aquad); - PUSH_VAR(utf8, cur, aquad); + PUSH_VAR(utf8, cur, aquad, needs_swap); } break; #endif /* HAS_QUAD */ @@ -3023,8 +3039,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) else aptr = SvPV_force_flags_nolen(fromstr, 0); } - DO_BO_PACK(aptr); - PUSH_VAR(utf8, cur, aptr); + PUSH_VAR(utf8, cur, aptr, needs_swap); } break; case 'u': { @@ -3070,7 +3085,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) end = doencodes(hunk, aptr, todo); aptr += todo; } - PUSH_BYTES(utf8, cur, hunk, end-hunk); + PUSH_BYTES(utf8, cur, hunk, end-hunk, 0); fromlen -= todo; } break;