Skip to content

Commit 2313828

Browse files
committed
Rename enum labels of PG_Locale_Strategy
PG_REGEX_BUILTIN was added in f69319f but it did not follow the same pattern as the previous labels, i.e. PG_LOCALE_*. In addition to this, the two libc strategies did not include in the name that they were related to this library. The enum labels are renamed as PG_STRATEGY_type[_subtype] to make the code clearer, in accordance to the library and the functions they rely on. Author: Andreas Karlsson Discussion: https://postgr.es/m/6f81200f-68fd-411e-97a1-d1f291d2e222@proxel.se
1 parent 4effd08 commit 2313828

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed

src/backend/regex/regc_pg_locale.c

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@
6565

6666
typedef enum
6767
{
68-
PG_REGEX_LOCALE_C, /* C locale (encoding independent) */
69-
PG_REGEX_BUILTIN, /* built-in Unicode semantics */
70-
PG_REGEX_LOCALE_WIDE_L, /* Use locale_t <wctype.h> functions */
71-
PG_REGEX_LOCALE_1BYTE_L, /* Use locale_t <ctype.h> functions */
72-
PG_REGEX_LOCALE_ICU, /* Use ICU uchar.h functions */
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 */
7373
} PG_Locale_Strategy;
7474

7575
static PG_Locale_Strategy pg_regex_strategy;
@@ -246,7 +246,7 @@ pg_set_regex_collation(Oid collation)
246246
if (lc_ctype_is_c(collation))
247247
{
248248
/* C/POSIX collations use this path regardless of database encoding */
249-
pg_regex_strategy = PG_REGEX_LOCALE_C;
249+
pg_regex_strategy = PG_REGEX_STRATEGY_C;
250250
pg_regex_locale = 0;
251251
pg_regex_collation = C_COLLATION_OID;
252252
}
@@ -262,20 +262,20 @@ pg_set_regex_collation(Oid collation)
262262
if (pg_regex_locale->provider == COLLPROVIDER_BUILTIN)
263263
{
264264
Assert(GetDatabaseEncoding() == PG_UTF8);
265-
pg_regex_strategy = PG_REGEX_BUILTIN;
265+
pg_regex_strategy = PG_REGEX_STRATEGY_BUILTIN;
266266
}
267267
#ifdef USE_ICU
268268
else if (pg_regex_locale->provider == COLLPROVIDER_ICU)
269269
{
270-
pg_regex_strategy = PG_REGEX_LOCALE_ICU;
270+
pg_regex_strategy = PG_REGEX_STRATEGY_ICU;
271271
}
272272
#endif
273273
else
274274
{
275275
if (GetDatabaseEncoding() == PG_UTF8)
276-
pg_regex_strategy = PG_REGEX_LOCALE_WIDE_L;
276+
pg_regex_strategy = PG_REGEX_STRATEGY_LIBC_WIDE;
277277
else
278-
pg_regex_strategy = PG_REGEX_LOCALE_1BYTE_L;
278+
pg_regex_strategy = PG_REGEX_STRATEGY_LIBC_1BYTE;
279279
}
280280

