PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
regc_pg_locale.c File Reference
Include dependency graph for regc_pg_locale.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pg_ctype_cache
 

Macros

#define PG_ISDIGIT   0x01
 
#define PG_ISALPHA   0x02
 
#define PG_ISALNUM   (PG_ISDIGIT | PG_ISALPHA)
 
#define PG_ISUPPER   0x04
 
#define PG_ISLOWER   0x08
 
#define PG_ISGRAPH   0x10
 
#define PG_ISPRINT   0x20
 
#define PG_ISPUNCT   0x40
 
#define PG_ISSPACE   0x80
 

Typedefs

typedef int(* pg_wc_probefunc) (pg_wchar c)
 
typedef struct pg_ctype_cache pg_ctype_cache
 

Enumerations

enum  PG_Locale_Strategy {
  PG_REGEX_STRATEGY_C , PG_REGEX_STRATEGY_BUILTIN , PG_REGEX_STRATEGY_LIBC_WIDE , PG_REGEX_STRATEGY_LIBC_1BYTE ,
  PG_REGEX_STRATEGY_ICU
}
 

Functions

void pg_set_regex_collation (Oid collation)
 
static int pg_wc_isdigit (pg_wchar c)
 
static int pg_wc_isalpha (pg_wchar c)
 
static int pg_wc_isalnum (pg_wchar c)
 
static int pg_wc_isword (pg_wchar c)
 
static int pg_wc_isupper (pg_wchar c)
 
static int pg_wc_islower (pg_wchar c)
 
static int pg_wc_isgraph (pg_wchar c)
 
static int pg_wc_isprint (pg_wchar c)
 
static int pg_wc_ispunct (pg_wchar c)
 
static int pg_wc_isspace (pg_wchar c)
 
static pg_wchar pg_wc_toupper (pg_wchar c)
 
static pg_wchar pg_wc_tolower (pg_wchar c)
 
static bool store_match (pg_ctype_cache *pcc, pg_wchar chr1, int nchrs)
 
static struct cvecpg_ctype_get_cache (pg_wc_probefunc probefunc, int cclasscode)
 

Variables

static PG_Locale_Strategy pg_regex_strategy
 
static pg_locale_t pg_regex_locale
 
static const unsigned char pg_char_properties [128]
 
static pg_ctype_cachepg_ctype_cache_list = NULL
 

Macro Definition Documentation

◆ PG_ISALNUM

#define PG_ISALNUM   (PG_ISDIGIT | PG_ISALPHA)

Definition at line 80 of file regc_pg_locale.c.

◆ PG_ISALPHA

#define PG_ISALPHA   0x02

Definition at line 79 of file regc_pg_locale.c.

◆ PG_ISDIGIT

#define PG_ISDIGIT   0x01

Definition at line 78 of file regc_pg_locale.c.

◆ PG_ISGRAPH

#define PG_ISGRAPH   0x10

Definition at line 83 of file regc_pg_locale.c.

◆ PG_ISLOWER

#define PG_ISLOWER   0x08

Definition at line 82 of file regc_pg_locale.c.

◆ PG_ISPRINT

#define PG_ISPRINT   0x20

Definition at line 84 of file regc_pg_locale.c.

◆ PG_ISPUNCT

#define PG_ISPUNCT   0x40

Definition at line 85 of file regc_pg_locale.c.

◆ PG_ISSPACE

#define PG_ISSPACE   0x80

Definition at line 86 of file regc_pg_locale.c.

◆ PG_ISUPPER

#define PG_ISUPPER   0x04

Definition at line 81 of file regc_pg_locale.c.

Typedef Documentation

◆ pg_ctype_cache

◆ pg_wc_probefunc

typedef int(* pg_wc_probefunc) (pg_wchar c)

Definition at line 632 of file regc_pg_locale.c.

Enumeration Type Documentation

◆ PG_Locale_Strategy

