Skip to content

Commit d81dcc8

Browse files
committed
Use pg_ascii_tolower()/pg_ascii_toupper() where appropriate.
Avoids unnecessary dependence on setlocale(). No behavior change. This commit reverts e1458f2, which reverted some changes unintentionally committed before the branch for 19. Reviewed-by: Peter Eisentraut <[email protected]> Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/[email protected]
1 parent 9e34541 commit d81dcc8

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

contrib/isn/isn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ string2ean(const char *str, struct Node *escontext, ean13 *result,
726726
if (type != INVALID)
727727
goto eaninvalid;
728728
type = ISSN;
729-
*aux1++ = toupper((unsigned char) *aux2);
729+
*aux1++ = pg_ascii_toupper((unsigned char) *aux2);
730730
length++;
731731
}
732732
else if (length == 9 && (digit || *aux2 == 'X' || *aux2 == 'x') && last)
@@ -736,7 +736,7 @@ string2ean(const char *str, struct Node *escontext, ean13 *result,
736736
goto eaninvalid;
737737
if (type == INVALID)
738738
type = ISBN; /* ISMN must start with 'M' */
739-
*aux1++ = toupper((unsigned char) *aux2);
739+
*aux1++ = pg_ascii_toupper((unsigned char) *aux2);
740740
length++;
741741
}
742742
else if (length == 11 && digit && last)

contrib/spi/refint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
321321
if (nrefs < 1)
322322
/* internal error */
323323
elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs);
324-
action = tolower((unsigned char) *(args[1]));
324+
action = pg_ascii_tolower((unsigned char) *(args[1]));
325325
if (action != 'r' && action != 'c' && action != 's')
326326
/* internal error */
327327
elog(ERROR, "check_foreign_key: invalid action %s", args[1]);

src/backend/commands/copyfromparse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ GetDecimalFromHex(char hex)
15381538
if (isdigit((unsigned char) hex))
15391539
return hex - '0';
15401540
else
1541-
return tolower((unsigned char) hex) - 'a' + 10;
1541+
return pg_ascii_tolower((unsigned char) hex) - 'a' + 10;
15421542
}
15431543

15441544
/*

src/backend/utils/adt/inet_net_pton.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size)
115115
src++; /* skip x or X. */
116116
while ((ch = *src++) != '\0' && isxdigit((unsigned char) ch))
117117
{
118-
if (isupper((unsigned char) ch))
119-
ch = tolower((unsigned char) ch);
118+
ch = pg_ascii_tolower((unsigned char) ch);
120119
n = strchr(xdigits, ch) - xdigits;
121120
assert(n >= 0 && n <= 15);
122121
if (dirty == 0)

0 commit comments

Comments
 (0)