Skip to content

Commit

Permalink
S_bool_setlocale_2008_i: Improve debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed May 12, 2023
1 parent f9ac4a9 commit 4f70268
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions locale.c
Expand Up @@ -1811,7 +1811,6 @@ S_bool_setlocale_2008_i(pTHX_

/* Our internal index of the 'category' setlocale is called with */
const unsigned int index,

const char * new_locale, /* The locale to set the category to */
const line_t caller_line /* Called from this line number */
)
Expand All @@ -1830,12 +1829,14 @@ S_bool_setlocale_2008_i(pTHX_
const char * locale_on_entry = querylocale_i(index);

DEBUG_Lv(PerlIO_printf(Perl_debug_log,
"bool_setlocale_2008_i input=%d (%s), mask=0x%x,"
" new locale=\"%s\", current locale=\"%s\","
"index=%d, object=%p\n",
categories[index], category_names[index], mask,
((new_locale == NULL) ? "(nil)" : new_locale),
locale_on_entry, index, entry_obj));
"(called from %" LINE_Tf "):"
"bool_setlocale_2008_i: input=%d (%s), mask=0x%x,"
" new locale=\"%s\", current locale=\"%s\","
"index=%d, entry object=%p\n",
caller_line,
categories[index], category_names[index], mask,
((new_locale == NULL) ? "(nil)" : new_locale),
locale_on_entry, index, entry_obj));

/* Here, trying to change the locale, but it is a no-op if the new boss is
* the same as the old boss. Except this routine is called when converting
Expand All @@ -1850,9 +1851,10 @@ S_bool_setlocale_2008_i(pTHX_
&& strEQ(new_locale, locale_on_entry))
{
DEBUG_Lv(PerlIO_printf(Perl_debug_log,
"(%" LINE_Tf "): bool_setlocale_2008_i"
" no-op to change to what it already was\n",
caller_line));
"(called from %" LINE_Tf "):"
" bool_setlocale_2008_i: no-op to change to"
" what it already was\n",
caller_line));
return true;
}

Expand Down Expand Up @@ -1909,8 +1911,10 @@ S_bool_setlocale_2008_i(pTHX_
}

DEBUG_Lv(PerlIO_printf(Perl_debug_log,
"(%" LINE_Tf "): bool_setlocale_2008_i now using C"
" object=%p\n", caller_line, PL_C_locale_obj));
"(called from %" LINE_Tf "):"
" bool_setlocale_2008_i: now using C"
" object=%p\n",
caller_line, PL_C_locale_obj));

locale_t new_obj;

Expand All @@ -1930,9 +1934,11 @@ S_bool_setlocale_2008_i(pTHX_
* have switched to it just above, in preparation for the general case.
* Since we're already there, no need to do further switching. */
if (mask == LC_ALL_MASK && isNAME_C_OR_POSIX(new_locale)) {
DEBUG_Lv(PerlIO_printf(Perl_debug_log, "(%" LINE_Tf "):"
" bool_setlocale_2008_i will stay"
" in C object\n", caller_line));
DEBUG_Lv(PerlIO_printf(Perl_debug_log,
"(called from %" LINE_Tf "):"
" bool_setlocale_2008_i: will stay in C"
" object\n",
caller_line));
new_obj = PL_C_locale_obj;

/* And free the old object if it isn't a special one */
Expand All @@ -1947,8 +1953,7 @@ S_bool_setlocale_2008_i(pTHX_

basis_obj = duplocale(basis_obj);
if (! basis_obj) {
locale_panic_(Perl_form(aTHX_ "(%" LINE_Tf "): duplocale failed",
caller_line));
locale_panic_via_("duplocale failed", __FILE__, caller_line);
NOT_REACHED; /* NOTREACHED */
}

Expand Down Expand Up @@ -1997,16 +2002,18 @@ S_bool_setlocale_2008_i(pTHX_
* locale; now switch into it */
if (! uselocale(new_obj)) {
freelocale(new_obj);
locale_panic_(Perl_form(aTHX_ "(%" LINE_Tf "): bool_setlocale_2008_i"
" switching into new locale failed",
caller_line));
locale_panic_(Perl_form(aTHX_ "(called from %" LINE_Tf "):"
" bool_setlocale_2008_i: switching"
" into new locale failed",
caller_line));
}
}

/* Here, we are using 'new_obj' which matches the input 'new_locale'. */
DEBUG_Lv(PerlIO_printf(Perl_debug_log,
"(%" LINE_Tf "): bool_setlocale_2008_i now using %p\n",
caller_line, new_obj));
"(called from %" LINE_Tf "):"
" bool_setlocale_2008_i: now using %p\n",
caller_line, new_obj));

#ifdef MULTIPLICITY

Expand Down

0 comments on commit 4f70268

Please sign in to comment.