diff options
author | Brad King <brad.king@kitware.com> | 2015-09-11 15:04:06 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-09-11 15:04:06 (GMT) |
commit | 8e8824149fb6525f1a6da5f9c825a67765ce240b (patch) | |
tree | effe36d0a7c3f9a085d2fd8751858ff579b59654 | |
parent | 8fb496a6c56fcfd3ca35a6cfae20cee1cf3651ca (diff) | |
parent | 9c4a500f75e821ec6afb303a6ef5d951dcdc5c63 (diff) | |
download | CMake-8e8824149fb6525f1a6da5f9c825a67765ce240b.zip CMake-8e8824149fb6525f1a6da5f9c825a67765ce240b.tar.gz CMake-8e8824149fb6525f1a6da5f9c825a67765ce240b.tar.bz2 |
Merge topic 'fix-TrimWhitespace'
9c4a500f cmSystemTools: Fix TrimWhitespace for non-ascii strings (#15735)
87a9061d cmSystemTools: Factor out a cm_isspace helper
-rw-r--r-- | Source/cmSystemTools.cxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b1b7f47..005a803 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -68,6 +68,11 @@ # include "cmMachO.h" #endif +static bool cm_isspace(char c) +{ + return ((c & 0x80) == 0) && isspace(c); +} + class cmSystemToolsFileTime { public: @@ -228,13 +233,13 @@ std::string cmSystemTools::HelpFileName(std::string name) std::string cmSystemTools::TrimWhitespace(const std::string& s) { std::string::const_iterator start = s.begin(); - while(start != s.end() && *start <= ' ') + while (start != s.end() && cm_isspace(*start)) ++start; if (start == s.end()) return ""; std::string::const_iterator stop = s.end()-1; - while(*stop <= ' ') + while (cm_isspace(*stop)) --stop; return std::string(start, stop+1); } @@ -496,7 +501,7 @@ void cmSystemTools::ParseWindowsCommandLine(const char* command, { arg.append(backslashes, '\\'); backslashes = 0; - if(((*c & 0x80) == 0 ) && isspace(*c)) + if (cm_isspace(*c)) { if(in_quotes) { |