const declaration fixup
[p5sagit/p5-mst-13.2.git] / perl.c
diff --git a/perl.c b/perl.c
index bc0c28b..6c2c366 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -155,6 +155,9 @@ perl_construct(pTHXx)
 
    /* Init the real globals (and main thread)? */
     if (!PL_linestr) {
+#ifdef USE_ITHREADS
+       MUTEX_INIT(&PL_dollarzero_mutex);       /* for $0 modifying */
+#endif
 #ifdef PERL_FLEXIBLE_EXCEPTIONS
        PL_protect = MEMBER_TO_FPTR(Perl_default_protect); /* for exceptions */
 #endif
@@ -213,12 +216,9 @@ perl_construct(pTHXx)
        *s = '\0';
        SvCUR_set(PL_patchlevel, s - (U8*)SvPVX(PL_patchlevel));
        SvPOK_on(PL_patchlevel);
-       SvNVX(PL_patchlevel) = (NV)PERL_REVISION
-                               + ((NV)PERL_VERSION / (NV)1000)
-#if defined(PERL_SUBVERSION) && PERL_SUBVERSION > 0
-                               + ((NV)PERL_SUBVERSION / (NV)1000000)
-#endif
-                               ;
+       SvNVX(PL_patchlevel) = (NV)PERL_REVISION +
+                             ((NV)PERL_VERSION / (NV)1000) +
+                             ((NV)PERL_SUBVERSION / (NV)1000000);
        SvNOK_on(PL_patchlevel);        /* dual valued */
        SvUTF8_on(PL_patchlevel);
        SvREADONLY_on(PL_patchlevel);
@@ -918,10 +918,6 @@ setuid perl scripts securely.\n");
     oldscope = PL_scopestack_ix;
     PL_dowarn = G_WARN_OFF;
 
-#ifdef USE_ITHREADS
-    MUTEX_INIT(&PL_dollarzero_mutex);
-#endif
-
 #ifdef PERL_FLEXIBLE_EXCEPTIONS
     CALLPROTECT(aTHX_ pcur_env, &ret, MEMBER_TO_FPTR(S_vparse_body), env, xsinit);
 #else
@@ -1356,10 +1352,11 @@ print \"  \\@INC:\\n    @INC\\n\";");
     if (!PL_do_undump)
        init_postdump_symbols(argc,argv,env);
 
-    /* PL_wantutf8 is conditionally turned on by
+    /* PL_utf8locale is conditionally turned on by
      * locale.c:Perl_init_i18nl10n() if the environment
-     * look like the user wants to use UTF-8. */
-    if (PL_wantutf8) { /* Requires init_predump_symbols(). */
+     * look like the user wants to use UTF-8.
+     * PL_wantutf8 is turned on by -C or by $ENV{PERL_UTF8_LOCALE}. */
+    if (PL_utf8locale && PL_wantutf8) { /* Requires init_predump_symbols(). */
         IO* io;
         PerlIO* fp;
         SV* sv;
@@ -2157,8 +2154,12 @@ Perl_moreswitches(pTHX_ char *s)
        return s + numlen;
     }
     case 'C':
-       PL_widesyscalls = TRUE;
+        PL_wantutf8 = TRUE; /* Can be set earlier by $ENV{PERL_UTF8_LOCALE}. */
        s++;
+       if (*s == ':') {
+            PL_wantutf8 = (bool) atoi(s + 1);
+            for (s++; isDIGIT(*s); s++) ;
+       }
        return s;
     case 'F':
        PL_minus_F = TRUE;
@@ -3398,7 +3399,7 @@ Perl_init_argv_symbols(pTHX_ register int argc, register char **argv)
        for (; argc > 0; argc--,argv++) {
            SV *sv = newSVpv(argv[0],0);
            av_push(GvAVn(PL_argvgv),sv);
-           if (PL_widesyscalls)
+           if (PL_wantutf8)
                (void)sv_utf8_decode(sv);
        }
     }
@@ -3909,7 +3910,6 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
            atsv = ERRSV;
            (void)SvPV(atsv, len);
            if (len) {
-               STRLEN n_a;
                PL_curcop = &PL_compiling;
                CopLINE_set(PL_curcop, oldline);
                if (paramList == PL_beginav)
@@ -3923,7 +3923,7 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
                while (PL_scopestack_ix > oldscope)
                    LEAVE;
                JMPENV_POP;
-               Perl_croak(aTHX_ "%s", SvPVx(atsv, n_a));
+               Perl_croak(aTHX_ "%"SVf"", atsv);
            }
            break;
        case 1: