From 4c787a24e7e220a60022e47c1776f22f72902899 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Tue, 10 Jun 2025 11:22:57 -0700 Subject: [PATCH 1/4] copyfromparse.c: use pg_ascii_tolower() rather than tolower(). Avoid dependence on setlocale(). No behavior change. Discussion: https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c162@eisentraut.org Reviewed-by: Peter Eisentraut --- src/backend/commands/copyfromparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c index f5fc346e2013b..f52f2477df129 100644 --- a/src/backend/commands/copyfromparse.c +++ b/src/backend/commands/copyfromparse.c @@ -1538,7 +1538,7 @@ GetDecimalFromHex(char hex) if (isdigit((unsigned char) hex)) return hex - '0'; else - return tolower((unsigned char) hex) - 'a' + 10; + return pg_ascii_tolower((unsigned char) hex) - 'a' + 10; } /* From 78bd364ee39ca70a8f9cb8719282389866a08e14 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Tue, 10 Jun 2025 11:23:05 -0700 Subject: [PATCH 2/4] contrib/spi/refint.c: use pg_ascii_tolower() instead. Avoid dependence on setlocale(). No behavior change. Discussion: https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c162@eisentraut.org Reviewed-by: Peter Eisentraut --- contrib/spi/refint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c index d5e25e07ae9e2..89898cad7b0d7 100644 --- a/contrib/spi/refint.c +++ b/contrib/spi/refint.c @@ -321,7 +321,7 @@ check_foreign_key(PG_FUNCTION_ARGS) if (nrefs < 1) /* internal error */ elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs); - action = tolower((unsigned char) *(args[1])); + action = pg_ascii_tolower((unsigned char) *(args[1])); if (action != 'r' && action != 'c' && action != 's') /* internal error */ elog(ERROR, "check_foreign_key: invalid action %s", args[1]); From 7a6880fadc177873d5663961ec3a02d67e34dcbe Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Tue, 10 Jun 2025 11:23:11 -0700 Subject: [PATCH 3/4] isn.c: use pg_ascii_toupper() instead of toupper(). Avoid dependence on setlocale(). No behavior change. Discussion: https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c162@eisentraut.org Reviewed-by: Peter Eisentraut --- contrib/isn/isn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c index 038c8ed4db7bd..1880c91844e90 100644 --- a/contrib/isn/isn.c +++ b/contrib/isn/isn.c @@ -726,7 +726,7 @@ string2ean(const char *str, struct Node *escontext, ean13 *result, if (type != INVALID) goto eaninvalid; type = ISSN; - *aux1++ = toupper((unsigned char) *aux2); + *aux1++ = pg_ascii_toupper((unsigned char) *aux2); length++; } else if (length == 9 && (digit || *aux2 == 'X' || *aux2 == 'x') && last) @@ -736,7 +736,7 @@ string2ean(const char *str, struct Node *escontext, ean13 *result, goto eaninvalid; if (type == INVALID) type = ISBN; /* ISMN must start with 'M' */ - *aux1++ = toupper((unsigned char) *aux2); + *aux1++ = pg_ascii_toupper((unsigned char) *aux2); length++; } else if (length == 11 && digit && last) From 8898082a5d3e94eef073f0e08124137e096e78ef Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Tue, 10 Jun 2025 11:23:20 -0700 Subject: [PATCH 4/4] inet_net_pton.c: use pg_ascii_tolower() rather than tolower(). Avoid dependence on setlocale(). No behavior change. Discussion: https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c162@eisentraut.org Reviewed-by: Peter Eisentraut --- src/backend/utils/adt/inet_net_pton.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/utils/adt/inet_net_pton.c b/src/backend/utils/adt/inet_net_pton.c index ef2236d9f0430..3b0db2a379937 100644 --- a/src/backend/utils/adt/inet_net_pton.c +++ b/src/backend/utils/adt/inet_net_pton.c @@ -115,8 +115,7 @@ inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size) src++; /* skip x or X. */ while ((ch = *src++) != '\0' && isxdigit((unsigned char) ch)) { - if (isupper((unsigned char) ch)) - ch = tolower((unsigned char) ch); + ch = pg_ascii_tolower((unsigned char) ch); n = strchr(xdigits, ch) - xdigits; assert(n >= 0 && n <= 15); if (dirty == 0)