This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
No need to use locale_r with thread-safe locales
[perl5.git] / doop.c
diff --git a/doop.c b/doop.c
index c7656bc..8822009 100644 (file)
--- a/doop.c
+++ b/doop.c
@@ -442,9 +442,6 @@ S_do_trans_invmap(pTHX_ SV * const sv, AV * const invmap)
      * assume cannot */
     if (! out_is_utf8 && (PL_op->op_private & OPpTRANS_CAN_FORCE_UTF8)) {
         inplace = FALSE;
-        if (max_expansion < 2) {
-            max_expansion = 2;
-        }
     }
 
     s = (U8*)SvPV_nomg(sv, len);
@@ -467,8 +464,9 @@ S_do_trans_invmap(pTHX_ SV * const sv, AV * const invmap)
     else {
         /* Here, we can't edit in place.  We have no idea how much, if any,
          * this particular input string will grow.  However, the compilation
-         * calculated the maximum expansion possible.  Use that to allocale
-         * based on the worst case scenario. */
+         * calculated the maximum expansion possible.  Use that to allocate
+         * based on the worst case scenario.  (First +1 is to round up; 2nd is
+         * for \0) */
        Newx(d, (STRLEN) (len * max_expansion + 1 + 1), U8);
        d0 = d;
     }
@@ -856,7 +854,7 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
        }
     }
     else if (size < 8)
-       retnum = (s[uoffset] >> bitoffs) & ((1 << size) - 1);
+       retnum = (s[uoffset] >> bitoffs) & nBIT_MASK(size);
     else {
        if (size == 8)
            retnum = s[uoffset];
@@ -959,7 +957,7 @@ Perl_do_vecset(pTHX_ SV *sv)
     }
 
     if (size < 8) {
-       mask = (1 << size) - 1;
+       mask = nBIT_MASK(size);
        lval &= mask;
        s[offset] &= ~(mask << bitoffs);
        s[offset] |= lval << bitoffs;