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 char2wchar (wchar_t *to, size_t tolen, const char *from, size_t fromlen, locale_t loc)
 
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_isxdigit_libc_sb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_iscased_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 bool wc_isxdigit_libc_mb (pg_wchar wc, pg_locale_t locale)
 
static bool wc_iscased_libc_mb (pg_wchar wc, 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)
 

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 81 of file pg_locale_libc.c.

Function Documentation

◆ char2wchar()

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

Definition at line 1240 of file pg_locale_libc.c.

1242{
1243 size_t result;
1244
1245 if (tolen == 0)
1246 return 0;
1247
1248#ifdef WIN32
1249 /* See WIN32 "Unicode" comment above */
1251 {
1252 /* Win32 API does not work for zero-length input */
1253 if (fromlen == 0)
1254 result = 0;
1255 else
1256 {
1257 result = MultiByteToWideChar(CP_UTF8, 0, from, fromlen, to, tolen - 1);
1258 /* A zero return is failure */
1259 if (result == 0)
1260 result = -1;
1261 }
1262
1263 if (result != -1)
1264 {
1265 Assert(result < tolen);
1266 /* Append trailing null wchar (MultiByteToWideChar() does not) */
1267 to[result] = 0;
1268 }
1269 }
1270 else
1271#endif /* WIN32 */
1272 {
1273 /* mbstowcs requires ending '\0' */
1274 char *str = pnstrdup(from, fromlen);
1275
1276 if (loc == (locale_t) 0)
1277 {
1278 /* Use mbstowcs directly for the default locale */
1279 result = mbstowcs(to, str, tolen);
1280 }
1281 else
1282 {
1283 /* Use mbstowcs_l for nondefault locales */
1284 result = mbstowcs_l(to, str, tolen, loc);
1285 }
1286
1287 pfree(str);
1288 }
1289
1290 if (result == -1)
1291 {
1292 /*
1293 * Invalid multibyte character encountered. We try to give a useful
1294 * error message by letting pg_verifymbstr check the string. But it's
1295 * possible that the string is OK to us, and not OK to mbstowcs ---
1296 * this suggests that the LC_CTYPE locale is different from the
1297 * database encoding. Give a generic error message if pg_verifymbstr
1298 * can't find anything wrong.
1299 */
1300 pg_verifymbstr(from, fromlen, false); /* might not return */
1301 /* but if it does ... */
1302 ereport(ERROR,
1303 (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
1304 errmsg("invalid multibyte character for locale"),
1305 errhint("The server's LC_CTYPE locale is probably incompatible with the database encoding.")));
1306 }
1307
1308 return result;
1309}
int errhint(const char *fmt,...)
Definition: elog.c:1330
int errcode(int sqlerrcode)
Definition: elog.c:863
int errmsg(const char *fmt,...)
Definition: elog.c:1080
#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:1264
bool pg_verifymbstr(const char *mbstr, int len, bool noError)
Definition: mbutils.c:1559
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:429

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(), and strupper_libc_mb().

◆ char_is_cased_libc()

static bool char_is_cased_libc ( char  ch,
pg_locale_t  locale 
)
static

Definition at line 266 of file pg_locale_libc.c.

267{
268 bool is_multibyte = pg_database_encoding_max_length() > 1;
269
270 if (is_multibyte && IS_HIGHBIT_SET(ch))
271 return true;
272 else
273 return isalpha_l((unsigned char) ch, locale->lt);
274}
#define IS_HIGHBIT_SET(ch)
Definition: c.h:1153
static char * locale
Definition: initdb.c:140
int pg_database_encoding_max_length(void)
Definition: mbutils.c:1549
#define isalpha_l
Definition: win32_port.h:436

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

◆ create_pg_locale_libc()

pg_locale_t create_pg_locale_libc ( Oid  collid,
MemoryContext  context 
)

Definition at line 722 of file pg_locale_libc.c.

