PostgreSQL Source Code git master
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 83 of file regc_pg_locale.c.

◆ PG_ISALPHA

#define PG_ISALPHA   0x02

Definition at line 82 of file regc_pg_locale.c.

◆ PG_ISDIGIT

#define PG_ISDIGIT   0x01

Definition at line 81 of file regc_pg_locale.c.

◆ PG_ISGRAPH

#define PG_ISGRAPH   0x10

Definition at line 86 of file regc_pg_locale.c.

◆ PG_ISLOWER

#define PG_ISLOWER   0x08

Definition at line 85 of file regc_pg_locale.c.

◆ PG_ISPRINT

#define PG_ISPRINT   0x20

Definition at line 87 of file regc_pg_locale.c.

◆ PG_ISPUNCT

#define PG_ISPUNCT   0x40

Definition at line 88 of file regc_pg_locale.c.

◆ PG_ISSPACE

#define PG_ISSPACE   0x80

Definition at line 89 of file regc_pg_locale.c.

◆ PG_ISUPPER

#define PG_ISUPPER   0x04

Definition at line 84 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 623 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 66 of file regc_pg_locale.c.

67{
68 PG_REGEX_STRATEGY_C, /* C locale (encoding independent) */
69 PG_REGEX_STRATEGY_BUILTIN, /* built-in Unicode semantics */
70 PG_REGEX_STRATEGY_LIBC_WIDE, /* Use locale_t <wctype.h> functions */
71 PG_REGEX_STRATEGY_LIBC_1BYTE, /* Use locale_t <ctype.h> functions */
72 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 683 of file regc_pg_locale.c.

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

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

357{
358 switch (pg_regex_strategy)
359 {
361 return (c <= (pg_wchar) 127 &&
364 return pg_u_isalnum(c, true);
366 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
367 return iswalnum_l((wint_t) c, pg_regex_locale->info.lt);
368 /* FALL THRU */
370 return (c <= (pg_wchar) UCHAR_MAX &&
371 isalnum_l((unsigned char) c, pg_regex_locale->info.lt));
372 break;
374#ifdef USE_ICU
375 return u_isalnum(c);
376#endif
377 break;
378 }
379 return 0; /* can't get here, but keep compiler quiet */
380}
char * c
#define PG_ISALNUM
static const unsigned char pg_char_properties[128]
union pg_locale_struct::@158 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::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 329 of file regc_pg_locale.c.

330{
331 switch (pg_regex_strategy)
332 {
334 return (c <= (pg_wchar) 127 &&
337 return pg_u_isalpha(c);
339 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
340 return iswalpha_l((wint_t) c, pg_regex_locale->info.lt);
341 /* FALL THRU */
343 return (c <= (pg_wchar) UCHAR_MAX &&
344 isalpha_l((unsigned char) c, pg_regex_locale->info.lt));
345 break;
347#ifdef USE_ICU
348 return u_isalpha(c);
349#endif
350 break;
351 }
352 return 0; /* can't get here, but keep compiler quiet */
353}
#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 302 of file regc_pg_locale.c.

303{
304 switch (pg_regex_strategy)
305 {
307 return (c <= (pg_wchar) 127 &&
310 return pg_u_isdigit(c, true);
312 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
313 return iswdigit_l((wint_t) c, pg_regex_locale->info.lt);
314 /* FALL THRU */
316 return (c <= (pg_wchar) UCHAR_MAX &&
317 isdigit_l((unsigned char) c, pg_regex_locale->info.lt));
318 break;
320#ifdef USE_ICU
321 return u_isdigit(c);
322#endif
323 break;
324 }
325 return 0; /* can't get here, but keep compiler quiet */
326}
#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::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 446 of file regc_pg_locale.c.

447{
448 switch (pg_regex_strategy)
449 {
451 return (c <= (pg_wchar) 127 &&
454 return pg_u_isgraph(c);
456 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
457 return iswgraph_l((wint_t) c, pg_regex_locale->info.lt);
458 /* FALL THRU */
460 return (c <= (pg_wchar) UCHAR_MAX &&
461 isgraph_l((unsigned char) c, pg_regex_locale->info.lt));
462 break;
464#ifdef USE_ICU
465 return u_isgraph(c);
466#endif
467 break;
468 }
469 return 0; /* can't get here, but keep compiler quiet */
470}
#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 419 of file regc_pg_locale.c.

420{
421 switch (pg_regex_strategy)
422 {
424 return (c <= (pg_wchar) 127 &&
427 return pg_u_islower(c);
429 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
430 return iswlower_l((wint_t) c, pg_regex_locale->info.lt);
431 /* FALL THRU */
433 return (c <= (pg_wchar) UCHAR_MAX &&
434 islower_l((unsigned char) c, pg_regex_locale->info.lt));
435 break;
437#ifdef USE_ICU
438 return u_islower(c);
439#endif
440 break;
441 }
442 return 0; /* can't get here, but keep compiler quiet */
443}
#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 473 of file regc_pg_locale.c.

474{
475 switch (pg_regex_strategy)
476 {
478 return (c <= (pg_wchar) 127 &&
481 return pg_u_isprint(c);
483 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
484 return iswprint_l((wint_t) c, pg_regex_locale->info.lt);
485 /* FALL THRU */
487 return (c <= (pg_wchar) UCHAR_MAX &&
488 isprint_l((unsigned char) c, pg_regex_locale->info.lt));
489 break;
491#ifdef USE_ICU
492 return u_isprint(c);
493#endif
494 break;
495 }
496 return 0; /* can't get here, but keep compiler quiet */
497}
#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 500 of file regc_pg_locale.c.

501{
502 switch (pg_regex_strategy)
503 {
505 return (c <= (pg_wchar) 127 &&
508 return pg_u_ispunct(c, true);
510 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
511 return iswpunct_l((wint_t) c, pg_regex_locale->info.lt);
512 /* FALL THRU */
514 return (c <= (pg_wchar) UCHAR_MAX &&
515 ispunct_l((unsigned char) c, pg_regex_locale->info.lt));
516 break;
518#ifdef USE_ICU
519 return u_ispunct(c);
520#endif
521 break;
522 }
523 return 0; /* can't get here, but keep compiler quiet */
524}
#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::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 527 of file regc_pg_locale.c.

528{
529 switch (pg_regex_strategy)
530 {
532 return (c <= (pg_wchar) 127 &&
535 return pg_u_isspace(c);
537 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
538 return iswspace_l((wint_t) c, pg_regex_locale->info.lt);
539 /* FALL THRU */
541 return (c <= (pg_wchar) UCHAR_MAX &&
542 isspace_l((unsigned char) c, pg_regex_locale->info.lt));
543 break;
545#ifdef USE_ICU
546 return u_isspace(c);
547#endif
548 break;
549 }
550 return 0; /* can't get here, but keep compiler quiet */
551}
#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 392 of file regc_pg_locale.c.

393{
394 switch (pg_regex_strategy)
395 {
397 return (c <= (pg_wchar) 127 &&
400 return pg_u_isupper(c);
402 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
403 return iswupper_l((wint_t) c, pg_regex_locale->info.lt);
404 /* FALL THRU */
406 return (c <= (pg_wchar) UCHAR_MAX &&
407 isupper_l((unsigned char) c, pg_regex_locale->info.lt));
408 break;
410#ifdef USE_ICU
411 return u_isupper(c);
412#endif
413 break;
414 }
415 return 0; /* can't get here, but keep compiler quiet */
416}
#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 383 of file regc_pg_locale.c.

384{
385 /* We define word characters as alnum class plus underscore */
386 if (c == CHR('_'))
387 return 1;
388 return pg_wc_isalnum(c);
389}
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 582 of file regc_pg_locale.c.

583{
584 switch (pg_regex_strategy)
585 {
587 if (c <= (pg_wchar) 127)
588 return pg_ascii_tolower((unsigned char) c);
589 return c;
593 if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
594 return towlower_l((wint_t) c, pg_regex_locale->info.lt);
595 /* FALL THRU */
597 if (c <= (pg_wchar) UCHAR_MAX)
598 return tolower_l((unsigned char) c, pg_regex_locale->info.lt);
599 return c;
601#ifdef USE_ICU
602 return u_tolower(c);
603#endif
604 break;
605 }
606 return 0; /* can't get here, but keep compiler quiet */
607}
unsigned char pg_ascii_tolower(unsigned char ch)
Definition: pgstrcasecmp.c:146
pg_wchar unicode_lowercase_simple(pg_wchar code)
Definition: unicode_case.c:28
#define towlower_l
Definition: win32_port.h:435
#define tolower_l
Definition: win32_port.h:433

References pg_locale_struct::info, 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 554 of file regc_pg_locale.c.

555{
556 switch (pg_regex_strategy)
557 {
559 if (c <= (pg_wchar) 127)
560 return pg_ascii_toupper((unsigned char) c);
561 return 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 if (c <= (pg_wchar) UCHAR_MAX)
570 return toupper_l((unsigned char) c, pg_regex_locale->info.lt);
571 return c;
573#ifdef USE_ICU
574 return u_toupper(c);
575#endif
576 break;
577 }
578 return 0; /* can't get here, but keep compiler quiet */
579}
unsigned char pg_ascii_toupper(unsigned char ch)
Definition: pgstrcasecmp.c:135
pg_wchar unicode_uppercase_simple(pg_wchar code)
Definition: unicode_case.c:44
#define toupper_l
Definition: win32_port.h:434
#define towupper_l
Definition: win32_port.h:436

References pg_locale_struct::info, 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 639 of file regc_pg_locale.c.

640{
641 chr *newchrs;
642
643 if (nchrs > 1)
644 {
645 if (pcc->cv.nranges >= pcc->cv.rangespace)
646 {
647 pcc->cv.rangespace *= 2;
648 newchrs = (chr *) realloc(pcc->cv.ranges,
649 pcc->cv.rangespace * sizeof(chr) * 2);
650 if (newchrs == NULL)
651 return false;
652 pcc->cv.ranges = newchrs;
653 }
654 pcc->cv.ranges[pcc->cv.nranges * 2] = chr1;
655 pcc->cv.ranges[pcc->cv.nranges * 2 + 1] = chr1 + nchrs - 1;
656 pcc->cv.nranges++;
657 }
658 else
659 {
660 assert(nchrs == 1);
661 if (pcc->cv.nchrs >= pcc->cv.chrspace)
662 {
663 pcc->cv.chrspace *= 2;
664 newchrs = (chr *) realloc(pcc->cv.chrs,
665 pcc->cv.chrspace * sizeof(chr));
666 if (newchrs == NULL)
667 return false;
668 pcc->cv.chrs = newchrs;
669 }
670 pcc->cv.chrs[pcc->cv.nchrs++] = chr1;
671 }
672 return true;
673}
#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 633 of file regc_pg_locale.c.

Referenced by pg_ctype_get_cache().

◆ pg_regex_locale

◆ pg_regex_strategy