diff options
author | Yuri Gorshenin <y@maps.me> | 2017-06-01 16:12:59 +0300 |
---|---|---|
committer | Yuri Gorshenin <y@maps.me> | 2017-06-01 16:12:59 +0300 |
commit | d95de0e1ecc1c509ca06063f9436c7b7bcc0256d (patch) | |
tree | 22610badafa27da2ca9cc59398bf51c21e80282c | |
parent | 08b0166a665ab98bfaf1273df9aa6911387abc09 (diff) |
Review fixes.
-rw-r--r-- | base/string_utils.cpp | 6 | ||||
-rw-r--r-- | base/string_utils.hpp | 1 | ||||
-rw-r--r-- | indexer/search_string_utils.cpp | 10 |
3 files changed, 11 insertions, 6 deletions
diff --git a/base/string_utils.cpp b/base/string_utils.cpp index f2546161fb..f90c24e7f8 100644 --- a/base/string_utils.cpp +++ b/base/string_utils.cpp @@ -236,6 +236,12 @@ bool IsASCIIString(std::string const & str) } bool IsASCIIDigit(UniChar c) { return c >= '0' && c <= '9'; } + +bool IsASCIISpace(UniChar c) +{ + return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; +} + bool IsASCIILatin(UniChar c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } bool StartsWith(UniString const & s, UniString const & p) diff --git a/base/string_utils.hpp b/base/string_utils.hpp index 1ebec6dc13..3e353fd3ac 100644 --- a/base/string_utils.hpp +++ b/base/string_utils.hpp @@ -88,6 +88,7 @@ UniString MakeUniString(std::string const & utf8s); std::string ToUtf8(UniString const & s); bool IsASCIIString(std::string const & str); bool IsASCIIDigit(UniChar c); +bool IsASCIISpace(UniChar c); bool IsASCIILatin(UniChar c); inline std::string DebugPrint(UniString const & s) { return ToUtf8(s); } diff --git a/indexer/search_string_utils.cpp b/indexer/search_string_utils.cpp index 88027211d6..9a651056ff 100644 --- a/indexer/search_string_utils.cpp +++ b/indexer/search_string_utils.cpp @@ -5,8 +5,6 @@ #include "base/macros.hpp" #include "base/mem_trie.hpp" -#include <cctype> - using namespace std; using namespace strings; @@ -29,10 +27,10 @@ void RemoveNumeroSigns(UniString & s) } size_t j = i + 1; - while (j < n && isspace(s[j])) + while (j < n && IsASCIISpace(s[j])) ++j; - if (j == n || isdigit(s[j])) + if (j == n || IsASCIIDigit(s[j])) s[i] = ' '; i = j; @@ -68,9 +66,9 @@ UniString NormalizeAndSimplifyString(string const & s) break; // Some Danish-specific hacks. case 0x00d8: // Ø - case 0x00f8: + case 0x00f8: // ø c = 'o'; - break; // ø + break; case 0x0152: // Œ case 0x0153: // œ c = 'o'; |