Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
pg_locale_libc.c File Reference
#include "postgres.h"
#include <limits.h>
#include <wctype.h>
#include "access/htup_details.h"
#include "catalog/pg_database.h"
#include "catalog/pg_collation.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/formatting.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
#include "utils/syscache.h"
Include dependency graph for pg_locale_libc.c:

Go to the source code of this file.

Macros

#define TEXTBUFLEN   1024
 

Functions

pg_locale_t create_pg_locale_libc (Oid collid, MemoryContext context)
 
static int strncoll_libc (const char *arg1, ssize_t len1, const char *arg2, ssize_t len2, pg_locale_t locale)
 
static size_t strnxfrm_libc (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
char * get_collation_actual_version_libc (const char *collcollate)
 
static locale_t make_libc_collator (const char *collate, const char *ctype)
 
static size_t strlower_libc_sb (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
static size_t strlower_libc_mb (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
static size_t strtitle_libc_sb (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
static size_t strtitle_libc_mb (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
static size_t strupper_libc_sb (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
static size_t strupper_libc_mb (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
static bool wc_isdigit_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isalpha_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isalnum_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isupper_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_islower_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isgraph_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isprint_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_ispunct_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isspace_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isdigit_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isalpha_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isalnum_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isupper_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_islower_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isgraph_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isprint_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_ispunct_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_isspace_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static char char_tolower_libc (unsigned char ch, pg_locale_t locale)
 
static bool char_is_cased_libc (char ch, pg_locale_t locale)
 
static pg_wchar toupper_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static pg_wchar toupper_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static pg_wchar tolower_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static pg_wchar tolower_libc_mb (pg_wchar wc, pg_locale_t locale)
 
void report_newlocale_failure (const char *localename)
 
static size_t mbstowcs_l (wchar_t *dest, const char *src, size_t n, locale_t loc)
 
static size_t wcstombs_l (char *dest, const wchar_t *src, size_t n, locale_t loc)
 
size_t wchar2char (char *to, const wchar_t *from, size_t tolen, locale_t loc)
 
size_t char2wchar (wchar_t *to, size_t tolen, const char *from, size_t fromlen, locale_t loc)
 

Variables

static const struct ctype_methods ctype_methods_libc_sb
 
static const struct ctype_methods ctype_methods_libc_other_mb
 
static const struct ctype_methods ctype_methods_libc_utf8
 
static const struct collate_methods collate_methods_libc
 

Macro Definition Documentation

◆ TEXTBUFLEN

#define TEXTBUFLEN   1024

Definition at line 82 of file pg_locale_libc.c.

Function Documentation

◆ char2wchar()

size_t char2wchar ( wchar_t *  to,
size_t  tolen,
const char *  from,
size_t  fromlen,
locale_t  loc 
)

Definition at line 1187 of file pg_locale_libc.c.

1189{
1190 size_t result;
1191
1192 if (tolen == 0)
1193 return 0;
1194
1195#ifdef WIN32
1196 /* See WIN32 "Unicode" comment above */
1198 {
1199 /* Win32 API does not work for zero-length input */
1200 if (fromlen == 0)
1201 result = 0;
1202 else
1203 {
1204 result = MultiByteToWideChar(CP_UTF8, 0, from, fromlen, to, tolen - 1);
1205 /* A zero return is failure */
1206 if (result == 0)
1207 result = -1;
1208 }
1209
1210 if (result != -1)
1211 {
1212 Assert(result < tolen);
1213 /* Append trailing null wchar (MultiByteToWideChar() does not) */
1214 to[result] = 0;
1215 }
1216 }
1217 else
1218#endif /* WIN32 */
1219 {
1220 /* mbstowcs requires ending '\0' */
1221 char *str = pnstrdup(from, fromlen);
1222
1223 if (loc == (locale_t) 0)
1224 {
1225 /* Use mbstowcs directly for the default locale */
1226 result = mbstowcs(to, str, tolen);
1227 }
1228 else
1229 {
1230 /* Use mbstowcs_l for nondefault locales */
1231 result = mbstowcs_l(to, str, tolen, loc);
1232 }
1233
1234 pfree(str);
1235 }
1236
1237 if (result == -1)
1238 {
1239 /*
1240 * Invalid multibyte character encountered. We try to give a useful
1241 * error message by letting pg_verifymbstr check the string. But it's
1242 * possible that the string is OK to us, and not OK to mbstowcs ---
1243 * this suggests that the LC_CTYPE locale is different from the
1244 * database encoding. Give a generic error message if pg_verifymbstr
1245 * can't find anything wrong.
1246 */
1247 pg_verifymbstr(from, fromlen, false); /* might not return */
1248 /* but if it does ... */
1249 ereport(ERROR,
1250 (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
1251 errmsg("invalid multibyte character for locale"),
1252 errhint("The server's LC_CTYPE locale is probably incompatible with the database encoding.")));
1253 }
1254
1255 return result;
1256}
int errhint(const char *fmt,...)
Definition: elog.c:1321
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:150
Assert(PointerIsAligned(start, uint64))
const char * str
int GetDatabaseEncoding(void)
Definition: mbutils.c:1262
bool pg_verifymbstr(const char *mbstr, int len, bool noError)
Definition: mbutils.c:1557
void pfree(void *pointer)
Definition: mcxt.c:1594
char * pnstrdup(const char *in, Size len)
Definition: mcxt.c:1770
static size_t mbstowcs_l(wchar_t *dest, const char *src, size_t n, locale_t loc)
@ PG_UTF8
Definition: pg_wchar.h:232
#define locale_t
Definition: win32_port.h:432

References Assert(), ereport, errcode(), errhint(), errmsg(), ERROR, GetDatabaseEncoding(), locale_t, mbstowcs_l(), pfree(), PG_UTF8, pg_verifymbstr(), pnstrdup(), and str.

Referenced by strlower_libc_mb(), strtitle_libc_mb(), strupper_libc_mb(), t_isalnum(), t_isalpha(), and TParserInit().

◆ char_is_cased_libc()

static bool char_is_cased_libc ( char  ch,
pg_locale_t  locale 
)
static

Definition at line 237 of file pg_locale_libc.c.

238{
239 bool is_multibyte = pg_database_encoding_max_length() > 1;
240
241 if (is_multibyte && IS_HIGHBIT_SET(ch))
242 return true;
243 else
244 return isalpha_l((unsigned char) ch, locale->info.lt);
245}
#define IS_HIGHBIT_SET(ch)
Definition: c.h:1155
static char * locale
Definition: initdb.c:140
int pg_database_encoding_max_length(void)
Definition: mbutils.c:1547
#define isalpha_l
Definition: win32_port.h:439

References IS_HIGHBIT_SET, isalpha_l, locale, and pg_database_encoding_max_length().

◆ char_tolower_libc()

static char char_tolower_libc ( unsigned char  ch,
pg_locale_t  locale 
)
static

Definition at line 230 of file pg_locale_libc.c.

231{
233 return tolower_l(ch, locale->info.lt);
234}
#define tolower_l
Definition: win32_port.h:433

References Assert(), locale, pg_database_encoding_max_length(), and tolower_l.

◆ create_pg_locale_libc()

pg_locale_t create_pg_locale_libc ( Oid  collid,
MemoryContext  context 
)

Definition at line 669 of file pg_locale_libc.c.

670{
671 const char *collate;
672 const char *ctype;
673 locale_t loc;
674 pg_locale_t result;
675
676 if (collid == DEFAULT_COLLATION_OID)
677 {
678 HeapTuple tp;
679 Datum datum;
680
682 if (!HeapTupleIsValid(tp))
683 elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
684 datum = SysCacheGetAttrNotNull(DATABASEOID, tp,
685 Anum_pg_database_datcollate);
686 collate = TextDatumGetCString(datum);
687 datum = SysCacheGetAttrNotNull(DATABASEOID, tp,
688 Anum_pg_database_datctype);
689 ctype = TextDatumGetCString(datum);
690
691 ReleaseSysCache(tp);
692 }
693 else
694 {
695 HeapTuple tp;
696 Datum datum;
697
699 if (!HeapTupleIsValid(tp))
700 elog(ERROR, "cache lookup failed for collation %u", collid);
701
702 datum = SysCacheGetAttrNotNull(COLLOID, tp,
703 Anum_pg_collation_collcollate);
704 collate = TextDatumGetCString(datum);
705 datum = SysCacheGetAttrNotNull(COLLOID, tp,
706 Anum_pg_collation_collctype);
707 ctype = TextDatumGetCString(datum);
708
709 ReleaseSysCache(tp);
710 }
711
712
713 loc = make_libc_collator(collate, ctype);
714
715 result = MemoryContextAllocZero(context, sizeof(struct pg_locale_struct));
716 result->deterministic = true;
717 result->collate_is_c = (strcmp(collate, "C") == 0) ||
718 (strcmp(collate, "POSIX") == 0);
719 result->ctype_is_c = (strcmp(ctype, "C") == 0) ||
720 (strcmp(ctype, "POSIX") == 0);
721 result->info.lt = loc;
722 if (!result->collate_is_c)
723 {
724#ifdef WIN32
726 result->collate = &collate_methods_libc_win32_utf8;
727 else
728#endif
729 result->collate = &collate_methods_libc;
730 }
731 if (!result->ctype_is_c)
732 {
737 else
738 result->ctype = &ctype_methods_libc_sb;
739 }
740
741 return result;
742}
#define TextDatumGetCString(d)
Definition: builtins.h:98
Oid collid
#define elog(elevel,...)
Definition: elog.h:226
Oid MyDatabaseId
Definition: globals.c:94
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:81
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:1263
static const struct ctype_methods ctype_methods_libc_other_mb
static const struct ctype_methods ctype_methods_libc_utf8
static locale_t make_libc_collator(const char *collate, const char *ctype)
static const struct collate_methods collate_methods_libc
static const struct ctype_methods ctype_methods_libc_sb
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:262
uint64_t Datum
Definition: postgres.h:70
const struct ctype_methods * ctype
Definition: pg_locale.h:157
const struct collate_methods * collate
Definition: pg_locale.h:156
union pg_locale_struct::@162 info
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:264
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:220
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
Definition: syscache.c:625

References pg_locale_struct::collate, pg_locale_struct::collate_is_c, collate_methods_libc, collid, pg_locale_struct::ctype, pg_locale_struct::ctype_is_c, ctype_methods_libc_other_mb, ctype_methods_libc_sb, ctype_methods_libc_utf8, pg_locale_struct::deterministic, elog, ERROR, GetDatabaseEncoding(), HeapTupleIsValid, if(), pg_locale_struct::info, locale_t, pg_locale_struct::lt, make_libc_collator(), MemoryContextAllocZero(), MyDatabaseId, ObjectIdGetDatum(), pg_database_encoding_max_length(), PG_UTF8, ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttrNotNull(), and TextDatumGetCString.

Referenced by create_pg_locale(), and init_database_collation().

◆ get_collation_actual_version_libc()

char * get_collation_actual_version_libc ( const char *  collcollate)

Definition at line 911 of file pg_locale_libc.c.

912{
913 char *collversion = NULL;
914
915 if (pg_strcasecmp("C", collcollate) != 0 &&
916 pg_strncasecmp("C.", collcollate, 2) != 0 &&
917 pg_strcasecmp("POSIX", collcollate) != 0)
918 {
919#if defined(__GLIBC__)
920 /* Use the glibc version because we don't have anything better. */
921 collversion = pstrdup(gnu_get_libc_version());
922#elif defined(LC_VERSION_MASK)
923 locale_t loc;
924
925 /* Look up FreeBSD collation version. */
926 loc = newlocale(LC_COLLATE_MASK, collcollate, NULL);
927 if (loc)
928 {
929 collversion =
930 pstrdup(querylocale(LC_COLLATE_MASK | LC_VERSION_MASK, loc));
931 freelocale(loc);
932 }
933 else
935 (errmsg("could not load locale \"%s\"", collcollate)));
936#elif defined(WIN32)
937 /*
938 * If we are targeting Windows Vista and above, we can ask for a name
939 * given a collation name (earlier versions required a location code
940 * that we don't have).
941 */
942 NLSVERSIONINFOEX version = {sizeof(NLSVERSIONINFOEX)};
943 WCHAR wide_collcollate[LOCALE_NAME_MAX_LENGTH];
944
945 MultiByteToWideChar(CP_ACP, 0, collcollate, -1, wide_collcollate,
946 LOCALE_NAME_MAX_LENGTH);
947 if (!GetNLSVersionEx(COMPARE_STRING, wide_collcollate, &version))
948 {
949 /*
950 * GetNLSVersionEx() wants a language tag such as "en-US", not a
951 * locale name like "English_United States.1252". Until those
952 * values can be prevented from entering the system, or 100%
953 * reliably converted to the more useful tag format, tolerate the
954 * resulting error and report that we have no version data.
955 */
956 if (GetLastError() == ERROR_INVALID_PARAMETER)
957 return NULL;
958
960 (errmsg("could not get collation version for locale \"%s\": error code %lu",
961 collcollate,
962 GetLastError())));
963 }
964 collversion = psprintf("%lu.%lu,%lu.%lu",
965 (version.dwNLSVersion >> 8) & 0xFFFF,
966 version.dwNLSVersion & 0xFF,
967 (version.dwDefinedVersion >> 8) & 0xFFFF,
968 version.dwDefinedVersion & 0xFF);
969#endif
970 }
971
972 return collversion;
973}
char * pstrdup(const char *in)
Definition: mcxt.c:1759
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: pgstrcasecmp.c:69
char * psprintf(const char *fmt,...)
Definition: psprintf.c:43

References ereport, errmsg(), ERROR, locale_t, pg_strcasecmp(), pg_strncasecmp(), psprintf(), and pstrdup().

Referenced by get_collation_actual_version().

◆ make_libc_collator()

static locale_t make_libc_collator ( const char *  collate,
const char *  ctype 
)
static

Definition at line 753 of file pg_locale_libc.c.

754{
755 locale_t loc = 0;
756
757 if (strcmp(collate, ctype) == 0)
758 {
759 if (strcmp(ctype, "C") != 0 && strcmp(ctype, "POSIX") != 0)
760 {
761 /* Normal case where they're the same */
762 errno = 0;
763#ifndef WIN32
764 loc = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, collate,
765 NULL);
766#else
767 loc = _create_locale(LC_ALL, collate);
768#endif
769 if (!loc)
771 }
772 }
773 else
774 {
775#ifndef WIN32
776 /* We need two newlocale() steps */
777 locale_t loc1 = 0;
778
779 if (strcmp(collate, "C") != 0 && strcmp(collate, "POSIX") != 0)
780 {
781 errno = 0;
782 loc1 = newlocale(LC_COLLATE_MASK, collate, NULL);
783 if (!loc1)
785 }
786
787 if (strcmp(ctype, "C") != 0 && strcmp(ctype, "POSIX") != 0)
788 {
789 errno = 0;
790 loc = newlocale(LC_CTYPE_MASK, ctype, loc1);
791 if (!loc)
792 {
793 if (loc1)
794 freelocale(loc1);
796 }
797 }
798 else
799 loc = loc1;
800#else
801
802 /*
803 * XXX The _create_locale() API doesn't appear to support this. Could
804 * perhaps be worked around by changing pg_locale_t to contain two
805 * separate fields.
806 */
808 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
809 errmsg("collations with different collate and ctype values are not supported on this platform")));
810#endif
811 }
812
813 return loc;
814}
void report_newlocale_failure(const char *localename)

References ereport, errcode(), errmsg(), ERROR, locale_t, and report_newlocale_failure().

Referenced by create_pg_locale_libc().

◆ mbstowcs_l()

static size_t mbstowcs_l ( wchar_t *  dest,
const char *  src,
size_t  n,
locale_t  loc 
)
static

Definition at line 1089 of file pg_locale_libc.c.

1090{
1091#ifdef WIN32
1092 return _mbstowcs_l(dest, src, n, loc);
1093#else
1094 size_t result;
1095 locale_t save_locale = uselocale(loc);
1096
1097 result = mbstowcs(dest, src, n);
1098 uselocale(save_locale);
1099 return result;
1100#endif
1101}

References generate_unaccent_rules::dest, and locale_t.

Referenced by char2wchar().

◆ report_newlocale_failure()

void report_newlocale_failure ( const char *  localename)

Definition at line 1055 of file pg_locale_libc.c.

1056{
1057 int save_errno;
1058
1059 /*
1060 * Windows doesn't provide any useful error indication from
1061 * _create_locale(), and BSD-derived platforms don't seem to feel they
1062 * need to set errno either (even though POSIX is pretty clear that
1063 * newlocale should do so). So, if errno hasn't been set, assume ENOENT
1064 * is what to report.
1065 */
1066 if (errno == 0)
1067 errno = ENOENT;
1068
1069 /*
1070 * ENOENT means "no such locale", not "no such file", so clarify that
1071 * errno with an errdetail message.
1072 */
1073 save_errno = errno; /* auxiliary funcs might change errno */
1074 ereport(ERROR,
1075 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1076 errmsg("could not create locale \"%s\": %m",
1077 localename),
1078 (save_errno == ENOENT ?
1079 errdetail("The operating system could not find any locale data for the locale name \"%s\".",
1080 localename) : 0)));
1081}
int errdetail(const char *fmt,...)
Definition: elog.c:1207

References ereport, errcode(), errdetail(), errmsg(), and ERROR.

Referenced by cache_locale_time(), and make_libc_collator().

◆ strlower_libc_mb()

static size_t strlower_libc_mb ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)
static