723{
724 const char *collate;
725 const char *ctype;
726 locale_t loc;
727 pg_locale_t result;
728
729 if (collid == DEFAULT_COLLATION_OID)
730 {
731 HeapTuple tp;
732 Datum datum;
733
735 if (!HeapTupleIsValid(tp))
736 elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
737 datum = SysCacheGetAttrNotNull(DATABASEOID, tp,
738 Anum_pg_database_datcollate);
739 collate = TextDatumGetCString(datum);
740 datum = SysCacheGetAttrNotNull(DATABASEOID, tp,
741 Anum_pg_database_datctype);
742 ctype = TextDatumGetCString(datum);
743
744 ReleaseSysCache(tp);
745 }
746 else
747 {
748 HeapTuple tp;
749 Datum datum;
750
752 if (!HeapTupleIsValid(tp))
753 elog(ERROR, "cache lookup failed for collation %u", collid);
754
755 datum = SysCacheGetAttrNotNull(COLLOID, tp,
756 Anum_pg_collation_collcollate);
757 collate = TextDatumGetCString(datum);
758 datum = SysCacheGetAttrNotNull(COLLOID, tp,
759 Anum_pg_collation_collctype);
760 ctype = TextDatumGetCString(datum);
761
762 ReleaseSysCache(tp);
763 }
764
765
766 loc = make_libc_collator(collate, ctype);
767
768 result = MemoryContextAllocZero(context, sizeof(struct pg_locale_struct));
769 result->deterministic = true;
770 result->collate_is_c = (strcmp(collate, "C") == 0) ||
771 (strcmp(collate, "POSIX") == 0);
772 result->ctype_is_c = (strcmp(ctype, "C") == 0) ||
773 (strcmp(ctype, "POSIX") == 0);
774 result->lt = loc;
775 if (!result->collate_is_c)
776 {
777#ifdef WIN32
779 result->collate = &collate_methods_libc_win32_utf8;
780 else
781#endif
782 result->collate = &collate_methods_libc;
783 }
784 if (!result->ctype_is_c)
785 {
790 else
791 result->ctype = &ctype_methods_libc_sb;
792 }
793
794 return result;
795}
#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:155
const struct collate_methods * collate
Definition: pg_locale.h:154
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(), 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 964 of file pg_locale_libc.c.

965{
966 char *collversion = NULL;
967
968 if (pg_strcasecmp("C", collcollate) != 0 &&
969 pg_strncasecmp("C.", collcollate, 2) != 0 &&
970 pg_strcasecmp("POSIX", collcollate) != 0)
971 {
972#if defined(__GLIBC__)
973 /* Use the glibc version because we don't have anything better. */
974 collversion = pstrdup(gnu_get_libc_version());
975#elif defined(LC_VERSION_MASK)
976 locale_t loc;
977
978 /* Look up FreeBSD collation version. */
979 loc = newlocale(LC_COLLATE_MASK, collcollate, NULL);
980 if (loc)
981 {
982 collversion =
983 pstrdup(querylocale(LC_COLLATE_MASK | LC_VERSION_MASK, loc));
984 freelocale(loc);
985 }
986 else
988 (errmsg("could not load locale \"%s\"", collcollate)));
989#elif defined(WIN32)
990 /*
991 * If we are targeting Windows Vista and above, we can ask for a name
992 * given a collation name (earlier versions required a location code
993 * that we don't have).
994 */
995 NLSVERSIONINFOEX version = {sizeof(NLSVERSIONINFOEX)};
996 WCHAR wide_collcollate[LOCALE_NAME_MAX_LENGTH];
997
998 MultiByteToWideChar(CP_ACP, 0, collcollate, -1, wide_collcollate,
999 LOCALE_NAME_MAX_LENGTH);
1000 if (!GetNLSVersionEx(COMPARE_STRING, wide_collcollate, &version))
1001 {
1002 /*
1003 * GetNLSVersionEx() wants a language tag such as "en-US", not a
1004 * locale name like "English_United States.1252". Until those
1005 * values can be prevented from entering the system, or 100%
1006 * reliably converted to the more useful tag format, tolerate the
1007 * resulting error and report that we have no version data.
1008 */
1009 if (GetLastError() == ERROR_INVALID_PARAMETER)
1010 return NULL;
1011
1012 ereport(ERROR,
1013 (errmsg("could not get collation version for locale \"%s\": error code %lu",
1014 collcollate,
1015 GetLastError())));
1016 }
1017 collversion = psprintf("%lu.%lu,%lu.%lu",
1018 (version.dwNLSVersion >> 8) & 0xFFFF,
1019 version.dwNLSVersion & 0xFF,
1020 (version.dwDefinedVersion >> 8) & 0xFFFF,
1021 version.dwDefinedVersion & 0xFF);
1022#endif
1023 }
1024
1025 return collversion;
1026}
char * pstrdup(const char *in)
Definition: mcxt.c:1759
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:32
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: pgstrcasecmp.c:65
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 806 of file pg_locale_libc.c.

