v2-0002-Another-unintentional-behavior-change-in-commit-e.patch
text/x-patch
Filename: v2-0002-Another-unintentional-behavior-change-in-commit-e.patch
Type: text/x-patch
Part: 1
Patch
Format: format-patch
Series: patch v2-0002
Subject: Another unintentional behavior change in commit e9931bfb75.
| File | + | − |
|---|---|---|
| src/backend/regex/regc_pg_locale.c | 12 | 0 |
From d7e18174cb25fc981ba906101c3f4582fc41a826 Mon Sep 17 00:00:00 2001 From: Jeff Davis <jeff@j-davis.com> Date: Tue, 15 Apr 2025 15:05:08 -0700 Subject: [PATCH v2 2/3] Another unintentional behavior change in commit e9931bfb75. Reported-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/20250412123430.8c.nmisch@google.com --- src/backend/regex/regc_pg_locale.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/regex/regc_pg_locale.c b/src/backend/regex/regc_pg_locale.c index 31d8ba0322a..7377f459607 100644 --- a/src/backend/regex/regc_pg_locale.c +++ b/src/backend/regex/regc_pg_locale.c @@ -559,10 +559,16 @@ pg_wc_toupper(pg_wchar c) case PG_REGEX_STRATEGY_BUILTIN: return unicode_uppercase_simple(c); case PG_REGEX_STRATEGY_LIBC_WIDE: + /* force C behavior for ASCII characters, per comments above */ + if (pg_regex_locale->is_default && c <= (pg_wchar) 127) + return pg_ascii_toupper((unsigned char) c); if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towupper_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: + /* force C behavior for ASCII characters, per comments above */ + if (pg_regex_locale->is_default && c <= (pg_wchar) 127) + return pg_ascii_toupper((unsigned char) c); if (c <= (pg_wchar) UCHAR_MAX) return toupper_l((unsigned char) c, pg_regex_locale->info.lt); return c; @@ -587,10 +593,16 @@ pg_wc_tolower(pg_wchar c) case PG_REGEX_STRATEGY_BUILTIN: return unicode_lowercase_simple(c); case PG_REGEX_STRATEGY_LIBC_WIDE: + /* force C behavior for ASCII characters, per comments above */ + if (pg_regex_locale->is_default && c <= (pg_wchar) 127) + return pg_ascii_tolower((unsigned char) c); if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towlower_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: + /* force C behavior for ASCII characters, per comments above */ + if (pg_regex_locale->is_default && c <= (pg_wchar) 127) + return pg_ascii_tolower((unsigned char) c); if (c <= (pg_wchar) UCHAR_MAX) return tolower_l((unsigned char) c, pg_regex_locale->info.lt); return c; -- 2.34.1