/* * We do handle case-insensitive matching for single-byte encodings using * fold-on-the-fly processing, however. */ static char SB_lower_char(unsigned char c, pg_locale_t locale, bool locale_is_c) { if (locale_is_c) return pg_ascii_tolower(c); #ifdef HAVE_LOCALE_T else if (locale) return tolower_l(c, locale); #endif else return pg_tolower(c); }
static pg_wchar pg_wc_tolower(pg_wchar c) { switch (pg_regex_strategy) { case PG_REGEX_LOCALE_C: if (c <= (pg_wchar) 127) return pg_ascii_tolower((unsigned char) c); return c; case PG_REGEX_LOCALE_WIDE: /* force C behavior for ASCII characters, per comments above */ if (c <= (pg_wchar) 127) return pg_ascii_tolower((unsigned char) c); #ifdef USE_WIDE_UPPER_LOWER if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towlower((wint_t) c); #endif /* FALL THRU */ case PG_REGEX_LOCALE_1BYTE: /* force C behavior for ASCII characters, per comments above */ if (c <= (pg_wchar) 127) return pg_ascii_tolower((unsigned char) c); if (c <= (pg_wchar) UCHAR_MAX) return tolower((unsigned char) c); return c; case PG_REGEX_LOCALE_WIDE_L: #if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towlower_l((wint_t) c, pg_regex_locale); #endif /* FALL THRU */ case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T if (c <= (pg_wchar) UCHAR_MAX) return tolower_l((unsigned char) c, pg_regex_locale); #endif return c; } return 0; /* can't get here, but keep compiler quiet */ }