aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-02 22:33:49 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-02 22:33:49 +0200
commit37005cc443d8725a0103fdd4ded0b1d38853ef42 (patch)
tree2249e41746a795d0ce292b5d7f25ce7730f8dda5
parentc8238a5764a76c45e2e2283cd41fdc00e12cfe88 (diff)
downloadliberty-37005cc443d8725a0103fdd4ded0b1d38853ef42.tar.gz
liberty-37005cc443d8725a0103fdd4ded0b1d38853ef42.tar.xz
liberty-37005cc443d8725a0103fdd4ded0b1d38853ef42.zip
Fix isspace_ascii(), add new _ascii() functions
-rw-r--r--liberty.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/liberty.c b/liberty.c
index 05c2a79..b3ea3e3 100644
--- a/liberty.c
+++ b/liberty.c
@@ -1806,9 +1806,35 @@ strcasecmp_ascii (const char *a, const char *b)
}
static bool
+isalpha_ascii (int c)
+{
+ c &= ~32;
+ return c >= 'A' && c <= 'Z';
+}
+
+static bool
+isdigit_ascii (int c)
+{
+ return c >= '0' && c <= '9';
+}
+
+static bool
+isalnum_ascii (int c)
+{
+ return isalpha_ascii (c) || isdigit_ascii (c);
+}
+
+static int
+toupper_ascii (int c)
+{
+ return c >= 'A' && c <= 'Z' ? c : c - ('a' - 'A');
+}
+
+static bool
isspace_ascii (int c)
{
- return c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
+ return c == ' ' || c == '\f' || c == '\n'
+ || c == '\r' || c == '\t' || c == '\v';
}
// --- UTF-8 -------------------------------------------------------------------