Permalink
Browse files

locale.c: Simplify expression

Since this is operating on C strings, we don't have to check the
lengths, but can rely on the underlying functions to work.
  • Loading branch information...
khwilliamson committed Jan 5, 2018
1 parent ceac0a2 commit cf585a6eb1dfac13a40b74fc282182920a1e044b
Showing with 7 additions and 4 deletions.
  1. +7 −4 locale.c
View
@@ -3206,10 +3206,13 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category)
Safefree(save_ctype_locale);
}
is_utf8 = ( ( strlen(codeset) == STRLENs("UTF-8")
&& foldEQ(codeset, STR_WITH_LEN("UTF-8")))
|| ( strlen(codeset) == STRLENs("UTF8")
&& foldEQ(codeset, STR_WITH_LEN("UTF8"))));
/* If the implementation of foldEQ() somehow were
* to change to not go byte-by-byte, this could
* read past end of string, as only one length is
* checked. But currently, a premature NUL will
* compare false, and it will stop there */
is_utf8 = cBOOL( 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",

0 comments on commit cf585a6

Please sign in to comment.