summaryrefslogtreecommitdiff
path: root/cpp/src
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
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')
-rw-r--r--cpp/src/FreezeScript/Functions.cpp4
-rw-r--r--cpp/src/FreezeScript/Scanner.l6
-rw-r--r--cpp/src/FreezeScript/TransformVisitor.cpp2
-rw-r--r--cpp/src/Glacier2/ProxyVerifier.cpp4
-rw-r--r--cpp/src/IceGrid/Activator.cpp6
-rw-r--r--cpp/src/IceGrid/Scanner.l2
-rw-r--r--cpp/src/IceGrid/ServerI.cpp2
-rw-r--r--cpp/src/IcePatch2/Calc.cpp7
-rw-r--r--cpp/src/IcePatch2/Client.cpp3
-rw-r--r--cpp/src/IcePatch2/Util.cpp9
-rw-r--r--cpp/src/IceSSL/Instance.cpp6
-rw-r--r--cpp/src/IceSSL/RFC2253.cpp13
-rw-r--r--cpp/src/IceStorm/Scanner.l2
-rw-r--r--cpp/src/IceStorm/Service.cpp4
-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
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp2
-rw-r--r--cpp/src/Slice/CsUtil.cpp2
-rw-r--r--cpp/src/Slice/DotNetNames.cpp2
-rw-r--r--cpp/src/Slice/Parser.cpp87
-rw-r--r--cpp/src/Slice/Preprocessor.cpp6
-rw-r--r--cpp/src/Slice/Scanner.l6
-rw-r--r--cpp/src/slice2cs/Gen.cpp2
-rw-r--r--cpp/src/slice2docbook/Gen.cpp2
-rw-r--r--cpp/src/slice2docbook/Main.cpp4
-rw-r--r--cpp/src/slice2freeze/Main.cpp18
-rw-r--r--cpp/src/slice2freezej/Main.cpp12
-rw-r--r--cpp/src/slice2html/Gen.cpp2
-rw-r--r--cpp/src/slice2java/Gen.cpp4
31 files changed, 141 insertions, 135 deletions
diff --git a/cpp/src/FreezeScript/Functions.cpp b/cpp/src/FreezeScript/Functions.cpp
index fe5a3192d77..69a7ab8ae46 100644
--- a/cpp/src/FreezeScript/Functions.cpp
+++ b/cpp/src/FreezeScript/Functions.cpp
@@ -10,6 +10,7 @@
#include <FreezeScript/Functions.h>
#include <FreezeScript/Util.h>
#include <IceUtil/UUID.h>
+#include <IceUtil/StringUtil.h>
using namespace std;
@@ -177,8 +178,7 @@ FreezeScript::invokeGlobalFunction(const Ice::CommunicatorPtr& communicator, con
{
errorReporter->error("lowercase() requires a string argument");
}
- string val = str->stringValue();
- transform(val.begin(), val.end(), val.begin(), ::tolower);
+ string val = IceUtilInternal::toLower(str->stringValue());
result = factory->createString(val, false);
return true;
}
diff --git a/cpp/src/FreezeScript/Scanner.l b/cpp/src/FreezeScript/Scanner.l
index 972a147dbfd..31a4586c789 100644
--- a/cpp/src/FreezeScript/Scanner.l
+++ b/cpp/src/FreezeScript/Scanner.l
@@ -330,14 +330,14 @@ parseString(char start)
case 'x':
{
IceUtil::Int64 ull = 0;
- while(isxdigit(next = static_cast<char>(yyinput())))
+ while(isxdigit(static_cast<unsigned char>(next = static_cast<char>(yyinput()))))
{
ull *= 16;
- if(isdigit(next))
+ if(isdigit(static_cast<unsigned char>(next)))
{
ull += next - '0';
}
- else if(islower(next))
+ else if(islower(static_cast<unsigned char>(next)))
{
ull += next - 'a' + 10;
}
diff --git a/cpp/src/FreezeScript/TransformVisitor.cpp b/cpp/src/FreezeScript/TransformVisitor.cpp
index 7b7e41197ed..c62db545f27 100644
--- a/cpp/src/FreezeScript/TransformVisitor.cpp
+++ b/cpp/src/FreezeScript/TransformVisitor.cpp
@@ -123,7 +123,7 @@ FreezeScript::TransformVisitor::visitDouble(const DoubleDataPtr& dest)
{
while(*end)
{
- if(!isspace(*end))
+ if(!isspace(static_cast<unsigned char>(*end)))
{
conversionError(type, _src->getType(), str);
return;
diff --git a/cpp/src/Glacier2/ProxyVerifier.cpp b/cpp/src/Glacier2/ProxyVerifier.cpp
index 71a7f475472..5724ddfe902 100644
--- a/cpp/src/Glacier2/ProxyVerifier.cpp
+++ b/cpp/src/Glacier2/ProxyVerifier.cpp
@@ -707,8 +707,8 @@ parseProperty(const Ice::CommunicatorPtr& communicator, const string& property,
// TODO: assuming that there is no leading or trailing whitespace. This
// should probably be confirmed.
//
- assert(!isspace(parameter[current]));
- assert(!isspace(addr[addr.size() -1]));
+ assert(!isspace(static_cast<unsigned char>(parameter[current])));
+ assert(!isspace(static_cast<unsigned char>(addr[addr.size() -1])));
if(current != 0)
{
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index 22325bb212d..1075348e348 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -514,8 +514,7 @@ Activator::activate(const string& name,
string::size_type pos = s.find('=');
if(pos != string::npos)
{
- string key = s.substr(0, pos);
- std::transform(key.begin(), key.end(), key.begin(), toupper);
+ string key = IceUtilInternal::toUpper(s.substr(0, pos));
envMap.insert(map<string, string>::value_type(key, s.substr(pos + 1)));
}
var += s.size();
@@ -528,8 +527,7 @@ Activator::activate(const string& name,
string::size_type pos = s.find('=');
if(pos != string::npos)
{
- string key = s.substr(0, pos);
- std::transform(key.begin(), key.end(), key.begin(), toupper);
+ string key = IceUtilInternal::toUpper(s.substr(0, pos));
envMap.erase(key);
envMap.insert(map<string, string>::value_type(key, s.substr(pos + 1)));
}
diff --git a/cpp/src/IceGrid/Scanner.l b/cpp/src/IceGrid/Scanner.l
index cfb70a50aa5..2c1fc68b64f 100644
--- a/cpp/src/IceGrid/Scanner.l
+++ b/cpp/src/IceGrid/Scanner.l
@@ -209,7 +209,7 @@ keyword [[:alpha:]]*
{
break;
}
- else if(isspace(c) || c == ';')
+ else if(isspace(static_cast<unsigned char>(c)) || c == ';')
{
unput(c);
break;
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 2e0910420e2..81a85c97157 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -320,7 +320,7 @@ struct EnvironmentEval : std::unary_function<string, string>
else
{
end = beg + 1;
- while((isalnum(v[end]) || v[end] == '_') && end < v.size())
+ while((isalnum(static_cast<unsigned char>(v[end])) || v[end] == '_') && end < v.size())
{
++end;
}
diff --git a/cpp/src/IcePatch2/Calc.cpp b/cpp/src/IcePatch2/Calc.cpp
index 9ed422548da..92bd17c9510 100644
--- a/cpp/src/IcePatch2/Calc.cpp
+++ b/cpp/src/IcePatch2/Calc.cpp
@@ -43,7 +43,7 @@ struct IFileInfoPathEqual: public binary_function<const FileInfo&, const FileInf
for(string::size_type i = 0; i < lhs.path.size(); ++i)
{
- if(::tolower(lhs.path[i]) != ::tolower(rhs.path[i]))
+ if(::tolower(static_cast<unsigned char>(lhs.path[i])) != ::tolower(static_cast<unsigned char>(rhs.path[i])))
{
return false;
}
@@ -60,11 +60,12 @@ struct IFileInfoPathLess: public binary_function<const FileInfo&, const FileInfo
{
for(string::size_type i = 0; i < lhs.path.size() && i < rhs.path.size(); ++i)
{
- if(::tolower(lhs.path[i]) < ::tolower(rhs.path[i]))
+ if(::tolower(static_cast<unsigned char>(lhs.path[i])) < ::tolower(static_cast<unsigned char>(rhs.path[i])))
{
return true;
}
- else if(::tolower(lhs.path[i]) > ::tolower(rhs.path[i]))
+ else if(::tolower(static_cast<unsigned char>(lhs.path[i])) >
+ ::tolower(static_cast<unsigned char>(rhs.path[i])))
{
return false;
}
diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp
index 3040c22d66b..52ac2bf2b17 100644
--- a/cpp/src/IcePatch2/Client.cpp
+++ b/cpp/src/IcePatch2/Client.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/StringUtil.h>
#include <Ice/Application.h>
#include <IcePatch2/Util.h>
#include <IcePatch2/ClientUtil.h>
@@ -54,7 +55,7 @@ public:
{
cout << "Do a thorough patch? (yes/no)" << endl;
cin >> answer;
- transform(answer.begin(), answer.end(), answer.begin(), ::tolower);
+ answer = IceUtilInternal::toLower(answer);
if(answer == "no")
{
return false;
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index 2b572c27e57..f4f6c32ddf6 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -280,7 +280,8 @@ IcePatch2::simplify(const string& path)
}
if(result == "/." ||
- (result.size() == 4 && isalpha(result[0]) && result[1] == ':' && result[2] == '/' && result[3] == '.'))
+ (result.size() == 4 && isalpha(static_cast<unsigned char>(result[0])) && result[1] == ':' &&
+ result[2] == '/' && result[3] == '.'))
{
return result.substr(0, result.size() - 1);
}
@@ -290,7 +291,8 @@ IcePatch2::simplify(const string& path)
result.erase(result.size() - 2, 2);
}
- if(result == "/" || (result.size() == 3 && isalpha(result[0]) && result[1] == ':' && result[2] == '/'))
+ if(result == "/" || (result.size() == 3 && isalpha(static_cast<unsigned char>(result[0])) && result[1] == ':' &&
+ result[2] == '/'))
{
return result;
}
@@ -313,7 +315,8 @@ IcePatch2::isRoot(const string& pa)
{
string path = simplify(pa);
#ifdef _WIN32
- return path == "/" || path.size() == 3 && isalpha(path[0]) && path[1] == ':' && path[2] == '/';
+ return path == "/" || path.size() == 3 && isalpha(static_cast<unsigned char>(path[0])) && path[1] == ':' &&
+ path[2] == '/';
#else
return path == "/";
#endif
diff --git a/cpp/src/IceSSL/Instance.cpp b/cpp/src/IceSSL/Instance.cpp
index a40dc5275cd..c2899b35f77 100644
--- a/cpp/src/IceSSL/Instance.cpp
+++ b/cpp/src/IceSSL/Instance.cpp
@@ -800,12 +800,10 @@ IceSSL::Instance::verifyPeer(SSL* ssl, SOCKET fd, const string& address, const s
if(!certNameOK && !dnsNames.empty())
{
- string host = address;
- transform(host.begin(), host.end(), host.begin(), ::tolower);
+ string host = IceUtilInternal::toLower(address);
for(vector<string>::const_iterator p = dnsNames.begin(); p != dnsNames.end() && !certNameOK; ++p)
{
- string s = *p;
- transform(s.begin(), s.end(), s.begin(), ::tolower);
+ string s = IceUtilInternal::toLower(*p);
if(host == s)
{
certNameOK = true;
diff --git a/cpp/src/IceSSL/RFC2253.cpp b/cpp/src/IceSSL/RFC2253.cpp
index ec547ce6c49..c6a19254358 100644
--- a/cpp/src/IceSSL/RFC2253.cpp
+++ b/cpp/src/IceSSL/RFC2253.cpp
@@ -253,10 +253,10 @@ parseAttributeType(const string& data, size_t& pos)
//
// First the OID case.
//
- if(isdigit(data[pos]) ||
+ if(isdigit(static_cast<unsigned char>(data[pos])) ||
(data.size() - pos >= 4 && (data.substr(pos, 4) == "oid." || data.substr(pos, 4) == "OID.")))
{
- if(!isdigit(data[pos]))
+ if(!isdigit(static_cast<unsigned char>(data[pos])))
{
result += data.substr(pos, 4);
pos += 4;
@@ -265,7 +265,7 @@ parseAttributeType(const string& data, size_t& pos)
while(true)
{
// 1*DIGIT
- while(pos < data.size() && isdigit(data[pos]))
+ while(pos < data.size() && isdigit(static_cast<unsigned char>(data[pos])))
{
result += data[pos];
++pos;
@@ -276,7 +276,7 @@ parseAttributeType(const string& data, size_t& pos)
result += data[pos];
++pos;
// 1*DIGIT must follow "."
- if(pos < data.size() && !isdigit(data[pos]))
+ if(pos < data.size() && !isdigit(static_cast<unsigned char>(data[pos])))
{
throw ParseException(__FILE__, __LINE__, "invalid attribute type (expected end of data)");
}
@@ -287,7 +287,7 @@ parseAttributeType(const string& data, size_t& pos)
}
}
}
- else if(isalpha(data[pos]))
+ else if(isalpha(static_cast<unsigned char>(data[pos])))
{
//
// The grammar is wrong in this case. It should be ALPHA
@@ -297,7 +297,8 @@ parseAttributeType(const string& data, size_t& pos)
result += data[pos];
++pos;
// 1* KEYCHAR
- while(pos < data.size() && (isalpha(data[pos]) || isdigit(data[pos]) || data[pos] == '-'))
+ while(pos < data.size() && (isalpha(static_cast<unsigned char>(data[pos])) ||
+ isdigit(static_cast<unsigned char>(data[pos])) || data[pos] == '-'))
{
result += data[pos];
++pos;
diff --git a/cpp/src/IceStorm/Scanner.l b/cpp/src/IceStorm/Scanner.l
index 3b922de2332..24e238b5f3c 100644
--- a/cpp/src/IceStorm/Scanner.l
+++ b/cpp/src/IceStorm/Scanner.l
@@ -209,7 +209,7 @@ keyword [[:alpha:]]*
{
break;
}
- else if(isspace(c) || c == ';')
+ else if(isspace(static_cast<unsigned char>(c)) || c == ';')
{
unput(c);
break;
diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp
index 4049b6b1017..519678d32b0 100644
--- a/cpp/src/IceStorm/Service.cpp
+++ b/cpp/src/IceStorm/Service.cpp
@@ -246,12 +246,12 @@ ServiceI::start(
// start of the node id, and then the end of the
// digits).
string::size_type start = instanceName.size();
- while(start < adapterid.size() && !isdigit(adapterid[start]))
+ while(start < adapterid.size() && !isdigit(static_cast<unsigned char>(adapterid[start])))
{
++start;
}
string::size_type end = start;
- while(end < adapterid.size() && isdigit(adapterid[end]))
+ while(end < adapterid.size() && isdigit(static_cast<unsigned char>(adapterid[end])))
{
++end;
}
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
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index bb6e5db83b4..7620e50e9c9 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -25,7 +25,7 @@ Slice::FeatureProfile Slice::featureProfile = Slice::Ice;
char
Slice::ToIfdef::operator()(char c)
{
- if(!isalnum(c))
+ if(!isalnum(static_cast<unsigned char>(c)))
{
return '_';
}
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index f329eb84606..a3197c1796b 100644
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -887,7 +887,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
}
default:
{
- typeS[0] = toupper(typeS[0]);
+ typeS[0] = toupper(static_cast<unsigned char>(typeS[0]));
if(marshal)
{
out << nl << stream << ".write" << typeS << "Seq(";
diff --git a/cpp/src/Slice/DotNetNames.cpp b/cpp/src/Slice/DotNetNames.cpp
index cd3b3187f47..6e1be365a3b 100644
--- a/cpp/src/Slice/DotNetNames.cpp
+++ b/cpp/src/Slice/DotNetNames.cpp
@@ -84,7 +84,7 @@ ciEquals(const string& s, const char* p)
string::const_iterator i = s.begin();
while(i != s.end())
{
- if(tolower(*i++) != tolower(*p++))
+ if(tolower(static_cast<unsigned char>(*i++)) != tolower(static_cast<unsigned char>(*p++)))
{
return false;
}
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index c93de96da22..98206069b03 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -48,16 +48,6 @@ Unit* unit;
}
// ----------------------------------------------------------------------
-// toLower() helper function
-// ----------------------------------------------------------------------
-
-static void
-toLower(string& s)
-{
- transform(s.begin(), s.end(), s.begin(), ::tolower);
-}
-
-// ----------------------------------------------------------------------
// DefinitionContext
// ----------------------------------------------------------------------
@@ -2044,10 +2034,8 @@ Slice::Container::nameIsLegal(const string& newName, const char* newConstruct)
}
if(!_unit->caseSensitive())
{
- string name = newName;
- toLower(name);
- string thisName = module->name();
- toLower(thisName);
+ string name = IceUtilInternal::toLower(newName);
+ string thisName = IceUtilInternal::toLower(module->name());
if(name == thisName)
{
string msg = newConstruct;
@@ -2075,10 +2063,8 @@ Slice::Container::nameIsLegal(const string& newName, const char* newConstruct)
}
if(!_unit->caseSensitive())
{
- string name = newName;
- toLower(name);
- string thisName = module->name();
- toLower(thisName);
+ string name = IceUtilInternal::toLower(newName);
+ string thisName = IceUtilInternal::toLower(module->name());
if(name == thisName)
{
string msg = newConstruct;
@@ -2125,9 +2111,9 @@ Slice::Container::checkPrefix(const string& name) const
if(name.size() >= 3)
{
string prefix3;
- prefix3 += ::tolower(name[0]);
- prefix3 += ::tolower(name[1]);
- prefix3 += ::tolower(name[2]);
+ prefix3 += ::tolower(static_cast<unsigned char>(name[0]));
+ prefix3 += ::tolower(static_cast<unsigned char>(name[1]));
+ prefix3 += ::tolower(static_cast<unsigned char>(name[2]));
if(prefix3 == "ice")
{
_unit->error("illegal identifier `" + name + "': `" + name.substr(0, 3) + "' prefix is reserved");
@@ -2649,10 +2635,8 @@ Slice::ClassDef::createOperation(const string& name,
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "operation `" + name + "' differs only in capitalization from enclosing ";
@@ -2690,10 +2674,8 @@ Slice::ClassDef::createOperation(const string& name,
}
if(!_unit->caseSensitive())
{
- string baseName = (*q)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
+ string baseName = IceUtilInternal::toLower((*q)->name());
+ string newName = IceUtilInternal::toLower(name);
if(baseName == newName)
{
string msg = "operation `" + name + "' differs only in capitalization from " + (*q)->kindOf();
@@ -2788,10 +2770,8 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "data member `" + name + "' differs only in capitalization from enclosing class name `";
@@ -2828,10 +2808,8 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string baseName = (*q)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
+ string baseName = IceUtilInternal::toLower((*q)->name());
+ string newName = IceUtilInternal::toLower(name);
if(baseName == newName)
{
string msg = "data member `" + name + "' differs only in capitalization from " + (*q)->kindOf();
@@ -3266,10 +3244,8 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "exception member `" + name + "' differs only in capitalization ";
@@ -3297,10 +3273,8 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string baseName = (*r)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
+ string baseName = IceUtilInternal::toLower((*r)->name());
+ string newName = IceUtilInternal::toLower(name);
if(baseName == newName)
{
string msg = "exception member `" + name + "' differs only in capitalization from exception member `";
@@ -3578,10 +3552,8 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "struct member `" + name + "' differs only in capitalization from enclosing struct name `";
@@ -4503,10 +4475,8 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "parameter `" + name + "' differs only in capitalization from operation name `";
@@ -5279,7 +5249,7 @@ Slice::Unit::addContent(const ContainedPtr& contained)
string scoped = contained->scoped();
if(!caseSensitive())
{
- toLower(scoped);
+ scoped = IceUtilInternal::toLower(scoped);
}
_contentMap[scoped].push_back(contained);
}
@@ -5290,7 +5260,7 @@ Slice::Unit::removeContent(const ContainedPtr& contained)
string scoped = contained->scoped();
if(!caseSensitive())
{
- toLower(scoped);
+ scoped = IceUtilInternal::toLower(scoped);
}
map<string, ContainedList>::iterator p = _contentMap.find(scoped);
assert(p != _contentMap.end());
@@ -5315,7 +5285,7 @@ Slice::Unit::findContents(const string& scoped) const
string name = scoped;
if(!_unit->caseSensitive())
{
- toLower(name);
+ name = IceUtilInternal::toLower(name);
}
map<string, ContainedList>::const_iterator p = _contentMap.find(name);
@@ -5600,7 +5570,8 @@ Slice::CICompare::operator()(const string& s1, const string& s2) const
{
string::const_iterator p1 = s1.begin();
string::const_iterator p2 = s2.begin();
- while(p1 != s1.end() && p2 != s2.end() && ::tolower(*p1) == ::tolower(*p2))
+ while(p1 != s1.end() && p2 != s2.end() &&
+ ::tolower(static_cast<unsigned char>(*p1)) == ::tolower(static_cast<unsigned char>(*p2)))
{
++p1;
++p2;
@@ -5619,7 +5590,7 @@ Slice::CICompare::operator()(const string& s1, const string& s2) const
}
else
{
- return ::tolower(*p1) < ::tolower(*p2);
+ return ::tolower(static_cast<unsigned char>(*p1)) < ::tolower(static_cast<unsigned char>(*p2));
}
}
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index e2ddc5cbe09..ac62657e59a 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -112,7 +112,8 @@ Slice::Preprocessor::normalizeIncludePath(const string& path)
result.replace(pos, 2, "/");
}
- if(result == "/" || (result.size() == 3 && isalpha(result[0]) && result[1] == ':' && result[2] == '/'))
+ if(result == "/" || (result.size() == 3 && isalpha(static_cast<unsigned char>(result[0])) && result[1] == ':' &&
+ result[2] == '/'))
{
return result;
}
@@ -477,8 +478,7 @@ Slice::Preprocessor::checkInputFile()
string::size_type pos = base.rfind('.');
if(pos != string::npos)
{
- suffix = base.substr(pos);
- transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
+ suffix = IceUtilInternal::toLower(base.substr(pos));
}
if(suffix != ".ice")
{
diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l
index be0dedaf96b..e836da8cf51 100644
--- a/cpp/src/Slice/Scanner.l
+++ b/cpp/src/Slice/Scanner.l
@@ -291,15 +291,15 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?[[:digit:]]+{e
case 'x':
{
IceUtil::Int64 ull = 0;
- while(isxdigit(next = static_cast<char>(yyinput())))
+ while(isxdigit(static_cast<unsigned char>(next = static_cast<char>(yyinput()))))
{
str->literal += next;
ull *= 16;
- if(isdigit(next))
+ if(isdigit(static_cast<unsigned char>(next)))
{
ull += next - '0';
}
- else if(islower(next))
+ else if(islower(static_cast<unsigned char>(next)))
{
ull += next - 'a' + 10;
}
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index a3aa45c4ce9..a3a02ab55c9 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -1223,7 +1223,7 @@ Slice::Gen::generateChecksums(const UnitPtr& u)
string className = "X" + IceUtil::generateUUID();
for(string::size_type pos = 1; pos < className.size(); ++pos)
{
- if(!isalnum(className[pos]))
+ if(!isalnum(static_cast<unsigned char>(className[pos])))
{
className[pos] = '_';
}
diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp
index f8950f72d46..3521184c01c 100644
--- a/cpp/src/slice2docbook/Gen.cpp
+++ b/cpp/src/slice2docbook/Gen.cpp
@@ -932,7 +932,7 @@ Slice::Gen::getComment(const ContainedPtr& contained, const ContainerPtr& contai
}
comment += toString(literal, container);
}
- else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
+ else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(static_cast<unsigned char>(s[i + 1]))))
{
comment += '.';
break;
diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp
index 4f1bd207afb..4386ceae454 100644
--- a/cpp/src/slice2docbook/Main.cpp
+++ b/cpp/src/slice2docbook/Main.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/StringUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/SignalHandler.h>
#include <Gen.h>
@@ -130,8 +131,7 @@ main(int argc, char* argv[])
string::size_type pos = docbook.rfind('.');
if(pos != string::npos)
{
- suffix = docbook.substr(pos);
- transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
+ suffix = IceUtilInternal::toLower(docbook.substr(pos));
}
if(suffix != ".sgml")
{
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index 417f50ad6aa..d89b03670eb 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -13,6 +13,7 @@
#include <Slice/Util.h>
#include <Slice/CPlusPlusUtil.h>
#include <IceUtil/OutputUtil.h>
+#include <IceUtil/StringUtil.h>
#include <Slice/SignalHandler.h>
#include <cstring>
@@ -221,7 +222,7 @@ usage(const char* n)
bool
checkIdentifier(string n, string t, string s)
{
- if(s.empty() || (!isalpha(s[0]) && s[0] != '_'))
+ if(s.empty() || (!isalpha(static_cast<unsigned char>(s[0])) && s[0] != '_'))
{
cerr << n << ": `" << t << "' is not a valid type name" << endl;
return false;
@@ -229,7 +230,7 @@ checkIdentifier(string n, string t, string s)
for(unsigned int i = 1; i < s.size(); ++i)
{
- if(!isalnum(s[i]) && s[i] != '_')
+ if(!isalnum(static_cast<unsigned char>(s[i])) && s[i] != '_')
{
cerr << n << ": `" << t << "' is not a valid type name" << endl;
return false;
@@ -409,7 +410,7 @@ writeDictWithIndicesH(const string& name, const Dict& dict,
if(!member.empty())
{
string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMember[0] = toupper(static_cast<unsigned char>(capitalizedMember[0]));
capitalizedMembers.push_back(capitalizedMember);
}
else
@@ -604,7 +605,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di
if(!member.empty())
{
string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMember[0] = toupper(static_cast<unsigned char>(capitalizedMember[0]));
capitalizedMembers.push_back(capitalizedMember);
}
else
@@ -1429,8 +1430,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("dict");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
Dict dict;
@@ -1562,8 +1562,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
Index index;
@@ -1629,8 +1628,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("dict-index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
string dictName;
DictIndex index;
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index f8c51ab112b..709de7a58cb 100644
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/StringUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/JavaUtil.h>
#include <Slice/SignalHandler.h>
@@ -351,7 +352,7 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
indexTypes.push_back(dataMemberType);
string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMember[0] = toupper(static_cast<unsigned char>(capitalizedMember[0]));
capitalizedMembers.push_back(capitalizedMember);
indexNames.push_back(member);
}
@@ -1203,8 +1204,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("dict");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
Dict dict;
@@ -1251,8 +1251,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
Index index;
@@ -1320,8 +1319,7 @@ main(int argc, char* argv[])
vector<string> optargs = opts.argVec("dict-index");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
string dictName;
DictIndex index;
diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp
index f1e9e5b02e0..c2a6ff52bbe 100644
--- a/cpp/src/slice2html/Gen.cpp
+++ b/cpp/src/slice2html/Gen.cpp
@@ -1116,7 +1116,7 @@ Slice::GeneratorBase::getComment(const ContainedPtr& contained, const ContainerP
comment += toString(literal, container, false, forIndex, summary ? &sz : 0);
summarySize += sz;
}
- else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
+ else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(static_cast<unsigned char>(s[i + 1]))))
{
comment += '.';
++summarySize;
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 974d0b6e647..e8f7145afc3 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -2670,7 +2670,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
if(p->hasMetaData(_getSetMetaData) || contained->hasMetaData(_getSetMetaData))
{
string capName = p->name();
- capName[0] = toupper(capName[0]);
+ capName[0] = toupper(static_cast<unsigned char>(capName[0]));
//
// If container is a class, get all of its operations so that we can check for conflicts.
@@ -3057,7 +3057,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
const string val = p->value();
for(string::const_iterator c = val.begin(); c != val.end(); ++c)
{
- if(isascii(*c) && isprint(*c))
+ if(isascii(static_cast<unsigned char>(*c)) && isprint(static_cast<unsigned char>(*c)))
{
switch(*c)
{