diff options
author | Brad King <brad.king@kitware.com> | 2001-08-02 18:10:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2001-08-02 18:10:19 (GMT) |
commit | ee12492c0a720d5e2b15a32fbb70000ab53aa050 (patch) | |
tree | 17f52bfd5f366d96905b5a76c2b4ec0049e77b99 | |
parent | 9e5c769c29ea7d97e0b29e9c6cfe905859bc358f (diff) | |
download | CMake-ee12492c0a720d5e2b15a32fbb70000ab53aa050.zip CMake-ee12492c0a720d5e2b15a32fbb70000ab53aa050.tar.gz CMake-ee12492c0a720d5e2b15a32fbb70000ab53aa050.tar.bz2 |
BUG: Fixed off-by-one error in ExpandVariablesInString for case of $ or @ as last character of string.
-rw-r--r-- | Source/cmMakefile.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f1187f9..7914840 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -823,8 +823,9 @@ void cmMakefile::ExpandVariablesInString(std::string& source, // start by look for $ or @ in the string std::string::size_type markerPos = source.find_first_of("$@"); - // if not found then leave quick as nothing needs to be expanded - if(markerPos == std::string::npos && markerPos > source.size()-1) + // if not found, or found as the last character, then leave quickly as + // nothing needs to be expanded + if((markerPos == std::string::npos) || (markerPos >= source.size()-1)) { return; } @@ -832,14 +833,14 @@ void cmMakefile::ExpandVariablesInString(std::string& source, std::string::size_type currentPos =0; // start at 0 std::string result; // string with replacements // go until the the end of the string - while(markerPos != std::string::npos) + while((markerPos != std::string::npos) && (markerPos < source.size()-1)) { // grab string from currentPos to the start of the variable // and add it to the result result += source.substr(currentPos, markerPos - currentPos); char endVariableMarker; // what is the end of the variable @ or } int markerStartSize = 1; // size of the start marker 1 or 2 - if(source[markerPos] == '$' ) + if(source[markerPos] == '$') { // ${var} case if(source[markerPos+1] == '{') |