summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/CHANGES7
-rw-r--r--cpp/include/Ice/Config.h2
-rw-r--r--cpp/include/IceUtil/Base64.h4
-rw-r--r--cpp/src/Ice/Connection.cpp10
-rw-r--r--cpp/src/IcePatch/ClientUtil.cpp4
-rw-r--r--cpp/src/IcePatch/Util.cpp12
-rw-r--r--cpp/src/IceSSL/SslClientTransceiver.cpp2
-rw-r--r--cpp/src/IceSSL/SslServerTransceiver.cpp2
-rw-r--r--cpp/src/IceSSL/SslTransceiver.cpp6
-rw-r--r--cpp/src/IceSSL/SslTransceiver.h4
-rw-r--r--cpp/src/IceUtil/Base64.cpp6
-rw-r--r--cpp/src/XMLTransform/XMLTransform.cpp4
-rw-r--r--cpp/src/slice2freeze/Main.cpp2
-rw-r--r--cpp/test/Freeze/cursor/Client.cpp8
-rw-r--r--cpp/test/Freeze/dbmap/Client.cpp2
15 files changed, 42 insertions, 33 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index 2903465eaa6..23f05e10243 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -1,6 +1,13 @@
Changes since version 1.1.0
---------------------------
+- Changed the mapping of the Slice byte type: ::Ice::Byte is now a typedef
+ for unsigned char. (Previously, ::Ice::Byte was a typedef to char.) This
+ change guarantees that byte values are always in the range 0..255 (instead
+ of either -128..127 or 0..255, depending on the CPU architecture). This
+ change also permits function overloading for ::Ice::Byte and char (which
+ can be useful if you use both strings and byte sequences).
+
Changes since version 1.0.1
---------------------------
diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h
index 804e4ede4a7..e6ecfc38c37 100644
--- a/cpp/include/Ice/Config.h
+++ b/cpp/include/Ice/Config.h
@@ -69,7 +69,7 @@ namespace IceInternal
namespace Ice
{
-typedef char Byte;
+typedef unsigned char Byte;
typedef short Short;
typedef int Int;
typedef IceUtil::Int64 Long;
diff --git a/cpp/include/IceUtil/Base64.h b/cpp/include/IceUtil/Base64.h
index 19027ce31b9..843de5149cf 100644
--- a/cpp/include/IceUtil/Base64.h
+++ b/cpp/include/IceUtil/Base64.h
@@ -26,8 +26,8 @@ class ICE_UTIL_API Base64
{
public:
- static std::string encode(const std::vector<char>&);
- static std::vector<char> decode(const std::string&);
+ static std::string encode(const std::vector<unsigned char>&);
+ static std::vector<unsigned char> decode(const std::string&);
private:
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index 3721cdc2334..95098e94681 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -1685,8 +1685,10 @@ IceInternal::Connection::doCompress(BasicStream& uncompressed, BasicStream& comp
unsigned int uncompressedLen = static_cast<unsigned int>(uncompressed.b.size() - headerSize);
unsigned int compressedLen = static_cast<unsigned int>(uncompressedLen * 1.01 + 600);
compressed.b.resize(headerSize + sizeof(Int) + compressedLen);
- int bzError = BZ2_bzBuffToBuffCompress(&compressed.b[0] + headerSize + sizeof(Int), &compressedLen,
- &uncompressed.b[0] + headerSize, uncompressedLen,
+ int bzError = BZ2_bzBuffToBuffCompress(reinterpret_cast<char*>(&compressed.b[0]) + headerSize + sizeof(Int),
+ &compressedLen,
+ reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
+ uncompressedLen,
1, 0, 0);
if(bzError != BZ_OK)
{
@@ -1741,9 +1743,9 @@ IceInternal::Connection::doUncompress(BasicStream& compressed, BasicStream& unco
uncompressed.resize(uncompressedSize);
unsigned int uncompressedLen = uncompressedSize - headerSize;
unsigned int compressedLen = static_cast<unsigned int>(compressed.b.size() - headerSize - sizeof(Int));
- int bzError = BZ2_bzBuffToBuffDecompress(&uncompressed.b[0] + headerSize,
+ int bzError = BZ2_bzBuffToBuffDecompress(reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
&uncompressedLen,
- &compressed.b[0] + headerSize + sizeof(Int),
+ reinterpret_cast<char*>(&compressed.b[0]) + headerSize + sizeof(Int),
compressedLen,
0, 0);
if(bzError != BZ_OK)
diff --git a/cpp/src/IcePatch/ClientUtil.cpp b/cpp/src/IcePatch/ClientUtil.cpp
index b9f54b78b0b..e6fefd967da 100644
--- a/cpp/src/IcePatch/ClientUtil.cpp
+++ b/cpp/src/IcePatch/ClientUtil.cpp
@@ -83,7 +83,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB)
posBZ2 += static_cast<Int>(bytesBZ2.size());
- fileBZ2.write(&bytesBZ2[0], bytesBZ2.size());
+ fileBZ2.write(reinterpret_cast<const char*>(&bytesBZ2[0]), bytesBZ2.size());
if(!fileBZ2)
{
FileAccessException ex;
@@ -169,7 +169,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB)
progressCB.updateUncompress(totalBZ2, static_cast<Int>(pos));
- file.write(bytesBZ2, sz);
+ file.write(reinterpret_cast<const char*>(bytesBZ2), sz);
if(!file)
{
FileAccessException ex;
diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp
index 036d7d6b1b7..e709b521065 100644
--- a/cpp/src/IcePatch/Util.cpp
+++ b/cpp/src/IcePatch/Util.cpp
@@ -441,7 +441,7 @@ IcePatch::getMD5(const string& path)
ByteSeq bytesMD5;
bytesMD5.resize(16);
- fileMD5.read(&bytesMD5[0], 16);
+ fileMD5.read(reinterpret_cast<char*>(&bytesMD5[0]), 16);
if(!fileMD5)
{
FileAccessException ex;
@@ -477,7 +477,7 @@ IcePatch::putMD5(const string& path, const ByteSeq& bytesMD5)
throw ex;
}
- fileMD5.write(&bytesMD5[0], 16);
+ fileMD5.write(reinterpret_cast<const char*>(&bytesMD5[0]), 16);
if(!fileMD5)
{
FileAccessException ex;
@@ -555,7 +555,7 @@ IcePatch::createMD5(const string& path, const LoggerPtr& logger)
bytes.resize(info.size);
if(bytes.size() > 0)
{
- file.read(&bytes[0], bytes.size());
+ file.read(reinterpret_cast<char*>(&bytes[0]), bytes.size());
if(!file)
{
FileAccessException ex;
@@ -633,7 +633,7 @@ IcePatch::calcPartialMD5(const string& path, Int size, const LoggerPtr& logger)
bytes.resize(size);
if(bytes.size() > 0)
{
- file.read(&bytes[0], bytes.size());
+ file.read(reinterpret_cast<char*>(&bytes[0]), bytes.size());
if(!file)
{
FileAccessException ex;
@@ -712,7 +712,7 @@ IcePatch::getBZ2(const string& path, Int pos, Int num)
ByteSeq bytesBZ2;
bytesBZ2.resize(num);
- fileBZ2.read(&bytesBZ2[0], bytesBZ2.size());
+ fileBZ2.read(reinterpret_cast<char*>(&bytesBZ2[0]), bytesBZ2.size());
if(!fileBZ2 && !fileBZ2.eof())
{
FileAccessException ex;
@@ -778,7 +778,7 @@ IcePatch::createBZ2(const string& path, const Ice::LoggerPtr& logger)
while(!file.eof())
{
- file.read(bytes, num);
+ file.read(reinterpret_cast<char*>(&bytes[0]), num);
if(!file && !file.eof())
{
FileAccessException ex;
diff --git a/cpp/src/IceSSL/SslClientTransceiver.cpp b/cpp/src/IceSSL/SslClientTransceiver.cpp
index 1b58023be0c..4deb7038700 100644
--- a/cpp/src/IceSSL/SslClientTransceiver.cpp
+++ b/cpp/src/IceSSL/SslClientTransceiver.cpp
@@ -74,7 +74,7 @@ IceSSL::SslClientTransceiver::write(Buffer& buf, int timeout)
break;
}
- bytesWritten = sslWrite(static_cast<char*>(&*buf.i), static_cast<Int>(packetSize));
+ bytesWritten = sslWrite(&*buf.i, static_cast<Int>(packetSize));
switch(getLastError())
{
diff --git a/cpp/src/IceSSL/SslServerTransceiver.cpp b/cpp/src/IceSSL/SslServerTransceiver.cpp
index 88b48696706..3a38180171b 100644
--- a/cpp/src/IceSSL/SslServerTransceiver.cpp
+++ b/cpp/src/IceSSL/SslServerTransceiver.cpp
@@ -75,7 +75,7 @@ IceSSL::SslServerTransceiver::write(Buffer& buf, int timeout)
break;
}
- bytesWritten = sslWrite(static_cast<char*>(&*buf.i), static_cast<Int>(packetSize));
+ bytesWritten = sslWrite(&*buf.i, static_cast<Int>(packetSize));
switch(getLastError())
{
diff --git a/cpp/src/IceSSL/SslTransceiver.cpp b/cpp/src/IceSSL/SslTransceiver.cpp
index 6a83659c3cd..2fd8b3ed2df 100644
--- a/cpp/src/IceSSL/SslTransceiver.cpp
+++ b/cpp/src/IceSSL/SslTransceiver.cpp
@@ -152,7 +152,7 @@ IceSSL::SslTransceiver::read(Buffer& buf, int timeout)
_readTimeout = timeout;
- bytesRead = sslRead(static_cast<char*>(&*buf.i), static_cast<Int>(packetSize));
+ bytesRead = sslRead(&*buf.i, static_cast<Int>(packetSize));
switch(getLastError())
{
@@ -680,7 +680,7 @@ IceSSL::SslTransceiver::getLastError() const
}
int
-IceSSL::SslTransceiver::sslRead(char* buffer, int bufferSize)
+IceSSL::SslTransceiver::sslRead(unsigned char* buffer, int bufferSize)
{
assert(_sslConnection != 0);
@@ -693,7 +693,7 @@ IceSSL::SslTransceiver::sslRead(char* buffer, int bufferSize)
}
int
-IceSSL::SslTransceiver::sslWrite(char* buffer, int bufferSize)
+IceSSL::SslTransceiver::sslWrite(unsigned char* buffer, int bufferSize)
{
assert(_sslConnection != 0);
diff --git a/cpp/src/IceSSL/SslTransceiver.h b/cpp/src/IceSSL/SslTransceiver.h
index 781fa34a9f2..582d648587e 100644
--- a/cpp/src/IceSSL/SslTransceiver.h
+++ b/cpp/src/IceSSL/SslTransceiver.h
@@ -160,8 +160,8 @@ protected:
int pending();
int getLastError() const;
- int sslRead(char*, int);
- int sslWrite(char*, int);
+ int sslRead(unsigned char*, int);
+ int sslWrite(unsigned char*, int);
int select(int, bool);
int readSelect(int);
diff --git a/cpp/src/IceUtil/Base64.cpp b/cpp/src/IceUtil/Base64.cpp
index 414b85f2bbf..3989e23533a 100644
--- a/cpp/src/IceUtil/Base64.cpp
+++ b/cpp/src/IceUtil/Base64.cpp
@@ -18,7 +18,7 @@
using namespace std;
string
-IceUtil::Base64::encode(const vector<char>& plainSeq)
+IceUtil::Base64::encode(const vector<unsigned char>& plainSeq)
{
string retval;
@@ -101,7 +101,7 @@ IceUtil::Base64::encode(const vector<char>& plainSeq)
return outString;
}
-vector<char>
+vector<unsigned char>
IceUtil::Base64::decode(const string& str)
{
string newStr;
@@ -116,7 +116,7 @@ IceUtil::Base64::decode(const string& str)
}
}
- vector<char> retval;
+ vector<unsigned char> retval;
if(newStr.length() == 0)
{
diff --git a/cpp/src/XMLTransform/XMLTransform.cpp b/cpp/src/XMLTransform/XMLTransform.cpp
index aa193397b55..9a82b790a44 100644
--- a/cpp/src/XMLTransform/XMLTransform.cpp
+++ b/cpp/src/XMLTransform/XMLTransform.cpp
@@ -2969,7 +2969,7 @@ XMLTransform::DBTransformer::transform(ICE_XERCES_NS DOMDocument* oldSchema, ICE
//
string fullKey;
fullKey.append(header);
- fullKey.append(&k[0], k.size());
+ fullKey.append(reinterpret_cast<const char*>(&k[0]), k.size());
fullKey.append(footer);
ICE_XERCES_NS MemBufInputSource keySource((const XMLByte*)fullKey.data(), static_cast<unsigned int>(fullKey.size()), "key");
parser.parse(keySource);
@@ -2990,7 +2990,7 @@ XMLTransform::DBTransformer::transform(ICE_XERCES_NS DOMDocument* oldSchema, ICE
Value value = _db->getWithTxn(txn, k);
string fullValue;
fullValue.append(header);
- fullValue.append(&value[0], value.size());
+ fullValue.append(reinterpret_cast<const char*>(&value[0]), value.size());
fullValue.append(footer);
ICE_XERCES_NS MemBufInputSource valueSource((const XMLByte*)fullValue.data(),
static_cast<unsigned int>(fullValue.size()),
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index c63deb92dae..24b3cb70f1e 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -151,7 +151,7 @@ writeCodecC(const TypePtr& type, const string& name, const string& freezeType, O
//
C << nl << "std::string str;";
C << nl << "str.append(\"<data>\");";
- C << nl << "str.append(&bytes[0], bytes.size());";
+ C << nl << "str.append(reinterpret_cast<const char*>(&bytes[0]), bytes.size());";
C << nl << "str.append(\"</data>\");";
C << nl << "std::istringstream istr(str);";
C << nl << "Ice::StreamPtr stream = new IceXML::StreamI(communicator, istr, false);";
diff --git a/cpp/test/Freeze/cursor/Client.cpp b/cpp/test/Freeze/cursor/Client.cpp
index 5827c89a896..39b81098b11 100644
--- a/cpp/test/Freeze/cursor/Client.cpp
+++ b/cpp/test/Freeze/cursor/Client.cpp
@@ -29,7 +29,7 @@ public:
typedef char value_type;
static Freeze::Key
- write(const char& key, const IceInternal::InstancePtr& instance)
+ write(const unsigned char& key, const IceInternal::InstancePtr& instance)
{
IceInternal::BasicStream keyStream(instance.get());
keyStream.write(key);
@@ -37,7 +37,7 @@ public:
}
static void
- read(char& key, const Freeze::Key& bytes, const IceInternal::InstancePtr& instance)
+ read(unsigned char& key, const Freeze::Key& bytes, const IceInternal::InstancePtr& instance)
{
IceInternal::BasicStream valueStream(instance.get());
valueStream.b = bytes;
@@ -97,7 +97,7 @@ populateDB(const DBPtr& db)
}
static void
-readValue(const DBPtr& db, const Freeze::Key& k, const Freeze::Value& v, char& key, int& value)
+readValue(const DBPtr& db, const Freeze::Key& k, const Freeze::Value& v, unsigned char& key, int& value)
{
IceInternal::InstancePtr instance = IceInternal::getInstance(db->getCommunicator());
@@ -119,7 +119,7 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
Freeze::Key k;
Freeze::Value v;
- char key;
+ unsigned char key;
int value;
DBCursorPtr cursor, clone;
diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp
index 84466d982f6..007584ba22d 100644
--- a/cpp/test/Freeze/dbmap/Client.cpp
+++ b/cpp/test/Freeze/dbmap/Client.cpp
@@ -86,7 +86,7 @@ public:
typename MAP::iterator p = _map.begin();
assert(p != _map.end());
Byte b = p->second;
- test(b >= 0);
+ test(b < 128);
}
}