Definition at line 438 of file pg_locale_libc.c.

440{
441 locale_t loc = locale->info.lt;
442 size_t result_size;
443 wchar_t *workspace;
444 char *result;
445 size_t curr_char;
446 size_t max_size;
447
448 if (srclen < 0)
449 srclen = strlen(src);
450
451 /* Overflow paranoia */
452 if ((srclen + 1) > (INT_MAX / sizeof(wchar_t)))
454 (errcode(ERRCODE_OUT_OF_MEMORY),
455 errmsg("out of memory")));
456
457 /* Output workspace cannot have more codes than input bytes */
458 workspace = (wchar_t *) palloc((srclen + 1) * sizeof(wchar_t));
459
460 char2wchar(workspace, srclen + 1, src, srclen, loc);
461
462 for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
463 workspace[curr_char] = towlower_l(workspace[curr_char], loc);
464
465 /*
466 * Make result large enough; case change might change number of bytes
467 */
468 max_size = curr_char * pg_database_encoding_max_length();
469 result = palloc(max_size + 1);
470
471 result_size = wchar2char(result, workspace, max_size + 1, loc);
472
473 if (result_size + 1 > destsize)
474 return result_size;
475
476 memcpy(dest, result, result_size);
477 dest[result_size] = '\0';
478
479 pfree(workspace);
480 pfree(result);
481
482 return result_size;
483}
void * palloc(Size size)
Definition: mcxt.c:1365
size_t wchar2char(char *to, const wchar_t *from, size_t tolen, locale_t loc)
size_t char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, locale_t loc)
#define towlower_l
Definition: win32_port.h:435