Enumerator
PG_REGEX_STRATEGY_C 
PG_REGEX_STRATEGY_BUILTIN 
PG_REGEX_STRATEGY_LIBC_WIDE 
PG_REGEX_STRATEGY_LIBC_1BYTE 
PG_REGEX_STRATEGY_ICU 

Definition at line 63 of file regc_pg_locale.c.

64{
65 PG_REGEX_STRATEGY_C, /* C locale (encoding independent) */
66 PG_REGEX_STRATEGY_BUILTIN, /* built-in Unicode semantics */
67 PG_REGEX_STRATEGY_LIBC_WIDE, /* Use locale_t <wctype.h> functions */
68 PG_REGEX_STRATEGY_LIBC_1BYTE, /* Use locale_t <ctype.h> functions */
69 PG_REGEX_STRATEGY_ICU, /* Use ICU uchar.h functions */
PG_Locale_Strategy
@ PG_REGEX_STRATEGY_C
@ PG_REGEX_STRATEGY_LIBC_WIDE
@ PG_REGEX_STRATEGY_ICU
@ PG_REGEX_STRATEGY_BUILTIN
@ PG_REGEX_STRATEGY_LIBC_1BYTE

Function Documentation

◆ pg_ctype_get_cache()

static struct cvec * pg_ctype_get_cache ( pg_wc_probefunc  probefunc,
int  cclasscode 
)
static

Definition at line 692 of file regc_pg_locale.c.

693{
694 pg_ctype_cache *pcc;
695 pg_wchar max_chr;
696 pg_wchar cur_chr;
697 int nmatches;
698 chr *newchrs;
699
700 /*
701 * Do we already have the answer cached?
702 */
703 for (pcc = pg_ctype_cache_list; pcc != NULL; pcc = pcc->next)
704 {
705 if (pcc->probefunc == probefunc &&
706 pcc->locale == pg_regex_locale)
707 return &pcc->cv;
708 }
709
710 /*
711 * Nope, so initialize some workspace ...
712 */
713 pcc = (pg_ctype_cache *) malloc(sizeof(pg_ctype_cache));
714 if (pcc == NULL)
715 return NULL;
716 pcc->probefunc = probefunc;
717 pcc->locale = pg_regex_locale;
718 pcc->cv.nchrs = 0;
719 pcc->cv.chrspace = 128;
720 pcc->cv.chrs = (chr *) malloc(pcc->cv.chrspace * sizeof(chr));
721 pcc->cv.nranges = 0;
722 pcc->cv.rangespace = 64;
723 pcc->cv.ranges = (chr *) malloc(pcc->cv.rangespace * sizeof(chr) * 2);
724 if (pcc->cv.chrs == NULL || pcc->cv.ranges == NULL)
725 goto out_of_memory;
726 pcc->cv.cclasscode = cclasscode;
727
728 /*
729 * Decide how many character codes we ought to look through. In general
730 * we don't go past MAX_SIMPLE_CHR; chr codes above that are handled at
731 * runtime using the "high colormap" mechanism. However, in C locale
732 * there's no need to go further than 127, and if we only have a 1-byte
733 * <ctype.h> API there's no need to go further than that can handle.
734 *
735 * If it's not MAX_SIMPLE_CHR that's constraining the search, mark the
736 * output cvec as not having any locale-dependent behavior, since there
737 * will be no need to do any run-time locale checks. (The #if's here
738 * would always be true for production values of MAX_SIMPLE_CHR, but it's
739 * useful to allow it to be small for testing purposes.)
740 */
741 switch (pg_regex_strategy)
742 {
744#if MAX_SIMPLE_CHR >= 127
745 max_chr = (pg_wchar) 127;
746 pcc->cv.cclasscode = -1;
747#else
748 max_chr = (pg_wchar) MAX_SIMPLE_CHR;
749#endif
750 break;
752 max_chr = (pg_wchar) MAX_SIMPLE_CHR;
753 break;
755 max_chr = (pg_wchar) MAX_SIMPLE_CHR;
756 break;
758#if MAX_SIMPLE_CHR >= UCHAR_MAX
759 max_chr = (pg_wchar) UCHAR_MAX;
760 pcc->cv.cclasscode = -1;
761#else
762 max_chr = (pg_wchar) MAX_SIMPLE_CHR;
763#endif
764 break;
766 max_chr = (pg_wchar) MAX_SIMPLE_CHR;
767 break;
768 default:
769 Assert(false);
770 max_chr = 0; /* can't get here, but keep compiler quiet */
771 break;
772 }
773
774 /*
775 * And scan 'em ...
776 */
777 nmatches = 0; /* number of consecutive matches */
778
779 for (cur_chr = 0; cur_chr <= max_chr; cur_chr++)
780 {
781 if ((*probefunc) (cur_chr))
782 nmatches++;
783 else if (nmatches > 0)
784 {
785 if (!store_match(pcc, cur_chr - nmatches, nmatches))
786 goto out_of_memory;
787 nmatches = 0;
788 }
789 }
790
791 if (nmatches > 0)
792 if (!store_match(pcc, cur_chr - nmatches, nmatches))
793 goto out_of_memory;
794
795 /*
796 * We might have allocated more memory than needed, if so free it
797 */
798 if (pcc->cv.nchrs == 0)
799 {
800 free(pcc->cv.chrs);
801 pcc->cv.chrs = NULL;
802 pcc->cv.chrspace = 0;
803 }
804 else if (pcc->cv.nchrs < pcc->cv.chrspace)
805 {
806 newchrs = (chr *) realloc(pcc->cv.chrs,
807 pcc->cv.nchrs * sizeof(chr));
808 if (newchrs == NULL)
809 goto out_of_memory;
810 pcc->cv.chrs = newchrs;
811 pcc->cv.chrspace = pcc->cv.nchrs;
812 }
813 if (pcc->cv.nranges == 0)
814 {
815 free(pcc->cv.ranges);
816 pcc->cv.ranges = NULL;
817 pcc->cv.rangespace = 0;
818 }
819 else if (pcc->cv.nranges < pcc->cv.rangespace)
820 {
821 newchrs = (chr *) realloc(pcc->cv.ranges,
822 pcc->cv.nranges * sizeof(chr) * 2);
823 if (newchrs == NULL)
824 goto out_of_memory;
825 pcc->cv.ranges = newchrs;
826 pcc->cv.rangespace = pcc->cv.nranges;
827 }
828
829 /*
830 * Success, link it into cache chain
831 */
834
835 return &pcc->cv;
836
837 /*
838 * Failure, clean up
839 */
840out_of_memory:
841 free(pcc->cv.chrs);
842 free(pcc->cv.ranges);
843 free(pcc);
844
845 return NULL;
846}
Assert(PointerIsAligned(start, uint64))
#define realloc(a, b)
Definition: header.h:60
#define free(a)
Definition: header.h:65
#define malloc(a)
Definition: header.h:50
unsigned int pg_wchar
Definition: mbprint.c:31
static pg_ctype_cache * pg_ctype_cache_list
static bool store_match(pg_ctype_cache *pcc, pg_wchar chr1, int nchrs)
static PG_Locale_Strategy pg_regex_strategy
static pg_locale_t pg_regex_locale
#define MAX_SIMPLE_CHR
Definition: regcustom.h:87
pg_wchar chr
Definition: regcustom.h:59
int chrspace
Definition: regguts.h:281
int nchrs
Definition: regguts.h:280
int rangespace
Definition: regguts.h:284
chr * chrs
Definition: regguts.h:282
chr * ranges
Definition: regguts.h:285
int cclasscode
Definition: regguts.h:286
int nranges
Definition: regguts.h:283
pg_wc_probefunc probefunc
struct pg_ctype_cache * next
pg_locale_t locale
struct cvec cv

References Assert(), cvec::cclasscode, cvec::chrs, cvec::chrspace, pg_ctype_cache::cv, free, pg_ctype_cache::locale, malloc, MAX_SIMPLE_CHR, cvec::nchrs, pg_ctype_cache::next, cvec::nranges, pg_ctype_cache_list, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, pg_ctype_cache::probefunc, cvec::ranges, cvec::rangespace, realloc, and store_match().

Referenced by cclasscvec().

◆ pg_set_regex_collation()

void pg_set_regex_collation ( Oid  collation)

Definition at line 228 of file regc_pg_locale.c.

229{
231 PG_Locale_Strategy strategy;
232
233 if (!OidIsValid(collation))
234 {
235 /*
236 * This typically means that the parser could not resolve a conflict
237 * of implicit collations, so report it that way.
238 */
240 (errcode(ERRCODE_INDETERMINATE_COLLATION),
241 errmsg("could not determine which collation to use for regular expression"),
242 errhint("Use the COLLATE clause to set the collation explicitly.")));
243 }
244
245 if (collation == C_COLLATION_OID)
246 {
247 /*
248 * Some callers expect regexes to work for C_COLLATION_OID before
249 * catalog access is available, so we can't call
250 * pg_newlocale_from_collation().
251 */
252 strategy = PG_REGEX_STRATEGY_C;
253 locale = 0;
254 }
255 else
256 {
258
259 if (!locale->deterministic)
261 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
262 errmsg("nondeterministic collations are not supported for regular expressions")));
263
264 if (locale->ctype_is_c)
265 {
266 /*
267 * C/POSIX collations use this path regardless of database
268 * encoding
269 */
270 strategy = PG_REGEX_STRATEGY_C;
271 locale = 0;
272 }
273 else if (locale->provider == COLLPROVIDER_BUILTIN)
274 {
276 strategy = PG_REGEX_STRATEGY_BUILTIN;
277 }
278#ifdef USE_ICU
279 else if (locale->provider == COLLPROVIDER_ICU)
280 {
281 strategy = PG_REGEX_STRATEGY_ICU;
282 }
283#endif
284 else
285 {
286 Assert(locale->provider == COLLPROVIDER_LIBC);
289 else
291 }
292 }
293
294 pg_regex_strategy = strategy;
296}
#define OidIsValid(objectId)
Definition: c.h:746
int errhint(const char *fmt,...)
Definition: elog.c:1318
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:149
static char * locale
Definition: initdb.c:140
int GetDatabaseEncoding(void)
Definition: mbutils.c:1261
pg_locale_t pg_newlocale_from_collation(Oid collid)
Definition: pg_locale.c:1188
@ PG_UTF8
Definition: pg_wchar.h:232

