Merge topic 'fix-TrimWhitespace'

9c4a500f cmSystemTools: Fix TrimWhitespace for non-ascii strings (#15735)
87a9061d cmSystemTools: Factor out a cm_isspace helper
This commit is contained in:
Brad King 2015-09-11 11:04:06 -04:00 committed by CMake Topic Stage
commit 8e8824149f

View File

@ -68,6 +68,11 @@
# include "cmMachO.h" # include "cmMachO.h"
#endif #endif
static bool cm_isspace(char c)
{
return ((c & 0x80) == 0) && isspace(c);
}
class cmSystemToolsFileTime class cmSystemToolsFileTime
{ {
public: public:
@ -228,13 +233,13 @@ std::string cmSystemTools::HelpFileName(std::string name)
std::string cmSystemTools::TrimWhitespace(const std::string& s) std::string cmSystemTools::TrimWhitespace(const std::string& s)
{ {
std::string::const_iterator start = s.begin(); std::string::const_iterator start = s.begin();
while(start != s.end() && *start <= ' ') while (start != s.end() && cm_isspace(*start))
++start; ++start;
if (start == s.end()) if (start == s.end())
return ""; return "";
std::string::const_iterator stop = s.end()-1; std::string::const_iterator stop = s.end()-1;
while(*stop <= ' ') while (cm_isspace(*stop))
--stop; --stop;
return std::string(start, stop+1); return std::string(start, stop+1);
} }
@ -496,7 +501,7 @@ void cmSystemTools::ParseWindowsCommandLine(const char* command,
{ {
arg.append(backslashes, '\\'); arg.append(backslashes, '\\');
backslashes = 0; backslashes = 0;
if(((*c & 0x80) == 0 ) && isspace(*c)) if (cm_isspace(*c))
{ {
if(in_quotes) if(in_quotes)
{ {