mirror of
https://github.com/postgres/postgres.git
synced 2025-11-28 11:44:57 +03:00
Inline pg_ascii_tolower() and pg_ascii_toupper().
Discussion: https://postgr.es/m/450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com Reviewed-by: Chao Li <li.evan.chao@gmail.com>
This commit is contained in:
@@ -169,8 +169,29 @@ extern int pg_strcasecmp(const char *s1, const char *s2);
|
|||||||
extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
|
extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||||
extern unsigned char pg_toupper(unsigned char ch);
|
extern unsigned char pg_toupper(unsigned char ch);
|
||||||
extern unsigned char pg_tolower(unsigned char ch);
|
extern unsigned char pg_tolower(unsigned char ch);
|
||||||
extern unsigned char pg_ascii_toupper(unsigned char ch);
|
|
||||||
extern unsigned char pg_ascii_tolower(unsigned char ch);
|
/*
|
||||||
|
* Fold a character to upper case, following C/POSIX locale rules.
|
||||||
|
*/
|
||||||
|
static inline unsigned char
|
||||||
|
pg_ascii_toupper(unsigned char ch)
|
||||||
|
{
|
||||||
|
if (ch >= 'a' && ch <= 'z')
|
||||||
|
ch += 'A' - 'a';
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fold a character to lower case, following C/POSIX locale rules.
|
||||||
|
*/
|
||||||
|
static inline unsigned char
|
||||||
|
pg_ascii_tolower(unsigned char ch)
|
||||||
|
{
|
||||||
|
if (ch >= 'A' && ch <= 'Z')
|
||||||
|
ch += 'a' - 'A';
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Beginning in v12, we always replace snprintf() and friends with our own
|
* Beginning in v12, we always replace snprintf() and friends with our own
|
||||||
|
|||||||
@@ -13,10 +13,6 @@
|
|||||||
*
|
*
|
||||||
* NB: this code should match downcase_truncate_identifier() in scansup.c.
|
* NB: this code should match downcase_truncate_identifier() in scansup.c.
|
||||||
*
|
*
|
||||||
* We also provide strict ASCII-only case conversion functions, which can
|
|
||||||
* be used to implement C/POSIX case folding semantics no matter what the
|
|
||||||
* C library thinks the locale is.
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
@@ -127,25 +123,3 @@ pg_tolower(unsigned char ch)
|
|||||||
ch = tolower(ch);
|
ch = tolower(ch);
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Fold a character to upper case, following C/POSIX locale rules.
|
|
||||||
*/
|
|
||||||
unsigned char
|
|
||||||
pg_ascii_toupper(unsigned char ch)
|
|
||||||
{
|
|
||||||
if (ch >= 'a' && ch <= 'z')
|
|
||||||
ch += 'A' - 'a';
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fold a character to lower case, following C/POSIX locale rules.
|
|
||||||
*/
|
|
||||||
unsigned char
|
|
||||||
pg_ascii_tolower(unsigned char ch)
|
|
||||||
{
|
|
||||||
if (ch >= 'A' && ch <= 'Z')
|
|
||||||
ch += 'a' - 'A';
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user