diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-07-31 07:06:04 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-05 09:25:30 (GMT) |
commit | 7fbcc16dcd92a80eb30baab93388a0b8e294969b (patch) | |
tree | 33958836b22312caaa67cd3eb331c5676e2cf8a7 /Source/cmSystemTools.cxx | |
parent | 3ebd3fa51d229e0067e8ca24f8fa4ed35ee5dac8 (diff) | |
download | CMake-7fbcc16dcd92a80eb30baab93388a0b8e294969b.zip CMake-7fbcc16dcd92a80eb30baab93388a0b8e294969b.tar.gz CMake-7fbcc16dcd92a80eb30baab93388a0b8e294969b.tar.bz2 |
cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize
This adds the following functions to `cmStringAlgorithms`:
- `cmIsSpace`
- `cmTrimWhitespace` (moved from `cmSystemTools::TrimWhitespace`)
- `cmEscapeQuotes` (moved from `cmSystemTools::EscapeQuotes`)
- `cmTokenize` (moved from `cmSystemTools::tokenize` and adapted to
accept `cm::string_view`)
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 61 |
1 files changed, 1 insertions, 60 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5f4e1fc..aed787e 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -84,11 +84,6 @@ cmSystemTools::OutputCallback s_StdoutCallback; } // namespace -static bool cm_isspace(char c) -{ - return ((c & 0x80) == 0) && isspace(c); -} - #if !defined(HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE) // For GetEnvironmentVariables # if defined(_WIN32) @@ -177,19 +172,6 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, } #endif -std::string cmSystemTools::EscapeQuotes(cm::string_view str) -{ - std::string result; - result.reserve(str.size()); - for (const char ch : str) { - if (ch == '"') { - result += '\\'; - } - result += ch; - } - return result; -} - std::string cmSystemTools::HelpFileName(cm::string_view str) { std::string name(str); @@ -198,22 +180,6 @@ std::string cmSystemTools::HelpFileName(cm::string_view str) return name; } -std::string cmSystemTools::TrimWhitespace(cm::string_view str) -{ - auto start = str.begin(); - while (start != str.end() && cm_isspace(*start)) { - ++start; - } - if (start == str.end()) { - return std::string(); - } - auto stop = str.end() - 1; - while (cm_isspace(*stop)) { - --stop; - } - return std::string(start, stop + 1); -} - void cmSystemTools::Error(const std::string& m) { std::string message = "CMake Error: " + m; @@ -396,7 +362,7 @@ void cmSystemTools::ParseWindowsCommandLine(const char* command, } else { arg.append(backslashes, '\\'); backslashes = 0; - if (cm_isspace(*c)) { + if (cmIsSpace(*c)) { if (in_quotes) { arg.append(1, *c); } else if (in_argument) { @@ -2882,31 +2848,6 @@ bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir) return false; } -std::vector<std::string> cmSystemTools::tokenize(const std::string& str, - const std::string& sep) -{ - std::vector<std::string> tokens; - std::string::size_type tokend = 0; - - do { - std::string::size_type tokstart = str.find_first_not_of(sep, tokend); - if (tokstart == std::string::npos) { - break; // no more tokens - } - tokend = str.find_first_of(sep, tokstart); - if (tokend == std::string::npos) { - tokens.push_back(str.substr(tokstart)); - } else { - tokens.push_back(str.substr(tokstart, tokend - tokstart)); - } - } while (tokend != std::string::npos); - - if (tokens.empty()) { - tokens.emplace_back(); - } - return tokens; -} - bool cmSystemTools::StringToLong(const char* str, long* value) { errno = 0; |