This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove IN_ENCODING macro, and all code dependent on it
authorFather Chrysostomos <sprout@cpan.org>
Sun, 22 May 2016 21:32:40 +0000 (14:32 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 13 Jul 2016 08:12:47 +0000 (01:12 -0700)
embed.fnc
embed.h
perl.h
pp.c
pp_hot.c
proto.h
regcomp.c
sv.c
toke.c

index 88a70f9..d919d18 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -2195,7 +2195,6 @@ Es        |regnode*|handle_regex_sets|NN RExC_state_t *pRExC_state \
                                |NN char * const oregcomp_parse
 Es     |void|parse_lparen_question_flags|NN RExC_state_t *pRExC_state
 Es     |regnode*|reg_node      |NN RExC_state_t *pRExC_state|U8 op
-Es     |UV     |reg_recode     |const U8 value|NN SV **encp
 Es     |regnode*|regpiece      |NN RExC_state_t *pRExC_state \
                                |NN I32 *flagp|U32 depth
 Es     |bool   |grok_bslash_N  |NN RExC_state_t *pRExC_state               \
diff --git a/embed.h b/embed.h
index de5a590..cf19da4 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define reg(a,b,c,d)           S_reg(aTHX_ a,b,c,d)
 #define reg2Lanode(a,b,c,d)    S_reg2Lanode(aTHX_ a,b,c,d)
 #define reg_node(a,b)          S_reg_node(aTHX_ a,b)
-#define reg_recode(a,b)                S_reg_recode(aTHX_ a,b)
 #define reg_scan_name(a,b)     S_reg_scan_name(aTHX_ a,b)
 #define reg_skipcomment                S_reg_skipcomment
 #define reganode(a,b,c)                S_reganode(aTHX_ a,b,c)
diff --git a/perl.h b/perl.h
index 6c001e0..1f19140 100644 (file)
--- a/perl.h
+++ b/perl.h
 #   endif
 #endif /* !NO_LOCALE && HAS_SETLOCALE */
 
-/* Is $^ENCODING set, or are we under the encoding pragma? */
-#define IN_ENCODING UNLIKELY(PL_encoding                                      \
-                             || (PL_lex_encoding && _get_encoding() != NULL))
-
 #include <setjmp.h>
 
 #ifdef I_SYS_PARAM
diff --git a/pp.c b/pp.c
index 3df0bea..4771134 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -809,17 +809,6 @@ S_do_chomp(pTHX_ SV *retval, SV *sv, bool chomping)
             Perl_croak_no_modify();
     }
 
-    if (IN_ENCODING) {
-       if (!SvUTF8(sv)) {
-           /* XXX, here sv is utf8-ized as a side-effect!
-              If encoding.pm is used properly, almost string-generating
-              operations, including literal strings, chr(), input data, etc.
-              should have been utf8-ized already, right?
-           */
-           sv_recode_to_utf8(sv, _get_encoding());
-       }
-    }
-
     s = SvPV(sv, len);
     if (chomping) {
        if (s && len) {
@@ -861,14 +850,6 @@ S_do_chomp(pTHX_ SV *retval, SV *sv, bool chomping)
                        }
                        rsptr = temp_buffer;
                    }
-                   else if (IN_ENCODING) {
-                       /* RS is 8 bit, encoding.pm is used.
-                        * Do not recode PL_rs as a side-effect. */
-                       svrecode = newSVpvn(rsptr, rslen);
-                       sv_recode_to_utf8(svrecode, _get_encoding());
-                       rsptr = SvPV_const(svrecode, rslen);
-                       rs_charlen = sv_len_utf8(svrecode);
-                   }
                    else {
                        /* RS is 8 bit, scalar is utf8.  */
                        temp_buffer = (char*)bytes_to_utf8((U8*)rsptr, &rslen);
@@ -3544,7 +3525,7 @@ PP(pp_index)
     little_utf8 = DO_UTF8(little);
     if (big_utf8 ^ little_utf8) {
        /* One needs to be upgraded.  */
-       if (little_utf8 && !IN_ENCODING) {
+       if (little_utf8) {
            /* Well, maybe instead we might be able to downgrade the small
               string?  */
            char * const pv = (char*)bytes_from_utf8((U8 *)little_p, &llen,
@@ -3566,11 +3547,7 @@ PP(pp_index)
            temp = little_utf8
                ? newSVpvn(big_p, biglen) : newSVpvn(little_p, llen);
 
-           if (IN_ENCODING) {
-               sv_recode_to_utf8(temp, _get_encoding());
-           } else {
-               sv_utf8_upgrade(temp);
-           }
+           sv_utf8_upgrade(temp);
            if (little_utf8) {
                big = temp;
                big_utf8 = TRUE;
@@ -3652,13 +3629,6 @@ PP(pp_ord)
     STRLEN len;
     const U8 *s = (U8*)SvPV_const(argsv, len);
 
-    if (IN_ENCODING && SvPOK(argsv) && !DO_UTF8(argsv)) {
-        SV * const tmpsv = sv_2mortal(newSVsv(argsv));
-        s = (U8*)sv_recode_to_utf8(tmpsv, _get_encoding());
-        len = UTF8SKIP(s);  /* Should be well-formed; so this is its length */
-        argsv = tmpsv;
-    }
-
     SETu(DO_UTF8(argsv)
            ? utf8n_to_uvchr(s, len, 0, UTF8_ALLOW_ANYUV)
            : (UV)(*s));
@@ -3720,22 +3690,6 @@ PP(pp_chr)
     *tmps = '\0';
     (void)SvPOK_only(TARG);
 
-    if (IN_ENCODING && !IN_BYTES) {
-        sv_recode_to_utf8(TARG, _get_encoding());
-       tmps = SvPVX(TARG);
-       if (SvCUR(TARG) == 0
-           || ! is_utf8_string((U8*)tmps, SvCUR(TARG))
-           || UTF8_IS_REPLACEMENT((U8*) tmps, (U8*) tmps + SvCUR(TARG)))
-       {
-           SvGROW(TARG, 2);
-           tmps = SvPVX(TARG);
-           SvCUR_set(TARG, 1);
-           *tmps++ = (char)value;
-           *tmps = '\0';
-           SvUTF8_off(TARG);
-       }
-    }
-
     SETTARG;
     return NORMAL;
 }
index ca90c1e..8734687 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3011,10 +3011,7 @@ PP(pp_subst)
        if (DO_UTF8(TARG) && !doutf8) {
             nsv = sv_newmortal();
             SvSetSV(nsv, dstr);
-            if (IN_ENCODING)
-                 sv_recode_to_utf8(nsv, _get_encoding());
-            else
-                 sv_utf8_upgrade(nsv);
+            sv_utf8_upgrade(nsv);
             c = SvPV_const(nsv, clen);
             doutf8 = TRUE;
        }
@@ -3193,13 +3190,7 @@ PP(pp_subst)
              first = FALSE;
            }
            else {
-               if (IN_ENCODING) {
-                   if (!nsv) nsv = sv_newmortal();
-                   sv_copypv(nsv, repl);
-                   if (!DO_UTF8(nsv)) sv_recode_to_utf8(nsv, _get_encoding());
-                   sv_catsv(dstr, nsv);
-               }
-               else sv_catsv(dstr, repl);
+               sv_catsv(dstr, repl);
                if (UNLIKELY(SvTAINTED(repl)))
                    rxtainted |= SUBST_TAINT_REPL;
            }
diff --git a/proto.h b/proto.h
index 5c8f9d8..4ba0c50 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -4991,9 +4991,6 @@ STATIC regnode*   S_reg2Lanode(pTHX_ RExC_state_t *pRExC_state, const U8 op, const
 STATIC regnode*        S_reg_node(pTHX_ RExC_state_t *pRExC_state, U8 op);
 #define PERL_ARGS_ASSERT_REG_NODE      \
        assert(pRExC_state)
-STATIC UV      S_reg_recode(pTHX_ const U8 value, SV **encp);
-#define PERL_ARGS_ASSERT_REG_RECODE    \
-       assert(encp)
 STATIC SV *    S_reg_scan_name(pTHX_ RExC_state_t *pRExC_state, U32 flags);
 #define PERL_ARGS_ASSERT_REG_SCAN_NAME \
        assert(pRExC_state)
index 378ebc9..4592f49 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11979,39 +11979,6 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,
 }
 
 
-/*
- * reg_recode
- *
- * It returns the code point in utf8 for the value in *encp.
- *    value: a code value in the source encoding
- *    encp:  a pointer to an Encode object
- *
- * If the result from Encode is not a single character,
- * it returns U+FFFD (Replacement character) and sets *encp to NULL.
- */
-STATIC UV
-S_reg_recode(pTHX_ const U8 value, SV **encp)
-{
-    STRLEN numlen = 1;
-    SV * const sv = newSVpvn_flags((const char *) &value, numlen, SVs_TEMP);
-    const char * const s = *encp ? sv_recode_to_utf8(sv, *encp) : SvPVX(sv);
-    const STRLEN newlen = SvCUR(sv);
-    UV uv = UNICODE_REPLACEMENT;
-
-    PERL_ARGS_ASSERT_REG_RECODE;
-
-    if (newlen)
-       uv = SvUTF8(sv)
-            ? utf8n_to_uvchr((U8*)s, newlen, &numlen, UTF8_ALLOW_DEFAULT)
-            : *(U8*)s;
-
-    if (!newlen || numlen != newlen) {
-       uv = UNICODE_REPLACEMENT;
-       *encp = NULL;
-    }
-    return uv;
-}
-
 PERL_STATIC_INLINE U8
 S_compute_EXACTish(RExC_state_t *pRExC_state)
 {
@@ -13081,9 +13048,6 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                                vFAIL(error_msg);
                            }
                             ender = result;
-                           if (IN_ENCODING && ender < 0x100) {
-                               goto recode_encoding;
-                           }
                            if (ender > 0xff) {
                                REQUIRE_UTF8(flagp);
                            }
@@ -13116,11 +13080,7 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                                 if (RExC_recode_x_to_native) {
                                     ender = LATIN1_TO_NATIVE(ender);
                                 }
-                                else
 #endif
-                                if (IN_ENCODING) {
-                                    goto recode_encoding;
-                                }
                            }
                             else {
                                REQUIRE_UTF8(flagp);
@@ -13180,17 +13140,6 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                                          form_short_octal_warning(p, numlen));
                             }
                        }
-                       if (IN_ENCODING && ender < 0x100)
-                           goto recode_encoding;
-                       break;
-                     recode_encoding:
-                       if (! RExC_override_recoding) {
-                           SV* enc = _get_encoding();
-                           ender = reg_recode((U8)ender, &enc);
-                           if (!enc && PASS2)
-                               ckWARNreg(p, "Invalid escape in the specified encoding");
-                           REQUIRE_UTF8(flagp);
-                       }
                        break;
                    case '\0':
                        if (p >= RExC_end)
@@ -16165,9 +16114,6 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
                    }
                }
                 non_portable_endpoint++;
