diff --git a/include/sys/u8_textprep.h b/include/sys/u8_textprep.h index 11bf8f4373e0..86161e0aafa0 100644 --- a/include/sys/u8_textprep.h +++ b/include/sys/u8_textprep.h @@ -45,7 +45,9 @@ extern "C" { */ #define U8_STRCMP_CS (0x00000001) #define U8_STRCMP_CI_UPPER (0x00000002) +#if 0 #define U8_STRCMP_CI_LOWER (0x00000004) +#endif #define U8_CANON_DECOMP (0x00000010) #define U8_COMPAT_DECOMP (0x00000020) @@ -57,7 +59,9 @@ extern "C" { #define U8_STRCMP_NFKC (U8_COMPAT_DECOMP | U8_CANON_COMP) #define U8_TEXTPREP_TOUPPER (U8_STRCMP_CI_UPPER) +#ifdef U8_STRCMP_CI_LOWER #define U8_TEXTPREP_TOLOWER (U8_STRCMP_CI_LOWER) +#endif #define U8_TEXTPREP_NFD (U8_STRCMP_NFD) #define U8_TEXTPREP_NFC (U8_STRCMP_NFC) diff --git a/include/sys/u8_textprep_data.h b/include/sys/u8_textprep_data.h index 3f2564f618cf..6c4c9dfa2b08 100644 --- a/include/sys/u8_textprep_data.h +++ b/include/sys/u8_textprep_data.h @@ -27630,6 +27630,7 @@ static const uchar_t u8_case_common_b2_tbl[U8_UNICODE_LATEST + 1][2][256] = { }; +#ifdef U8_STRCMP_CI_LOWER static const u8_displacement_t u8_tolower_b3_tbl[U8_UNICODE_LATEST + 1][5][256] = { #ifdef U8_UNICODE_320 { @@ -31412,6 +31413,7 @@ static const uchar_t u8_tolower_final_tbl[U8_UNICODE_LATEST + 1][2299] = { 0x90, 0x91, 0x8F, }, }; +#endif static const u8_displacement_t u8_toupper_b3_tbl[U8_UNICODE_LATEST + 1][5][256] = { #ifdef U8_UNICODE_320 diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c index 37eb848a5288..9164983d9fa2 100644 --- a/module/unicode/u8_textprep.c +++ b/module/unicode/u8_textprep.c @@ -531,7 +531,9 @@ do_case_conv(int uv, uchar_t *u8s, uchar_t *s, int sz, boolean_t is_it_toupper) for (i = 0; start_id < end_id; start_id++) u8s[i++] = u8_toupper_final_tbl[uv][b3_base + start_id]; - } else { + } +#ifdef U8_STRCMP_CI_LOWER + else { b3_tbl = u8_tolower_b3_tbl[uv][b2][b3].tbl_id; if (b3_tbl == U8_TBL_ELEMENT_NOT_DEF) return ((size_t)sz); @@ -547,6 +549,7 @@ do_case_conv(int uv, uchar_t *u8s, uchar_t *s, int sz, boolean_t is_it_toupper) for (i = 0; start_id < end_id; start_id++) u8s[i++] = u8_tolower_final_tbl[uv][b3_base + start_id]; } +#endif /* * If i is still zero, that means there is no corresponding character. @@ -1758,7 +1761,11 @@ do_norm_compare(size_t uv, uchar_t *s1, uchar_t *s2, size_t n1, size_t n2, s2last = s2 + n2; is_it_toupper = flag & U8_TEXTPREP_TOUPPER; +#ifdef U8_STRCMP_CI_LOWER is_it_tolower = flag & U8_TEXTPREP_TOLOWER; +#else + is_it_tolower = 0; +#endif canonical_decomposition = flag & U8_CANON_DECOMP; compatibility_decomposition = flag & U8_COMPAT_DECOMP; canonical_composition = flag & U8_CANON_COMP; @@ -1875,12 +1882,18 @@ u8_strcmp(const char *s1, const char *s2, size_t n, int flag, size_t uv, if (flag == 0) { flag = U8_STRCMP_CS; } else { - f = flag & (U8_STRCMP_CS | U8_STRCMP_CI_UPPER | - U8_STRCMP_CI_LOWER); + f = flag & (U8_STRCMP_CS | U8_STRCMP_CI_UPPER +#ifdef U8_STRCMP_CI_LOWER + | U8_STRCMP_CI_LOWER +#endif + ); if (f == 0) { flag |= U8_STRCMP_CS; - } else if (f != U8_STRCMP_CS && f != U8_STRCMP_CI_UPPER && - f != U8_STRCMP_CI_LOWER) { + } else if (f != U8_STRCMP_CS && f != U8_STRCMP_CI_UPPER +#ifdef U8_STRCMP_CI_LOWER + && f != U8_STRCMP_CI_LOWER +#endif + ) { *errnum = EBADF; flag = U8_STRCMP_CS; } @@ -1913,10 +1926,13 @@ u8_strcmp(const char *s1, const char *s2, size_t n, int flag, size_t uv, if (flag == U8_STRCMP_CI_UPPER) { return (do_case_compare(uv, (uchar_t *)s1, (uchar_t *)s2, n1, n2, B_TRUE, errnum)); - } else if (flag == U8_STRCMP_CI_LOWER) { + } +#ifdef U8_STRCMP_CI_LOWER + else if (flag == U8_STRCMP_CI_LOWER) { return (do_case_compare(uv, (uchar_t *)s1, (uchar_t *)s2, n1, n2, B_FALSE, errnum)); } +#endif return (do_norm_compare(uv, (uchar_t *)s1, (uchar_t *)s2, n1, n2, flag, errnum)); @@ -1950,11 +1966,15 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen, return ((size_t)-1); } +#ifdef U8_TEXTPREP_TOLOWER f = flag & (U8_TEXTPREP_TOUPPER | U8_TEXTPREP_TOLOWER); if (f == (U8_TEXTPREP_TOUPPER | U8_TEXTPREP_TOLOWER)) { *errnum = EBADF; return ((size_t)-1); } +#else + f = flag & U8_TEXTPREP_TOUPPER; +#endif f = flag & (U8_CANON_DECOMP | U8_COMPAT_DECOMP | U8_CANON_COMP); if (f && f != U8_TEXTPREP_NFD && f != U8_TEXTPREP_NFC && @@ -1979,7 +1999,11 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen, do_not_ignore_null = !(flag & U8_TEXTPREP_IGNORE_NULL); do_not_ignore_invalid = !(flag & U8_TEXTPREP_IGNORE_INVALID); is_it_toupper = flag & U8_TEXTPREP_TOUPPER; +#ifdef U8_TEXTPREP_TOLOWER is_it_tolower = flag & U8_TEXTPREP_TOLOWER; +#else + is_it_tolower = 0; +#endif ret_val = 0;