References char2wchar(), generate_unaccent_rules::dest, ereport, errcode(), errmsg(), ERROR, locale, locale_t, palloc(), pfree(), pg_database_encoding_max_length(), towlower_l, and wchar2char().

◆ strlower_libc_sb()

static size_t strlower_libc_sb ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)
static

Definition at line 401 of file pg_locale_libc.c.

403{
404 if (srclen < 0)
405 srclen = strlen(src);
406
407 if (srclen + 1 <= destsize)
408 {
409 locale_t loc = locale->info.lt;
410 char *p;
411
412 if (srclen + 1 > destsize)
413 return srclen;
414
415 memcpy(dest, src, srclen);
416 dest[srclen] = '\0';
417
418 /*
419 * Note: we assume that tolower_l() will not be so broken as to need
420 * an isupper_l() guard test. When using the default collation, we
421 * apply the traditional Postgres behavior that forces ASCII-style
422 * treatment of I/i, but in non-default collations you get exactly
423 * what the collation says.
424 */
425 for (p = dest; *p; p++)
426 {
427 if (locale->is_default)
428 *p = pg_tolower((unsigned char) *p);
429 else
430 *p = tolower_l((unsigned char) *p, loc);
431 }
432 }
433
434 return srclen;
435}
unsigned char pg_tolower(unsigned char ch)
Definition: pgstrcasecmp.c:122

References generate_unaccent_rules::dest, locale, locale_t, pg_tolower(), and tolower_l.

◆ strncoll_libc()

int strncoll_libc ( const char *  arg1,
ssize_t  len1,
const char *  arg2,
ssize_t  len2,
pg_locale_t  locale 
)
static

Definition at line 824 of file pg_locale_libc.c.

826{
827 char sbuf[TEXTBUFLEN];
828 char *buf = sbuf;
829 size_t bufsize1 = (len1 == -1) ? 0 : len1 + 1;
830 size_t bufsize2 = (len2 == -1) ? 0 : len2 + 1;
831 const char *arg1n;
832 const char *arg2n;
833 int result;
834
835 if (bufsize1 + bufsize2 > TEXTBUFLEN)
836 buf = palloc(bufsize1 + bufsize2);
837
838 /* nul-terminate arguments if necessary */
839 if (len1 == -1)
840 {
841 arg1n = arg1;
842 }
843 else
844 {
845 char *buf1 = buf;
846
847 memcpy(buf1, arg1, len1);
848 buf1[len1] = '\0';
849 arg1n = buf1;
850 }
851
852 if (len2 == -1)
853 {
854 arg2n = arg2;
855 }
856 else
857 {
858 char *buf2 = buf + bufsize1;
859
860 memcpy(buf2, arg2, len2);
861 buf2[len2] = '\0';
862 arg2n = buf2;
863 }
864
865 result = strcoll_l(arg1n, arg2n, locale->info.lt);
866
867 if (buf != sbuf)
868 pfree(buf);
869
870 return result;
871}
#define TEXTBUFLEN
static char * buf
Definition: pg_test_fsync.c:72
#define strcoll_l
Definition: win32_port.h:455

