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 /cpp/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 'cpp/src')
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 73 | ||||
-rw-r--r-- | cpp/src/IceUtil/StringUtil.cpp | 15 | ||||
-rwxr-xr-x | cpp/src/Slice/Preprocessor.cpp | 9 |
3 files changed, 56 insertions, 41 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) { diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp index 62bd9e1f44d..54e1a1d6253 100644 --- a/cpp/src/IceUtil/StringUtil.cpp +++ b/cpp/src/IceUtil/StringUtil.cpp @@ -364,6 +364,21 @@ IceUtilInternal::splitString(const string& str, const string& delim, vector<stri return true; } +// +// Trim white space (" \t\r\n") +// +string +IceUtilInternal::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, diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 7b3acd99500..869dc5ca760 100755 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -284,14 +284,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin while((end = unprocessed.find(".ice", pos)) != string::npos) { end += 4; - string file = unprocessed.substr(pos, end - pos); - - // - // Strip white space from the file name. - // - size_t b = file.find_first_not_of(" \t"); - size_t e = file.find_last_not_of(" \t"); - file = file.substr(b, e - b + 1); + string file = IceUtilInternal::trim(unprocessed.substr(pos, end - pos)); // // Normalize paths if not relative path. |