1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Use pg_ascii_tolower()/pg_ascii_toupper() where appropriate.

Avoids unnecessary dependence on setlocale(). No behavior change.

This commit reverts e1458f2f1b, which reverted some changes
unintentionally committed before the branch for 19.

Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/a8666c391dfcabe79868d95f7160eac533ace718.camel@j-davis.com
Discussion: https://postgr.es/m/7efaaa645aa5df3771bb47b9c35df27e08f3520e.camel@j-davis.com
This commit is contained in:
Jeff Davis
2025-07-01 07:24:23 -07:00
parent 9e345415bc
commit d81dcc8d62
4 changed files with 5 additions and 6 deletions

View File

@ -726,7 +726,7 @@ string2ean(const char *str, struct Node *escontext, ean13 *result,
if (type != INVALID) if (type != INVALID)
goto eaninvalid; goto eaninvalid;
type = ISSN; type = ISSN;
*aux1++ = toupper((unsigned char) *aux2); *aux1++ = pg_ascii_toupper((unsigned char) *aux2);
length++; length++;
} }
else if (length == 9 && (digit || *aux2 == 'X' || *aux2 == 'x') && last) 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; goto eaninvalid;
if (type == INVALID) if (type == INVALID)
type = ISBN; /* ISMN must start with 'M' */ type = ISBN; /* ISMN must start with 'M' */
*aux1++ = toupper((unsigned char) *aux2); *aux1++ = pg_ascii_toupper((unsigned char) *aux2);
length++; length++;
} }
else if (length == 11 && digit && last) else if (length == 11 && digit && last)

View File

@ -321,7 +321,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
if (nrefs < 1) if (nrefs < 1)
/* internal error */ /* internal error */
elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs); 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') if (action != 'r' && action != 'c' && action != 's')
/* internal error */ /* internal error */
elog(ERROR, "check_foreign_key: invalid action %s", args[1]); elog(ERROR, "check_foreign_key: invalid action %s", args[1]);

View File

@ -1538,7 +1538,7 @@ GetDecimalFromHex(char hex)
if (isdigit((unsigned char) hex)) if (isdigit((unsigned char) hex))
return hex - '0'; return hex - '0';
else else
return tolower((unsigned char) hex) - 'a' + 10; return pg_ascii_tolower((unsigned char) hex) - 'a' + 10;
} }
/* /*

View File

@ -115,8 +115,7 @@ inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size)
src++; /* skip x or X. */ src++; /* skip x or X. */
while ((ch = *src++) != '\0' && isxdigit((unsigned char) ch)) while ((ch = *src++) != '\0' && isxdigit((unsigned char) ch))
{ {
if (isupper((unsigned char) ch)) ch = pg_ascii_tolower((unsigned char) ch);
ch = tolower((unsigned char) ch);
n = strchr(xdigits, ch) - xdigits; n = strchr(xdigits, ch) - xdigits;
assert(n >= 0 && n <= 15); assert(n >= 0 && n <= 15);
if (dirty == 0) if (dirty == 0)