807{
808 locale_t loc = 0;
809
810 if (strcmp(collate, ctype) == 0)
811 {
812 if (strcmp(ctype, "C") != 0 && strcmp(ctype, "POSIX") != 0)
813 {
814 /* Normal case where they're the same */
815 errno = 0;
816#ifndef WIN32
817 loc = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, collate,
818 NULL);
819#else
820 loc = _create_locale(LC_ALL, collate);
821#endif
822 if (!loc)
824 }
825 }
826 else
827 {
828#ifndef WIN32
829 /* We need two newlocale() steps */
830 locale_t loc1 = 0;
831
832 if (strcmp(collate, "C") != 0 && strcmp(collate, "POSIX") != 0)
833 {
834 errno = 0;
835 loc1 = newlocale(LC_COLLATE_MASK, collate, NULL);
836 if (!loc1)
838 }
839
840 if (strcmp(ctype, "C") != 0 && strcmp(ctype, "POSIX") != 0)
841 {
842 errno = 0;
843 loc = newlocale(LC_CTYPE_MASK, ctype, loc1);
844 if (!loc)
845 {
846 if (loc1)
847 freelocale(loc1);
849 }
850 }
851 else
852 loc = loc1;
853#else
854
855 /*
856 * XXX The _create_locale() API doesn't appear to support this. Could
857 * perhaps be worked around by changing pg_locale_t to contain two
858 * separate fields.
859 */
861 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
862 errmsg("collations with different collate and ctype values are not supported on this platform")));
863#endif
864 }
865
866 return loc;
867}
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 1142 of file pg_locale_libc.c.

1143{
1144#ifdef WIN32
1145 return _mbstowcs_l(dest, src, n, loc);
1146#else
1147 size_t result;
1148 locale_t save_locale = uselocale(loc);
1149
1150 result = mbstowcs(dest, src, n);
1151 uselocale(save_locale);
1152 return result;
1153#endif
1154}

References generate_unaccent_rules::dest, and locale_t.

Referenced by char2wchar().

◆ report_newlocale_failure()

void report_newlocale_failure ( const char *  localename)

Definition at line 1108 of file pg_locale_libc.c.

1109{
1110 int save_errno;
1111
1112 /*
1113 * Windows doesn't provide any useful error indication from
1114 * _create_locale(), and BSD-derived platforms don't seem to feel they
1115 * need to set errno either (even though POSIX is pretty clear that
1116 * newlocale should do so). So, if errno hasn't been set, assume ENOENT
1117 * is what to report.
1118 */
1119 if (errno == 0)
1120 errno = ENOENT;
1121
1122 /*
1123 * ENOENT means "no such locale", not "no such file", so clarify that
1124 * errno with an errdetail message.
1125 */
1126 save_errno = errno; /* auxiliary funcs might change errno */
1127 ereport(ERROR,
1128 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1129 errmsg("could not create locale \"%s\": %m",
1130 localename),
1131 (save_errno == ENOENT ?
1132 errdetail("The operating system could not find any locale data for the locale name \"%s\".",
1133 localename) : 0)));
1134}
int errdetail(const char *fmt,...)
Definition: elog.c:1216

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 476 of file pg_locale_libc.c.