References Assert(), ereport, errcode(), errhint(), errmsg(), ERROR, GetDatabaseEncoding(), locale, OidIsValid, pg_newlocale_from_collation(), pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and PG_UTF8.

Referenced by pg_regcomp(), pg_regexec(), and pg_regprefix().

◆ pg_wc_isalnum()

static int pg_wc_isalnum ( pg_wchar  c)
static

Definition at line 353 of file regc_pg_locale.c.

354{
355 switch (pg_regex_strategy)
356 {
358 return (c <= (pg_wchar) 127 &&
363 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
364 return iswalnum_l((wint_t) c, pg_regex_locale->info.lt);
365 /* FALL THRU */
367 return (c <= (pg_wchar) UCHAR_MAX &&
368 isalnum_l((unsigned char) c, pg_regex_locale->info.lt));
369 break;
371#ifdef USE_ICU
372 return u_isalnum(c);
373#endif
374 break;
375 }
376 return 0; /* can't get here, but keep compiler quiet */
377}
char * c
#define PG_ISALNUM
static const unsigned char pg_char_properties[128]
struct pg_locale_struct::@161::@162 builtin
union pg_locale_struct::@161 info
bool pg_u_isalnum(pg_wchar code, bool posix)
#define iswalnum_l
Definition: win32_port.h:442
#define isalnum_l
Definition: win32_port.h:441

References pg_locale_struct::builtin, pg_locale_struct::casemap_full, pg_locale_struct::info, isalnum_l, iswalnum_l, pg_locale_struct::lt, pg_char_properties, PG_ISALNUM, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_isalnum().

Referenced by cclass_column_index(), cclasscvec(), and pg_wc_isword().

◆ pg_wc_isalpha()

static int pg_wc_isalpha ( pg_wchar  c)
static

Definition at line 326 of file regc_pg_locale.c.

327{
328 switch (pg_regex_strategy)
329 {
331 return (c <= (pg_wchar) 127 &&
334 return pg_u_isalpha(c);
336 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
337 return iswalpha_l((wint_t) c, pg_regex_locale->info.lt);
338 /* FALL THRU */
340 return (c <= (pg_wchar) UCHAR_MAX &&
341 isalpha_l((unsigned char) c, pg_regex_locale->info.lt));
342 break;
344#ifdef USE_ICU
345 return u_isalpha(c);
346#endif
347 break;
348 }
349 return 0; /* can't get here, but keep compiler quiet */
350}
#define PG_ISALPHA
bool pg_u_isalpha(pg_wchar code)
#define isalpha_l
Definition: win32_port.h:439
#define iswalpha_l
Definition: win32_port.h:440

References pg_locale_struct::info, isalpha_l, iswalpha_l, pg_locale_struct::lt, pg_char_properties, PG_ISALPHA, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_isalpha().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_isdigit()

static int pg_wc_isdigit ( pg_wchar  c)
static

Definition at line 299 of file regc_pg_locale.c.

300{
301 switch (pg_regex_strategy)
302 {
304 return (c <= (pg_wchar) 127 &&
309 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
310 return iswdigit_l((wint_t) c, pg_regex_locale->info.lt);
311 /* FALL THRU */
313 return (c <= (pg_wchar) UCHAR_MAX &&
314 isdigit_l((unsigned char) c, pg_regex_locale->info.lt));
315 break;
317#ifdef USE_ICU
318 return u_isdigit(c);
319#endif
320 break;
321 }
322 return 0; /* can't get here, but keep compiler quiet */
323}
#define PG_ISDIGIT
bool pg_u_isdigit(pg_wchar code, bool posix)
#define isdigit_l
Definition: win32_port.h:437
#define iswdigit_l
Definition: win32_port.h:438

References pg_locale_struct::builtin, pg_locale_struct::casemap_full, pg_locale_struct::info, isdigit_l, iswdigit_l, pg_locale_struct::lt, pg_char_properties, PG_ISDIGIT, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_isdigit().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_isgraph()

static int pg_wc_isgraph ( pg_wchar  c)
static

Definition at line 443 of file regc_pg_locale.c.

444{
445 switch (pg_regex_strategy)
446 {
448 return (c <= (pg_wchar) 127 &&
451 return pg_u_isgraph(c);
453 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
454 return iswgraph_l((wint_t) c, pg_regex_locale->info.lt);
455 /* FALL THRU */
457 return (c <= (pg_wchar) UCHAR_MAX &&
458 isgraph_l((unsigned char) c, pg_regex_locale->info.lt));
459 break;
461#ifdef USE_ICU
462 return u_isgraph(c);
463#endif
464 break;
465 }
466 return 0; /* can't get here, but keep compiler quiet */
467}
#define PG_ISGRAPH
bool pg_u_isgraph(pg_wchar code)
#define isgraph_l
Definition: win32_port.h:447
#define iswgraph_l
Definition: win32_port.h:448

References pg_locale_struct::info, isgraph_l, iswgraph_l, pg_locale_struct::lt, pg_char_properties, PG_ISGRAPH, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_isgraph().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_islower()

static int pg_wc_islower ( pg_wchar  c)
static

Definition at line 416 of file regc_pg_locale.c.

417{
418 switch (pg_regex_strategy)
419 {
421 return (c <= (pg_wchar) 127 &&
424 return pg_u_islower(c);
426 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
427 return iswlower_l((wint_t) c, pg_regex_locale->info.lt);
428 /* FALL THRU */
430 return (c <= (pg_wchar) UCHAR_MAX &&
431 islower_l((unsigned char) c, pg_regex_locale->info.lt));
432 break;
434#ifdef USE_ICU
435 return u_islower(c);
436#endif
437 break;
438 }
439 return 0; /* can't get here, but keep compiler quiet */
440}
#define PG_ISLOWER
bool pg_u_islower(pg_wchar code)
#define islower_l
Definition: win32_port.h:445
#define iswlower_l
Definition: win32_port.h:446

References pg_locale_struct::info, islower_l, iswlower_l, pg_locale_struct::lt, pg_char_properties, PG_ISLOWER, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_islower().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_isprint()

static int pg_wc_isprint ( pg_wchar  c)
static

Definition at line 470 of file regc_pg_locale.c.

471{
472 switch (pg_regex_strategy)
473 {
475 return (c <= (pg_wchar) 127 &&
478 return pg_u_isprint(c);
480 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
481 return iswprint_l((wint_t) c, pg_regex_locale->info.lt);
482 /* FALL THRU */
484 return (c <= (pg_wchar) UCHAR_MAX &&
485 isprint_l((unsigned char) c, pg_regex_locale->info.lt));
486 break;
488#ifdef USE_ICU
489 return u_isprint(c);
490#endif
491 break;
492 }
493 return 0; /* can't get here, but keep compiler quiet */
494}
#define PG_ISPRINT
bool pg_u_isprint(pg_wchar code)
#define isprint_l
Definition: win32_port.h:449
#define iswprint_l
Definition: win32_port.h:450

References pg_locale_struct::info, isprint_l, iswprint_l, pg_locale_struct::lt, pg_char_properties, PG_ISPRINT, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_isprint().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_ispunct()

static int pg_wc_ispunct ( pg_wchar  c)
static

Definition at line 497 of file regc_pg_locale.c.

498{
499 switch (pg_regex_strategy)
500 {
502 return (c <= (pg_wchar) 127 &&
507 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
508 return iswpunct_l((wint_t) c, pg_regex_locale->info.lt);
509 /* FALL THRU */
511 return (c <= (pg_wchar) UCHAR_MAX &&
512 ispunct_l((unsigned char) c, pg_regex_locale->info.lt));
513 break;
515#ifdef USE_ICU
516 return u_ispunct(c);
517#endif
518 break;
519 }
520 return 0; /* can't get here, but keep compiler quiet */
521}
#define PG_ISPUNCT
bool pg_u_ispunct(pg_wchar code, bool posix)
#define ispunct_l
Definition: win32_port.h:451
#define iswpunct_l
Definition: win32_port.h:452

References pg_locale_struct::builtin, pg_locale_struct::casemap_full, pg_locale_struct::info, ispunct_l, iswpunct_l, pg_locale_struct::lt, pg_char_properties, PG_ISPUNCT, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_ispunct().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_isspace()

static int pg_wc_isspace ( pg_wchar  c)
static

Definition at line 524 of file regc_pg_locale.c.

525{
526 switch (pg_regex_strategy)
527 {
529 return (c <= (pg_wchar) 127 &&
532 return pg_u_isspace(c);
534 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
535 return iswspace_l((wint_t) c, pg_regex_locale->info.lt);
536 /* FALL THRU */
538 return (c <= (pg_wchar) UCHAR_MAX &&
539 isspace_l((unsigned char) c, pg_regex_locale->info.lt));
540 break;
542#ifdef USE_ICU
543 return u_isspace(c);
544#endif
545 break;
546 }
547 return 0; /* can't get here, but keep compiler quiet */
548}
#define PG_ISSPACE
bool pg_u_isspace(pg_wchar code)
#define iswspace_l
Definition: win32_port.h:454
#define isspace_l
Definition: win32_port.h:453

References pg_locale_struct::info, isspace_l, iswspace_l, pg_locale_struct::lt, pg_char_properties, PG_ISSPACE, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_isspace().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_isupper()

static int pg_wc_isupper ( pg_wchar  c)
static

Definition at line 389 of file regc_pg_locale.c.

390{
391 switch (pg_regex_strategy)
392 {
394 return (c <= (pg_wchar) 127 &&
397 return pg_u_isupper(c);
399 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
400 return iswupper_l((wint_t) c, pg_regex_locale->info.lt);
401 /* FALL THRU */
403 return (c <= (pg_wchar) UCHAR_MAX &&
404 isupper_l((unsigned char) c, pg_regex_locale->info.lt));
405 break;
407#ifdef USE_ICU
408 return u_isupper(c);
409#endif
410 break;
411 }
412 return 0; /* can't get here, but keep compiler quiet */
413}
#define PG_ISUPPER
bool pg_u_isupper(pg_wchar code)
#define iswupper_l
Definition: win32_port.h:444
#define isupper_l
Definition: win32_port.h:443

References pg_locale_struct::info, isupper_l, iswupper_l, pg_locale_struct::lt, pg_char_properties, PG_ISUPPER, pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, and pg_u_isupper().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_isword()

static int pg_wc_isword ( pg_wchar  c)
static

Definition at line 380 of file regc_pg_locale.c.

381{
382 /* We define word characters as alnum class plus underscore */
383 if (c == CHR('_'))
384 return 1;
385 return pg_wc_isalnum(c);
386}
static int pg_wc_isalnum(pg_wchar c)
#define CHR(c)
Definition: regcustom.h:62

References CHR, and pg_wc_isalnum().

Referenced by cclass_column_index(), and cclasscvec().

◆ pg_wc_tolower()

static pg_wchar pg_wc_tolower ( pg_wchar  c)
static

Definition at line 585 of file regc_pg_locale.c.

586{
587 switch (pg_regex_strategy)
588 {
590 if (c <= (pg_wchar) 127)
591 return pg_ascii_tolower((unsigned char) c);
592 return c;
596 /* force C behavior for ASCII characters, per comments above */
597 if (pg_regex_locale->is_default && c <= (pg_wchar) 127)
598 return pg_ascii_tolower((unsigned char) c);
599 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
600 return towlower_l((wint_t) c, pg_regex_locale->info.lt);
601 /* FALL THRU */
603 /* force C behavior for ASCII characters, per comments above */
604 if (pg_regex_locale->is_default && c <= (pg_wchar) 127)
605 return pg_ascii_tolower((unsigned char) c);
606 if (c <= (pg_wchar) UCHAR_MAX)
607 return tolower_l((unsigned char) c, pg_regex_locale->info.lt);
608 return c;
610#ifdef USE_ICU
611 return u_tolower(c);
612#endif
613 break;
614 }
615 return 0; /* can't get here, but keep compiler quiet */
616}
unsigned char pg_ascii_tolower(unsigned char ch)
Definition: pgstrcasecmp.c:146
pg_wchar unicode_lowercase_simple(pg_wchar code)
Definition: unicode_case.c:50
#define towlower_l
Definition: win32_port.h:435
#define tolower_l
Definition: win32_port.h:433

References pg_locale_struct::info, pg_locale_struct::is_default, pg_locale_struct::lt, pg_ascii_tolower(), pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, tolower_l, towlower_l, and unicode_lowercase_simple().

Referenced by allcases(), casecmp(), and range().

◆ pg_wc_toupper()

static pg_wchar pg_wc_toupper ( pg_wchar  c)
static

Definition at line 551 of file regc_pg_locale.c.

552{
553 switch (pg_regex_strategy)
554 {
556 if (c <= (pg_wchar) 127)
557 return pg_ascii_toupper((unsigned char) c);
558 return c;
562 /* force C behavior for ASCII characters, per comments above */
563 if (pg_regex_locale->is_default && c <= (pg_wchar) 127)
564 return pg_ascii_toupper((unsigned char) c);
565 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
566 return towupper_l((wint_t) c, pg_regex_locale->info.lt);
567 /* FALL THRU */
569 /* force C behavior for ASCII characters, per comments above */
570 if (pg_regex_locale->is_default && c <= (pg_wchar) 127)
571 return pg_ascii_toupper((unsigned char) c);
572 if (c <= (pg_wchar) UCHAR_MAX)
573 return toupper_l((unsigned char) c, pg_regex_locale->info.lt);
574 return c;
576#ifdef USE_ICU
577 return u_toupper(c);
578#endif
579 break;
580 }
581 return 0; /* can't get here, but keep compiler quiet */
582}
unsigned char pg_ascii_toupper(unsigned char ch)
Definition: pgstrcasecmp.c:135
pg_wchar unicode_uppercase_simple(pg_wchar code)
Definition: unicode_case.c:66
#define toupper_l
Definition: win32_port.h:434
#define towupper_l
Definition: win32_port.h:436

References pg_locale_struct::info, pg_locale_struct::is_default, pg_locale_struct::lt, pg_ascii_toupper(), pg_regex_locale, pg_regex_strategy, PG_REGEX_STRATEGY_BUILTIN, PG_REGEX_STRATEGY_C, PG_REGEX_STRATEGY_ICU, PG_REGEX_STRATEGY_LIBC_1BYTE, PG_REGEX_STRATEGY_LIBC_WIDE, toupper_l, towupper_l, and unicode_uppercase_simple().

Referenced by allcases(), and range().

◆ store_match()

static bool store_match ( pg_ctype_cache pcc,
pg_wchar  chr1,
int  nchrs 
)
static

Definition at line 648 of file regc_pg_locale.c.

649{
650 chr *newchrs;
651
652 if (nchrs > 1)
653 {
654 if (pcc->cv.nranges >= pcc->cv.rangespace)
655 {
656 pcc->cv.rangespace *= 2;
657 newchrs = (chr *) realloc(pcc->cv.ranges,
658 pcc->cv.rangespace * sizeof(chr) * 2);
659 if (newchrs == NULL)
660 return false;
661 pcc->cv.ranges = newchrs;
662 }
663 pcc->cv.ranges[pcc->cv.nranges * 2] = chr1;
664 pcc->cv.ranges[pcc->cv.nranges * 2 + 1] = chr1 + nchrs - 1;
665 pcc->cv.nranges++;
666 }
667 else
668 {
669 assert(nchrs == 1);
670 if (pcc->cv.nchrs >= pcc->cv.chrspace)
671 {
672 pcc->cv.chrspace *= 2;
673 newchrs = (chr *) realloc(pcc->cv.chrs,
674 pcc->cv.chrspace * sizeof(chr));
675 if (newchrs == NULL)
676 return false;
677 pcc->cv.chrs = newchrs;
678 }
679 pcc->cv.chrs[pcc->cv.nchrs++] = chr1;
680 }
681 return true;
682}
#define assert(x)
Definition: regcustom.h:56

References assert, cvec::chrs, cvec::chrspace, pg_ctype_cache::cv, cvec::nchrs, cvec::nranges, cvec::ranges, cvec::rangespace, and realloc.

Referenced by pg_ctype_get_cache().

Variable Documentation

◆ pg_char_properties

const unsigned char pg_char_properties[128]
static

◆ pg_ctype_cache_list

pg_ctype_cache* pg_ctype_cache_list = NULL
static

Definition at line 642 of file regc_pg_locale.c.

Referenced by pg_ctype_get_cache().

◆ pg_regex_locale

◆ pg_regex_strategy