summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2008-10-30 13:58:03 -0230
committerDwayne Boone <dwayne@zeroc.com>2008-10-30 13:58:03 -0230
commit07de2f5bc3a42b00812b1e5677548cbd45f6f203 (patch)
treec555541f713f9412f4a88995e300f22f8d23aba2 /cpp/src/IceUtil
parentBug 3380 - windows release build broken (diff)
downloadice-07de2f5bc3a42b00812b1e5677548cbd45f6f203.tar.bz2
ice-07de2f5bc3a42b00812b1e5677548cbd45f6f203.tar.xz
ice-07de2f5bc3a42b00812b1e5677548cbd45f6f203.zip
Bug 3519 - fix isalpha, isprint, ... usage
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r--cpp/src/IceUtil/FileUtil.cpp2
-rw-r--r--cpp/src/IceUtil/InputUtil.cpp6
-rw-r--r--cpp/src/IceUtil/Options.cpp13
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp36
4 files changed, 47 insertions, 10 deletions
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp
index c387115fee1..37d05249a49 100644
--- a/cpp/src/IceUtil/FileUtil.cpp
+++ b/cpp/src/IceUtil/FileUtil.cpp
@@ -21,7 +21,7 @@ IceUtilInternal::isAbsolutePath(const string& path)
size_t size = path.size();
// Skip whitespace
- while(i < size && isspace(path[i]))
+ while(i < size && isspace(static_cast<unsigned char>(path[i])))
{
++i;
}
diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp
index d4d6253b589..5d5f8a616d0 100644
--- a/cpp/src/IceUtil/InputUtil.cpp
+++ b/cpp/src/IceUtil/InputUtil.cpp
@@ -58,7 +58,7 @@ strToInt64Impl(const char* s, char** endptr, int base)
//
// Skip leading whitespace
//
- while(*s && isspace(*s))
+ while(*s && isspace(static_cast<unsigned char>(*s)))
{
++s;
}
@@ -127,12 +127,12 @@ strToInt64Impl(const char* s, char** endptr, int base)
bool overflow = false;
bool digitFound = false;
const string validDigits(allDigits.begin(), allDigits.begin() + base);
- while(*s && validDigits.find_first_of(toupper(*s)) != validDigits.npos)
+ while(*s && validDigits.find_first_of(toupper(static_cast<unsigned char>(*s))) != validDigits.npos)
{
digitFound = true;
if(!overflow)
{
- int digit = digitVal[toupper(*s) - '0'];
+ int digit = digitVal[toupper(static_cast<unsigned char>(*s)) - '0'];
assert(digit != 100);
if(result < _I64_MAX / base)
{
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp
index 444c71d96cc..9c79e5b1130 100644
--- a/cpp/src/IceUtil/Options.cpp
+++ b/cpp/src/IceUtil/Options.cpp
@@ -455,7 +455,7 @@ IceUtilInternal::Options::split(const string& line)
//
case 'x':
{
- if(i < l.size() - 1 && !isxdigit(l[i + 1]))
+ if(i < l.size() - 1 && !isxdigit(static_cast<unsigned char>(l[i + 1])))
{
arg.push_back('\\');
arg.push_back('x');
@@ -464,14 +464,15 @@ IceUtilInternal::Options::split(const string& line)
Int64 ull = 0;
string::size_type j;
- for(j = i + 1; j < i + 3 && j < l.size() && isxdigit(c = l[j]); ++j)
+ for(j = i + 1; j < i + 3 && j < l.size() &&
+ isxdigit(static_cast<unsigned char>(c = l[j])); ++j)
{
ull *= 16;
- if(isdigit(c))
+ if(isdigit(static_cast<unsigned char>(c)))
{
ull += c - '0';
}
- else if(islower(c))
+ else if(islower(static_cast<unsigned char>(c)))
{
ull += c - 'a' + 10;
}
@@ -491,9 +492,9 @@ IceUtilInternal::Options::split(const string& line)
case 'c':
{
c = l[++i];
- if(isalpha(c) || c == '@' || (c >= '[' && c <= '_'))
+ if(isalpha(static_cast<unsigned char>(c)) || c == '@' || (c >= '[' && c <= '_'))
{
- arg.push_back(static_cast<char>(toupper(c) - '@'));
+ arg.push_back(static_cast<char>(toupper(static_cast<unsigned char>(c)) - '@'));
}
else
{
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index 99c4d759724..b6eb12390db 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -687,4 +687,40 @@ IceUtilInternal::lastErrorToString()
return errorToString(errno);
}
+string
+IceUtilInternal::toLower(const std::string& s)
+{
+ string result;
+ for(unsigned int i = 0; i < s.length(); ++ i)
+ {
+ result += tolower(static_cast<unsigned char>(s[i]));
+ }
+ return result;
+}
+
+string
+IceUtilInternal::toUpper(const std::string& s)
+{
+ string result;
+ for(unsigned int i = 0; i < s.length(); ++ i)
+ {
+ result += toupper(static_cast<unsigned char>(s[i]));
+ }
+ return result;
+}
+
+string
+IceUtilInternal::removeWhitespace(const std::string& s)
+{
+ string result;
+ for(unsigned int i = 0; i < s.length(); ++ i)
+ {
+ if(!isspace(static_cast<unsigned char>(s[i])))
+ {
+ result += s[i];
+ }
+ }
+ return result;
+}
+
#endif