Skip to content

Commit

Permalink
locale.c: Simplify S_new_ctype
Browse files Browse the repository at this point in the history
By creating a temporary variable, an else is eliminated, and the
lock/unlock are brought close together.
  • Loading branch information
khwilliamson committed May 7, 2023
1 parent 7e4014f commit a3256a1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions locale.c
Expand Up @@ -4157,8 +4157,10 @@ S_new_ctype(pTHX_ const char *newctype, bool force)
* */

LC_CTYPE_LOCK;
const int mb_cur_max = MB_CUR_MAX;
LC_CTYPE_UNLOCK;

if (MB_CUR_MAX > 1 && ! PL_in_utf8_CTYPE_locale
if (mb_cur_max > 1 && ! PL_in_utf8_CTYPE_locale

/* Some platforms return MB_CUR_MAX > 1 for even the "C" locale.
* Just assume that the implementation for them (plus for POSIX) is
Expand All @@ -4167,19 +4169,14 @@ S_new_ctype(pTHX_ const char *newctype, bool force)
* as this is the only problem, everything should work fine */
&& ! isNAME_C_OR_POSIX(newctype))
{
LC_CTYPE_UNLOCK;

DEBUG_L(PerlIO_printf(Perl_debug_log,
"Unsupported, MB_CUR_MAX=%d\n", (int) MB_CUR_MAX));
"Unsupported, MB_CUR_MAX=%d\n", mb_cur_max));

Perl_ck_warner_d(aTHX_ packWARN(WARN_LOCALE),
"Locale '%s' is unsupported, and may crash the"
" interpreter.\n",
newctype);
}
else {
LC_CTYPE_UNLOCK;
}

# endif

Expand Down

0 comments on commit a3256a1

Please sign in to comment.