In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/76f2ffcdf8c40f8ff5966aa85d388596131ff8fe?hp=112284f43082e616b936428a3b2d4877ef232864>
- Log ----------------------------------------------------------------- commit 76f2ffcdf8c40f8ff5966aa85d388596131ff8fe Author: Karl Williamson <[email protected]> Date: Mon Nov 24 11:37:41 2014 -0700 utf8.c: Shorten long constant names, and simplify The previous commit fixed a typo caused by it being hard to see the differences in a long ALL_CAP name. This uses #defines to type the long name only once, and compile-time variables so the expression for the length of strings only is specified once. M utf8.c commit 2721f3e1a76dd0fcb2b451f10ca59245c5bfb539 Author: Karl Williamson <[email protected]> Date: Mon Nov 24 11:30:14 2014 -0700 utf8.c: Was taking sizeof() wrong thing This was a typo due to the long name. A future commit will make it cleaner. The sizeof() the wrong name evaluates to the right number on ASCII platforms, but not EBCDIC. M utf8.c ----------------------------------------------------------------------- Summary of changes: utf8.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/utf8.c b/utf8.c index cd38768..72a9c1d 100644 --- a/utf8.c +++ b/utf8.c @@ -2179,11 +2179,16 @@ Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags) if (flags & FOLD_FLAGS_LOCALE) { +# define CAP_SHARP_S LATIN_CAPITAL_LETTER_SHARP_S_UTF8 +# define LONG_S_T LATIN_SMALL_LIGATURE_LONG_S_T_UTF8 + + const unsigned int cap_sharp_s_len = sizeof(CAP_SHARP_S) - 1; + const unsigned int long_s_t_len = sizeof(LONG_S_T) - 1; + /* Special case these two characters, as what normally gets * returned under locale doesn't work */ - if (UTF8SKIP(p) == sizeof(LATIN_CAPITAL_LETTER_SHARP_S_UTF8) - 1 - && memEQ((char *) p, LATIN_CAPITAL_LETTER_SHARP_S_UTF8, - sizeof(LATIN_CAPITAL_LETTER_SHARP_S_UTF8) - 1)) + if (UTF8SKIP(p) == cap_sharp_s_len + && memEQ((char *) p, CAP_SHARP_S, cap_sharp_s_len)) { /* diag_listed_as: Can't do %s("%s") on non-UTF-8 locale; resolved to "%s". */ Perl_ck_warner(aTHX_ packWARN(WARN_LOCALE), @@ -2191,9 +2196,8 @@ Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags) "resolved to \"\\x{17F}\\x{17F}\"."); goto return_long_s; } - else if (UTF8SKIP(p) == sizeof(LATIN_SMALL_LIGATURE_LONG_S_T) - 1 - && memEQ((char *) p, LATIN_SMALL_LIGATURE_LONG_S_T_UTF8, - sizeof(LATIN_SMALL_LIGATURE_LONG_S_T_UTF8) - 1)) + else if (UTF8SKIP(p) == long_s_t_len + && memEQ((char *) p, LONG_S_T, long_s_t_len)) { /* diag_listed_as: Can't do %s("%s") on non-UTF-8 locale; resolved to "%s". */ Perl_ck_warner(aTHX_ packWARN(WARN_LOCALE), -- Perl5 Master Repository
