summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-12-18 21:13:09 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-12-18 21:13:09 +0100
commitaa6809bd9431b5cc3952d6a6e2abde76b2bf003c (patch)
tree0da37ff519b9a3b6effbd1583b61abbf6f132c2a /cpp/src
parenthttp://bugzilla/bugzilla/show_bug.cgi?id=4509 - parallel build issues. (diff)
downloadice-aa6809bd9431b5cc3952d6a6e2abde76b2bf003c.tar.bz2
ice-aa6809bd9431b5cc3952d6a6e2abde76b2bf003c.tar.xz
ice-aa6809bd9431b5cc3952d6a6e2abde76b2bf003c.zip
Fixed bug 4511 - properties override doesn't handle quotes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/NodeI.cpp66
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp60
2 files changed, 48 insertions, 78 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;
}