References buf, locale, palloc(), pfree(), strcoll_l, and TEXTBUFLEN.

◆ strnxfrm_libc()

size_t strnxfrm_libc ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)
static

Definition at line 881 of file pg_locale_libc.c.

883{
884 char sbuf[TEXTBUFLEN];
885 char *buf = sbuf;
886 size_t bufsize = srclen + 1;
887 size_t result;
888
889 if (srclen == -1)
890 return strxfrm_l(dest, src, destsize, locale->info.lt);
891
892 if (bufsize > TEXTBUFLEN)
893 buf = palloc(bufsize);
894
895 /* nul-terminate argument */
896 memcpy(buf, src, srclen);
897 buf[srclen] = '\0';
898
899 result = strxfrm_l(dest, buf, destsize, locale->info.lt);
900
901 if (buf != sbuf)
902 pfree(buf);
903
904 /* if dest is defined, it should be nul-terminated */
905 Assert(result >= destsize || dest[result] == '\0');
906
907 return result;
908}
#define bufsize
Definition: indent_globs.h:36
#define strxfrm_l
Definition: win32_port.h:456

References Assert(), buf, bufsize, generate_unaccent_rules::dest, locale, palloc(), pfree(), strxfrm_l, and TEXTBUFLEN.

◆ strtitle_libc_mb()

static size_t strtitle_libc_mb ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)
static

Definition at line 532 of file pg_locale_libc.c.

534{
535 locale_t loc = locale->info.lt;
536 int wasalnum = false;
537 size_t result_size;
538 wchar_t *workspace;
539 char *result;
540 size_t curr_char;
541 size_t max_size;
542
543 if (srclen < 0)
544 srclen = strlen(src);
545
546 /* Overflow paranoia */
547 if ((srclen + 1) > (INT_MAX / sizeof(wchar_t)))
549 (errcode(ERRCODE_OUT_OF_MEMORY),
550 errmsg("out of memory")));
551
552 /* Output workspace cannot have more codes than input bytes */
553 workspace = (wchar_t *) palloc((srclen + 1) * sizeof(wchar_t));
554
555 char2wchar(workspace, srclen + 1, src, srclen, loc);
556
557 for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
558 {
559 if (wasalnum)
560 workspace[curr_char] = towlower_l(workspace[curr_char], loc);
561 else
562 workspace[curr_char] = towupper_l(workspace[curr_char], loc);
563 wasalnum = iswalnum_l(workspace[curr_char], loc);
564 }
565
566 /*
567 * Make result large enough; case change might change number of bytes
568 */
569 max_size = curr_char * pg_database_encoding_max_length();
570 result = palloc(max_size + 1);
571
572 result_size = wchar2char(result, workspace, max_size + 1, loc);
573
574 if (result_size + 1 > destsize)
575 return result_size;
576
577 memcpy(dest, result, result_size);
578 dest[result_size] = '\0';
579
580 pfree(workspace);
581 pfree(result);
582
583 return result_size;
584}
#define iswalnum_l
Definition: win32_port.h:442
#define towupper_l
Definition: win32_port.h:436

References char2wchar(), generate_unaccent_rules::dest, ereport, errcode(), errmsg(), ERROR, iswalnum_l, locale, locale_t, palloc(), pfree(), pg_database_encoding_max_length(), towlower_l, towupper_l, and wchar2char().

◆ strtitle_libc_sb()

static size_t strtitle_libc_sb ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)
static

Definition at line 486 of file pg_locale_libc.c.

488{
489 if (srclen < 0)
490 srclen = strlen(src);
491
492 if (srclen + 1 <= destsize)
493 {
494 locale_t loc = locale->info.lt;
495 int wasalnum = false;
496 char *p;
497
498 memcpy(dest, src, srclen);
499 dest[srclen] = '\0';
500
501 /*
502 * Note: we assume that toupper_l()/tolower_l() will not be so broken
503 * as to need guard tests. When using the default collation, we apply
504 * the traditional Postgres behavior that forces ASCII-style treatment
505 * of I/i, but in non-default collations you get exactly what the
506 * collation says.
507 */
508 for (p = dest; *p; p++)
509 {
510 if (locale->is_default)
511 {
512 if (wasalnum)
513 *p = pg_tolower((unsigned char) *p);
514 else
515 *p = pg_toupper((unsigned char) *p);
516 }
517 else
518 {
519 if (wasalnum)
520 *p = tolower_l((unsigned char) *p, loc);
521 else
522 *p = toupper_l((unsigned char) *p, loc);
523 }
524 wasalnum = isalnum_l((unsigned char) *p, loc);
525 }
526 }
527
528 return srclen;
529}
unsigned char pg_toupper(unsigned char ch)
Definition: pgstrcasecmp.c:105
#define toupper_l
Definition: win32_port.h:434
#define isalnum_l
Definition: win32_port.h:441

References generate_unaccent_rules::dest, isalnum_l, locale, locale_t, pg_tolower(), pg_toupper(), tolower_l, and toupper_l.

◆ strupper_libc_mb()

static size_t strupper_libc_mb ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)
static

Definition at line 621 of file pg_locale_libc.c.

