aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CharClassify.cxx2
-rw-r--r--src/CharacterType.h4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/CharClassify.cxx b/src/CharClassify.cxx
index caff785b0..b5eb33700 100644
--- a/src/CharClassify.cxx
+++ b/src/CharClassify.cxx
@@ -24,7 +24,7 @@ void CharClassify::SetDefaultCharClasses(bool includeWordClass) {
for (int ch = 0; ch < maxChar; ch++) {
if (ch == '\r' || ch == '\n')
charClass[ch] = CharacterClass::newLine;
- else if (ch < 0x20 || ch == ' ')
+ else if (IsControl(ch) || ch == ' ')
charClass[ch] = CharacterClass::space;
else if (includeWordClass && (ch >= 0x80 || IsAlphaNumeric(ch) || ch == '_'))
charClass[ch] = CharacterClass::word;
diff --git a/src/CharacterType.h b/src/CharacterType.h
index dcef6aa78..70f4cbd05 100644
--- a/src/CharacterType.h
+++ b/src/CharacterType.h
@@ -20,6 +20,10 @@ constexpr bool IsASpaceOrTab(int ch) noexcept {
return (ch == ' ') || (ch == '\t');
}
+constexpr bool IsControl(int ch) noexcept {
+ return ((ch >= 0) && (ch <= 0x1F)) || (ch == 0x7F);
+}
+
constexpr bool IsADigit(int ch) noexcept {
return (ch >= '0') && (ch <= '9');
}