diff options
author | Benoit Foucher <benoit@zeroc.com> | 2002-07-08 22:51:20 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2002-07-08 22:51:20 +0000 |
commit | 475e94627c081e0f28cfe1e5b1d5227aab28de92 (patch) | |
tree | dc1607238449e2f2181478b8eb7e881dd2dd5512 /cpp/src | |
parent | fixes (diff) | |
download | ice-475e94627c081e0f28cfe1e5b1d5227aab28de92.tar.bz2 ice-475e94627c081e0f28cfe1e5b1d5227aab28de92.tar.xz ice-475e94627c081e0f28cfe1e5b1d5227aab28de92.zip |
Use istringstream >> operator instead of atoi and check for errors where
needed (to behave like in Java).
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/DefaultsAndOverrides.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/ProxyFactory.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Ice/TcpEndpoint.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Ice/UdpEndpoint.cpp | 4 |
5 files changed, 21 insertions, 15 deletions
diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp index 31f3972ea6f..1c153be8b00 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.cpp +++ b/cpp/src/Ice/DefaultsAndOverrides.cpp @@ -41,14 +41,14 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro if(!value.empty()) { const_cast<bool&>(overrideTimeout) = true; - const_cast<Int&>(overrideTimeoutValue) = atoi(value.c_str()); + const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout"); } value = properties->getProperty("Ice.Override.Compress"); if(!value.empty()) { const_cast<bool&>(overrideComppress) = true; - const_cast<bool&>(overrideComppressValue) = atoi(value.c_str()); + const_cast<bool&>(overrideComppressValue) = properties->getPropertyAsInt("Ice.Override.Compress"); } const_cast<string&>(defaultLocator) = properties->getProperty("Ice.Default.Locator"); diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 9a4f492eaeb..59c40111c33 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -62,12 +62,14 @@ Ice::PropertiesI::getPropertyAsIntWithDefault(const string& key, Int value) map<string, string>::const_iterator p = _properties.find(key); if(p != _properties.end()) { - return static_cast<Int>(atoi(p->second.c_str())); - } - else - { - return value; + istringstream v(p->second); + if(!(v >> value) || !v.eof()) + { + return 0; + } } + + return value; } PropertyDict diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index 8ce9567e156..ba258de8731 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -129,9 +129,13 @@ IceInternal::ProxyFactory::ProxyFactory(const InstancePtr& instance) : break; } - string value = str.substr(beg, end - beg); + istringstream value(str.substr(beg, end - beg)); - int v = atoi(value.c_str()); + int v; + if(!(value >> v) || !value.eof()) + { + v = 0; + } // // If -1 is the first value, no retry and wait intervals. diff --git a/cpp/src/Ice/TcpEndpoint.cpp b/cpp/src/Ice/TcpEndpoint.cpp index 7ffb353d33f..91d6f7405a7 100644 --- a/cpp/src/Ice/TcpEndpoint.cpp +++ b/cpp/src/Ice/TcpEndpoint.cpp @@ -87,21 +87,21 @@ IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& case 'p': { - if(argument.empty()) + istringstream p(argument); + if(!(p >> const_cast<Int&>(_port)) || !p.eof()) { throw EndpointParseException(__FILE__, __LINE__); } - const_cast<Int&>(_port) = atoi(argument.c_str()); break; } case 't': { - if(argument.empty()) + istringstream t(argument); + if(!(t >> const_cast<Int&>(_timeout)) || !t.eof()) { throw EndpointParseException(__FILE__, __LINE__); } - const_cast<Int&>(_timeout) = atoi(argument.c_str()); break; } diff --git a/cpp/src/Ice/UdpEndpoint.cpp b/cpp/src/Ice/UdpEndpoint.cpp index 8bed2486497..a59b0e4d966 100644 --- a/cpp/src/Ice/UdpEndpoint.cpp +++ b/cpp/src/Ice/UdpEndpoint.cpp @@ -85,11 +85,11 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& case 'p': { - if(argument.empty()) + istringstream p(argument); + if(!(p >> const_cast<Int&>(_port)) || !p.eof()) { throw EndpointParseException(__FILE__, __LINE__); } - const_cast<Int&>(_port) = atoi(argument.c_str()); break; } |