623{
624 locale_t loc = locale->info.lt;
625 size_t result_size;
626 wchar_t *workspace;
627 char *result;
628 size_t curr_char;
629 size_t max_size;
630
631 if (srclen < 0)
632 srclen = strlen(src);
633
634 /* Overflow paranoia */
635 if ((srclen + 1) > (INT_MAX / sizeof(wchar_t)))
637 (errcode(ERRCODE_OUT_OF_MEMORY),
638 errmsg("out of memory")));
639
640 /* Output workspace cannot have more codes than input bytes */
641 workspace = (wchar_t *) palloc((srclen + 1) * sizeof(wchar_t));
642
643 char2wchar(workspace, srclen + 1, src, srclen, loc);
644
645 for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
646 workspace[curr_char] = towupper_l(workspace[curr_char], loc);
647
648 /*
649 * Make result large enough; case change might change number of bytes
650 */
651 max_size = curr_char * pg_database_encoding_max_length();
652 result = palloc(max_size + 1);
653
654 result_size = wchar2char(result, workspace, max_size + 1, loc);
655
656 if (result_size + 1 > destsize)
657 return result_size;
658
659 memcpy(dest, result, result_size);
660 dest[result_size] = '\0';
661
662 pfree(workspace);
663 pfree(result);
664
665 return result_size;
666}

References char2wchar(), generate_unaccent_rules::dest, ereport, errcode(), errmsg(), ERROR, locale, locale_t, palloc(), pfree(), pg_database_encoding_max_length(), towupper_l, and wchar2char().

◆ strupper_libc_sb()

static size_t strupper_libc_sb ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)
static

Definition at line 587 of file pg_locale_libc.c.

589{
590 if (srclen < 0)
591 srclen = strlen(src);
592
593 if (srclen + 1 <= destsize)
594 {
595 locale_t loc = locale->info.lt;
596 char *p;
597
598 memcpy(dest, src, srclen);
599 dest[srclen] = '\0';
600
601 /*
602 * Note: we assume that toupper_l() will not be so broken as to need
603 * an islower_l() guard test. When using the default collation, we
604 * apply the traditional Postgres behavior that forces ASCII-style
605 * treatment of I/i, but in non-default collations you get exactly
606 * what the collation says.
607 */
608 for (p = dest; *p; p++)
609 {
610 if (locale->is_default)
611 *p = pg_toupper((unsigned char) *p);
612 else
613 *p = toupper_l((unsigned char) *p, loc);
614 }
615 }
616
617 return srclen;
618}

References generate_unaccent_rules::dest, locale, locale_t, pg_toupper(), and toupper_l.

◆ tolower_libc_mb()

static pg_wchar tolower_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 290 of file pg_locale_libc.c.

291{
293
294 /* force C behavior for ASCII characters, per comments above */
295 if (locale->is_default && wc <= (pg_wchar) 127)
296 return pg_ascii_tolower((unsigned char) wc);
297 if (sizeof(wchar_t) >= 4 || wc <= (pg_wchar) 0xFFFF)
298 return towlower_l((wint_t) wc, locale->info.lt);
299 else
300 return wc;
301}
unsigned int pg_wchar
Definition: mbprint.c:31
unsigned char pg_ascii_tolower(unsigned char ch)
Definition: pgstrcasecmp.c:146

References Assert(), GetDatabaseEncoding(), locale, pg_ascii_tolower(), PG_UTF8, and towlower_l.

◆ tolower_libc_sb()

static pg_wchar tolower_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 276 of file pg_locale_libc.c.

277{
279
280 /* force C behavior for ASCII characters, per comments above */
281 if (locale->is_default && wc <= (pg_wchar) 127)
282 return pg_ascii_tolower((unsigned char) wc);
283 if (wc <= (pg_wchar) UCHAR_MAX)
284 return tolower_l((unsigned char) wc, locale->info.lt);
285 else
286 return wc;
287}

References Assert(), GetDatabaseEncoding(), locale, pg_ascii_tolower(), PG_UTF8, and tolower_l.

◆ toupper_libc_mb()

static pg_wchar toupper_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 262 of file pg_locale_libc.c.

263{
265
266 /* force C behavior for ASCII characters, per comments above */
267 if (locale->is_default && wc <= (pg_wchar) 127)
268 return pg_ascii_toupper((unsigned char) wc);
269 if (sizeof(wchar_t) >= 4 || wc <= (pg_wchar) 0xFFFF)
270 return towupper_l((wint_t) wc, locale->info.lt);
271 else
272 return wc;
273}
unsigned char pg_ascii_toupper(unsigned char ch)
Definition: pgstrcasecmp.c:135

References Assert(), GetDatabaseEncoding(), locale, pg_ascii_toupper(), PG_UTF8, and towupper_l.

◆ toupper_libc_sb()

static pg_wchar toupper_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 248 of file pg_locale_libc.c.

249{
251
252 /* force C behavior for ASCII characters, per comments above */
253 if (locale->is_default && wc <= (pg_wchar) 127)
254 return pg_ascii_toupper((unsigned char) wc);
255 if (wc <= (pg_wchar) UCHAR_MAX)
256 return toupper_l((unsigned char) wc, locale->info.lt);
257 else
258 return wc;
259}

References Assert(), GetDatabaseEncoding(), locale, pg_ascii_toupper(), PG_UTF8, and toupper_l.

◆ wc_isalnum_libc_mb()

static bool wc_isalnum_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 188 of file pg_locale_libc.c.

189{
190 return iswalnum_l((wint_t) wc, locale->info.lt);
191}

References iswalnum_l, and locale.

◆ wc_isalnum_libc_sb()

static bool wc_isalnum_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 134 of file pg_locale_libc.c.

135{
136 return isalnum_l((unsigned char) wc, locale->info.lt);
137}

References isalnum_l, and locale.

◆ wc_isalpha_libc_mb()

static bool wc_isalpha_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 182 of file pg_locale_libc.c.

183{
184 return iswalpha_l((wint_t) wc, locale->info.lt);
185}
#define iswalpha_l
Definition: win32_port.h:440

References iswalpha_l, and locale.

◆ wc_isalpha_libc_sb()

static bool wc_isalpha_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 128 of file pg_locale_libc.c.

