This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
APItest/t/locale.t: Sort some tests
[perl5.git] / perl.c
diff --git a/perl.c b/perl.c
index 9817220..1bc15a0 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -320,7 +320,6 @@ perl_construct(pTHXx)
     PL_Assigned_invlist = _new_invlist_C_array(Assigned_invlist);
     PL_SCX_invlist = _new_invlist_C_array(_Perl_SCX_invlist);
 
-    init_i18nl10n(1);
 
 #if defined(LOCAL_PATCH_COUNT)
     PL_localpatches = local_patches;   /* For possible -v */
@@ -476,6 +475,7 @@ perl_construct(pTHXx)
 #endif
 
     ENTER;
+    init_i18nl10n(1);
 }
 
 /*
@@ -1146,7 +1146,14 @@ perl_destruct(pTHXx)
     Safefree(PL_collation_name);
     PL_collation_name = NULL;
 #endif
-
+#if   defined(USE_POSIX_2008_LOCALE)      \
+ &&   defined(USE_THREAD_SAFE_LOCALE)     \
+ && ! defined(HAS_QUERYLOCALE)
+    for (i = 0; i < (int) C_ARRAY_LENGTH(PL_curlocales); i++) {
+        Safefree(PL_curlocales[i]);
+        PL_curlocales[i] = NULL;
+    }
+#endif
 #ifdef USE_LOCALE_NUMERIC
     Safefree(PL_numeric_name);
     PL_numeric_name = NULL;
@@ -1163,6 +1170,11 @@ perl_destruct(pTHXx)
 #  endif
 #endif
 
+    if (PL_setlocale_buf) {
+        Safefree(PL_setlocale_buf);
+        PL_setlocale_buf = NULL;
+    }
+
     if (PL_langinfo_buf) {
         Safefree(PL_langinfo_buf);
         PL_langinfo_buf = NULL;