-               if (IN_ENCODING && value < 0x100) {
-                   goto recode_encoding;
-               }
                break;
            case 'x':
                RExC_parse--;   /* function expects to be pointed at the 'x' */
@@ -16185,8 +16131,6 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
                    }
                }
                 non_portable_endpoint++;
-               if (IN_ENCODING && value < 0x100)
-                   goto recode_encoding;
                break;
            case 'c':
                value = grok_bslash_c(*RExC_parse++, PASS2);
@@ -16219,23 +16163,6 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
                         }
                     }
                     non_portable_endpoint++;
-                   if (IN_ENCODING && value < 0x100)
-                       goto recode_encoding;
-                   break;
-               }
-             recode_encoding:
-               if (! RExC_override_recoding) {
-                   SV* enc = _get_encoding();
-                   value = reg_recode((U8)value, &enc);
-                   if (!enc) {
-                        if (strict) {
-                            vFAIL("Invalid escape in the specified encoding");
-                        }
-                        else if (PASS2) {
-                            ckWARNreg(RExC_parse,
-                                 "Invalid escape in the specified encoding");
-                        }
-                    }
                    break;
                }
            default:
diff --git a/sv.c b/sv.c
index 0cbe371..0cd0f6b 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3456,12 +3456,6 @@ Perl_sv_utf8_upgrade_flags_grow(pTHX_ SV *const sv, const I32 flags, STRLEN extr
         S_sv_uncow(aTHX_ sv, 0);
     }
 