129{
130 return isalpha_l((unsigned char) wc, locale->info.lt);
131}

References isalpha_l, and locale.

◆ wc_isdigit_libc_mb()

static bool wc_isdigit_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 176 of file pg_locale_libc.c.

177{
178 return iswdigit_l((wint_t) wc, locale->info.lt);
179}
#define iswdigit_l
Definition: win32_port.h:438

References iswdigit_l, and locale.

◆ wc_isdigit_libc_sb()

static bool wc_isdigit_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 122 of file pg_locale_libc.c.

123{
124 return isdigit_l((unsigned char) wc, locale->info.lt);
125}
#define isdigit_l
Definition: win32_port.h:437

References isdigit_l, and locale.

◆ wc_isgraph_libc_mb()

static bool wc_isgraph_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 206 of file pg_locale_libc.c.

207{
208 return iswgraph_l((wint_t) wc, locale->info.lt);
209}
#define iswgraph_l
Definition: win32_port.h:448

References iswgraph_l, and locale.

◆ wc_isgraph_libc_sb()

static bool wc_isgraph_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 152 of file pg_locale_libc.c.

153{
154 return isgraph_l((unsigned char) wc, locale->info.lt);
155}
#define isgraph_l
Definition: win32_port.h:447

References isgraph_l, and locale.

◆ wc_islower_libc_mb()

static bool wc_islower_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 200 of file pg_locale_libc.c.

201{
202 return iswlower_l((wint_t) wc, locale->info.lt);
203}
#define iswlower_l
Definition: win32_port.h:446

References iswlower_l, and locale.

◆ wc_islower_libc_sb()

static bool wc_islower_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 146 of file pg_locale_libc.c.

147{
148 return islower_l((unsigned char) wc, locale->info.lt);
149}
#define islower_l
Definition: win32_port.h:445

References islower_l, and locale.

◆ wc_isprint_libc_mb()

static bool wc_isprint_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 212 of file pg_locale_libc.c.

213{
214 return iswprint_l((wint_t) wc, locale->info.lt);
215}
#define iswprint_l
Definition: win32_port.h:450

References iswprint_l, and locale.

◆ wc_isprint_libc_sb()

static bool wc_isprint_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 158 of file pg_locale_libc.c.

159{
160 return isprint_l((unsigned char) wc, locale->info.lt);
161}
#define isprint_l
Definition: win32_port.h:449

References isprint_l, and locale.

◆ wc_ispunct_libc_mb()

static bool wc_ispunct_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 218 of file pg_locale_libc.c.

219{
220 return iswpunct_l((wint_t) wc, locale->info.lt);
221}
#define iswpunct_l
Definition: win32_port.h:452

References iswpunct_l, and locale.

◆ wc_ispunct_libc_sb()

static bool wc_ispunct_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 164 of file pg_locale_libc.c.

165{
166 return ispunct_l((unsigned char) wc, locale->info.lt);
167}
#define ispunct_l
Definition: win32_port.h:451

References ispunct_l, and locale.

◆ wc_isspace_libc_mb()

static bool wc_isspace_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 224 of file pg_locale_libc.c.

225{
226 return iswspace_l((wint_t) wc, locale->info.lt);
227}
#define iswspace_l
Definition: win32_port.h:454

References iswspace_l, and locale.

◆ wc_isspace_libc_sb()

static bool wc_isspace_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 170 of file pg_locale_libc.c.

171{
172 return isspace_l((unsigned char) wc, locale->info.lt);
173}
#define isspace_l
Definition: win32_port.h:453

References isspace_l, and locale.

◆ wc_isupper_libc_mb()

static bool wc_isupper_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 194 of file pg_locale_libc.c.

195{
196 return iswupper_l((wint_t) wc, locale->info.lt);
197}
#define iswupper_l
Definition: win32_port.h:444

References iswupper_l, and locale.

◆ wc_isupper_libc_sb()

static bool wc_isupper_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 140 of file pg_locale_libc.c.

141{
142 return isupper_l((unsigned char) wc, locale->info.lt);
143}
#define isupper_l
Definition: win32_port.h:443

References isupper_l, and locale.

◆ wchar2char()

size_t wchar2char ( char *  to,
const wchar_t *  from,
size_t  tolen,
locale_t  loc 
)

Definition at line 1133 of file pg_locale_libc.c.

1134{
1135 size_t result;
1136
1137 if (tolen == 0)
1138 return 0;
1139
1140#ifdef WIN32
1141
1142 /*
1143 * On Windows, the "Unicode" locales assume UTF16 not UTF8 encoding, and
1144 * for some reason mbstowcs and wcstombs won't do this for us, so we use
1145 * MultiByteToWideChar().
1146 */
1148 {
1149 result = WideCharToMultiByte(CP_UTF8, 0, from, -1, to, tolen,
1150 NULL, NULL);
1151 /* A zero return is failure */
1152 if (result <= 0)
1153 result = -1;
1154 else
1155 {
1156 Assert(result <= tolen);
1157 /* Microsoft counts the zero terminator in the result */
1158 result--;
1159 }
1160 }
1161 else
1162#endif /* WIN32 */
1163 if (loc == (locale_t) 0)
1164 {
1165 /* Use wcstombs directly for the default locale */
1166 result = wcstombs(to, from, tolen);
1167 }
1168 else
1169 {
1170 /* Use wcstombs_l for nondefault locales */
1171 result = wcstombs_l(to, from, tolen, loc);
1172 }
1173
1174 return result;
1175}
static size_t wcstombs_l(char *dest, const wchar_t *src, size_t n, locale_t loc)

References Assert(), GetDatabaseEncoding(), locale_t, PG_UTF8, and wcstombs_l().

