diff --git a/src/Nibbler.cpp b/src/Nibbler.cpp index 9974ca687..583e3bb37 100644 --- a/src/Nibbler.cpp +++ b/src/Nibbler.cpp @@ -37,6 +37,7 @@ #ifdef NIBBLER_FEATURE_REGEX #include #endif +#include static const char* _uuid_pattern = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; static const unsigned int _uuid_min_length = 14; @@ -1031,12 +1032,12 @@ bool Nibbler::getName (std::string& result) { if (! isdigit (_input[i]) && ! ispunct (_input[i]) && - ! isspace (_input[i])) + ! Lexer::is_ws (_input[i])) { ++i; while (i < _length && ! ispunct (_input[i]) && - ! isspace (_input[i])) + ! Lexer::is_ws (_input[i])) { ++i; } @@ -1063,7 +1064,7 @@ bool Nibbler::getWord (std::string& result) { while (!isdigit (_input[i]) && !isPunctuation (_input[i]) && - !isspace (_input[i])) + !Lexer::is_ws (_input[i])) { ++i; } diff --git a/src/text.cpp b/src/text.cpp index b75d2db01..d454f01d6 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -529,8 +529,10 @@ void guess ( //////////////////////////////////////////////////////////////////////////////// bool nontrivial (const std::string& input) { - for (size_t i = 0; i < input.length (); ++i) - if (!isspace (input[i])) + std::string::size_type i = 0; + int character; + while ((character = utf8_next_char (input, i))) + if (! Lexer::is_ws (character)) return true; return false; @@ -549,8 +551,10 @@ bool digitsOnly (const std::string& input) //////////////////////////////////////////////////////////////////////////////// bool noSpaces (const std::string& input) { - for (size_t i = 0; i < input.length (); ++i) - if (isspace (input[i])) + std::string::size_type i = 0; + int character; + while ((character = utf8_next_char (input, i))) + if (Lexer::is_ws (character)) return false; return true; @@ -575,13 +579,13 @@ bool isWordStart (const std::string& input, std::string::size_type pos) return false; // If pos is the first non space/punct character of the string. - if (pos == 0 && !isspace (input[pos]) && !isPunctuation (input[pos])) + if (pos == 0 && ! Lexer::is_ws (input[pos]) && !isPunctuation (input[pos])) return true; // If pos is not the first alphanumeric character, but there is a preceding // space/punct character. - if (pos > 0 && !isspace (input[pos]) && !isPunctuation (input[pos]) - && (isspace (input[pos - 1]) || isPunctuation (input[pos - 1]))) + if (pos > 0 && ! Lexer::is_ws (input[pos]) && !isPunctuation (input[pos]) + && ( Lexer::is_ws (input[pos - 1]) || isPunctuation (input[pos - 1]))) return true; return false; @@ -597,13 +601,13 @@ bool isWordEnd (const std::string& input, std::string::size_type pos) return false; // If pos is the last alphanumeric character of the string. - if (pos == input.length () - 1 && !isspace (input[pos]) && !isPunctuation (input[pos])) + if (pos == input.length () - 1 && ! Lexer::is_ws (input[pos]) && !isPunctuation (input[pos])) return true; // If pos is not the last alphanumeric character, but there is a following // non-alphanumeric character. - if (pos < input.length () - 1 && !isspace (input[pos]) && !isPunctuation (input[pos]) - && (isspace (input[pos + 1]) || isPunctuation (input[pos + 1]))) + if (pos < input.length () - 1 && ! Lexer::is_ws (input[pos]) && !isPunctuation (input[pos]) + && ( Lexer::is_ws (input[pos + 1]) || isPunctuation (input[pos + 1]))) return true; return false;