diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/IceGrid/NodeI.cpp | 66 | ||||
-rw-r--r-- | cpp/src/IceUtil/StringUtil.cpp | 60 | ||||
-rwxr-xr-x | cpp/test/IceGrid/activation/run.py | 5 | ||||
-rwxr-xr-x | cpp/test/IceGrid/replication/run.py | 3 | ||||
-rwxr-xr-x | cpp/test/IceGrid/session/run.py | 2 | ||||
-rwxr-xr-x | cpp/test/IceGrid/update/run.py | 7 | ||||
-rw-r--r-- | cpp/test/IceUtil/inputUtil/Client.cpp | 45 |
7 files changed, 101 insertions, 87 deletions
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 7e5659771b1..90066875029 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -366,60 +366,28 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter, string overrides = props->getProperty("IceGrid.Node.PropertiesOverride"); if(!overrides.empty()) { - string::size_type end = 0; - while(end != string::npos) + const string delim = " \t\r\n"; + vector<string> overrideProps; + if(!IceUtilInternal::splitString(overrides, delim, overrideProps)) { - const string delim = " \t\r\n"; - - string::size_type beg = overrides.find_first_not_of(delim, end); - if(beg == string::npos) - { - break; - } - - end = overrides.find_first_of(delim, beg); - string arg; - if(end == string::npos) - { - arg = overrides.substr(beg); - } - else - { - arg = overrides.substr(beg, end - beg); - } + Ice::Warning out(_traceLevels->logger); + out << "invalid value for property `IceGrid.Node.PropertiesOverride':\nunmatched quote"; + } - if(arg.find("--") == 0) + for(vector<string>::iterator p = overrideProps.begin(); p != overrideProps.end(); ++p) + { + if(p->find("--") != 0) { - arg = arg.substr(2); + *p = "--" + *p; } + } - // - // Extract the key/value - // - string::size_type argEnd = arg.find_first_of(delim + "="); - if(argEnd == string::npos) - { - continue; - } - - string key = arg.substr(0, argEnd); - - argEnd = arg.find('=', argEnd); - if(argEnd == string::npos) - { - return; - } - ++argEnd; - - string value; - string::size_type argBeg = arg.find_first_not_of(delim, argEnd); - if(argBeg != string::npos) - { - argEnd = arg.length(); - value = arg.substr(argBeg, argEnd - argBeg); - } - - _propertiesOverride.push_back(createProperty(key, value)); + Ice::PropertiesPtr p = Ice::createProperties(); + p->parseCommandLineOptions("", overrideProps); + Ice::PropertyDict propDict = p->getPropertiesForPrefix(""); + for(Ice::PropertyDict::const_iterator q = propDict.begin(); q != propDict.end(); ++q) + { + _propertiesOverride.push_back(createProperty(q->first, q->second)); } } } diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp index 296c5dd9cf6..edec3076976 100644 --- a/cpp/src/IceUtil/StringUtil.cpp +++ b/cpp/src/IceUtil/StringUtil.cpp @@ -321,50 +321,52 @@ IceUtilInternal::splitString(const string& str, const string& delim, vector<stri string::size_type length = str.length(); string elt; + char quoteChar = '\0'; while(pos < length) { - char quoteChar = '\0'; - if(str[pos] == '"' || str[pos] == '\'') + if(quoteChar == '\0' && (str[pos] == '"' || str[pos] == '\'')) + { + quoteChar = str[pos++]; + continue; // Skip the quote + } + else if(quoteChar != '\0' && str[pos] == '\\' && pos + 1 < length && str[pos + 1] == quoteChar) { - quoteChar = str[pos]; ++pos; } - while(pos < length) + else if(quoteChar != '\0' && str[pos] == quoteChar) { - if(quoteChar != '\0' && str[pos] == '\\' && pos + 1 < length && str[pos + 1] == quoteChar) - { - ++pos; - } - else if(quoteChar != '\0' && str[pos] == quoteChar) + ++pos; + quoteChar = '\0'; + continue; // Skip the end quote + } + else if(delim.find(str[pos]) != string::npos) + { + if(quoteChar == '\0') { ++pos; - quoteChar = '\0'; - break; - } - else if(delim.find(str[pos]) != string::npos) - { - if(quoteChar == '\0') + if(elt.length() > 0) { - ++pos; - break; + result.push_back(elt); + elt = ""; } - } - - if(pos < length) - { - elt += str[pos++]; + continue; } } - if(quoteChar != '\0') - { - return false; // Unmatched quote. - } - if(elt.length() > 0) + + if(pos < length) { - result.push_back(elt); - elt = ""; + elt += str[pos++]; } } + + if(elt.length() > 0) + { + result.push_back(elt); + } + if(quoteChar != '\0') + { + return false; // Unmatched quote. + } return true; } diff --git a/cpp/test/IceGrid/activation/run.py b/cpp/test/IceGrid/activation/run.py index de13d8e8020..2c65cf1a8aa 100755 --- a/cpp/test/IceGrid/activation/run.py +++ b/cpp/test/IceGrid/activation/run.py @@ -20,6 +20,7 @@ if len(path) == 0: sys.path.append(os.path.join(path[0])) from scripts import * -IceGridAdmin.iceGridTest("application.xml", "", - " 'properties-override=%s'" % TestUtil.getCommandLine("", TestUtil.DriverConfig("colloc")).replace("--", "")) +IceGridAdmin.iceGridTest("application.xml", + "", + "properties-override='%s'" % IceGridAdmin.iceGridNodePropertiesOverride()) diff --git a/cpp/test/IceGrid/replication/run.py b/cpp/test/IceGrid/replication/run.py index 2fef9022081..d7c1ccac6aa 100755 --- a/cpp/test/IceGrid/replication/run.py +++ b/cpp/test/IceGrid/replication/run.py @@ -26,8 +26,7 @@ if TestUtil.sqlType != None and TestUtil.sqlType != "QSQLITE": print "*** This test only supports Freeze or SQLite databases" sys.exit(0) -variables = "'properties-override=%s'" % \ - TestUtil.getCommandLine("", TestUtil.DriverConfig("server")).replace("--", "") +variables = "properties-override='%s'" % IceGridAdmin.iceGridNodePropertiesOverride() if TestUtil.sqlType != None: variables += " db-plugin=IceGridSqlDB:createSqlDB" diff --git a/cpp/test/IceGrid/session/run.py b/cpp/test/IceGrid/session/run.py index 62b7513b69f..ac8d585aac1 100755 --- a/cpp/test/IceGrid/session/run.py +++ b/cpp/test/IceGrid/session/run.py @@ -48,7 +48,7 @@ IceGridAdmin.registryOptions += \ IceGridAdmin.iceGridTest("application.xml", '--IceBinDir="%s" --TestDir="%s"' % (TestUtil.getCppBinDir(), os.getcwd()), - '\\"properties-override=%s\\"' % TestUtil.getCommandLine("", TestUtil.DriverConfig("server")).replace("--", "")) + 'properties-override=\'%s\'' % IceGridAdmin.iceGridNodePropertiesOverride()) verifierProc.waitTestSuccess() diff --git a/cpp/test/IceGrid/update/run.py b/cpp/test/IceGrid/update/run.py index 3a721ebb429..740a7c841d4 100755 --- a/cpp/test/IceGrid/update/run.py +++ b/cpp/test/IceGrid/update/run.py @@ -34,10 +34,9 @@ if not os.path.exists(node2Dir): else: IceGridAdmin.cleanDbDir(node2Dir) -nodeOverrideOptions = '--IceBinDir="%s" --TestDir="%s" --NodePropertiesOverride="%s Ice.ServerIdleTime=0 Ice.PrintProcessId=0 Ice.PrintAdapterReady=0"' % ( - TestUtil.getCppBinDir(), - os.getcwd(), - TestUtil.getCommandLine("", TestUtil.DriverConfig("server")).replace("--", "")) +nodeOverrideOptions = '--IceBinDir="%s" --TestDir="%s" ' % (TestUtil.getCppBinDir(), os.getcwd()) + \ + '--NodePropertiesOverride=\"%s Ice.ServerIdleTime=0 Ice.PrintProcessId=0 Ice.PrintAdapterReady=0\"' % \ + IceGridAdmin.iceGridNodePropertiesOverride() IceGridAdmin.iceGridTest("", nodeOverrideOptions) diff --git a/cpp/test/IceUtil/inputUtil/Client.cpp b/cpp/test/IceUtil/inputUtil/Client.cpp index 544ea1c6959..8341b43ecea 100644 --- a/cpp/test/IceUtil/inputUtil/Client.cpp +++ b/cpp/test/IceUtil/inputUtil/Client.cpp @@ -9,6 +9,7 @@ #include <IceUtil/Unicode.h> #include <IceUtil/InputUtil.h> +#include <IceUtil/StringUtil.h> #include <IceUtil/Options.h> #include <TestCommon.h> @@ -190,5 +191,49 @@ main(int, char**) } cout << "ok" << endl; + cout << "checking string splitting... " << flush; + { + vector<string> ss; + test(IceUtilInternal::splitString("", "", ss) && ss.empty()); + ss.clear(); + test(IceUtilInternal::splitString("", ":", ss) && ss.empty()); + ss.clear(); + test(IceUtilInternal::splitString("a", "", ss) && ss.size() == 1 && ss[0] == "a"); + ss.clear(); + test(IceUtilInternal::splitString("a", ":", ss) && ss.size() == 1 && ss[0] == "a"); + ss.clear(); + test(IceUtilInternal::splitString("ab", "", ss) && ss.size() == 1 && ss[0] == "ab"); + ss.clear(); + test(IceUtilInternal::splitString("ab:", ":", ss) && ss.size() == 1 && ss[0] == "ab"); + ss.clear(); + test(IceUtilInternal::splitString(":ab", ":", ss) && ss.size() == 1 && ss[0] == "ab"); + ss.clear(); + test(IceUtilInternal::splitString("a:b", ":", ss) && ss.size() == 2 && ss[0] == "a" && ss[1] == "b"); + ss.clear(); + test(IceUtilInternal::splitString(":a:b:", ":", ss) && ss.size() == 2 && ss[0] == "a" && ss[1] == "b"); + ss.clear(); + + test(IceUtilInternal::splitString("\"a\"", ":", ss) && ss.size() == 1 && ss[0] == "a"); + ss.clear(); + test(IceUtilInternal::splitString("\"a\":b", ":", ss) && ss.size() == 2 && ss[0] == "a" && ss[1] == "b"); + ss.clear(); + test(IceUtilInternal::splitString("\"a\":\"b\"", ":", ss) && ss.size() == 2 && ss[0] == "a" && ss[1] == "b"); + ss.clear(); + test(IceUtilInternal::splitString("\"a:b\"", ":", ss) && ss.size() == 1 && ss[0] == "a:b"); + ss.clear(); + test(IceUtilInternal::splitString("a=\"a:b\"", ":", ss) && ss.size() == 1 && ss[0] == "a=a:b"); + ss.clear(); + + test(IceUtilInternal::splitString("'a'", ":", ss) && ss.size() == 1 && ss[0] == "a"); + ss.clear(); + test(IceUtilInternal::splitString("'\"a'", ":", ss) && ss.size() == 1 && ss[0] == "\"a"); + ss.clear(); + test(IceUtilInternal::splitString("\"'a\"", ":", ss) && ss.size() == 1 && ss[0] == "'a"); + ss.clear(); + + test(!IceUtilInternal::splitString("a\"b", ":", ss)); + } + cout << "ok" << endl; + return EXIT_SUCCESS; } |