mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
Refactor logic to check for ASCII-only characters in string
The same logic was present for collation commands, SASLprep and pgcrypto, so this removes some code. Author: Michael Paquier Reviewed-by: Stephen Frost, Heikki Linnakangas Discussion: https://postgr.es/m/X9womIn6rne6Gud2@paquier.xyz
This commit is contained in:
@@ -92,6 +92,22 @@ pg_clean_ascii(char *str)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pg_is_ascii -- Check if string is made only of ASCII characters
|
||||
*/
|
||||
bool
|
||||
pg_is_ascii(const char *str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
if (IS_HIGHBIT_SET(*str))
|
||||
return false;
|
||||
str++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pg_strip_crlf -- Remove any trailing newline and carriage return
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user