281281
pg_regex_collation = collation;
@@ -287,20 +287,20 @@ pg_wc_isdigit(pg_wchar c)
287287
{
288288
switch (pg_regex_strategy)
289289
{
290-
case PG_REGEX_LOCALE_C:
290+
case PG_REGEX_STRATEGY_C:
291291
return (c <= (pg_wchar) 127 &&
292292
(pg_char_properties[c] & PG_ISDIGIT));
293-
case PG_REGEX_BUILTIN:
293+
case PG_REGEX_STRATEGY_BUILTIN:
294294
return pg_u_isdigit(c, true);
295-
case PG_REGEX_LOCALE_WIDE_L:
295+
case PG_REGEX_STRATEGY_LIBC_WIDE:
296296
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
297297
return iswdigit_l((wint_t) c, pg_regex_locale->info.lt);
298298
/* FALL THRU */
299-
case PG_REGEX_LOCALE_1BYTE_L:
299+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
300300
return (c <= (pg_wchar) UCHAR_MAX &&
301301
isdigit_l((unsigned char) c, pg_regex_locale->info.lt));
302302
break;
303-
case PG_REGEX_LOCALE_ICU:
303+
case PG_REGEX_STRATEGY_ICU:
304304
#ifdef USE_ICU
305305
return u_isdigit(c);
306306
#endif
@@ -314,20 +314,20 @@ pg_wc_isalpha(pg_wchar c)
314314
{
315315
switch (pg_regex_strategy)
316316
{
317-
case PG_REGEX_LOCALE_C:
317+
case PG_REGEX_STRATEGY_C:
318318
return (c <= (pg_wchar) 127 &&
319319
(pg_char_properties[c] & PG_ISALPHA));
320-
case PG_REGEX_BUILTIN:
320+
case PG_REGEX_STRATEGY_BUILTIN:
321321
return pg_u_isalpha(c);
322-
case PG_REGEX_LOCALE_WIDE_L:
322+
case PG_REGEX_STRATEGY_LIBC_WIDE:
323323
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
324324
return iswalpha_l((wint_t) c, pg_regex_locale->info.lt);
325325
/* FALL THRU */
326-
case PG_REGEX_LOCALE_1BYTE_L:
326+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
327327
return (c <= (pg_wchar) UCHAR_MAX &&
328328
isalpha_l((unsigned char) c, pg_regex_locale->info.lt));
329329
break;
330-
case PG_REGEX_LOCALE_ICU:
330+
case PG_REGEX_STRATEGY_ICU:
331331
#ifdef USE_ICU
332332
return u_isalpha(c);
333333
#endif
@@ -341,20 +341,20 @@ pg_wc_isalnum(pg_wchar c)
341341
{
342342
switch (pg_regex_strategy)
343343
{
344-
case PG_REGEX_LOCALE_C:
344+
case PG_REGEX_STRATEGY_C:
345345
return (c <= (pg_wchar) 127 &&
346346
(pg_char_properties[c] & PG_ISALNUM));
347-
case PG_REGEX_BUILTIN:
347+
case PG_REGEX_STRATEGY_BUILTIN:
348348
return pg_u_isalnum(c, true);
349-
case PG_REGEX_LOCALE_WIDE_L:
349+
case PG_REGEX_STRATEGY_LIBC_WIDE:
350350
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
351351
return iswalnum_l((wint_t) c, pg_regex_locale->info.lt);
352352
/* FALL THRU */
353-
case PG_REGEX_LOCALE_1BYTE_L:
353+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
354354
return (c <= (pg_wchar) UCHAR_MAX &&
355355
isalnum_l((unsigned char) c, pg_regex_locale->info.lt));
356356
break;
357-
case PG_REGEX_LOCALE_ICU:
357+
case PG_REGEX_STRATEGY_ICU:
358358
#ifdef USE_ICU
359359
return u_isalnum(c);
360360
#endif
@@ -377,20 +377,20 @@ pg_wc_isupper(pg_wchar c)
377377
{
378378
switch (pg_regex_strategy)
379379
{
380-
case PG_REGEX_LOCALE_C:
380+
case PG_REGEX_STRATEGY_C:
381381
return (c <= (pg_wchar) 127 &&
382382
(pg_char_properties[c] & PG_ISUPPER));
383-
case PG_REGEX_BUILTIN:
383+
case PG_REGEX_STRATEGY_BUILTIN:
384384
return pg_u_isupper(c);
385-
case PG_REGEX_LOCALE_WIDE_L:
385+
case PG_REGEX_STRATEGY_LIBC_WIDE:
386386
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
387387
return iswupper_l((wint_t) c, pg_regex_locale->info.lt);
388388
/* FALL THRU */
389-
case PG_REGEX_LOCALE_1BYTE_L:
389+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
390390
return (c <= (pg_wchar) UCHAR_MAX &&
391391
isupper_l((unsigned char) c, pg_regex_locale->info.lt));
392392
break;
393-
case PG_REGEX_LOCALE_ICU:
393+
case PG_REGEX_STRATEGY_ICU:
394394
#ifdef USE_ICU
395395
return u_isupper(c);
396396
#endif
@@ -404,20 +404,20 @@ pg_wc_islower(pg_wchar c)
404404
{
405405
switch (pg_regex_strategy)
406406
{
407-
case PG_REGEX_LOCALE_C:
407+
case PG_REGEX_STRATEGY_C:
408408
return (c <= (pg_wchar) 127 &&
409409
(pg_char_properties[c] & PG_ISLOWER));
410-
case PG_REGEX_BUILTIN:
410+
case PG_REGEX_STRATEGY_BUILTIN:
411411
return pg_u_islower(c);
412-
case PG_REGEX_LOCALE_WIDE_L:
412+
case PG_REGEX_STRATEGY_LIBC_WIDE:
413413
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
414414
return iswlower_l((wint_t) c, pg_regex_locale->info.lt);
415415
/* FALL THRU */
416-
case PG_REGEX_LOCALE_1BYTE_L:
416+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
417417
return (c <= (pg_wchar) UCHAR_MAX &&
418418
islower_l((unsigned char) c, pg_regex_locale->info.lt));
419419
break;
420-
case PG_REGEX_LOCALE_ICU:
420+
case PG_REGEX_STRATEGY_ICU:
421421
#ifdef USE_ICU
422422
return u_islower(c);
423423
#endif
@@ -431,20 +431,20 @@ pg_wc_isgraph(pg_wchar c)
431431
{
432432
switch (pg_regex_strategy)
433433
{
434-
case PG_REGEX_LOCALE_C:
434+
case PG_REGEX_STRATEGY_C:
435435
return (c <= (pg_wchar) 127 &&
436436
(pg_char_properties[c] & PG_ISGRAPH));
437-
case PG_REGEX_BUILTIN:
437+
case PG_REGEX_STRATEGY_BUILTIN:
438438
return pg_u_isgraph(c);
439-
case PG_REGEX_LOCALE_WIDE_L:
439+
case PG_REGEX_STRATEGY_LIBC_WIDE:
440440
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
441441
return iswgraph_l((wint_t) c, pg_regex_locale->info.lt);
442442
/* FALL THRU */
443-
case PG_REGEX_LOCALE_1BYTE_L:
443+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
444444
return (c <= (pg_wchar) UCHAR_MAX &&
445445
isgraph_l((unsigned char) c, pg_regex_locale->info.lt));
446446
break;
447-
case PG_REGEX_LOCALE_ICU:
447+
case PG_REGEX_STRATEGY_ICU:
448448
#ifdef USE_ICU
449449
return u_isgraph(c);
450450
#endif
@@ -458,20 +458,20 @@ pg_wc_isprint(pg_wchar c)
458458
{
459459
switch (pg_regex_strategy)
460460
{
461-
case PG_REGEX_LOCALE_C:
461+
case PG_REGEX_STRATEGY_C:
462462
return (c <= (pg_wchar) 127 &&
463463
(pg_char_properties[c] & PG_ISPRINT));
464-
case PG_REGEX_BUILTIN:
464+
case PG_REGEX_STRATEGY_BUILTIN:
465465
return pg_u_isprint(c);
466-
case PG_REGEX_LOCALE_WIDE_L:
466+
case PG_REGEX_STRATEGY_LIBC_WIDE:
467467
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
468468
return iswprint_l((wint_t) c, pg_regex_locale->info.lt);
469469
/* FALL THRU */
470-
case PG_REGEX_LOCALE_1BYTE_L:
470+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
471471
return (c <= (pg_wchar) UCHAR_MAX &&
472472
isprint_l((unsigned char) c, pg_regex_locale->info.lt));
473473
break;
474-
case PG_REGEX_LOCALE_ICU:
474+
case PG_REGEX_STRATEGY_ICU:
475475
#ifdef USE_ICU
476476
return u_isprint(c);
477477
#endif
@@ -485,20 +485,20 @@ pg_wc_ispunct(pg_wchar c)
485485
{
486486
switch (pg_regex_strategy)
487487
{
488-
case PG_REGEX_LOCALE_C:
488+
case PG_REGEX_STRATEGY_C:
489489
return (c <= (pg_wchar) 127 &&
490490
(pg_char_properties[c] & PG_ISPUNCT));
491-
case PG_REGEX_BUILTIN:
491+
case PG_REGEX_STRATEGY_BUILTIN:
492492
return pg_u_ispunct(c, true);
493-
case PG_REGEX_LOCALE_WIDE_L:
493+
case PG_REGEX_STRATEGY_LIBC_WIDE:
494494
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
495495
return iswpunct_l((wint_t) c, pg_regex_locale->info.lt);
496496
/* FALL THRU */
497-
case PG_REGEX_LOCALE_1BYTE_L:
497+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
498498
return (c <= (pg_wchar) UCHAR_MAX &&
499499
ispunct_l((unsigned char) c, pg_regex_locale->info.lt));
500500
break;
501-
case PG_REGEX_LOCALE_ICU:
501+
case PG_REGEX_STRATEGY_ICU:
502502
#ifdef USE_ICU
503503
return u_ispunct(c);
504504
#endif
@@ -512,20 +512,20 @@ pg_wc_isspace(pg_wchar c)
512512
{
513513
switch (pg_regex_strategy)
514514
{
515-
case PG_REGEX_LOCALE_C:
515+
case PG_REGEX_STRATEGY_C:
516516
return (c <= (pg_wchar) 127 &&
517517
(pg_char_properties[c] & PG_ISSPACE));
518-
case PG_REGEX_BUILTIN:
518+
case PG_REGEX_STRATEGY_BUILTIN:
519519
return pg_u_isspace(c);
520-
case PG_REGEX_LOCALE_WIDE_L:
520+
case PG_REGEX_STRATEGY_LIBC_WIDE:
521521
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
522522
return iswspace_l((wint_t) c, pg_regex_locale->info.lt);
523523
/* FALL THRU */
524-
case PG_REGEX_LOCALE_1BYTE_L:
524+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
525525
return (c <= (pg_wchar) UCHAR_MAX &&
526526
isspace_l((unsigned char) c, pg_regex_locale->info.lt));
527527
break;
528-
case PG_REGEX_LOCALE_ICU:
528+
case PG_REGEX_STRATEGY_ICU:
529529
#ifdef USE_ICU
530530
return u_isspace(c);
531531
#endif
@@ -539,21 +539,21 @@ pg_wc_toupper(pg_wchar c)
539539
{
540540
switch (pg_regex_strategy)
541541
{
542-
case PG_REGEX_LOCALE_C:
542+
case PG_REGEX_STRATEGY_C:
543543
if (c <= (pg_wchar) 127)
544544
return pg_ascii_toupper((unsigned char) c);
545545
return c;
546-
case PG_REGEX_BUILTIN:
546+
case PG_REGEX_STRATEGY_BUILTIN:
547547
return unicode_uppercase_simple(c);
548-
case PG_REGEX_LOCALE_WIDE_L:
548+
case PG_REGEX_STRATEGY_LIBC_WIDE:
549549
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
550550
return towupper_l((wint_t) c, pg_regex_locale->info.lt);
551551
/* FALL THRU */
552-
case PG_REGEX_LOCALE_1BYTE_L:
552+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
553553
if (c <= (pg_wchar) UCHAR_MAX)
554554
return toupper_l((unsigned char) c, pg_regex_locale->info.lt);
555555
return c;
556-
case PG_REGEX_LOCALE_ICU:
556+
case PG_REGEX_STRATEGY_ICU:
557557
#ifdef USE_ICU
558558
return u_toupper(c);
559559
#endif
@@ -567,21 +567,21 @@ pg_wc_tolower(pg_wchar c)
567567
{
568568
switch (pg_regex_strategy)
569569
{
570-
case PG_REGEX_LOCALE_C:
570+
case PG_REGEX_STRATEGY_C:
571571
if (c <= (pg_wchar) 127)
572572
return pg_ascii_tolower((unsigned char) c);
573573
return c;
574-
case PG_REGEX_BUILTIN:
574+
case PG_REGEX_STRATEGY_BUILTIN:
575575
return unicode_lowercase_simple(c);
576-
case PG_REGEX_LOCALE_WIDE_L:
576+
case PG_REGEX_STRATEGY_LIBC_WIDE:
577577
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
578578
return towlower_l((wint_t) c, pg_regex_locale->info.lt);
579579
/* FALL THRU */
580-
case PG_REGEX_LOCALE_1BYTE_L:
580+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
581581
if (c <= (pg_wchar) UCHAR_MAX)
582582
return tolower_l((unsigned char) c, pg_regex_locale->info.lt);
583583
return c;
584-
case PG_REGEX_LOCALE_ICU:
584+
case PG_REGEX_STRATEGY_ICU:
585585
#ifdef USE_ICU
586586
return u_tolower(c);
587587
#endif
@@ -715,29 +715,29 @@ pg_ctype_get_cache(pg_wc_probefunc probefunc, int cclasscode)
715715
*/
716716
switch (pg_regex_strategy)
717717
{
718-
case PG_REGEX_LOCALE_C:
718+
case PG_REGEX_STRATEGY_C:
719719
#if MAX_SIMPLE_CHR >= 127
720720
max_chr = (pg_wchar) 127;
721721
pcc->cv.cclasscode = -1;
722722
#else
723723
max_chr = (pg_wchar) MAX_SIMPLE_CHR;
724724
#endif
725725
break;
726-
case PG_REGEX_BUILTIN:
726+
case PG_REGEX_STRATEGY_BUILTIN:
727727
max_chr = (pg_wchar) MAX_SIMPLE_CHR;
728728
break;
729-
case PG_REGEX_LOCALE_WIDE_L:
729+
case PG_REGEX_STRATEGY_LIBC_WIDE:
730730
max_chr = (pg_wchar) MAX_SIMPLE_CHR;
731731
break;
732-
case PG_REGEX_LOCALE_1BYTE_L:
732+
case PG_REGEX_STRATEGY_LIBC_1BYTE:
733733
#if MAX_SIMPLE_CHR >= UCHAR_MAX
734734
max_chr = (pg_wchar) UCHAR_MAX;
735735
pcc->cv.cclasscode = -1;
736736
#else
737737
max_chr = (pg_wchar) MAX_SIMPLE_CHR;
738738
#endif
739739
break;
740-
case PG_REGEX_LOCALE_ICU:
740+
case PG_REGEX_STRATEGY_ICU:
741741
max_chr = (pg_wchar) MAX_SIMPLE_CHR;
742742
break;
743743
default:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy