aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/util.cpp22
-rw-r--r--common/util.h19
2 files changed, 28 insertions, 13 deletions
diff --git a/common/util.cpp b/common/util.cpp
index a6c7958a0d..9a4214eda8 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -20,17 +20,7 @@
*
*/
-#define FORBIDDEN_SYMBOL_EXCEPTION_isalnum
-#define FORBIDDEN_SYMBOL_EXCEPTION_isalpha
-#define FORBIDDEN_SYMBOL_EXCEPTION_isdigit
-#define FORBIDDEN_SYMBOL_EXCEPTION_isxdigit
-#define FORBIDDEN_SYMBOL_EXCEPTION_isnumber
-#define FORBIDDEN_SYMBOL_EXCEPTION_islower
-#define FORBIDDEN_SYMBOL_EXCEPTION_isspace
-#define FORBIDDEN_SYMBOL_EXCEPTION_isupper
-#define FORBIDDEN_SYMBOL_EXCEPTION_isprint
-#define FORBIDDEN_SYMBOL_EXCEPTION_ispunct
-
+#define FORBIDDEN_SYMBOL_EXCEPTION_ctype_h
#include "common/util.h"
#include "common/debug.h"
@@ -163,4 +153,14 @@ bool isPunct(int c) {
return ispunct((byte)c);
}
+bool isCntrl(int c) {
+ ENSURE_ASCII_CHAR(c);
+ return iscntrl((byte)c);
+}
+
+bool isGraph(int c) {
+ ENSURE_ASCII_CHAR(c);
+ return isgraph((byte)c);
+}
+
} // End of namespace Common
diff --git a/common/util.h b/common/util.h
index 5f853da43a..a90ea72167 100644
--- a/common/util.h
+++ b/common/util.h
@@ -195,16 +195,31 @@ bool isUpper(int c);
*/
bool isPrint(int c);
-
/**
* Test whether the given character is a punctuation character,
- * (i.e not alphanumeric.
+ * (i.e. not alphanumeric).
*
* @param c the character to test
* @return true if the character is punctuation, false otherwise.
*/
bool isPunct(int c);
+/**
+ * Test whether the given character is a control character.
+ *
+ * @param c the character to test
+ * @return true if the character is a control character, false otherwise.
+ */
+bool isCntrl(int c);
+
+/**
+ * Test whether the given character has a graphical representation.
+ *
+ * @param c the character to test
+ * @return true if the character is a graphic, false otherwise.
+ */
+bool isGraph(int c);
+
} // End of namespace Common
#endif