From b977136904223e1763414527683ff4a4891a5549 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Fri, 22 Jun 2001 10:21:08 -0400 Subject: [PATCH] added escape quote method --- Source/cmSystemTools.cxx | 13 +++++++++++++ Source/cmSystemTools.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index de181f099..c05238a31 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -321,6 +321,19 @@ std::string cmSystemTools::EscapeSpaces(const char* str) #endif } +std::string cmSystemTools::EscapeQuotes(const char* str) +{ + std::string result = ""; + for(const char* ch = str; *ch != '\0'; ++ch) + { + if(*ch == '"') + { + result += '\\'; + } + result += *ch; + } + return result; +} // return true if the file exists bool cmSystemTools::FileExists(const char* filename) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index df5d2d5a7..87f63c7c0 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -78,6 +78,12 @@ public: */ static std::string EscapeSpaces(const char*); + /** + * Return a string equivalent to the input string, but with all " replaced + * with \" to escape the quote + */ + static std::string EscapeQuotes(const char*); + /** * Return a capitalized string (i.e the first letter is uppercased, all other * are lowercased).