diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-03-10 13:51:08 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-03-10 13:51:08 -0230 |
commit | 0ff27f134e039854880b5c7148d2c56dcd5fb7e2 (patch) | |
tree | b6fb848e7dfbed6bb8e8f677eb4c6f3c2bc6cb35 /cpp/src/Ice/PropertiesI.cpp | |
parent | Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff) | |
download | ice-0ff27f134e039854880b5c7148d2c56dcd5fb7e2.tar.bz2 ice-0ff27f134e039854880b5c7148d2c56dcd5fb7e2.tar.xz ice-0ff27f134e039854880b5c7148d2c56dcd5fb7e2.zip |
Allow esacpae of leading/trailing whitespace
Diffstat (limited to 'cpp/src/Ice/PropertiesI.cpp')
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 76 |
1 files changed, 70 insertions, 6 deletions
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 2cab2878c7c..faf997b0c93 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -145,8 +145,6 @@ Ice::PropertiesI::setProperty(const string& key, const string& value) // Trim whitespace // string currentKey = IceUtilInternal::trim(key); - string currentValue = IceUtilInternal::trim(value); - if(currentKey.empty()) { return; @@ -208,9 +206,9 @@ Ice::PropertiesI::setProperty(const string& key, const string& value) // // Set or clear the property. // - if(!currentValue.empty()) + if(!value.empty()) { - PropertyValue pv(currentValue, false); + PropertyValue pv(value, false); map<string, PropertyValue>::const_iterator p = _properties.find(currentKey); if(p != _properties.end()) { @@ -459,8 +457,74 @@ Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& conver return; } - string key = IceUtilInternal::trim(s.substr(0, split)); - string value = IceUtilInternal::trim(s.substr(split + 1, s.length() - split - 1)); + // + // Deal with espaced spaces. For key we just unescape and trim but + // for values any esaped spaces must be kept. + // + string key = s.substr(0, split); + while((idx = key.find("\\ ")) != string::npos) + { + key.replace(idx, 2, " "); + } + key = IceUtilInternal::trim(key); + + string value = s.substr(split + 1, s.length() - split - 1); + idx = 0; + string whitespace = ""; + while(idx < value.length()) + { + if(value[idx] == '\\') + { + if(idx + 1 != value.length() && + (value[idx + 1] == ' ' || value[idx + 1] == '\t' || value[idx + 1] == '\r' || value[idx + 1] == '\n')) + { + whitespace += value[idx + 1]; + idx += 2; + } + else + { + break; + } + } + else if(value[idx] == ' ' || value[idx] == '\t' || value[idx] == '\r' || value[idx] == '\n') + { + ++idx; + } + else + { + break; + } + } + value = whitespace + value.substr(idx, value.length() - idx); + if(idx != value.length()) + { + idx = value.length() - 1; + whitespace = ""; + while(idx > 0) + { + if(value[idx] == ' ' || value[idx] == '\t' || value[idx] == '\r' || value[idx] == '\n') + { + if(value[idx - 1] == '\\') + { + whitespace += value[idx]; + idx -= 2; + } + else + { + --idx; + } + } + else + { + break; + } + } + value = value.substr(0, idx + 1) + whitespace; + } + while((idx = value.find("\\ ")) != string::npos) + { + value.replace(idx, 2, " "); + } if(converter) { |