Referenced by strlower_libc_mb(), strtitle_libc_mb(), and strupper_libc_mb().

◆ wcstombs_l()

static size_t wcstombs_l ( char *  dest,
const wchar_t *  src,
size_t  n,
locale_t  loc 
)
static

Definition at line 1105 of file pg_locale_libc.c.

1106{
1107#ifdef WIN32
1108 return _wcstombs_l(dest, src, n, loc);
1109#else
1110 size_t result;
1111 locale_t save_locale = uselocale(loc);
1112
1113 result = wcstombs(dest, src, n);
1114 uselocale(save_locale);
1115 return result;
1116#endif
1117}

References generate_unaccent_rules::dest, and locale_t.

Referenced by wchar2char().

Variable Documentation

◆ collate_methods_libc

const struct collate_methods collate_methods_libc
static
Initial value:
= {
.strncoll = strncoll_libc,
.strnxfrm = strnxfrm_libc,
.strnxfrm_prefix = NULL,
.strxfrm_is_safe = false,
}
static int strncoll_libc(const char *arg1, ssize_t len1, const char *arg2, ssize_t len2, pg_locale_t locale)
static size_t strnxfrm_libc(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)

Definition at line 366 of file pg_locale_libc.c.

Referenced by create_pg_locale_libc().

◆ ctype_methods_libc_other_mb

const struct ctype_methods ctype_methods_libc_other_mb
static
Initial value:
= {
.strlower = strlower_libc_mb,
.strtitle = strtitle_libc_mb,
.strupper = strupper_libc_mb,
.wc_isdigit = wc_isdigit_libc_sb,
.wc_isalpha = wc_isalpha_libc_sb,
.wc_isalnum = wc_isalnum_libc_sb,
.wc_isupper = wc_isupper_libc_sb,
.wc_islower = wc_islower_libc_sb,
.wc_isgraph = wc_isgraph_libc_sb,
.wc_isprint = wc_isprint_libc_sb,
.wc_ispunct = wc_ispunct_libc_sb,
.wc_isspace = wc_isspace_libc_sb,
.char_is_cased = char_is_cased_libc,
.char_tolower = char_tolower_libc,
.wc_toupper = toupper_libc_sb,
.wc_tolower = tolower_libc_sb,
.max_chr = UCHAR_MAX,
}
static size_t strtitle_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static bool wc_ispunct_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isdigit_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isspace_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_islower_libc_sb(pg_wchar wc, pg_locale_t locale)
static pg_wchar toupper_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isalnum_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isalpha_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isprint_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isupper_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isgraph_libc_sb(pg_wchar wc, pg_locale_t locale)
static pg_wchar tolower_libc_sb(pg_wchar wc, pg_locale_t locale)
static size_t strupper_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static char char_tolower_libc(unsigned char ch, pg_locale_t locale)
static bool char_is_cased_libc(char ch, pg_locale_t locale)
static size_t strlower_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)

Definition at line 327 of file pg_locale_libc.c.

Referenced by create_pg_locale_libc().

◆ ctype_methods_libc_sb

const struct ctype_methods ctype_methods_libc_sb
static
Initial value:
= {
.strlower = strlower_libc_sb,
.strtitle = strtitle_libc_sb,
.strupper = strupper_libc_sb,
.wc_isdigit = wc_isdigit_libc_sb,
.wc_isalpha = wc_isalpha_libc_sb,
.wc_isalnum = wc_isalnum_libc_sb,
.wc_isupper = wc_isupper_libc_sb,
.wc_islower = wc_islower_libc_sb,
.wc_isgraph = wc_isgraph_libc_sb,
.wc_isprint = wc_isprint_libc_sb,
.wc_ispunct = wc_ispunct_libc_sb,
.wc_isspace = wc_isspace_libc_sb,
.char_is_cased = char_is_cased_libc,
.char_tolower = char_tolower_libc,
.wc_toupper = toupper_libc_sb,
.wc_tolower = tolower_libc_sb,
.max_chr = UCHAR_MAX,
}
static size_t strupper_libc_sb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static size_t strlower_libc_sb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static size_t strtitle_libc_sb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)

Definition at line 303 of file pg_locale_libc.c.

Referenced by create_pg_locale_libc().

◆ ctype_methods_libc_utf8

const struct ctype_methods ctype_methods_libc_utf8
static
Initial value:
= {
.strlower = strlower_libc_mb,
.strtitle = strtitle_libc_mb,
.strupper = strupper_libc_mb,
.wc_isdigit = wc_isdigit_libc_mb,
.wc_isalpha = wc_isalpha_libc_mb,
.wc_isalnum = wc_isalnum_libc_mb,
.wc_isupper = wc_isupper_libc_mb,
.wc_islower = wc_islower_libc_mb,
.wc_isgraph = wc_isgraph_libc_mb,
.wc_isprint = wc_isprint_libc_mb,
.wc_ispunct = wc_ispunct_libc_mb,
.wc_isspace = wc_isspace_libc_mb,
.char_is_cased = char_is_cased_libc,
.char_tolower = char_tolower_libc,
.wc_toupper = toupper_libc_mb,
.wc_tolower = tolower_libc_mb,
}
static bool wc_isalpha_libc_mb(pg_wchar wc, pg_locale_t locale)
static pg_wchar toupper_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isprint_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isupper_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isgraph_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isalnum_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_ispunct_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_islower_libc_mb(pg_wchar wc, pg_locale_t locale)
static pg_wchar tolower_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isdigit_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isspace_libc_mb(pg_wchar wc, pg_locale_t locale)

Definition at line 347 of file pg_locale_libc.c.

Referenced by create_pg_locale_libc().