diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-02-05 14:02:38 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-02-05 14:02:38 -0330 |
commit | e4dadd4907bdc43f35f87a743fb6ba89df53257d (patch) | |
tree | b6928dfd4601a8e8d989661dc6a072483b23f39d /cppe/src | |
parent | Minor fix (diff) | |
download | ice-e4dadd4907bdc43f35f87a743fb6ba89df53257d.tar.bz2 ice-e4dadd4907bdc43f35f87a743fb6ba89df53257d.tar.xz ice-e4dadd4907bdc43f35f87a743fb6ba89df53257d.zip |
Bug 1373 - allowable property names in config files
Added continue to allDemos scripts
Diffstat (limited to 'cppe/src')
-rw-r--r-- | cppe/src/IceE/Properties.cpp | 72 | ||||
-rw-r--r-- | cppe/src/IceE/StringUtil.cpp | 16 |
2 files changed, 53 insertions, 35 deletions
diff --git a/cppe/src/IceE/Properties.cpp b/cppe/src/IceE/Properties.cpp index fa7002fc246..515323ea477 100644 --- a/cppe/src/IceE/Properties.cpp +++ b/cppe/src/IceE/Properties.cpp @@ -291,50 +291,52 @@ Ice::Properties::parseLine(const string& line #endif ) { - 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) - { - return; - } - - string::size_type end = s.find_first_of(delim + "=", beg); - if(end == 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 key = s.substr(beg, end - beg); - - end = s.find('=', end); - 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; } - ++end; - string value; - beg = s.find_first_not_of(delim, end); - if(beg != string::npos) + if(split == 0 || split == string::npos) { - end = s.length(); - value = s.substr(beg, end - beg); + return; } + string key = IceUtil::trim(s.substr(0, split)); + string value = IceUtil::trim(s.substr(split + 1, s.length() - split - 1)); + #ifdef ICEE_HAS_WSTRING if(converter) { diff --git a/cppe/src/IceE/StringUtil.cpp b/cppe/src/IceE/StringUtil.cpp index 8ea102ad407..1a797592071 100644 --- a/cppe/src/IceE/StringUtil.cpp +++ b/cppe/src/IceE/StringUtil.cpp @@ -309,6 +309,22 @@ IceUtil::unescapeString(const string& s, string::size_type start, string::size_t } // +// Trim white space (" \t\r\n") +// +string +IceUtil::trim(const string& s) +{ + const string delim = " \t\r\n"; + if(s.length() != 0) + { + string::size_type beg = s.find_first_not_of(delim); + string::size_type end = s.find_last_not_of(delim); + return s.substr(beg, end - beg + 1); + } + return s; +} + +// // If a single or double quotation mark is found at the start position, // then the position of the matching closing quote is returned. If no // quotation mark is found at the start position, then 0 is returned. |