diff options
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r-- | Source/cmStringCommand.cxx | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 998f904..8b3b1e3 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -8,7 +8,6 @@ #include <algorithm> #include <ctype.h> #include <iterator> -#include <memory> // IWYU pragma: keep #include <sstream> #include <stdio.h> #include <stdlib.h> @@ -19,6 +18,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRange.h" +#include "cmStringAlgorithms.h" #include "cmStringReplaceHelper.h" #include "cmSystemTools.h" #include "cmTimestamp.h" @@ -124,7 +124,7 @@ bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args) std::unique_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str())); if (hash) { std::string out = hash->HashString(args[2]); - this->Makefile->AddDefinition(args[1], out.c_str()); + this->Makefile->AddDefinition(args[1], out); return true; } return false; @@ -154,7 +154,7 @@ bool cmStringCommand::HandleToUpperLowerCommand( } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar, output.c_str()); + this->Makefile->AddDefinition(outvar, output); return true; } @@ -180,7 +180,7 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args) } } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar, output.c_str()); + this->Makefile->AddDefinition(outvar, output); return true; } @@ -217,7 +217,7 @@ bool cmStringCommand::HandleConfigureCommand( this->Makefile->ConfigureString(args[1], output, atOnly, escapeQuotes); // Store the output in the provided variable. - this->Makefile->AddDefinition(args[2], output.c_str()); + this->Makefile->AddDefinition(args[2], output); return true; } @@ -296,7 +296,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar, output.c_str()); + this->Makefile->AddDefinition(outvar, output); return true; } @@ -343,7 +343,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar, output.c_str()); + this->Makefile->AddDefinition(outvar, output); return true; } @@ -384,7 +384,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar, output.c_str()); + this->Makefile->AddDefinition(outvar, output); return true; } @@ -431,7 +431,7 @@ bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args) if (std::string::npos != pos) { std::ostringstream s; s << pos; - this->Makefile->AddDefinition(outvar, s.str().c_str()); + this->Makefile->AddDefinition(outvar, s.str()); return true; } @@ -506,7 +506,7 @@ bool cmStringCommand::HandleReplaceCommand( cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(), replaceExpression.c_str()); - this->Makefile->AddDefinition(variableName, input.c_str()); + this->Makefile->AddDefinition(variableName, input); return true; } @@ -539,8 +539,7 @@ bool cmStringCommand::HandleSubstringCommand( return false; } - this->Makefile->AddDefinition(variableName, - stringValue.substr(begin, end).c_str()); + this->Makefile->AddDefinition(variableName, stringValue.substr(begin, end)); return true; } @@ -582,7 +581,7 @@ bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args) value = oldValue; } value += cmJoin(cmMakeRange(args).advance(2), std::string()); - this->Makefile->AddDefinition(variable, value.c_str()); + this->Makefile->AddDefinition(variable, value); return true; } @@ -606,7 +605,7 @@ bool cmStringCommand::HandlePrependCommand( if (oldValue) { value += oldValue; } - this->Makefile->AddDefinition(variable, value.c_str()); + this->Makefile->AddDefinition(variable, value); return true; } @@ -638,7 +637,7 @@ bool cmStringCommand::joinImpl(std::vector<std::string> const& args, // both `CONCAT` and `JOIN` sub-commands. std::string value = cmJoin(cmMakeRange(args).advance(varIdx + 1), glue); - this->Makefile->AddDefinition(variableName, value.c_str()); + this->Makefile->AddDefinition(variableName, value); return true; } @@ -654,7 +653,7 @@ bool cmStringCommand::HandleMakeCIdentifierCommand( const std::string& variableName = args[2]; this->Makefile->AddDefinition(variableName, - cmSystemTools::MakeCidentifier(input).c_str()); + cmSystemTools::MakeCidentifier(input)); return true; } @@ -673,7 +672,7 @@ bool cmStringCommand::HandleGenexStripCommand( const std::string& variableName = args[2]; - this->Makefile->AddDefinition(variableName, result.c_str()); + this->Makefile->AddDefinition(variableName, result); return true; } @@ -712,8 +711,8 @@ bool cmStringCommand::HandleStripCommand(std::vector<std::string> const& args) outLength = endPos - startPos + 1; } - this->Makefile->AddDefinition( - variableName, stringValue.substr(startPos, outLength).c_str()); + this->Makefile->AddDefinition(variableName, + stringValue.substr(startPos, outLength)); return true; } @@ -766,7 +765,7 @@ bool cmStringCommand::HandleRepeatCommand(std::vector<std::string> const& args) break; } - this->Makefile->AddDefinition(variableName, result.c_str()); + this->Makefile->AddDefinition(variableName, result); return true; } @@ -872,7 +871,7 @@ bool cmStringCommand::HandleTimestampCommand( cmTimestamp timestamp; std::string result = timestamp.CurrentTime(formatString, utcFlag); - this->Makefile->AddDefinition(outputVariable, result.c_str()); + this->Makefile->AddDefinition(outputVariable, result); return true; } @@ -955,7 +954,7 @@ bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args) uuid = cmSystemTools::UpperCase(uuid); } - this->Makefile->AddDefinition(outputVariable, uuid.c_str()); + this->Makefile->AddDefinition(outputVariable, uuid); return true; #else std::ostringstream e; |