diff options
author | Benoit Foucher <benoit@zeroc.com> | 2009-12-18 21:13:09 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2009-12-18 21:13:09 +0100 |
commit | aa6809bd9431b5cc3952d6a6e2abde76b2bf003c (patch) | |
tree | 0da37ff519b9a3b6effbd1583b61abbf6f132c2a /cpp/src/IceUtil/StringUtil.cpp | |
parent | http://bugzilla/bugzilla/show_bug.cgi?id=4509 - parallel build issues. (diff) | |
download | ice-aa6809bd9431b5cc3952d6a6e2abde76b2bf003c.tar.bz2 ice-aa6809bd9431b5cc3952d6a6e2abde76b2bf003c.tar.xz ice-aa6809bd9431b5cc3952d6a6e2abde76b2bf003c.zip |
Fixed bug 4511 - properties override doesn't handle quotes
Diffstat (limited to 'cpp/src/IceUtil/StringUtil.cpp')
-rw-r--r-- | cpp/src/IceUtil/StringUtil.cpp | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp index 296c5dd9cf6..edec3076976 100644 --- a/cpp/src/IceUtil/StringUtil.cpp +++ b/cpp/src/IceUtil/StringUtil.cpp @@ -321,50 +321,52 @@ IceUtilInternal::splitString(const string& str, const string& delim, vector<stri string::size_type length = str.length(); string elt; + char quoteChar = '\0'; while(pos < length) { - char quoteChar = '\0'; - if(str[pos] == '"' || str[pos] == '\'') + if(quoteChar == '\0' && (str[pos] == '"' || str[pos] == '\'')) + { + quoteChar = str[pos++]; + continue; // Skip the quote + } + else if(quoteChar != '\0' && str[pos] == '\\' && pos + 1 < length && str[pos + 1] == quoteChar) { - quoteChar = str[pos]; ++pos; } - while(pos < length) + else if(quoteChar != '\0' && str[pos] == quoteChar) { - if(quoteChar != '\0' && str[pos] == '\\' && pos + 1 < length && str[pos + 1] == quoteChar) - { - ++pos; - } - else if(quoteChar != '\0' && str[pos] == quoteChar) + ++pos; + quoteChar = '\0'; + continue; // Skip the end quote + } + else if(delim.find(str[pos]) != string::npos) + { + if(quoteChar == '\0') { ++pos; - quoteChar = '\0'; - break; - } - else if(delim.find(str[pos]) != string::npos) - { - if(quoteChar == '\0') + if(elt.length() > 0) { - ++pos; - break; + result.push_back(elt); + elt = ""; } - } - - if(pos < length) - { - elt += str[pos++]; + continue; } } - if(quoteChar != '\0') - { - return false; // Unmatched quote. - } - if(elt.length() > 0) + + if(pos < length) { - result.push_back(elt); - elt = ""; + elt += str[pos++]; } } + + if(elt.length() > 0) + { + result.push_back(elt); + } + if(quoteChar != '\0') + { + return false; // Unmatched quote. + } return true; } |