(printwarn &&
(!(p = PerlEnv_getenv("PERL_BADLANG")) || atoi(p))));
bool done = FALSE;
+#ifdef WIN32
+ /* In some systems you can find out the system default locale
+ * and use that as the fallback locale. */
+# define SYSTEM_DEFAULT_LOCALE
+#endif
+#ifdef SYSTEM_DEFAULT_LOCALE
const char *system_default_locale = NULL;
-
+#endif
#ifndef LOCALE_ENVIRON_REQUIRED
PERL_UNUSED_VAR(done);
* sense */
setlocale_failure = FALSE;
-#ifdef WIN32
-
+#ifdef SYSTEM_DEFAULT_LOCALE
+# ifdef WIN32
/* On Windows machines, an entry of "" after the 0th means to use
* the system default locale, which we now proceed to get. */
if (strEQ(trial_locale, "")) {
trial_locale = system_default_locale;
}
-#endif
+# endif /* WIN32 */
+#endif /* SYSTEM_DEFAULT_LOCALE */
}
#ifdef LC_ALL
description = "the standard locale";
name = "C";
}
+#ifdef SYSTEM_DEFAULT_LOCALE
else if (strEQ(trial_locales[i], "")) {
description = "the system default locale";
if (system_default_locale) {
name = system_default_locale;
}
}
+#endif /* SYSTEM_DEFAULT_LOCALE */
else {
description = "a fallback locale";
name = trial_locales[i];
Safefree(save_input_locale);
return is_utf8;
}
+ Safefree(codeset);
}
# endif
(void) mbtowc(&wc, NULL, 0); /* Reset any shift state */
GCC_DIAG_RESTORE;
errno = 0;
- if (mbtowc(&wc, HYPHEN_UTF8, strlen(HYPHEN_UTF8))
+ if ((size_t)mbtowc(&wc, HYPHEN_UTF8, strlen(HYPHEN_UTF8))
!= strlen(HYPHEN_UTF8)
|| wc != (wchar_t) 0x2010)
{
&& *(save_input_locale + final_pos - 3) == '5'
&& *(save_input_locale + final_pos - 4) == '6')
{
- Safefree(save_input_locale);
DEBUG_L(PerlIO_printf(Perl_debug_log,
"Locale %s ends with 10056 in name, is UTF-8 locale\n",
save_input_locale));
+ Safefree(save_input_locale);
return TRUE;
}
#endif
/* Other common encodings are the ISO 8859 series, which aren't UTF-8 */
if (instr(save_input_locale, "8859")) {
- Safefree(save_input_locale);
DEBUG_L(PerlIO_printf(Perl_debug_log,
"Locale %s has 8859 in name, not UTF-8 locale\n",
save_input_locale));
+ Safefree(save_input_locale);
return FALSE;
}