478{
479 locale_t loc = locale->lt;
480 size_t result_size;
481 wchar_t *workspace;
482 char *result;
483 size_t curr_char;
484 size_t max_size;
485
486 if (srclen < 0)
487 srclen = strlen(src);
488
489 /* Overflow paranoia */
490 if ((srclen + 1) > (INT_MAX / sizeof(wchar_t)))
492 (errcode(ERRCODE_OUT_OF_MEMORY),
493 errmsg("out of memory")));
494
495 /* Output workspace cannot have more codes than input bytes */
496 workspace = palloc_array(wchar_t, srclen + 1);
497
498 char2wchar(workspace, srclen + 1, src, srclen, loc);
499
500 for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
501 workspace[curr_char] = towlower_l(workspace[curr_char], loc);
502
503 /*
504 * Make result large enough; case change might change number of bytes
505 */
506 max_size = curr_char * pg_database_encoding_max_length();
507 result = palloc(max_size + 1);
508
509 result_size = wchar2char(result, workspace, max_size + 1, loc);
510
511 if (result_size + 1 > destsize)
512 return result_size;
513
514 memcpy(dest, result, result_size);
515 dest[result_size] = '\0';
516
517 pfree(workspace);
518 pfree(result);
519
520 return result_size;
521}
#define palloc_array(type, count)
Definition: fe_memutils.h:76
void * palloc(Size size)
Definition: mcxt.c:1365
size_t wchar2char(char *to, const wchar_t *from, size_t tolen, locale_t loc)
static 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:432

References char2wchar(), generate_unaccent_rules::dest, ereport, errcode(), errmsg(), ERROR, locale, locale_t, palloc(), palloc_array, 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 437 of file pg_locale_libc.c.

439{
440 if (srclen < 0)
441 srclen = strlen(src);
442
443 if (srclen + 1 <= destsize)
444 {
445 locale_t loc = locale->lt;
446 char *p;
447
448 memcpy(dest, src, srclen);
449 dest[srclen] = '\0';
450
451 /*
452 * Note: we assume that tolower_l() will not be so broken as to need
453 * an isupper_l() guard test. When using the default collation, we
454 * apply the traditional Postgres behavior that forces ASCII-style
455 * treatment of I/i, but in non-default collations you get exactly
456 * what the collation says.
457 */
458 for (p = dest; *p; p++)
459 {
460 if (locale->is_default)
461 {
462 if (*p >= 'A' && *p <= 'Z')
463 *p += 'a' - 'A';
464 else if (IS_HIGHBIT_SET(*p) && isupper_l(*p, loc))
465 *p = tolower_l((unsigned char) *p, loc);
466 }
467 else
468 *p = tolower_l((unsigned char) *p, loc);
469 }
470 }
471
472 return srclen;
473}
#define tolower_l
Definition: win32_port.h:430
#define isupper_l
Definition: win32_port.h:440

References generate_unaccent_rules::dest, IS_HIGHBIT_SET, isupper_l, locale, locale_t, 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 877 of file pg_locale_libc.c.

879{
880 char sbuf[TEXTBUFLEN];
881 char *buf = sbuf;
882 size_t bufsize1 = (len1 == -1) ? 0 : len1 + 1;
883 size_t bufsize2 = (len2 == -1) ? 0 : len2 + 1;
884 const char *arg1n;
885 const char *arg2n;
886 int result;
887
888 if (bufsize1 + bufsize2 > TEXTBUFLEN)
889 buf = palloc(bufsize1 + bufsize2);
890
891 /* nul-terminate arguments if necessary */
892 if (len1 == -1)
893 {
894 arg1n = arg1;
895 }
896 else
897 {
898 char *buf1 = buf;
899
900 memcpy(buf1, arg1, len1);
901 buf1[len1] = '\0';
902 arg1n = buf1;
903 }
904
905 if (len2 == -1)
906 {
907 arg2n = arg2;
908 }
909 else
910 {
911 char *buf2 = buf + bufsize1;
912
913 memcpy(buf2, arg2, len2);
914 buf2[len2] = '\0';
915 arg2n = buf2;
916 }
917
918 result = strcoll_l(arg1n, arg2n, locale->lt);
919
920 if (buf != sbuf)
921 pfree(buf);
922
923 return result;
924}
#define TEXTBUFLEN
static char buf[DEFAULT_XLOG_SEG_SIZE]
Definition: pg_test_fsync.c:71
#define strcoll_l
Definition: win32_port.h:452

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 934 of file pg_locale_libc.c.

