diff options
author | Karl Williamson <khw@cpan.org> | 2017-09-11 17:32:42 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-11-08 20:52:52 -0700 |
commit | 51fc4b19eb5af1211f960bc49d322c020490bc61 (patch) | |
tree | 7990abd0a9a52e0dbbe04c1b6afb12137cef1fed /locale.c | |
parent | ff1b739b7e749b9f4005279ddb782cb23a2322a9 (diff) | |
download | perl-51fc4b19eb5af1211f960bc49d322c020490bc61.tar.gz |
locale.c: Avoid extra call to mbtowc()
This is done only when debugging, but in some locales that have shift
states, the extra call could blow up. Instead save the result of the
mbtowc() call we care about.
Diffstat (limited to 'locale.c')
-rw-r--r-- | locale.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -3055,17 +3055,20 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category) * result */ if (is_utf8) { wchar_t wc; + int len; + PERL_UNUSED_RESULT(mbtowc(&wc, NULL, 0));/* Reset any shift state */ errno = 0; - if ((size_t)mbtowc(&wc, HYPHEN_UTF8, strlen(HYPHEN_UTF8)) - != strlen(HYPHEN_UTF8) + len = mbtowc(&wc, STR_WITH_LEN(HYPHEN_UTF8)); + + if ( len != STRLENs(HYPHEN_UTF8) || wc != (wchar_t) 0x2010) { is_utf8 = FALSE; DEBUG_L(PerlIO_printf(Perl_debug_log, "\thyphen=U+%x\n", (unsigned int)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)); + len, errno)); } } |