diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-11-28 00:13:42 +0800 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-11-28 00:13:42 +0800 |
| commit | a52da6fe348f2b7f0a04d887af574662e28360ce (patch) | |
| tree | 7393f2f116bd5ee1de6bee7b50eb868a3495bf66 /src | |
| parent | d142db80f2393d7b74b2088cf8df986b592b9675 (diff) | |
Regex: Tweak is_ctype implementation style
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex_impl.cc | 25 | ||||
| -rw-r--r-- | src/regex_impl.hh | 12 |
2 files changed, 14 insertions, 23 deletions
diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 9d7d98ab..cf22130b 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -1091,23 +1091,14 @@ bool is_character_class(const CharacterClass& character_class, Codepoint cp) bool is_ctype(CharacterType ctype, Codepoint cp) { - if ((ctype & CharacterType::Digit) and iswdigit(cp)) - return true; - if ((ctype & CharacterType::Word) and is_word(cp)) - return true; - if ((ctype & CharacterType::Whitespace) and is_blank(cp)) - return true; - if ((ctype & CharacterType::HorizontalWhitespace) and is_horizontal_blank(cp)) - return true; - if ((ctype & CharacterType::NotDigit) and not iswdigit(cp)) - return true; - if ((ctype & CharacterType::NotWord) and not is_word(cp)) - return true; - if ((ctype & CharacterType::NotWhitespace) and not is_blank(cp)) - return true; - if ((ctype & CharacterType::NotHorizontalWhitespace) and not is_horizontal_blank(cp)) - return true; - return false; + return ((ctype & CharacterType::Whitespace) and is_blank(cp)) or + ((ctype & CharacterType::HorizontalWhitespace) and is_horizontal_blank(cp)) or + ((ctype & CharacterType::Digit) and iswdigit(cp)) or + ((ctype & CharacterType::Word) and is_word(cp)) or + ((ctype & CharacterType::NotWhitespace) and not is_blank(cp)) or + ((ctype & CharacterType::NotHorizontalWhitespace) and not is_horizontal_blank(cp)) or + ((ctype & CharacterType::NotDigit) and not iswdigit(cp)) or + ((ctype & CharacterType::NotWord) and not is_word(cp)); } namespace diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 6c687e4f..a2575ca6 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -26,13 +26,13 @@ enum class MatchDirection enum class CharacterType : unsigned char { None = 0, - Word = 1 << 0, - Whitespace = 1 << 1, - HorizontalWhitespace = 1 << 2, + Whitespace = 1 << 0, + HorizontalWhitespace = 1 << 1, + Word = 1 << 2, Digit = 1 << 3, - NotWord = 1 << 4, - NotWhitespace = 1 << 5, - NotHorizontalWhitespace = 1 << 6, + NotWhitespace = 1 << 4, + NotHorizontalWhitespace = 1 << 5, + NotWord = 1 << 6, NotDigit = 1 << 7 }; constexpr bool with_bit_ops(Meta::Type<CharacterType>) { return true; } |
