diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2018-04-27 15:28:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-05-01 14:24:31 (GMT) |
commit | e13fa223fc870ea95c6a1cfa09b61b527a1c2db5 (patch) | |
tree | 484e5094c95c38d4d3b65599020f9daadf44e98d /Source | |
parent | b542e0c74f543954ba26048ce38776269b9ba203 (diff) | |
download | CMake-e13fa223fc870ea95c6a1cfa09b61b527a1c2db5.zip CMake-e13fa223fc870ea95c6a1cfa09b61b527a1c2db5.tar.gz CMake-e13fa223fc870ea95c6a1cfa09b61b527a1c2db5.tar.bz2 |
cmMakefile: Improve ExpandVariablesInString return type
Return `std::string const&` instead of a `const char*` that points
into a string anyway. Update call sites accordingly.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCPluginAPI.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 9 | ||||
-rw-r--r-- | Source/cmMakefile.h | 11 |
3 files changed, 12 insertions, 11 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index e6d7f8f..8e7e3ad 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -405,7 +405,8 @@ char CCONV* cmExpandVariablesInString(void* arg, const char* source, { cmMakefile* mf = static_cast<cmMakefile*>(arg); std::string barf = source; - std::string result = mf->ExpandVariablesInString(barf, escapeQuotes, atOnly); + std::string const& result = + mf->ExpandVariablesInString(barf, escapeQuotes, atOnly); return strdup(result.c_str()); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b6bf08b..53f0a3d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2412,12 +2412,13 @@ std::vector<std::string> cmMakefile::GetDefinitions() const return res; } -const char* cmMakefile::ExpandVariablesInString(std::string& source) const +const std::string& cmMakefile::ExpandVariablesInString( + std::string& source) const { return this->ExpandVariablesInString(source, false, false); } -const char* cmMakefile::ExpandVariablesInString( +const std::string& cmMakefile::ExpandVariablesInString( std::string& source, bool escapeQuotes, bool noEscapes, bool atOnly, const char* filename, long line, bool removeEmpty, bool replaceAt) const { @@ -2433,7 +2434,7 @@ const char* cmMakefile::ExpandVariablesInString( this->IssueMessage(cmake::INTERNAL_ERROR, "ExpandVariablesInString @ONLY called " "on something with escapes."); - return source.c_str(); + return source; } // Variables used in the WARN case. @@ -2515,7 +2516,7 @@ const char* cmMakefile::ExpandVariablesInString( this->IssueMessage(cmake::AUTHOR_WARNING, msg); } - return source.c_str(); + return source; } cmake::MessageType cmMakefile::ExpandVariablesInStringOld( diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 16b2047..7a688b3 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -565,12 +565,11 @@ public: * entry in the this->Definitions map. Also \@var\@ is * expanded to match autoconf style expansions. */ - const char* ExpandVariablesInString(std::string& source) const; - const char* ExpandVariablesInString(std::string& source, bool escapeQuotes, - bool noEscapes, bool atOnly = false, - const char* filename = nullptr, - long line = -1, bool removeEmpty = false, - bool replaceAt = false) const; + const std::string& ExpandVariablesInString(std::string& source) const; + const std::string& ExpandVariablesInString( + std::string& source, bool escapeQuotes, bool noEscapes, + bool atOnly = false, const char* filename = nullptr, long line = -1, + bool removeEmpty = false, bool replaceAt = false) const; /** * Remove any remaining variables in the string. Anything with ${var} or |