Move the UTF-8 conversion code earlier so that
Jarkko Hietaniemi [Sun, 13 Jan 2002 19:38:17 +0000 (19:38 +0000)]
op/ver is happy.

p4raw-id: //depot/perl@14246

sv.c
t/op/ver.t

diff --git a/sv.c b/sv.c
index 0e0c5fc..006fb8c 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -8337,6 +8337,22 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
            continue;   /* not "break" */
        }
 
+       if (is_utf8 != has_utf8) {
+            if (is_utf8) {
+                 if (SvCUR(sv))
+                      sv_utf8_upgrade(sv);
+            }
+            else {
+                 SV *nsv = sv_2mortal(newSVpvn(eptr, elen));
+                 sv_utf8_upgrade(nsv);
+                 eptr = SvPVX(nsv);
+                 elen = SvCUR(nsv);
+            }
+            SvGROW(sv, SvCUR(sv) + elen + 1);
+            p = SvEND(sv);
+            *p = '\0';
+       }
+       
        have = esignlen + zeros + elen;
        need = (have > width ? have : width);
        gap = need - have;
@@ -8360,20 +8376,6 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
                *p++ = '0';
        }
        if (elen) {
-           if (is_utf8 != has_utf8) {
-               if (is_utf8) {
-                   if (SvCUR(sv))
-                       sv_utf8_upgrade(sv);
-               }
-               else {
-                   SV *nsv = sv_2mortal(newSVpvn(eptr, elen));
-                   sv_utf8_upgrade(nsv);
-                   eptr = SvPVX(nsv);
-                   elen = SvCUR(nsv);
-               }
-               SvGROW(sv, SvCUR(sv) + elen + 1);
-               p = SvEND(sv);
-           }
            Copy(eptr, p, elen, char);
            p += elen;
        }
index 31bd09c..ecfc15c 100755 (executable)
@@ -208,7 +208,7 @@ my ($revision,$version,$subversion) = split '\.', sprintf("%vd",$^V);
 
 my $v = sprintf("%d.%.3d%.3d",$revision,$version,$subversion);
 
-ok( $v eq "$]", "\$^V eq \$] (string)");
+ok( $v eq "$]", qq{"\$^V eq "\$]"});
 
 $v = $revision + $version/1000 + $subversion/1000000;