From d36f3c5543eed9e120b855e3c1b0d55d800f374e Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Mon, 13 Jun 2005 10:00:59 -0400 Subject: ENH: Handle errors and optimize a bit --- Source/cmCommandArgumentParserHelper.cxx | 18 +++++++++++++++--- Source/cmCommandArgumentParserHelper.h | 14 +++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index e925bf2..18f6fe5 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -27,7 +27,14 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() { m_FileLine = -1; m_FileName = 0; + m_EmptyVariable[0] = 0; + strcpy(m_DCURLYVariable, "${"); + strcpy(m_RCURLYVariable, "}"); + strcpy(m_ATVariable, "@"); + strcpy(m_DOLLARVariable, "$"); + strcpy(m_LCURLYVariable, "{"); + strcpy(m_BSLASHVariable, "\\"); } @@ -234,8 +241,8 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb) cmCommandArgument_yylex_destroy(yyscanner); if ( res != 0 ) { - std::cerr << "CAL_Parser returned: " << res << std::endl; - std::cerr << "When parsing: [" << str << "]" << std::endl; + //str << "CAL_Parser returned: " << res << std::endl; + //std::cerr << "When parsing: [" << str << "]" << std::endl; return 0; } @@ -296,7 +303,10 @@ int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen) void cmCommandArgumentParserHelper::Error(const char* str) { unsigned long pos = static_cast(this->InputBufferPos); - fprintf(stderr, "Argument Parser Error: %s (%lu / Line: %d)\n", str, pos, this->CurrentLine); + //fprintf(stderr, "Argument Parser Error: %s (%lu / Line: %d)\n", str, pos, this->CurrentLine); + cmOStringStream ostr; + ostr << str << " (" << pos << ")"; + /* int cc; std::cerr << "String: ["; for ( cc = 0; cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc); @@ -305,6 +315,8 @@ void cmCommandArgumentParserHelper::Error(const char* str) std::cerr << *(this->InputBuffer.c_str() + this->InputBufferPos + cc); } std::cerr << "]" << std::endl; + */ + m_Error = ostr.str(); } void cmCommandArgumentParserHelper::UpdateCombine(const char* str1, const char* str2) diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index e1d4216..0d0ff6c 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -77,6 +77,16 @@ public: void SetLineFile(long line, const char* file); void SetEscapeQuotes(bool b) { m_EscapeQuotes = b; } + const char* GetError() { return m_Error.c_str(); } + + char m_EmptyVariable[1]; + char m_DCURLYVariable[3]; + char m_RCURLYVariable[3]; + char m_ATVariable[3]; + char m_DOLLARVariable[3]; + char m_LCURLYVariable[3]; + char m_BSLASHVariable[3]; + private: cmStdString::size_type InputBufferPos; cmStdString InputBuffer; @@ -98,13 +108,15 @@ private: void CleanupParser(); std::set m_Variables; - char m_EmptyVariable[1]; const cmMakefile* m_Makefile; std::string m_Result; const char* m_FileName; long m_FileLine; bool m_EscapeQuotes; + + std::string m_Error; + }; #endif -- cgit v0.12