summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-03-27 11:58:07 -0600
committerKarl Williamson <khw@cpan.org>2022-06-12 09:50:10 -0600
commit4a283f4fd171ac8daa68fa3ebacb9aef8d126283 (patch)
tree93fb3d9a981f7731d3c77a1ae627aed96345d736
parentef620431e6b6679423d762667ac461f7d0ba7fd2 (diff)
downloadperl-4a283f4fd171ac8daa68fa3ebacb9aef8d126283.tar.gz
handy.h: Move some macro defns around
This is to make the difference listing in future commits smaller. This change includes some comment changes, and some extra parens around some subexpressions
-rw-r--r--handy.h90
1 files changed, 45 insertions, 45 deletions
diff --git a/handy.h b/handy.h
index c8bb3ba078..1a60145659 100644
--- a/handy.h
+++ b/handy.h
@@ -1895,50 +1895,6 @@ END_EXTERN_C
generic_isCC_A_(c, classnum)
#endif
-/* These next three are also for internal core Perl use only: case-change
- * helper macros. The reason for using the PL_latin arrays is in case the
- * system function is defective; it ensures uniform results that conform to the
- * Unicode standard. It does not handle the anomalies in UTF-8 Turkic
- * locales. */
-#define generic_toLOWER_LC_(c, function) \
- (! FITS_IN_8_BITS(c) \
- ? (c) \
- : (IN_UTF8_CTYPE_LOCALE) \
- ? PL_latin1_lc[ (U8) (c) ] \
- : (U8) function((U8) (c)))
-
-/* Note that the result can be larger than a byte in a UTF-8 locale. It
- * returns a single value, so can't adequately return the upper case of LATIN
- * SMALL LETTER SHARP S in a UTF-8 locale (which should be a string of two
- * values "SS"); instead it asserts against that under DEBUGGING, and
- * otherwise returns its input. It does not handle the anomalies in UTF-8
- * Turkic locales. */
-#define generic_toUPPER_LC_(c, function) \
- (! FITS_IN_8_BITS(c) \
- ? (c) \
- : ((! IN_UTF8_CTYPE_LOCALE) \
- ? (U8) function((U8) (c)) \
- : (UNLIKELY(((U8)(c)) == MICRO_SIGN) \
- ? GREEK_CAPITAL_LETTER_MU \
- : (UNLIKELY(((U8)(c)) == LATIN_SMALL_LETTER_Y_WITH_DIAERESIS) \
- ? LATIN_CAPITAL_LETTER_Y_WITH_DIAERESIS \
- : (UNLIKELY(((U8)(c)) == LATIN_SMALL_LETTER_SHARP_S) \
- ? (__ASSERT_(0) (c)) \
- : PL_mod_latin1_uc[ (U8) (c) ])))))
-
-/* Note that the result can be larger than a byte in a UTF-8 locale. It
- * returns a single value, so can't adequately return the fold case of LATIN
- * SMALL LETTER SHARP S in a UTF-8 locale (which should be a string of two
- * values "ss"); instead it asserts against that under DEBUGGING, and
- * otherwise returns its input. It does not handle the anomalies in UTF-8
- * Turkic locales */
-#define generic_toFOLD_LC_(c, function) \
- ((UNLIKELY((c) == MICRO_SIGN) && IN_UTF8_CTYPE_LOCALE) \
- ? GREEK_SMALL_LETTER_MU \
- : (__ASSERT_( ! IN_UTF8_CTYPE_LOCALE \
- || LIKELY((c) != LATIN_SMALL_LETTER_SHARP_S)) \
- generic_toLOWER_LC_(c, function)))
-
/* Use the libc versions for these if available. */
#if defined(HAS_ISASCII)
# define isASCII_LC(c) (FITS_IN_8_BITS(c) && isascii( (U8) (c)))
@@ -2009,16 +1965,60 @@ END_EXTERN_C
# define isUPPER_LC(c) generic_LC_(c, CC_UPPER_, isupper)
# define isXDIGIT_LC(c) generic_LC_(c, CC_XDIGIT_, isxdigit)
# endif
+
#ifndef CTYPE256
# define toLOWER_LC(c) toLOWER_A(c)
# define toUPPER_LC(c) toUPPER_A(c)
# define toFOLD_LC(c) toFOLD_A(c)
#else
+/* In the next three macros, the reason for using the PL_latin arrays is in
+ * case the system function is defective; it ensures uniform results that
+ * conform to the Unicode standard. */
+
+/* This does not handle the anomalies in UTF-8 Turkic locales. */
+#define generic_toLOWER_LC_(c, function) \
+ ((! FITS_IN_8_BITS(c)) \
+ ? (c) \
+ : ((IN_UTF8_CTYPE_LOCALE) \
+ ? PL_latin1_lc[ (U8) (c) ] \
+ : (U8) function((U8) (c))))
+
+/* In this macro, note that the result can be larger than a byte in a UTF-8
+ * locale. It returns a single value, so can't adequately return the upper
+ * case of LATIN SMALL LETTER SHARP S in a UTF-8 locale (which should be a
+ * string of two values "SS"); instead it asserts against that under
+ * DEBUGGING, and otherwise returns its input. It does not handle the
+ * anomalies in UTF-8 Turkic locales. */
+#define generic_toUPPER_LC_(c, function) \
+ ((! FITS_IN_8_BITS(c)) \
+ ? (c) \
+ : ((! IN_UTF8_CTYPE_LOCALE) \
+ ? (U8) function((U8) (c)) \
+ : (UNLIKELY(((U8)(c)) == MICRO_SIGN) \
+ ? GREEK_CAPITAL_LETTER_MU \
+ : ((UNLIKELY(((U8) (c)) == LATIN_SMALL_LETTER_Y_WITH_DIAERESIS) \
+ ? LATIN_CAPITAL_LETTER_Y_WITH_DIAERESIS \
+ : (UNLIKELY(((U8)(c)) == LATIN_SMALL_LETTER_SHARP_S) \
+ ? (__ASSERT_(0) (c)) /* Fail on Sharp S in DEBUGGING */ \
+ : PL_mod_latin1_uc[ (U8) (c) ]))))))
+
+/* In this macro, note that the result can be larger than a byte in a UTF-8
+ * locale. It returns a single value, so can't adequately return the fold case
+ * of LATIN SMALL LETTER SHARP S in a UTF-8 locale (which should be a string of
+ * two values "ss"); instead it asserts against that under DEBUGGING, and
+ * otherwise returns its input. It does not handle the anomalies in UTF-8
+ * Turkic locales */
+#define generic_toFOLD_LC_(c, function) \
+ ((UNLIKELY((c) == MICRO_SIGN) && IN_UTF8_CTYPE_LOCALE) \
+ ? GREEK_SMALL_LETTER_MU \
+ : (__ASSERT_( ! IN_UTF8_CTYPE_LOCALE \
+ || LIKELY((c) != LATIN_SMALL_LETTER_SHARP_S)) \
+ generic_toLOWER_LC_(c, function)))
+
# define toLOWER_LC(c) generic_toLOWER_LC_((c), tolower)
# define toUPPER_LC(c) generic_toUPPER_LC_((c), toupper)
# define toFOLD_LC(c) generic_toFOLD_LC_((c), tolower)
-
#endif
#define isIDCONT(c) isWORDCHAR(c)