From 37005cc443d8725a0103fdd4ded0b1d38853ef42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sat, 2 May 2015 22:33:49 +0200 Subject: [PATCH] Fix isspace_ascii(), add new _ascii() functions --- liberty.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/liberty.c b/liberty.c index 05c2a79..b3ea3e3 100644 --- a/liberty.c +++ b/liberty.c @@ -1805,10 +1805,36 @@ strcasecmp_ascii (const char *a, const char *b) return 0; } +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 -------------------------------------------------------------------