diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-06-17 19:50:08 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-06-17 19:50:08 (GMT) |
commit | 1bbccc5bef5c195e9fae2d3d5ab350b386fe45cc (patch) | |
tree | 667a2ac3cb8fa341d4960ea0065e33775567ecaf /Source/cmCommandArgumentParserHelper.cxx | |
parent | b7a2d11f2d6dd27719282f1fcd2f69bef3513cac (diff) | |
download | CMake-1bbccc5bef5c195e9fae2d3d5ab350b386fe45cc.zip CMake-1bbccc5bef5c195e9fae2d3d5ab350b386fe45cc.tar.gz CMake-1bbccc5bef5c195e9fae2d3d5ab350b386fe45cc.tar.bz2 |
ENH: Improve handling of escaped characters
Diffstat (limited to 'Source/cmCommandArgumentParserHelper.cxx')
-rw-r--r-- | Source/cmCommandArgumentParserHelper.cxx | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 6038f66..85741b0 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -22,7 +22,7 @@ #include "cmMakefile.h" int cmCommandArgument_yyparse( yyscan_t yyscanner ); - +// cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() { m_FileLine = -1; @@ -35,6 +35,8 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() strcpy(m_DOLLARVariable, "$"); strcpy(m_LCURLYVariable, "{"); strcpy(m_BSLASHVariable, "\\"); + + m_NoEscapeMode = false; } @@ -145,6 +147,53 @@ void cmCommandArgumentParserHelper::AllocateParserType(cmCommandArgumentParserHe // std::cout << (void*) pt->str << " " << pt->str << " JPAllocateParserType" << std::endl; } +bool cmCommandArgumentParserHelper::HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt, char symbol) +{ + if ( m_NoEscapeMode ) + { + char buffer[3]; + buffer[0] = '\\'; + buffer[1] = symbol; + buffer[2] = 0; + this->AllocateParserType(pt, buffer, 2); + return true; + } + switch ( symbol ) + { + case '\\': + case '"': + case ' ': + case '#': + case '(': + case ')': + case '$': + case '^': + case ';': + this->AllocateParserType(pt, &symbol, 1); + break; + case 't': + this->AllocateParserType(pt, "\t", 1); + break; + case 'n': + this->AllocateParserType(pt, "\n", 1); + break; + case 'r': + this->AllocateParserType(pt, "\r", 1); + break; + case '0': + this->AllocateParserType(pt, "\0", 1); + break; + default: + char buffer[2]; + buffer[0] = symbol; + buffer[1] = 0; + cmSystemTools::Error("Invalid escape sequence \\", buffer); + abort(); + return false; + } + return true; +} + int cmCommandArgumentParserHelper::ParseString(const char* str, int verb) { if ( !str) |