An inconvenient hang would happen if the stdio _ptr wasn't
[p5sagit/p5-mst-13.2.git] / sv.c
diff --git a/sv.c b/sv.c
index be1947a..01076cb 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -2447,22 +2447,26 @@ bool
 Perl_sv_utf8_downgrade(pTHX_ register SV* sv, bool fail_ok)
 {
     if (SvPOK(sv) && SvUTF8(sv)) {
-        char *c = SvPVX(sv);
-       STRLEN len = SvCUR(sv) + 1;     /* include trailing NUL */
-        if (!utf8_to_bytes((U8*)c, &len)) {
-           if (fail_ok)
-               return FALSE;
-           else {
-               if (PL_op)
-                   Perl_croak(aTHX_ "Wide character in %s",
-                              PL_op_desc[PL_op->op_type]);
-               else
-                   Perl_croak(aTHX_ "Wide character");
+        if (SvCUR(sv)) {
+           char *c = SvPVX(sv);
+           STRLEN len = SvCUR(sv);
+
+           if (!utf8_to_bytes((U8*)c, &len)) {
+               if (fail_ok)
+                   return FALSE;
+               else {
+                   if (PL_op)
+                       Perl_croak(aTHX_ "Wide character in %s",
+                                  PL_op_desc[PL_op->op_type]);
+                   else
+                       Perl_croak(aTHX_ "Wide character");
+               }
            }
+           SvCUR(sv) = len;
        }
-       SvCUR(sv) = len - 1;
        SvUTF8_off(sv);
     }
+
     return TRUE;
 }
 
@@ -6623,11 +6627,10 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
                *--eptr = '#';
            *--eptr = '%';
 
+           /* No taint.  Otherwise we are in the strange situation
+            * where printf() taints but print($float) doesn't.
+            * --jhi */
            (void)sprintf(PL_efloatbuf, eptr, nv);
-#ifdef USE_LOCALE_NUMERIC
-           if ((PL_hints & HINT_LOCALE) && maybe_tainted)
-               *maybe_tainted = TRUE;
-#endif
 
            eptr = PL_efloatbuf;
            elen = strlen(PL_efloatbuf);