Skip to content

Commit a3256a1

Browse files
committed
locale.c: Simplify S_new_ctype
By creating a temporary variable, an else is eliminated, and the lock/unlock are brought close together.
1 parent 7e4014f commit a3256a1

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

locale.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -4157,8 +4157,10 @@ S_new_ctype(pTHX_ const char *newctype, bool force)
41574157
* */
41584158

41594159
LC_CTYPE_LOCK;
4160+
const int mb_cur_max = MB_CUR_MAX;
4161+
LC_CTYPE_UNLOCK;
41604162

4161-
if (MB_CUR_MAX > 1 && ! PL_in_utf8_CTYPE_locale
4163+
if (mb_cur_max > 1 && ! PL_in_utf8_CTYPE_locale
41624164

41634165
/* Some platforms return MB_CUR_MAX > 1 for even the "C" locale.
41644166
* Just assume that the implementation for them (plus for POSIX) is
@@ -4167,19 +4169,14 @@ S_new_ctype(pTHX_ const char *newctype, bool force)
41674169
* as this is the only problem, everything should work fine */
41684170
&& ! isNAME_C_OR_POSIX(newctype))
41694171
{
4170-
LC_CTYPE_UNLOCK;
4171-
41724172
DEBUG_L(PerlIO_printf(Perl_debug_log,
4173-
"Unsupported, MB_CUR_MAX=%d\n", (int) MB_CUR_MAX));
4173+
"Unsupported, MB_CUR_MAX=%d\n", mb_cur_max));
41744174

41754175
Perl_ck_warner_d(aTHX_ packWARN(WARN_LOCALE),
41764176
"Locale '%s' is unsupported, and may crash the"
41774177
" interpreter.\n",
41784178
newctype);
41794179
}
4180-
else {
4181-
LC_CTYPE_UNLOCK;
4182-
}
41834180

41844181
# endif
41854182

0 commit comments

Comments
 (0)