diff options
author | Michael Paquier <michael@paquier.xyz> | 2020-12-21 09:37:11 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2020-12-21 09:37:11 +0900 |
commit | 93e8ff8701a65a70ea8826bdde7fdbbd9c285477 (patch) | |
tree | 70afa5868c3b27609fe50097204bba45a21092d6 /src/common/string.c | |
parent | 4e1ee79e3182256d9c8ddbc1ce9c4e8419c611ff (diff) | |
download | postgresql-93e8ff8701a65a70ea8826bdde7fdbbd9c285477.tar.gz postgresql-93e8ff8701a65a70ea8826bdde7fdbbd9c285477.zip |
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
Diffstat (limited to 'src/common/string.c')
-rw-r--r-- | src/common/string.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/string.c b/src/common/string.c index bcbbfb813db..3e76e2c59fb 100644 --- a/src/common/string.c +++ b/src/common/string.c @@ -93,6 +93,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 * * Removes any trailing newline and carriage return characters (\r on |