summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/PropertiesI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/PropertiesI.cpp')
-rw-r--r--cpp/src/Ice/PropertiesI.cpp73
1 files changed, 40 insertions, 33 deletions
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index 94a8f0cf276..cc60f9bde79 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -406,49 +406,56 @@ Ice::PropertiesI::PropertiesI(StringSeq& args, const PropertiesPtr& defaults, co
void
Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& converter)
{
- const string delim = " \t\r\n";
string s = line;
- string::size_type idx = s.find('#');
- if(idx != string::npos)
- {
- s.erase(idx);
- }
-
- idx = s.find_last_not_of(delim);
- if(idx != string::npos && idx + 1 < s.length())
- {
- s.erase(idx + 1);
- }
-
- string::size_type beg = s.find_first_not_of(delim);
- if(beg == string::npos)
+ //
+ // Remove comments and unescape #'s
+ //
+ string::size_type idx = 0;
+ while((idx = s.find("#", idx)) != string::npos)
{
- return;
+ if(idx != 0 && s[idx - 1] == '\\')
+ {
+ s.erase(idx - 1, 1);
+ ++idx;
+ }
+ else
+ {
+ s.erase(idx);
+ break;
+ }
}
-
- string::size_type end = s.find_first_of(delim + "=", beg);
- if(end == string::npos)
+
+ //
+ // Split key/value and unescape ='s
+ //
+ string::size_type split = string::npos;
+ idx = 0;
+ while((idx = s.find("=", idx)) != string::npos)
{
- return;
+ if(idx != 0 && s[idx - 1] == '\\')
+ {
+ s.erase(idx - 1, 1);
+ }
+ else if(split == string::npos)
+ {
+ split = idx;
+ }
+ ++idx;
}
-
- string key = s.substr(beg, end - beg);
-
- end = s.find('=', end);
- if(end == string::npos)
+
+ if(split == 0 || split == string::npos)
{
+ s = IceUtilInternal::trim(s);
+ if(s.length() != 0)
+ {
+ getProcessLogger()->warning("invalid config file entry: \"" + line + "\"");
+ }
return;
}
- ++end;
- string value;
- beg = s.find_first_not_of(delim, end);
- if(beg != string::npos)
- {
- end = s.length();
- value = s.substr(beg, end - beg);
- }
+ string key = IceUtilInternal::trim(s.substr(0, split));
+ string value = IceUtilInternal::trim(s.substr(split + 1, s.length() - split - 1));
if(converter)
{