Skip to content

Commit 2e5353b

Browse files
committed
Another unintentional behavior change in commit e9931bf.
Reported-by: Noah Misch <noah@leadboat.com> Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/20250412123430.8c.nmisch@google.com
1 parent b107744 commit 2e5353b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/backend/regex/regc_pg_locale.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,16 @@ pg_wc_toupper(pg_wchar c)
559559
case PG_REGEX_STRATEGY_BUILTIN:
560560
return unicode_uppercase_simple(c);
561561
case PG_REGEX_STRATEGY_LIBC_WIDE:
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);
562565
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
563566
return towupper_l((wint_t) c, pg_regex_locale->info.lt);
564567
/* FALL THRU */
565568
case PG_REGEX_STRATEGY_LIBC_1BYTE:
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);
566572
if (c <= (pg_wchar) UCHAR_MAX)
567573
return toupper_l((unsigned char) c, pg_regex_locale->info.lt);
568574
return c;
@@ -587,10 +593,16 @@ pg_wc_tolower(pg_wchar c)
587593
case PG_REGEX_STRATEGY_BUILTIN:
588594
return unicode_lowercase_simple(c);
589595
case PG_REGEX_STRATEGY_LIBC_WIDE:
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);
590599
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
591600
return towlower_l((wint_t) c, pg_regex_locale->info.lt);
592601
/* FALL THRU */
593602
case PG_REGEX_STRATEGY_LIBC_1BYTE:
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);
594606
if (c <= (pg_wchar) UCHAR_MAX)
595607
return tolower_l((unsigned char) c, pg_regex_locale->info.lt);
596608
return c;

0 commit comments

Comments
 (0)