936{
937 char sbuf[TEXTBUFLEN];
938 char *buf = sbuf;
939 size_t bufsize = srclen + 1;
940 size_t result;
941
942 if (srclen == -1)
943 return strxfrm_l(dest, src, destsize, locale->lt);
944
945 if (bufsize > TEXTBUFLEN)
946 buf = palloc(bufsize);
947
948 /* nul-terminate argument */
949 memcpy(buf, src, srclen);
950 buf[srclen] = '\0';
951
952 result = strxfrm_l(dest, buf, destsize, locale->lt);
953
954 if (buf != sbuf)
955 pfree(buf);
956
957 /* if dest is defined, it should be nul-terminated */
958 Assert(result >= destsize || dest[result] == '\0');
959
960 return result;
961}
#define bufsize
Definition: indent_globs.h:36
#define strxfrm_l
Definition: win32_port.h:453

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 580 of file pg_locale_libc.c.

582{
583 locale_t loc = locale->lt;
584 int wasalnum = false;
585 size_t result_size;
586 wchar_t *workspace;
587 char *result;
588 size_t curr_char;
589 size_t max_size;
590
591 if (srclen < 0)
592 srclen = strlen(src);
593
594 /* Overflow paranoia */
595 if ((srclen + 1) > (INT_MAX / sizeof(wchar_t)))
597 (errcode(ERRCODE_OUT_OF_MEMORY),
598 errmsg("out of memory")));
599
600 /* Output workspace cannot have more codes than input bytes */
601 workspace = palloc_array(wchar_t, srclen + 1);
602
603 char2wchar(workspace, srclen + 1, src, srclen, loc);
604
605 for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
606 {
607 if (wasalnum)
608 workspace[curr_char] = towlower_l(workspace[curr_char], loc);
609 else
610 workspace[curr_char] = towupper_l(workspace[curr_char], loc);
611 wasalnum = iswalnum_l(workspace[curr_char], loc);
612 }
613
614 /*
615 * Make result large enough; case change might change number of bytes
616 */
617 max_size = curr_char * pg_database_encoding_max_length();
618 result = palloc(max_size + 1);
619
620 result_size = wchar2char(result, workspace, max_size + 1, loc);
621
622 if (result_size + 1 > destsize)
623 return result_size;
624
625 memcpy(dest, result, result_size);
626 dest[result_size] = '\0';
627
628 pfree(workspace);
629 pfree(result);
630
631 return result_size;
632}
#define iswalnum_l
Definition: win32_port.h:439
#define towupper_l
Definition: win32_port.h:433

References char2wchar(), generate_unaccent_rules::dest, ereport, errcode(), errmsg(), ERROR, iswalnum_l, locale, locale_t, palloc(), palloc_array, 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 524 of file pg_locale_libc.c.

526{
527 if (srclen < 0)
528 srclen = strlen(src);
529
530 if (srclen + 1 <= destsize)
531 {
532 locale_t loc = locale->lt;
533 int wasalnum = false;
534 char *p;
535
536 memcpy(dest, src, srclen);
537 dest[srclen] = '\0';
538
539 /*
540 * Note: we assume that toupper_l()/tolower_l() will not be so broken
541 * as to need guard tests. When using the default collation, we apply
542 * the traditional Postgres behavior that forces ASCII-style treatment
543 * of I/i, but in non-default collations you get exactly what the
544 * collation says.
545 */
546 for (p = dest; *p; p++)
547 {
548 if (locale->is_default)
549 {
550 if (wasalnum)
551 {
552 if (*p >= 'A' && *p <= 'Z')
553 *p += 'a' - 'A';
554 else if (IS_HIGHBIT_SET(*p) && isupper_l(*p, loc))
555 *p = tolower_l((unsigned char) *p, loc);
556 }
557 else
558 {
559 if (*p >= 'a' && *p <= 'z')
560 *p -= 'a' - 'A';
561 else if (IS_HIGHBIT_SET(*p) && islower_l(*p, loc))
562 *p = toupper_l((unsigned char) *p, loc);
563 }
564 }
565 else
566 {
567 if (wasalnum)
568 *p = tolower_l((unsigned char) *p, loc);
569 else
570 *p = toupper_l((unsigned char) *p, loc);
571 }
572 wasalnum = isalnum_l((unsigned char) *p, loc);
573 }
574 }
575
576 return srclen;
577}
#define toupper_l
Definition: win32_port.h:431
#define isalnum_l
Definition: win32_port.h:438
#define islower_l
Definition: win32_port.h:442

References generate_unaccent_rules::dest, IS_HIGHBIT_SET, isalnum_l, islower_l, isupper_l, locale, locale_t, 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 674 of file pg_locale_libc.c.

676{
677 locale_t loc = locale->lt;
678 size_t result_size;
679 wchar_t *workspace;
680 char *result;
681 size_t curr_char;
682 size_t max_size;
683
684 if (srclen < 0)
685 srclen = strlen(src);
686
687 /* Overflow paranoia */
688 if ((srclen + 1) > (INT_MAX / sizeof(wchar_t)))
690 (errcode(ERRCODE_OUT_OF_MEMORY),
691 errmsg("out of memory")));
692
693 /* Output workspace cannot have more codes than input bytes */
694 workspace = palloc_array(wchar_t, srclen + 1);
695
696 char2wchar(workspace, srclen + 1, src, srclen, loc);
697
698 for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
699 workspace[curr_char] = towupper_l(workspace[curr_char], loc);
700
701 /*
702 * Make result large enough; case change might change number of bytes
703 */
704 max_size = curr_char * pg_database_encoding_max_length();
705 result = palloc(max_size + 1);
706
707 result_size = wchar2char(result, workspace, max_size + 1, loc);
708
709 if (result_size + 1 > destsize)
710 return result_size;
711
712 memcpy(dest, result, result_size);
713 dest[result_size] = '\0';
714
715 pfree(workspace);
716 pfree(result);
717
718 return result_size;
719}

References char2wchar(), generate_unaccent_rules::dest, ereport, errcode(), errmsg(), ERROR, locale, locale_t, palloc(), palloc_array, 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 635 of file pg_locale_libc.c.

637{
638 if (srclen < 0)
639 srclen = strlen(src);
640
641 if (srclen + 1 <= destsize)
642 {
643 locale_t loc = locale->lt;
644 char *p;
645
646 memcpy(dest, src, srclen);
647 dest[srclen] = '\0';
648
649 /*
650 * Note: we assume that toupper_l() will not be so broken as to need
651 * an islower_l() guard test. When using the default collation, we
652 * apply the traditional Postgres behavior that forces ASCII-style
653 * treatment of I/i, but in non-default collations you get exactly
654 * what the collation says.
655 */
656 for (p = dest; *p; p++)
657 {
658 if (locale->is_default)
659 {
660 if (*p >= 'a' && *p <= 'z')
661 *p -= 'a' - 'A';
662 else if (IS_HIGHBIT_SET(*p) && islower_l(*p, loc))
663 *p = toupper_l((unsigned char) *p, loc);
664 }
665 else
666 *p = toupper_l((unsigned char) *p, loc);
667 }
668 }
669
670 return srclen;
671}

References generate_unaccent_rules::dest, IS_HIGHBIT_SET, islower_l, locale, locale_t, and toupper_l.

◆ tolower_libc_mb()

static pg_wchar tolower_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 319 of file pg_locale_libc.c.

320{
322
323 /* force C behavior for ASCII characters, per comments above */
324 if (locale->is_default && wc <= (pg_wchar) 127)
325 return pg_ascii_tolower((unsigned char) wc);
326 if (sizeof(wchar_t) >= 4 || wc <= (pg_wchar) 0xFFFF)
327 return towlower_l((wint_t) wc, locale->lt);
328 else
329 return wc;
330}
unsigned int pg_wchar
Definition: mbprint.c:31
static unsigned char pg_ascii_tolower(unsigned char ch)
Definition: port.h:188

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 305 of file pg_locale_libc.c.

306{
308
309 /* force C behavior for ASCII characters, per comments above */
310 if (locale->is_default && wc <= (pg_wchar) 127)
311 return pg_ascii_tolower((unsigned char) wc);
312 if (wc <= (pg_wchar) UCHAR_MAX)
313 return tolower_l((unsigned char) wc, locale->lt);
314 else
315 return wc;
316}

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 291 of file pg_locale_libc.c.

292{
294
295 /* force C behavior for ASCII characters, per comments above */
296 if (locale->is_default && wc <= (pg_wchar) 127)
297 return pg_ascii_toupper((unsigned char) wc);
298 if (sizeof(wchar_t) >= 4 || wc <= (pg_wchar) 0xFFFF)
299 return towupper_l((wint_t) wc, locale->lt);
300 else
301 return wc;
302}
static unsigned char pg_ascii_toupper(unsigned char ch)
Definition: port.h:177

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 277 of file pg_locale_libc.c.

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

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 207 of file pg_locale_libc.c.

208{
209 return iswalnum_l((wint_t) wc, locale->lt);
210}

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 136 of file pg_locale_libc.c.

137{
138 return isalnum_l((unsigned char) wc, locale->lt);
139}

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 201 of file pg_locale_libc.c.

202{
203 return iswalpha_l((wint_t) wc, locale->lt);
204}
#define iswalpha_l
Definition: win32_port.h:437

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 130 of file pg_locale_libc.c.

131{
132 return isalpha_l((unsigned char) wc, locale->lt);
133}

References isalpha_l, and locale.

◆ wc_iscased_libc_mb()

static bool wc_iscased_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 259 of file pg_locale_libc.c.

260{
261 return iswupper_l((wint_t) wc, locale->lt) ||
262 iswlower_l((wint_t) wc, locale->lt);
263}
#define iswupper_l
Definition: win32_port.h:441
#define iswlower_l
Definition: win32_port.h:443

References iswlower_l, iswupper_l, and locale.

◆ wc_iscased_libc_sb()

static bool wc_iscased_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 188 of file pg_locale_libc.c.

189{
190 return isupper_l((unsigned char) wc, locale->lt) ||
191 islower_l((unsigned char) wc, locale->lt);
192}

References islower_l, isupper_l, and locale.

◆ wc_isdigit_libc_mb()

static bool wc_isdigit_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 195 of file pg_locale_libc.c.

196{
197 return iswdigit_l((wint_t) wc, locale->lt);
198}
#define iswdigit_l
Definition: win32_port.h:435

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 124 of file pg_locale_libc.c.

125{
126 return isdigit_l((unsigned char) wc, locale->lt);
127}
#define isdigit_l
Definition: win32_port.h:434

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 225 of file pg_locale_libc.c.

226{
227 return iswgraph_l((wint_t) wc, locale->lt);
228}
#define iswgraph_l
Definition: win32_port.h:445

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 154 of file pg_locale_libc.c.

155{
156 return isgraph_l((unsigned char) wc, locale->lt);
157}
#define isgraph_l
Definition: win32_port.h:444

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 219 of file pg_locale_libc.c.

220{
221 return iswlower_l((wint_t) wc, locale->lt);
222}

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 148 of file pg_locale_libc.c.

149{
150 return islower_l((unsigned char) wc, locale->lt);
151}

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 231 of file pg_locale_libc.c.

232{
233 return iswprint_l((wint_t) wc, locale->lt);
234}
#define iswprint_l
Definition: win32_port.h:447

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 160 of file pg_locale_libc.c.

161{
162 return isprint_l((unsigned char) wc, locale->lt);
163}
#define isprint_l
Definition: win32_port.h:446

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 237 of file pg_locale_libc.c.

238{
239 return iswpunct_l((wint_t) wc, locale->lt);
240}
#define iswpunct_l
Definition: win32_port.h:449

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 166 of file pg_locale_libc.c.

167{
168 return ispunct_l((unsigned char) wc, locale->lt);
169}
#define ispunct_l
Definition: win32_port.h:448

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 243 of file pg_locale_libc.c.

