}
else
PL_numeric_radix_sv = NULL;
+
+ DEBUG_L(PerlIO_printf(Perl_debug_log, "Locale radix is %s\n",
+ (PL_numeric_radix_sv)
+ ? lc->decimal_point
+ : "NULL"));
+
# endif /* HAS_LOCALECONV */
#endif /* USE_LOCALE_NUMERIC */
}
PL_numeric_local = FALSE;
set_numeric_radix();
}
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Underlying LC_NUMERIC locale now is C\n"));
#endif /* USE_LOCALE_NUMERIC */
}
PL_numeric_local = TRUE;
set_numeric_radix();
}
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Underlying LC_NUMERIC locale now is %s\n",
+ PL_numeric_name));
#endif /* USE_LOCALE_NUMERIC */
}
/* First dispose of the trivial cases */
save_input_locale = setlocale(category, NULL);
if (! save_input_locale) {
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Could not find current locale for category %d\n",
+ category));
return FALSE; /* XXX maybe should croak */
}
save_input_locale = stdize_locale(savepv(save_input_locale));
if ((*save_input_locale == 'C' && save_input_locale[1] == '\0')
|| strEQ(save_input_locale, "POSIX"))
{
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Current locale for category %d is %s\n",
+ category, save_input_locale));
Safefree(save_input_locale);
return FALSE;
}
/* Get the current LC_CTYPE locale */
save_ctype_locale = stdize_locale(savepv(setlocale(LC_CTYPE, NULL)));
if (! save_ctype_locale) {
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Could not find current locale for LC_CTYPE\n"));
goto cant_use_nllanginfo;
}
save_ctype_locale = NULL;
}
else if (! setlocale(LC_CTYPE, save_input_locale)) {
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Could not change LC_CTYPE locale to %s\n",
+ save_input_locale));
Safefree(save_ctype_locale);
goto cant_use_nllanginfo;
}
}
+ DEBUG_L(PerlIO_printf(Perl_debug_log, "Current LC_CTYPE locale=%s\n",
+ save_input_locale));
+
/* Here the current LC_CTYPE is set to the locale of the category whose
* information is desired. This means that nl_langinfo() and MB_CUR_MAX
* should give the correct results */
is_utf8 = foldEQ(codeset, STR_WITH_LEN("UTF-8"))
|| foldEQ(codeset, STR_WITH_LEN("UTF8"));
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "\tnllanginfo returned CODESET '%s'; ?UTF8 locale=%d\n",
+ codeset, is_utf8));
Safefree(codeset);
Safefree(save_input_locale);
return is_utf8;
* turns out to be wrong, other things will fail */
is_utf8 = MB_CUR_MAX >= 4;
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "\tMB_CUR_MAX=%d; ?UTF8 locale=%d\n",
+ (int) MB_CUR_MAX, is_utf8));
+
Safefree(save_input_locale);
# ifdef HAS_MBTOWC
if (is_utf8) {
wchar_t wc;
(void) mbtowc(&wc, NULL, 0); /* Reset any shift state */
+ errno = 0;
if (mbtowc(&wc, HYPHEN_UTF8, strlen(HYPHEN_UTF8))
!= strlen(HYPHEN_UTF8)
|| wc != (wchar_t) 0x2010)
{
is_utf8 = FALSE;
+ DEBUG_L(PerlIO_printf(Perl_debug_log, "\thyphen=U+%x\n", wc));
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "\treturn from mbtowc=%d; errno=%d; ?UTF8 locale=0\n",
+ mbtowc(&wc, HYPHEN_UTF8, strlen(HYPHEN_UTF8)), errno));
}
}
# endif
}
if (*(name) == '8') {
Safefree(save_input_locale);
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Locale %s ends with UTF-8 in name\n",
+ save_input_locale));
return TRUE;
}
}
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Locale %s doesn't end with UTF-8 in name\n",
+ save_input_locale));
}
#ifdef WIN32
&& *(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));
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));
return FALSE;
}
save_monetary_locale = stdize_locale(savepv(setlocale(LC_MONETARY,
NULL)));
if (! save_monetary_locale) {
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Could not find current locale for LC_MONETARY\n"));
goto cant_use_monetary;
}
if (strNE(save_monetary_locale, save_input_locale)) {
if (! setlocale(LC_MONETARY, save_input_locale)) {
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Could not change LC_MONETARY locale to %s\n",
+ save_input_locale));
Safefree(save_monetary_locale);
goto cant_use_monetary;
}
if (lc && lc->currency_symbol) {
if (! is_utf8_string((U8 *) lc->currency_symbol, 0)) {
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Currency symbol for %s is not legal UTF-8\n",
+ save_input_locale));
illegal_utf8 = TRUE;
}
else if (is_ascii_string((U8 *) lc->currency_symbol, 0)) {
+ DEBUG_L(PerlIO_printf(Perl_debug_log, "Currency symbol for %s contains only ASCII; can't use for determining if UTF-8 locale\n", save_input_locale));
only_ascii = TRUE;
}
}
* UTF-8. (We can't really tell if the locale is UTF-8 or not if the
* symbol is just a '$', so we err on the side of it not being UTF-8)
* */
+ DEBUG_L(PerlIO_printf(Perl_debug_log, "\tis_utf8=%d\n", (illegal_utf8)
+ ? FALSE
+ : ! only_ascii));
return (illegal_utf8)
? FALSE
: ! only_ascii;
#endif
+ DEBUG_L(PerlIO_printf(Perl_debug_log,
+ "Assuming locale %s is not a UTF-8 locale\n",
+ save_input_locale));
Safefree(save_input_locale);
return FALSE;
}
#define DEBUG_q_FLAG 0x00800000 /*8388608 */
#define DEBUG_M_FLAG 0x01000000 /*16777216*/
#define DEBUG_B_FLAG 0x02000000 /*33554432*/
-#define DEBUG_MASK 0x03FFEFFF /* mask of all the standard flags */
+#define DEBUG_L_FLAG 0x04000000 /*67108864*/
+#define DEBUG_MASK 0x07FFEFFF /* mask of all the standard flags */
#define DEBUG_DB_RECURSE_FLAG 0x40000000
#define DEBUG_TOP_FLAG 0x80000000 /* XXX what's this for ??? Signal
# define DEBUG_q_TEST_ (PL_debug & DEBUG_q_FLAG)
# define DEBUG_M_TEST_ (PL_debug & DEBUG_M_FLAG)
# define DEBUG_B_TEST_ (PL_debug & DEBUG_B_FLAG)
+# define DEBUG_L_TEST_ (PL_debug & DEBUG_L_FLAG)
# define DEBUG_Xv_TEST_ (DEBUG_X_TEST_ && DEBUG_v_TEST_)
# define DEBUG_Uv_TEST_ (DEBUG_U_TEST_ && DEBUG_v_TEST_)
# define DEBUG_Pv_TEST_ (DEBUG_P_TEST_ && DEBUG_v_TEST_)
# define DEBUG_q_TEST DEBUG_q_TEST_
# define DEBUG_M_TEST DEBUG_M_TEST_
# define DEBUG_B_TEST DEBUG_B_TEST_
+# define DEBUG_L_TEST DEBUG_L_TEST_
# define DEBUG_Xv_TEST DEBUG_Xv_TEST_
# define DEBUG_Uv_TEST DEBUG_Uv_TEST_
# define DEBUG_Pv_TEST DEBUG_Pv_TEST_
# define DEBUG_q(a) DEBUG__(DEBUG_q_TEST, a)
# define DEBUG_M(a) DEBUG__(DEBUG_M_TEST, a)
# define DEBUG_B(a) DEBUG__(DEBUG_B_TEST, a)
+# define DEBUG_L(a) DEBUG__(DEBUG_L_TEST, a)
#else /* DEBUGGING */
# define DEBUG_q_TEST (0)
# define DEBUG_M_TEST (0)
# define DEBUG_B_TEST (0)
+# define DEBUG_L_TEST (0)
# define DEBUG_Xv_TEST (0)
# define DEBUG_Uv_TEST (0)
# define DEBUG_Pv_TEST (0)
# define DEBUG_q(a)
# define DEBUG_M(a)
# define DEBUG_B(a)
+# define DEBUG_L(a)
# define DEBUG_Xv(a)
# define DEBUG_Uv(a)
# define DEBUG_Pv(a)