This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #33928] chomp() fails after alarm(), `sleep`
[perl5.git] / sv.c
diff --git a/sv.c b/sv.c
index b1edb2f..343c5f0 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -7858,13 +7858,10 @@ Perl_newSVsv(pTHX_ register SV *old)
        return Nullsv;
     }
     new_SV(sv);
-    if (SvTEMP(old)) {
-       SvTEMP_off(old);
-       sv_setsv(sv,old);
-       SvTEMP_on(old);
-    }
-    else
-       sv_setsv(sv,old);
+    /* SV_GMAGIC is the default for sv_setv()
+       SV_NOSTEAL prevents TEMP buffers being, well, stolen, and saves games
+       with SvTEMP_off and SvTEMP_on round a call to sv_setsv.  */
+    sv_setsv_flags(sv, old, SV_GMAGIC | SV_NOSTEAL);
     return sv;
 }
 
@@ -9011,7 +9008,8 @@ output to an SV.  If the appended data contains "wide" characters
 (including, but not limited to, SVs with a UTF-8 PV formatted with %s,
 and characters >255 formatted with %c), the original SV might get
 upgraded to UTF-8.  Handles 'get' magic, but not 'set' magic.  See
-C<sv_catpvf_mg>.
+C<sv_catpvf_mg>. If the original SV was UTF-8, the pattern should be
+valid UTF-8; if the original SV was bytes, the pattern should be too.
 
 =cut */
 
@@ -9273,7 +9271,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
 #endif
 
        char esignbuf[4];
-       U8 utf8buf[UTF8_MAXLEN+1];
+       U8 utf8buf[UTF8_MAXBYTES+1];
        STRLEN esignlen = 0;
 
        char *eptr = Nullch;
@@ -9392,11 +9390,6 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
                fill = *q++;
            EXPECT_NUMBER(q, width);
 
-#ifdef CHECK_FORMAT
-       if ((*q == 'p') && left) {
-            vectorize = (width == 1);
-       }
-#endif
        if (vectorize) {
            if (vectorarg) {
                if (args)
@@ -9617,10 +9610,6 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
                left = FALSE;
                if (!width)
                    goto format_sv;     /* %-p  -> %_   */
-               if (vectorize) {
-                   width = 0;
-                   goto format_d;      /* %-1p -> %vd  */      
-               }
                precis = width;
                has_precis = TRUE;
                width = 0;
@@ -9639,9 +9628,6 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
 #else
            intsize = 'l';
 #endif
-#ifdef CHECK_FORMAT
-       format_d:
-#endif
            /* FALL THROUGH */
        case 'd':
        case 'i':
@@ -12410,5 +12396,5 @@ Perl_sv_cat_decode(pTHX_ SV *dsv, SV *encoding,
  * indent-tabs-mode: t
  * End:
  *
- * vim: expandtab shiftwidth=4:
+ * vim: shiftwidth=4:
 */