From 430765e1323398e7540ed49fa9cc1d8d5c134c3f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 30 Sep 2012 16:23:18 +0200 Subject: [PATCH] extract is_alpha to string.hh --- src/selectors.cc | 15 ++------------- src/string.hh | 8 ++++++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/selectors.cc b/src/selectors.cc index 5282e7f6..2ac1168c 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -21,20 +21,9 @@ bool is_blank(char c) } template -bool is_word(char c); - -template<> -bool is_word(char c) +bool is_word(char c) { - if (c >= '0' and c <= '9') - return true; - if (c >= 'a' and c <= 'z') - return true; - if (c >= 'A' and c <= 'Z') - return true; - if (c == '_') - return true; - return false; + return Kakoune::is_word(c); } template<> diff --git a/src/string.hh b/src/string.hh index 8676c5da..2e8172c1 100644 --- a/src/string.hh +++ b/src/string.hh @@ -119,6 +119,14 @@ String int_to_str(int value); int str_to_int(const String& str); std::vector split(const String& str, Character separator); +inline bool is_word(Character c) +{ + return (c >= '0' and c <= '9') or + (c >= 'a' and c <= 'z') or + (c >= 'A' and c <= 'Z') or + c == '_'; +} + } namespace std