mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
Add pg_iswxdigit(), useful for tsearch.
Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/0151ad01239e2cc7b3139644358cf8f7b9622ff7.camel@j-davis.com
This commit is contained in:
@@ -1493,6 +1493,18 @@ pg_iswspace(pg_wchar wc, pg_locale_t locale)
|
|||||||
return locale->ctype->wc_isspace(wc, locale);
|
return locale->ctype->wc_isspace(wc, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
pg_iswxdigit(pg_wchar wc, pg_locale_t locale)
|
||||||
|
{
|
||||||
|
if (locale->ctype == NULL)
|
||||||
|
return (wc <= (pg_wchar) 127 &&
|
||||||
|
((pg_char_properties[wc] & PG_ISDIGIT) ||
|
||||||
|
((wc >= 'A' && wc <= 'F') ||
|
||||||
|
(wc >= 'a' && wc <= 'f'))));
|
||||||
|
else
|
||||||
|
return locale->ctype->wc_isxdigit(wc, locale);
|
||||||
|
}
|
||||||
|
|
||||||
pg_wchar
|
pg_wchar
|
||||||
pg_towupper(pg_wchar wc, pg_locale_t locale)
|
pg_towupper(pg_wchar wc, pg_locale_t locale)
|
||||||
{
|
{
|
||||||
|
@@ -163,6 +163,12 @@ wc_isspace_builtin(pg_wchar wc, pg_locale_t locale)
|
|||||||
return pg_u_isspace(wc);
|
return pg_u_isspace(wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
wc_isxdigit_builtin(pg_wchar wc, pg_locale_t locale)
|
||||||
|
{
|
||||||
|
return pg_u_isxdigit(wc, !locale->builtin.casemap_full);
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
char_is_cased_builtin(char ch, pg_locale_t locale)
|
char_is_cased_builtin(char ch, pg_locale_t locale)
|
||||||
{
|
{
|
||||||
@@ -196,6 +202,7 @@ static const struct ctype_methods ctype_methods_builtin = {
|
|||||||
.wc_isprint = wc_isprint_builtin,
|
.wc_isprint = wc_isprint_builtin,
|
||||||
.wc_ispunct = wc_ispunct_builtin,
|
.wc_ispunct = wc_ispunct_builtin,
|
||||||
.wc_isspace = wc_isspace_builtin,
|
.wc_isspace = wc_isspace_builtin,
|
||||||
|
.wc_isxdigit = wc_isxdigit_builtin,
|
||||||
.char_is_cased = char_is_cased_builtin,
|
.char_is_cased = char_is_cased_builtin,
|
||||||
.wc_tolower = wc_tolower_builtin,
|
.wc_tolower = wc_tolower_builtin,
|
||||||
.wc_toupper = wc_toupper_builtin,
|
.wc_toupper = wc_toupper_builtin,
|
||||||
|
@@ -212,6 +212,12 @@ wc_isspace_icu(pg_wchar wc, pg_locale_t locale)
|
|||||||
return u_isspace(wc);
|
return u_isspace(wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
wc_isxdigit_icu(pg_wchar wc, pg_locale_t locale)
|
||||||
|
{
|
||||||
|
return u_isxdigit(wc);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct ctype_methods ctype_methods_icu = {
|
static const struct ctype_methods ctype_methods_icu = {
|
||||||
.strlower = strlower_icu,
|
.strlower = strlower_icu,
|
||||||
.strtitle = strtitle_icu,
|
.strtitle = strtitle_icu,
|
||||||
@@ -226,6 +232,7 @@ static const struct ctype_methods ctype_methods_icu = {
|
|||||||
.wc_isprint = wc_isprint_icu,
|
.wc_isprint = wc_isprint_icu,
|
||||||
.wc_ispunct = wc_ispunct_icu,
|
.wc_ispunct = wc_ispunct_icu,
|
||||||
.wc_isspace = wc_isspace_icu,
|
.wc_isspace = wc_isspace_icu,
|
||||||
|
.wc_isxdigit = wc_isxdigit_icu,
|
||||||
.char_is_cased = char_is_cased_icu,
|
.char_is_cased = char_is_cased_icu,
|
||||||
.wc_toupper = toupper_icu,
|
.wc_toupper = toupper_icu,
|
||||||
.wc_tolower = tolower_icu,
|
.wc_tolower = tolower_icu,
|
||||||
|
@@ -172,6 +172,16 @@ wc_isspace_libc_sb(pg_wchar wc, pg_locale_t locale)
|
|||||||
return isspace_l((unsigned char) wc, locale->lt);
|
return isspace_l((unsigned char) wc, locale->lt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
wc_isxdigit_libc_sb(pg_wchar wc, pg_locale_t locale)
|
||||||
|
{
|
||||||
|
#ifndef WIN32
|
||||||
|
return isxdigit_l((unsigned char) wc, locale->lt);
|
||||||
|
#else
|
||||||
|
return _isxdigit_l((unsigned char) wc, locale->lt);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
wc_isdigit_libc_mb(pg_wchar wc, pg_locale_t locale)
|
wc_isdigit_libc_mb(pg_wchar wc, pg_locale_t locale)
|
||||||
{
|
{
|
||||||
@@ -226,6 +236,16 @@ wc_isspace_libc_mb(pg_wchar wc, pg_locale_t locale)
|
|||||||
return iswspace_l((wint_t) wc, locale->lt);
|
return iswspace_l((wint_t) wc, locale->lt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
wc_isxdigit_libc_mb(pg_wchar wc, pg_locale_t locale)
|
||||||
|
{
|
||||||
|
#ifndef WIN32
|
||||||
|
return iswxdigit_l((wint_t) wc, locale->lt);
|
||||||
|
#else
|
||||||
|
return _iswxdigit_l((wint_t) wc, locale->lt);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static char
|
static char
|
||||||
char_tolower_libc(unsigned char ch, pg_locale_t locale)
|
char_tolower_libc(unsigned char ch, pg_locale_t locale)
|
||||||
{
|
{
|
||||||
@@ -313,6 +333,7 @@ static const struct ctype_methods ctype_methods_libc_sb = {
|
|||||||
.wc_isprint = wc_isprint_libc_sb,
|
.wc_isprint = wc_isprint_libc_sb,
|
||||||
.wc_ispunct = wc_ispunct_libc_sb,
|
.wc_ispunct = wc_ispunct_libc_sb,
|
||||||
.wc_isspace = wc_isspace_libc_sb,
|
.wc_isspace = wc_isspace_libc_sb,
|
||||||
|
.wc_isxdigit = wc_isxdigit_libc_sb,
|
||||||
.char_is_cased = char_is_cased_libc,
|
.char_is_cased = char_is_cased_libc,
|
||||||
.char_tolower = char_tolower_libc,
|
.char_tolower = char_tolower_libc,
|
||||||
.wc_toupper = toupper_libc_sb,
|
.wc_toupper = toupper_libc_sb,
|
||||||
@@ -337,6 +358,7 @@ static const struct ctype_methods ctype_methods_libc_other_mb = {
|
|||||||
.wc_isprint = wc_isprint_libc_sb,
|
.wc_isprint = wc_isprint_libc_sb,
|
||||||
.wc_ispunct = wc_ispunct_libc_sb,
|
.wc_ispunct = wc_ispunct_libc_sb,
|
||||||
.wc_isspace = wc_isspace_libc_sb,
|
.wc_isspace = wc_isspace_libc_sb,
|
||||||
|
.wc_isxdigit = wc_isxdigit_libc_sb,
|
||||||
.char_is_cased = char_is_cased_libc,
|
.char_is_cased = char_is_cased_libc,
|
||||||
.char_tolower = char_tolower_libc,
|
.char_tolower = char_tolower_libc,
|
||||||
.wc_toupper = toupper_libc_sb,
|
.wc_toupper = toupper_libc_sb,
|
||||||
@@ -357,6 +379,7 @@ static const struct ctype_methods ctype_methods_libc_utf8 = {
|
|||||||
.wc_isprint = wc_isprint_libc_mb,
|
.wc_isprint = wc_isprint_libc_mb,
|
||||||
.wc_ispunct = wc_ispunct_libc_mb,
|
.wc_ispunct = wc_ispunct_libc_mb,
|
||||||
.wc_isspace = wc_isspace_libc_mb,
|
.wc_isspace = wc_isspace_libc_mb,
|
||||||
|
.wc_isxdigit = wc_isxdigit_libc_mb,
|
||||||
.char_is_cased = char_is_cased_libc,
|
.char_is_cased = char_is_cased_libc,
|
||||||
.char_tolower = char_tolower_libc,
|
.char_tolower = char_tolower_libc,
|
||||||
.wc_toupper = toupper_libc_mb,
|
.wc_toupper = toupper_libc_mb,
|
||||||
|
@@ -110,6 +110,7 @@ struct ctype_methods
|
|||||||
bool (*wc_isprint) (pg_wchar wc, pg_locale_t locale);
|
bool (*wc_isprint) (pg_wchar wc, pg_locale_t locale);
|
||||||
bool (*wc_ispunct) (pg_wchar wc, pg_locale_t locale);
|
bool (*wc_ispunct) (pg_wchar wc, pg_locale_t locale);
|
||||||
bool (*wc_isspace) (pg_wchar wc, pg_locale_t locale);
|
bool (*wc_isspace) (pg_wchar wc, pg_locale_t locale);
|
||||||
|
bool (*wc_isxdigit) (pg_wchar wc, pg_locale_t locale);
|
||||||
pg_wchar (*wc_toupper) (pg_wchar wc, pg_locale_t locale);
|
pg_wchar (*wc_toupper) (pg_wchar wc, pg_locale_t locale);
|
||||||
pg_wchar (*wc_tolower) (pg_wchar wc, pg_locale_t locale);
|
pg_wchar (*wc_tolower) (pg_wchar wc, pg_locale_t locale);
|
||||||
|
|
||||||
@@ -217,6 +218,7 @@ extern bool pg_iswgraph(pg_wchar wc, pg_locale_t locale);
|
|||||||
extern bool pg_iswprint(pg_wchar wc, pg_locale_t locale);
|
extern bool pg_iswprint(pg_wchar wc, pg_locale_t locale);
|
||||||
extern bool pg_iswpunct(pg_wchar wc, pg_locale_t locale);
|
extern bool pg_iswpunct(pg_wchar wc, pg_locale_t locale);
|
||||||
extern bool pg_iswspace(pg_wchar wc, pg_locale_t locale);
|
extern bool pg_iswspace(pg_wchar wc, pg_locale_t locale);
|
||||||
|
extern bool pg_iswxdigit(pg_wchar wc, pg_locale_t locale);
|
||||||
extern pg_wchar pg_towupper(pg_wchar wc, pg_locale_t locale);
|
extern pg_wchar pg_towupper(pg_wchar wc, pg_locale_t locale);
|
||||||
extern pg_wchar pg_towlower(pg_wchar wc, pg_locale_t locale);
|
extern pg_wchar pg_towlower(pg_wchar wc, pg_locale_t locale);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user