summaryrefslogtreecommitdiffstats
path: root/Source/cmStringAlgorithms.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-08-08 11:33:58 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-08-09 10:20:50 (GMT)
commit27090096ef3dc572515c23e2ec92e5ee19432950 (patch)
tree2cee785fef19832b0f69c64256845d800dee4d4a /Source/cmStringAlgorithms.cxx
parent242435a9c891bda62880b77d6d612a8975f11059 (diff)
downloadCMake-27090096ef3dc572515c23e2ec92e5ee19432950.zip
CMake-27090096ef3dc572515c23e2ec92e5ee19432950.tar.gz
CMake-27090096ef3dc572515c23e2ec92e5ee19432950.tar.bz2
cmStringAlgorithms: Add cmRemoveQuotes
- Add `cmRemoveQuotes` function to cmStringAlgorithms - Remove unused removeQuotes inline functions
Diffstat (limited to 'Source/cmStringAlgorithms.cxx')
-rw-r--r--Source/cmStringAlgorithms.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx
index 5867a44..eca761b 100644
--- a/Source/cmStringAlgorithms.cxx
+++ b/Source/cmStringAlgorithms.cxx
@@ -21,6 +21,20 @@ std::string cmTrimWhitespace(cm::string_view str)
return std::string(start, stop + 1);
}
+std::string cmRemoveQuotes(cm::string_view str)
+{
+ // We process only strings that have two quotes at least.
+ // Also front() and back() are only defined behavior on non empty strings.
+ if (str.size() >= 2 && //
+ str.front() == '"' && //
+ str.back() == '"') {
+ // Remove a quote from the front and back
+ str.remove_prefix(1);
+ str.remove_suffix(1);
+ }
+ return std::string(str);
+}
+
std::string cmEscapeQuotes(cm::string_view str)
{
std::string result;