-    if (IN_ENCODING && !(flags & SV_UTF8_NO_ENCODING)) {
-        sv_recode_to_utf8(sv, _get_encoding());
-       if (extra) SvGROW(sv, SvCUR(sv) + extra);
-       return SvCUR(sv);
-    }
-
     if (SvCUR(sv) == 0) {
        if (extra) SvGROW(sv, extra);
     } else { /* Assume Latin-1/EBCDIC */
@@ -7757,37 +7751,17 @@ Perl_sv_eq_flags(pTHX_ SV *sv1, SV *sv2, const U32 flags)
        pv2 = SvPV_flags_const(sv2, cur2, flags);
 
     if (cur1 && cur2 && SvUTF8(sv1) != SvUTF8(sv2) && !IN_BYTES) {
-        /* Differing utf8ness.
-        * Do not UTF8size the comparands as a side-effect. */
-        if (IN_ENCODING) {
-             if (SvUTF8(sv1)) {
-                  svrecode = newSVpvn(pv2, cur2);
-                  sv_recode_to_utf8(svrecode, _get_encoding());
-                  pv2 = SvPV_const(svrecode, cur2);
-             }
-             else {
-                  svrecode = newSVpvn(pv1, cur1);
-                  sv_recode_to_utf8(svrecode, _get_encoding());
-                  pv1 = SvPV_const(svrecode, cur1);
-             }
-             /* Now both are in UTF-8. */
-             if (cur1 != cur2) {
-                  SvREFCNT_dec_NN(svrecode);
-                  return FALSE;
-             }
-        }
-        else {
-             if (SvUTF8(sv1)) {
+        /* Differing utf8ness.  */
+       if (SvUTF8(sv1)) {
                  /* sv1 is the UTF-8 one  */
                  return bytes_cmp_utf8((const U8*)pv2, cur2,
                                        (const U8*)pv1, cur1) == 0;
-             }
-             else {
+       }
+       else {
                  /* sv2 is the UTF-8 one  */
                  return bytes_cmp_utf8((const U8*)pv1, cur1,
                                        (const U8*)pv2, cur2) == 0;
-             }
-        }
+       }
     }
 
     if (cur1 == cur2)
@@ -7847,31 +7821,16 @@ Perl_sv_cmp_flags(pTHX_ SV *const sv1, SV *const sv2,
        pv2 = SvPV_flags_const(sv2, cur2, flags);
 
     if (cur1 && cur2 && SvUTF8(sv1) != SvUTF8(sv2) && !IN_BYTES) {
-        /* Differing utf8ness.
-        * Do not UTF8size the comparands as a side-effect. */
+        /* Differing utf8ness.  */
        if (SvUTF8(sv1)) {
-           if (IN_ENCODING) {
-                svrecode = newSVpvn(pv2, cur2);
-                sv_recode_to_utf8(svrecode, _get_encoding());
-                pv2 = SvPV_const(svrecode, cur2);
-           }
-           else {
                const int retval = -bytes_cmp_utf8((const U8*)pv2, cur2,
                                                   (const U8*)pv1, cur1);
                return retval ? retval < 0 ? -1 : +1 : 0;
-           }
        }
        else {
-           if (IN_ENCODING) {
-                svrecode = newSVpvn(pv1, cur1);
-                sv_recode_to_utf8(svrecode, _get_encoding());
-                pv1 = SvPV_const(svrecode, cur1);
-           }
-           else {
                const int retval = bytes_cmp_utf8((const U8*)pv1, cur1,
                                                  (const U8*)pv2, cur2);
                return retval ? retval < 0 ? -1 : +1 : 0;
-           }
        }
     }
 
diff --git a/toke.c b/toke.c
index c359813..f26c211 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3798,11 +3798,6 @@ S_scan_const(pTHX_ char *start)
                   " >= %"UVuf, (UV)SvCUR(sv), (UV)SvLEN(sv));
 
     SvPOK_on(sv);
-    if (IN_ENCODING && !has_utf8) {
-       sv_recode_to_utf8(sv, _get_encoding());
-       if (SvUTF8(sv))
-           has_utf8 = TRUE;
-    }
     if (has_utf8) {
        SvUTF8_on(sv);
        if (PL_lex_inwhat == OP_TRANS && PL_sublex_info.sub_op) {
@@ -7278,24 +7273,6 @@ Perl_yylex(pTHX)
                if (!IN_BYTES) {
                    if (UTF)
                        PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, ":utf8");
-                   else if (IN_ENCODING) {
-                       SV *name;
-                       dSP;
-                       ENTER;
-                       SAVETMPS;
-                       PUSHMARK(sp);
-                       XPUSHs(_get_encoding());
-                       PUTBACK;
-                       call_method("name", G_SCALAR);
-                       SPAGAIN;
-                       name = POPs;
-                       PUTBACK;
-                       PerlIO_apply_layers(aTHX_ PL_rsfp, NULL,
-                                           Perl_form(aTHX_ ":encoding(%"SVf")",
-                                                     SVfARG(name)));
-                       FREETMPS;
-                       LEAVE;
-                   }
                }
 #endif
                PL_rsfp = NULL;
@@ -9698,8 +9675,6 @@ S_scan_heredoc(pTHX_ char *s)
     if (!IN_BYTES) {
        if (UTF && is_utf8_string((U8*)SvPVX_const(tmpstr), SvCUR(tmpstr)))
            SvUTF8_on(tmpstr);
-       else if (IN_ENCODING)
-           sv_recode_to_utf8(tmpstr, _get_encoding());
     }
     PL_lex_stuff = tmpstr;
     pl_yylval.ival = op_type;
@@ -9936,7 +9911,6 @@ S_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int re
     I32 termcode;              /* terminating char. code */
     U8 termstr[UTF8_MAXBYTES]; /* terminating string */
     STRLEN termlen;            /* length of terminating string */
-    int last_off = 0;          /* last position for nesting bracket */
     line_t herelines;
 
     PERL_ARGS_ASSERT_SCAN_STR;
@@ -9989,116 +9963,6 @@ S_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int re
        sv_catpvn(sv, s, termlen);
     s += termlen;
     for (;;) {
-       if (IN_ENCODING && !UTF && !re_reparse) {
-           bool cont = TRUE;
-
-           while (cont) {
-               int offset = s - SvPVX_const(PL_linestr);
-               const bool found = sv_cat_decode(sv, _get_encoding(), PL_linestr,
-                                          &offset, (char*)termstr, termlen);
-               const char *ns;
-               char *svlast;
-
-               if (SvIsCOW(PL_linestr)) {
-                   STRLEN bufend_pos, bufptr_pos, oldbufptr_pos;
-                   STRLEN oldoldbufptr_pos, linestart_pos, last_uni_pos;
-                   STRLEN last_lop_pos, re_eval_start_pos, s_pos;
-                   char *buf = SvPVX(PL_linestr);
-                   bufend_pos = PL_parser->bufend - buf;
-                   bufptr_pos = PL_parser->bufptr - buf;
-                   oldbufptr_pos = PL_parser->oldbufptr - buf;
-                   oldoldbufptr_pos = PL_parser->oldoldbufptr - buf;
-                   linestart_pos = PL_parser->linestart - buf;
-                   last_uni_pos = PL_parser->last_uni
-                       ? PL_parser->last_uni - buf
-                       : 0;
-                   last_lop_pos = PL_parser->last_lop
-                       ? PL_parser->last_lop - buf
-                       : 0;
-                   re_eval_start_pos =
-                       PL_parser->lex_shared->re_eval_start ?
-                            PL_parser->lex_shared->re_eval_start - buf : 0;
-                   s_pos = s - buf;
-
-                   sv_force_normal(PL_linestr);
-
-                   buf = SvPVX(PL_linestr);
-                   PL_parser->bufend = buf + bufend_pos;
-                   PL_parser->bufptr = buf + bufptr_pos;
-                   PL_parser->oldbufptr = buf + oldbufptr_pos;
-                   PL_parser->oldoldbufptr = buf + oldoldbufptr_pos;
-                   PL_parser->linestart = buf + linestart_pos;
-                   if (PL_parser->last_uni)
-                       PL_parser->last_uni = buf + last_uni_pos;
-                   if (PL_parser->last_lop)
-                       PL_parser->last_lop = buf + last_lop_pos;
-                   if (PL_parser->lex_shared->re_eval_start)
-                       PL_parser->lex_shared->re_eval_start  =
-                           buf + re_eval_start_pos;
-                   s = buf + s_pos;
-               }
-               ns = SvPVX_const(PL_linestr) + offset;
-               svlast = SvEND(sv) - 1;
-
-               for (; s < ns; s++) {
-                   if (*s == '\n' && !PL_rsfp && !PL_parser->filtered)
-                       COPLINE_INC_WITH_HERELINES;
-               }
-               if (!found)
-                   goto read_more_line;
-               else {
-                   /* handle quoted delimiters */
-                   if (SvCUR(sv) > 1 && *(svlast-1) == '\\') {
-                       const char *t;
-                       for (t = svlast-2; t >= SvPVX_const(sv) && *t == '\\';)
-                           t--;
-                       if ((svlast-1 - t) % 2) {
-                           if (!keep_bracketed_quoted) {
-                               *(svlast-1) = term;
-                               *svlast = '\0';
-                               SvCUR_set(sv, SvCUR(sv) - 1);
-                           }
-                           continue;
-                       }
-                   }
-                   if (PL_multi_open == PL_multi_close) {
-                       cont = FALSE;
-                   }
-                   else {
-                       const char *t;
-                       char *w;
-                       for (t = w = SvPVX(sv)+last_off; t < svlast; w++, t++) {
-                           /* At here, all closes are "was quoted" one,
-                              so we don't check PL_multi_close. */
-                           if (*t == '\\') {
-                               if (!keep_bracketed_quoted && *(t+1) == PL_multi_open)
-                                   t++;
-                               else
-                                   *w++ = *t++;
-                           }
-                           else if (*t == PL_multi_open)
-                               brackets++;
-
-                           *w = *t;
-                       }
-                       if (w < t) {
-                           *w++ = term;
-                           *w = '\0';
-                           SvCUR_set(sv, w - SvPVX_const(sv));
-                       }
-                       last_off = w - SvPVX(sv);
-                       if (--brackets <= 0)
-                           cont = FALSE;
-                   }
-               }
-           }
-           if (!keep_delims) {
-               SvCUR_set(sv, SvCUR(sv) - 1);
-               *SvEND(sv) = '\0';
-           }
-           break;
-       }
-
        /* extend sv if need be */
        SvGROW(sv, SvCUR(sv) + (PL_bufend - s) + 1);
        /* set 'to' to the next character in the sv's string */
@@ -10191,7 +10055,6 @@ S_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int re
            to[-1] = '\n';
 #endif
        
-     read_more_line:
        /* if we're out of file, or a read fails, bail and reset the current
           line marker so we can report where the unterminated string began
        */
@@ -10207,13 +10070,11 @@ S_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int re
 
     /* at this point, we have successfully read the delimited string */
 
-    if (!IN_ENCODING || UTF || re_reparse) {
-
-       if (keep_delims)
+    if (keep_delims)
            sv_catpvn(sv, s, termlen);
-       s += termlen;
-    }
-    if (has_utf8 || (IN_ENCODING && !re_reparse))
+    s += termlen;
+
+    if (has_utf8)
        SvUTF8_on(sv);
 
     PL_multi_end = CopLINE(PL_curcop);
@@ -10950,8 +10811,6 @@ S_scan_formline(pTHX_ char *s)
        if (!IN_BYTES) {
            if (UTF && is_utf8_string((U8*)SvPVX_const(stuff), SvCUR(stuff)))
                SvUTF8_on(stuff);
-           else if (IN_ENCODING)
-               sv_recode_to_utf8(stuff, _get_encoding());
        }
        NEXTVAL_NEXTTOKE.opval = (OP*)newSVOP(OP_CONST, 0, stuff);
        force_next(THING);