1
0
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:
Michael Paquier
2020-12-21 09:37:11 +09:00
parent 4e1ee79e31
commit 93e8ff8701
5 changed files with 26 additions and 52 deletions

View File

@@ -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
*