From cfc2cf9559eacbf45d04249ee1dd7f75bb0cdff0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 12:01:01 -0500 Subject: [PATCH] cmGeneratorExpression: Tokenize over strings --- Source/cmGeneratorExpression.cxx | 16 ++++++++-------- Source/cmGeneratorExpression.h | 4 ++-- Source/cmGeneratorExpressionLexer.cxx | 6 ++---- Source/cmGeneratorExpressionLexer.h | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 3ebb1b600..433adcf7c 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -33,17 +33,17 @@ cmGeneratorExpression::cmGeneratorExpression( cmsys::auto_ptr cmGeneratorExpression::Parse(std::string const& input) { - return this->Parse(input.c_str()); + return cmsys::auto_ptr( + new cmCompiledGeneratorExpression( + this->Backtrace, + input)); } //---------------------------------------------------------------------------- cmsys::auto_ptr cmGeneratorExpression::Parse(const char* input) { - return cmsys::auto_ptr( - new cmCompiledGeneratorExpression( - this->Backtrace, - input)); + return this->Parse(std::string(input ? input : "")); } cmGeneratorExpression::~cmGeneratorExpression() @@ -122,13 +122,13 @@ const char *cmCompiledGeneratorExpression::Evaluate( cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace const& backtrace, - const char *input) - : Backtrace(backtrace), Input(input ? input : ""), + const std::string& input) + : Backtrace(backtrace), Input(input), HadContextSensitiveCondition(false) { cmGeneratorExpressionLexer l; std::vector tokens = - l.Tokenize(this->Input.c_str()); + l.Tokenize(this->Input); this->NeedsEvaluation = l.GetSawGeneratorExpression(); if (this->NeedsEvaluation) diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 58abf1407..9aa590d36 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -100,7 +100,7 @@ public: ~cmCompiledGeneratorExpression(); - std::string GetInput() const + std::string const& GetInput() const { return this->Input; } @@ -116,7 +116,7 @@ public: private: cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, - const char *input); + const std::string& input); friend class cmGeneratorExpression; diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx index 117a24e09..1c83466ce 100644 --- a/Source/cmGeneratorExpressionLexer.cxx +++ b/Source/cmGeneratorExpressionLexer.cxx @@ -32,13 +32,11 @@ static void InsertText(const char *upto, const char *c, //---------------------------------------------------------------------------- std::vector -cmGeneratorExpressionLexer::Tokenize(const char *input) +cmGeneratorExpressionLexer::Tokenize(const std::string& input) { std::vector result; - if (!input) - return result; - const char *c = input; + const char *c = input.c_str(); const char *upto = c; for ( ; *c; ++c) diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h index 83d661de1..1e2e8c25e 100644 --- a/Source/cmGeneratorExpressionLexer.h +++ b/Source/cmGeneratorExpressionLexer.h @@ -43,7 +43,7 @@ class cmGeneratorExpressionLexer public: cmGeneratorExpressionLexer(); - std::vector Tokenize(const char *input); + std::vector Tokenize(const std::string& input); bool GetSawGeneratorExpression() const {