244{
245 return iswspace_l((wint_t) wc, locale->lt);
246}
#define iswspace_l
Definition: win32_port.h:451

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 172 of file pg_locale_libc.c.

173{
174 return isspace_l((unsigned char) wc, locale->lt);
175}
#define isspace_l
Definition: win32_port.h:450

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 213 of file pg_locale_libc.c.

214{
215 return iswupper_l((wint_t) wc, locale->lt);
216}

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 142 of file pg_locale_libc.c.

143{
144 return isupper_l((unsigned char) wc, locale->lt);
145}

References isupper_l, and locale.

◆ wc_isxdigit_libc_mb()

static bool wc_isxdigit_libc_mb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 249 of file pg_locale_libc.c.

250{
251#ifndef WIN32
252 return iswxdigit_l((wint_t) wc, locale->lt);
253#else
254 return _iswxdigit_l((wint_t) wc, locale->lt);
255#endif
256}

References locale.

◆ wc_isxdigit_libc_sb()

static bool wc_isxdigit_libc_sb ( pg_wchar  wc,
pg_locale_t  locale 
)
static

Definition at line 178 of file pg_locale_libc.c.

179{
180#ifndef WIN32
181 return isxdigit_l((unsigned char) wc, locale->lt);
182#else
183 return _isxdigit_l((unsigned char) wc, locale->lt);
184#endif
185}

References locale.

◆ wchar2char()

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

Definition at line 1186 of file pg_locale_libc.c.

1187{
1188 size_t result;
1189
1190 if (tolen == 0)
1191 return 0;
1192
1193#ifdef WIN32
1194
1195 /*
1196 * On Windows, the "Unicode" locales assume UTF16 not UTF8 encoding, and
1197 * for some reason mbstowcs and wcstombs won't do this for us, so we use
1198 * MultiByteToWideChar().
1199 */
1201 {
1202 result = WideCharToMultiByte(CP_UTF8, 0, from, -1, to, tolen,
1203 NULL, NULL);
1204 /* A zero return is failure */
1205 if (result <= 0)
1206 result = -1;
1207 else
1208 {
1209 Assert(result <= tolen);
1210 /* Microsoft counts the zero terminator in the result */
1211 result--;
1212 }
1213 }
1214 else
1215#endif /* WIN32 */
1216 if (loc == (locale_t) 0)
1217 {
1218 /* Use wcstombs directly for the default locale */
1219 result = wcstombs(to, from, tolen);
1220 }
1221 else
1222 {
1223 /* Use wcstombs_l for nondefault locales */
1224 result = wcstombs_l(to, from, tolen, loc);
1225 }
1226
1227 return result;
1228}
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 1158 of file pg_locale_libc.c.

1159{
1160#ifdef WIN32
1161 return _wcstombs_l(dest, src, n, loc);
1162#else
1163 size_t result;
1164 locale_t save_locale = uselocale(loc);
1165
1166 result = wcstombs(dest, src, n);
1167 uselocale(save_locale);
1168 return result;
1169#endif
1170}

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 402 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,
.strfold = strlower_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,
.wc_isxdigit = wc_isxdigit_libc_sb,
.char_is_cased = char_is_cased_libc,
.wc_iscased = wc_iscased_libc_sb,
.wc_toupper = toupper_libc_sb,
.wc_tolower = tolower_libc_sb,
}
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_iscased_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 bool wc_isxdigit_libc_sb(pg_wchar wc, 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 358 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,
.strfold = strlower_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,
.wc_isxdigit = wc_isxdigit_libc_sb,
.char_is_cased = char_is_cased_libc,
.wc_iscased = wc_iscased_libc_sb,
.wc_toupper = toupper_libc_sb,
.wc_tolower = tolower_libc_sb,
}
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 332 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,
.strfold = strlower_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,
.wc_isxdigit = wc_isxdigit_libc_mb,
.char_is_cased = char_is_cased_libc,
.wc_iscased = wc_iscased_libc_mb,
.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_iscased_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)
static bool wc_isxdigit_libc_mb(pg_wchar wc, pg_locale_t locale)

Definition at line 380 of file pg_locale_libc.c.

Referenced by create_pg_locale_libc().