From e4dadd4907bdc43f35f87a743fb6ba89df53257d Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Tue, 5 Feb 2008 14:02:38 -0330 Subject: Bug 1373 - allowable property names in config files Added continue to allDemos scripts --- cpp/src/Ice/PropertiesI.cpp | 73 +++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'cpp/src/Ice/PropertiesI.cpp') 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) { -- cgit v1.2.3