diff options
| author | Neil <nyamatongwe@gmail.com> | 2021-10-05 14:38:47 +1100 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2021-10-05 14:38:47 +1100 |
| commit | 9e06aef78c343476ee39698c0f17aa49b7e49999 (patch) | |
| tree | fe5bb15362ffed7ff10ced26339c80df7a1e2de6 /src/CharacterType.h | |
| parent | 180ea34843782451f6d0684af51b584b83a4dd62 (diff) | |
| download | scintilla-mirror-9e06aef78c343476ee39698c0f17aa49b7e49999.tar.gz | |
Feature [feature-requests:#1417] Consolidate character classification functions
in CharacterType.h, merging duplicate functions, removing unused functions and
stadardizing names.
Diffstat (limited to 'src/CharacterType.h')
| -rw-r--r-- | src/CharacterType.h | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/src/CharacterType.h b/src/CharacterType.h index 70f4cbd05..b014f1050 100644 --- a/src/CharacterType.h +++ b/src/CharacterType.h @@ -12,11 +12,15 @@ namespace Scintilla::Internal { // Functions for classifying characters +/** + * Check if a character is a space. + * This is ASCII specific but is safe with chars >= 0x80. + */ constexpr bool IsASpace(int ch) noexcept { return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); } -constexpr bool IsASpaceOrTab(int ch) noexcept { +constexpr bool IsSpaceOrTab(int ch) noexcept { return (ch == ' ') || (ch == '\t'); } @@ -24,6 +28,10 @@ constexpr bool IsControl(int ch) noexcept { return ((ch >= 0) && (ch <= 0x1F)) || (ch == 0x7F); } +constexpr bool IsEOLCharacter(int ch) noexcept { + return ch == '\r' || ch == '\n'; +} + constexpr bool IsADigit(int ch) noexcept { return (ch >= '0') && (ch <= '9'); } @@ -61,33 +69,44 @@ constexpr bool IsAlphaNumeric(int ch) noexcept { ((ch >= 'A') && (ch <= 'Z')); } -/** - * Check if a character is a space. - * This is ASCII specific but is safe with chars >= 0x80. - */ -constexpr bool isspacechar(int ch) noexcept { - return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); -} - -constexpr bool iswordchar(int ch) noexcept { - return IsAlphaNumeric(ch) || ch == '.' || ch == '_'; -} - -constexpr bool iswordstart(int ch) noexcept { - return IsAlphaNumeric(ch) || ch == '_'; -} - -constexpr bool isoperator(int ch) noexcept { - if (IsAlphaNumeric(ch)) - return false; - if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || - ch == '(' || ch == ')' || ch == '-' || ch == '+' || - ch == '=' || ch == '|' || ch == '{' || ch == '}' || - ch == '[' || ch == ']' || ch == ':' || ch == ';' || - ch == '<' || ch == '>' || ch == ',' || ch == '/' || - ch == '?' || ch == '!' || ch == '.' || ch == '~') +constexpr bool IsPunctuation(int ch) noexcept { + switch (ch) { + case '!': + case '"': + case '#': + case '$': + case '%': + case '&': + case '\'': + case '(': + case ')': + case '*': + case '+': + case ',': + case '-': + case '.': + case '/': + case ':': + case ';': + case '<': + case '=': + case '>': + case '?': + case '@': + case '[': + case '\\': + case ']': + case '^': + case '_': + case '`': + case '{': + case '|': + case '}': + case '~': return true; - return false; + default: + return false; + } } // Simple case functions for ASCII supersets. |
