From b6ecee0d7d8ad353fae54c68c74e73d2ea36f22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 27 May 2017 18:33:52 -0700 Subject: [PATCH] Fixed isPrint. --- src/debug.cpp | 2 +- src/string.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index 5e52be8..d0720b1 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -125,7 +125,7 @@ namespace bx ascii[asciiPos] = '\0'; debugPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii); data += asciiPos; - hexPos = 0; + hexPos = 0; asciiPos = 0; } } diff --git a/src/string.cpp b/src/string.cpp index 24d0ca5..1568a7b 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -25,14 +25,19 @@ namespace bx ; } + inline bool isInRange(char _ch, char _from, char _to) + { + return unsigned(_ch - _from) < unsigned(_to-_from); + } + bool isUpper(char _ch) { - return _ch >= 'A' && _ch <= 'Z'; + return isInRange(_ch, 'A', 'Z'); } bool isLower(char _ch) { - return _ch >= 'a' && _ch <= 'z'; + return isInRange(_ch, 'a', 'z'); } bool isAlpha(char _ch) @@ -42,7 +47,7 @@ namespace bx bool isNumeric(char _ch) { - return _ch >= '0' && _ch <= '9'; + return isInRange(_ch, '0', '9'); } bool isAlphaNum(char _ch) @@ -52,7 +57,7 @@ namespace bx bool isPrint(char _ch) { - return isAlphaNum(_ch) || isSpace(_ch); + return isInRange(_ch, ' ', '~'); } char toLower(char _ch)