summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2018-07-27 13:55:58 +0200
committerJose <jose@zeroc.com>2018-07-27 13:55:58 +0200
commit83b85371785bae2928332ac758f2359b724ef420 (patch)
treede77474c09aeb5c2038286216578bbc628801734
parentFix UWP Build failure (diff)
downloadice-83b85371785bae2928332ac758f2359b724ef420.tar.bz2
ice-83b85371785bae2928332ac758f2359b724ef420.tar.xz
ice-83b85371785bae2928332ac758f2359b724ef420.zip
Replace strerror usage with IceUtilInternal::errorToString
Close #154
-rw-r--r--cpp/include/Ice/IconvStringConverter.h12
-rw-r--r--cpp/src/Ice/AsyncResult.cpp1
-rw-r--r--cpp/src/Ice/CollocatedRequestHandler.cpp1
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp1
-rw-r--r--cpp/src/Ice/Initialize.cpp1
-rw-r--r--cpp/src/Ice/OutputStream.cpp1
-rw-r--r--cpp/src/Ice/Service.cpp7
-rw-r--r--cpp/src/Ice/ValueFactoryManagerI.cpp1
-rw-r--r--cpp/src/IceGrid/Activator.cpp13
-rw-r--r--cpp/src/IceGrid/Client.cpp3
-rw-r--r--cpp/src/IceGrid/FileUserAccountMapperI.cpp4
-rw-r--r--cpp/src/IcePatch2/FileServerI.cpp7
-rw-r--r--cpp/src/IceStorm/IceStormDB.cpp8
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp35
-rw-r--r--cpp/src/Slice/JavaUtil.cpp6
-rw-r--r--cpp/src/Slice/Python.cpp13
-rw-r--r--cpp/src/Slice/Ruby.cpp4
-rw-r--r--cpp/src/Slice/SliceUtil.cpp3
-rw-r--r--cpp/src/icegriddb/IceGridDB.cpp5
-rw-r--r--cpp/src/slice2confluence/Gen.cpp8
-rw-r--r--cpp/src/slice2cpp/Gen.cpp11
-rw-r--r--cpp/src/slice2cs/Gen.cpp5
-rw-r--r--cpp/src/slice2html/Gen.cpp9
-rw-r--r--cpp/src/slice2js/Gen.cpp3
-rw-r--r--cpp/src/slice2matlab/Main.cpp3
-rw-r--r--cpp/src/slice2objc/Gen.cpp6
-rw-r--r--cpp/src/slice2php/Main.cpp3
27 files changed, 96 insertions, 78 deletions
diff --git a/cpp/include/Ice/IconvStringConverter.h b/cpp/include/Ice/IconvStringConverter.h
index 5dd6d8f98d2..104ad09e0ce 100644
--- a/cpp/include/Ice/IconvStringConverter.h
+++ b/cpp/include/Ice/IconvStringConverter.h
@@ -18,13 +18,13 @@
#ifndef _WIN32
#include <Ice/StringConverter.h>
+#include <IceUtil/StringUtil.h>
#include <IceUtil/ThreadException.h>
#include <IceUtil/UndefSysMacros.h>
#include <algorithm>
#include <iconv.h>
#include <langinfo.h>
-#include <string.h> // For strerror
#if (defined(__APPLE__) && _LIBICONV_VERSION < 0x010B)
//
@@ -289,9 +289,8 @@ IconvStringConverter<charT>::toUTF8(const charT* sourceStart,
if(count == size_t(-1))
{
- throw Ice::IllegalConversionException(__FILE__,
- __LINE__,
- errno != 0 ? strerror(errno) : "Unknown error");
+ throw Ice::IllegalConversionException(__FILE__, __LINE__,
+ errno == 0 ? "Unknown error" : IceUtilInternal::errorToString(errno));
}
return reinterpret_cast<Ice::Byte*>(outbuf);
}
@@ -345,9 +344,8 @@ IconvStringConverter<charT>::fromUTF8(const Ice::Byte* sourceStart, const Ice::B
if(count == size_t(-1))
{
- throw Ice::IllegalConversionException(__FILE__,
- __LINE__,
- errno != 0 ? strerror(errno) : "Unknown error");
+ throw Ice::IllegalConversionException(__FILE__, __LINE__,
+ errno == 0 ? "Unknown error" : IceUtilInternal::errorToString(errno));
}
target.resize(target.size() - (outbytesleft / sizeof(charT)));
diff --git a/cpp/src/Ice/AsyncResult.cpp b/cpp/src/Ice/AsyncResult.cpp
index adf998472ab..745b0e171a5 100644
--- a/cpp/src/Ice/AsyncResult.cpp
+++ b/cpp/src/Ice/AsyncResult.cpp
@@ -9,7 +9,6 @@
#ifndef ICE_CPP11_MAPPING
-#include <IceUtil/DisableWarnings.h>
#include <Ice/AsyncResult.h>
#include <Ice/Proxy.h>
diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp
index 3b140527fc6..6a46dfb5efc 100644
--- a/cpp/src/Ice/CollocatedRequestHandler.cpp
+++ b/cpp/src/Ice/CollocatedRequestHandler.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <Ice/CollocatedRequestHandler.h>
#include <Ice/ObjectAdapterI.h>
#include <Ice/ThreadPool.h>
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index 45aa4f2567c..2df1fe56f52 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <Ice/CommunicatorI.h>
#include <Ice/Instance.h>
#include <Ice/Properties.h>
diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp
index 2954bfa34d7..9aea1864dd5 100644
--- a/cpp/src/Ice/Initialize.cpp
+++ b/cpp/src/Ice/Initialize.cpp
@@ -8,7 +8,6 @@
// **********************************************************************
#include <Ice/ArgVector.h>
-#include <IceUtil/DisableWarnings.h>
#include <Ice/CommunicatorI.h>
#include <Ice/PropertiesI.h>
#include <Ice/Initialize.h>
diff --git a/cpp/src/Ice/OutputStream.cpp b/cpp/src/Ice/OutputStream.cpp
index 52d0e8609fc..578e4d4db82 100644
--- a/cpp/src/Ice/OutputStream.cpp
+++ b/cpp/src/Ice/OutputStream.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <Ice/OutputStream.h>
#include <Ice/DefaultsAndOverrides.h>
#include <Ice/Instance.h>
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index f7b19c31932..22b18eff970 100644
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -1530,7 +1530,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
{
consoleErr << argv[0] << ": ";
}
- consoleErr << strerror(errno) << endl;
+ consoleErr << IceUtilInternal::errorToString(errno) << endl;
return EXIT_FAILURE;
}
@@ -1563,7 +1563,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
{
consoleErr << argv[0] << ": ";
}
- consoleErr << strerror(errno) << endl;
+ consoleErr << IceUtilInternal::errorToString(errno) << endl;
_exit(EXIT_FAILURE);
}
break;
@@ -1590,7 +1590,8 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
{
consoleErr << ": ";
}
- consoleErr << "I/O error while reading error message from child:\n" << strerror(errno) << endl;
+ consoleErr << "I/O error while reading error message from child:\n"
+ << IceUtilInternal::errorToString(errno) << endl;
_exit(EXIT_FAILURE);
}
pos += n;
diff --git a/cpp/src/Ice/ValueFactoryManagerI.cpp b/cpp/src/Ice/ValueFactoryManagerI.cpp
index bb33f624848..0730fdb8871 100644
--- a/cpp/src/Ice/ValueFactoryManagerI.cpp
+++ b/cpp/src/Ice/ValueFactoryManagerI.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <Ice/ValueFactoryManagerI.h>
#include <Ice/LocalException.h>
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index 70ea3d9659f..bd76a224546 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -83,17 +83,14 @@ reportChildError(int err, int fd, const char* cannot, const char* name, const Tr
// Send any errors to the parent process, using the write
// end of the pipe.
//
- char msg[500];
- strcpy(msg, cannot);
- strcat(msg, " `");
- strcat(msg, name);
- strcat(msg, "'");
+ ostringstream os;
+ os << cannot << " `" << name << "'";
if(err)
{
- strcat(msg, ": ");
- strcat(msg, strerror(err));
+ os << ": " << IceUtilInternal::errorToString(err) << endl;
}
- ssize_t sz = write(fd, msg, strlen(msg));
+ const string msg = os.str();
+ ssize_t sz = write(fd, msg.c_str(), msg.size() + 1);
if(sz == -1)
{
Ice::Warning out(traceLevels->logger);
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index 838c49cd0ff..de5e2ebc1a2 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <IceUtil/Options.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Thread.h>
@@ -383,7 +382,7 @@ Client::run(StringSeq& originalArgs)
}
debug = opts.isSet("debug");
- bool ssl = communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL");
+ bool ssl = communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL") > 0;
if(opts.isSet("ssl"))
{
ssl = true;
diff --git a/cpp/src/IceGrid/FileUserAccountMapperI.cpp b/cpp/src/IceGrid/FileUserAccountMapperI.cpp
index e5df2898d78..8e7a0084d29 100644
--- a/cpp/src/IceGrid/FileUserAccountMapperI.cpp
+++ b/cpp/src/IceGrid/FileUserAccountMapperI.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
+#include <IceUtil/StringUtil.h>
#include <IceUtil/FileUtil.h>
#include <IceGrid/FileUserAccountMapperI.h>
#include <fstream>
@@ -20,7 +20,7 @@ FileUserAccountMapperI::FileUserAccountMapperI(const string& filename)
ifstream file(IceUtilInternal::streamFilename(filename).c_str()); // filename is a UTF-8 string
if(!file)
{
- throw runtime_error("cannot open `" + filename + "' for reading: " + strerror(errno));
+ throw runtime_error("cannot open `" + filename + "' for reading: " + IceUtilInternal::errorToString(errno));
}
const string delim = " \t\r\n";
diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp
index 36531e93e89..395f27422d8 100644
--- a/cpp/src/IcePatch2/FileServerI.cpp
+++ b/cpp/src/IcePatch2/FileServerI.cpp
@@ -144,7 +144,8 @@ IcePatch2::FileServerI::getFileCompressedInternal(const std::string& pa, Ice::Lo
int fd = IceUtilInternal::open(absolutePath, O_RDONLY|O_BINARY);
if(fd == -1)
{
- throw FileAccessException(string("cannot open `") + path + "' for reading: " + strerror(errno));
+ throw FileAccessException(string("cannot open `") + path + "' for reading: " +
+ IceUtilInternal::errorToString(errno));
}
if(!largeFile)
@@ -177,7 +178,7 @@ IcePatch2::FileServerI::getFileCompressedInternal(const std::string& pa, Ice::Lo
posStr << pos;
throw FileAccessException("cannot seek position " + posStr.str() + " in file `" + path + "': " +
- strerror(errno));
+ IceUtilInternal::errorToString(errno));
}
buffer.resize(num);
@@ -190,7 +191,7 @@ IcePatch2::FileServerI::getFileCompressedInternal(const std::string& pa, Ice::Lo
#endif
{
IceUtilInternal::close(fd);
- throw FileAccessException("cannot read `" + path + "': " + strerror(errno));
+ throw FileAccessException("cannot read `" + path + "': " + IceUtilInternal::errorToString(errno));
}
IceUtilInternal::close(fd);
diff --git a/cpp/src/IceStorm/IceStormDB.cpp b/cpp/src/IceStorm/IceStormDB.cpp
index e61499f7cd6..7fc13ef3a65 100644
--- a/cpp/src/IceStorm/IceStormDB.cpp
+++ b/cpp/src/IceStorm/IceStormDB.cpp
@@ -8,12 +8,12 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/StringUtil.h>
#include <IceUtil/FileUtil.h>
#include <Ice/Ice.h>
#include <Ice/ConsoleUtil.h>
#include <IceDB/IceDB.h>
#include <IceStorm/DBTypes.h>
-#include <IceUtil/DisableWarnings.h>
#include <fstream>
using namespace std;
@@ -164,7 +164,8 @@ Client::run(int argc, char* argv[])
ifstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << argv[0] << ": could not open input file: " << strerror(errno) << endl;
+ consoleErr << argv[0] << ": could not open input file: " << IceUtilInternal::errorToString(errno)
+ << endl;
return EXIT_FAILURE;
}
fs.unsetf(ios::skipws);
@@ -307,7 +308,8 @@ Client::run(int argc, char* argv[])
ofstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << argv[0] << ": could not open output file: " << strerror(errno) << endl;
+ consoleErr << argv[0] << ": could not open output file: " << IceUtilInternal::errorToString(errno)
+ << endl;
return EXIT_FAILURE;
}
fs.write(reinterpret_cast<const char*>(stream.b.begin()), stream.b.size());
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index c1c9099e215..3ecbe9ebd99 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -10,7 +10,9 @@
#include <IceUtil/StringUtil.h>
#include <IceUtil/StringConverter.h>
#include <cstring>
+#include <string.h> // for strerror_r
+#include <sstream>
#include <iomanip>
using namespace std;
@@ -1071,7 +1073,38 @@ IceUtilInternal::lastErrorToString()
string
IceUtilInternal::errorToString(int error)
{
- return strerror(error);
+ char buf[500];
+#if !defined(__GLIBC__) || defined(BSD) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE)
+ //
+ // Use the XSI-compliant version of strerror_r
+ //
+ if(strerror_r(error, &buf[0], 500) != 0)
+ {
+ ostringstream os;
+ os << "Unknown error `" << error << "'";
+ return os.str();
+ }
+ else
+ {
+ return string(buf);
+ }
+#else
+ //
+ // Use the GNU-specific version of strerror_r
+ //
+ errno = 0;
+ const char* msg = strerror_r(error, &buf[0], 500);
+ if(errno != 0)
+ {
+ ostringstream os;
+ os << "Unknown error `" << error << "'";
+ return os.str();
+ }
+ else
+ {
+ return msg;
+ }
+#endif
}
string
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp
index dce07e4689b..094f2fd373a 100644
--- a/cpp/src/Slice/JavaUtil.cpp
+++ b/cpp/src/Slice/JavaUtil.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
+#include <IceUtil/StringUtil.h>
#include <Slice/JavaUtil.h>
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
@@ -740,7 +740,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri
if(IceUtilInternal::mkdir(path, 0777) != 0)
{
ostringstream os;
- os << "cannot create directory `" << path << "': " << strerror(errno);
+ os << "cannot create directory `" << path << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addDirectory(path);
@@ -779,7 +779,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri
else
{
ostringstream os;
- os << "cannot open file `" << path << "': " << strerror(errno);
+ os << "cannot open file `" << path << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
}
diff --git a/cpp/src/Slice/Python.cpp b/cpp/src/Slice/Python.cpp
index 158c55cb107..adc4a3ba3f1 100644
--- a/cpp/src/Slice/Python.cpp
+++ b/cpp/src/Slice/Python.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <IceUtil/IceUtil.h>
#include <IceUtil/Options.h>
#include <IceUtil/StringUtil.h>
@@ -92,7 +91,7 @@ createDirectory(const string& dir)
if(IceUtilInternal::mkdir(dir, 0777) != 0)
{
ostringstream os;
- os << "cannot create directory '" << dir << "': " << strerror(errno);
+ os << "cannot create directory '" << dir << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
}
@@ -132,7 +131,7 @@ createPackageDirectory(const string& output, const string& pkgdir)
if(IceUtilInternal::mkdir(path, 0777) != 0)
{
ostringstream os;
- os << "cannot create directory '" << path << "': " << strerror(errno);
+ os << "cannot create directory '" << path << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addDirectory(path);
@@ -160,7 +159,7 @@ createPackageDirectory(const string& output, const string& pkgdir)
if(!out)
{
ostringstream os;
- os << "cannot open '" << init << "': " << strerror(errno);
+ os << "cannot open '" << init << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(init);
@@ -322,7 +321,7 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub
if(!in)
{
ostringstream os;
- os << "cannot open file '" << initPath << "': " << strerror(errno);
+ os << "cannot open file '" << initPath << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
@@ -415,7 +414,7 @@ PackageVisitor::writeInit(const string& dir, const string& name, const StringLis
if(!os)
{
ostringstream os;
- os << "cannot open file '" << initPath << "': " << strerror(errno);
+ os << "cannot open file '" << initPath << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(initPath);
@@ -751,7 +750,7 @@ Slice::Python::compile(const vector<string>& argv)
if(!out)
{
ostringstream os;
- os << "cannot open '" << path << "': " << strerror(errno);
+ os << "cannot open '" << path << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(path);
diff --git a/cpp/src/Slice/Ruby.cpp b/cpp/src/Slice/Ruby.cpp
index 014b022208e..8b61d7947b0 100644
--- a/cpp/src/Slice/Ruby.cpp
+++ b/cpp/src/Slice/Ruby.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
+#include <IceUtil/StringUtil.h>
#include <IceUtil/Options.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
@@ -297,7 +297,7 @@ Slice::Ruby::compile(const vector<string>& argv)
if(!out)
{
ostringstream os;
- os << "cannot open`" << file << "': " << strerror(errno);
+ os << "cannot open`" << file << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(file);
diff --git a/cpp/src/Slice/SliceUtil.cpp b/cpp/src/Slice/SliceUtil.cpp
index 2f4e67c5221..ae45fe5967d 100644
--- a/cpp/src/Slice/SliceUtil.cpp
+++ b/cpp/src/Slice/SliceUtil.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <Slice/Util.h>
#include <Slice/FileTracker.h>
#include <IceUtil/FileUtil.h>
@@ -397,7 +396,7 @@ Slice::writeDependencies(const string& dependencies, const string& dependFile)
if(!of)
{
ostringstream os;
- os << "cannot open file `" << dependFile << "': " << strerror(errno);
+ os << "cannot open file `" << dependFile << "': " << IceUtilInternal::errorToString(errno);
throw Slice::FileException(__FILE__, __LINE__, os.str());
}
of << dependencies;
diff --git a/cpp/src/icegriddb/IceGridDB.cpp b/cpp/src/icegriddb/IceGridDB.cpp
index 8b808807f8d..18c0e452c8e 100644
--- a/cpp/src/icegriddb/IceGridDB.cpp
+++ b/cpp/src/icegriddb/IceGridDB.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/StringUtil.h>
#include <IceUtil/FileUtil.h>
#include <Ice/Ice.h>
#include <Ice/ConsoleUtil.h>
@@ -270,7 +271,7 @@ Client::run(int argc, char* argv[])
ifstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << argv[0] << ": could not open input file: " << strerror(errno) << endl;
+ consoleErr << argv[0] << ": could not open input file: " << IceUtilInternal::errorToString(errno) << endl;
return EXIT_FAILURE;
}
fs.unsetf(ios::skipws);
@@ -545,7 +546,7 @@ Client::run(int argc, char* argv[])
ofstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << argv[0] << ": could not open output file: " << strerror(errno) << endl;
+ consoleErr << argv[0] << ": could not open output file: " << IceUtilInternal::errorToString(errno) << endl;
return EXIT_FAILURE;
}
fs.write(reinterpret_cast<const char*>(stream.b.begin()), stream.b.size());
diff --git a/cpp/src/slice2confluence/Gen.cpp b/cpp/src/slice2confluence/Gen.cpp
index 9d054b22272..16629ab5aa5 100644
--- a/cpp/src/slice2confluence/Gen.cpp
+++ b/cpp/src/slice2confluence/Gen.cpp
@@ -1426,7 +1426,7 @@ Slice::GeneratorBase::openStream(const string& path)
if(!_out.isOpen())
{
ostringstream os;
- os << "cannot open file `" << path << "': " << strerror(errno);
+ os << "cannot open file `" << path << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(path);
@@ -1787,7 +1787,7 @@ Slice::GeneratorBase::makeDir(const string& dir)
if(IceUtilInternal::mkdir(dir, 0777) != 0)
{
ostringstream os;
- os << "cannot create directory `" << dir << "': " << strerror(errno);
+ os << "cannot create directory `" << dir << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addDirectory(dir);
@@ -1800,7 +1800,7 @@ Slice::GeneratorBase::readFile(const string& file)
if(!in)
{
ostringstream os;
- os << "cannot open file `" << file << "': " << strerror(errno);
+ os << "cannot open file `" << file << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
@@ -1836,7 +1836,7 @@ Slice::GeneratorBase::readFile(const string& file, string& part1, string& part2)
if(!in)
{
ostringstream os;
- os << "cannot open file `" << file << "': " << strerror(errno);
+ os << "cannot open file `" << file << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index c06fd88c76c..e095a71e97e 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include "Gen.h"
#include <Slice/Util.h>
#include <Slice/CPlusPlusUtil.h>
@@ -107,7 +106,7 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt
}
else
{
- bool cpp11 = typeContext & TypeContextCpp11;
+ bool cpp11 = (typeContext & TypeContextCpp11) == TypeContextCpp11;
BuiltinPtr bp = BuiltinPtr::dynamicCast(type);
if(bp && bp->kind() == Builtin::KindString)
{
@@ -803,7 +802,7 @@ Slice::Gen::generate(const UnitPtr& p)
if(!implH)
{
ostringstream os;
- os << "cannot open `" << fileImplH << "': " << strerror(errno);
+ os << "cannot open `" << fileImplH << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(fileImplH);
@@ -812,7 +811,7 @@ Slice::Gen::generate(const UnitPtr& p)
if(!implC)
{
ostringstream os;
- os << "cannot open `" << fileImplC << "': " << strerror(errno);
+ os << "cannot open `" << fileImplC << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(fileImplC);
@@ -840,7 +839,7 @@ Slice::Gen::generate(const UnitPtr& p)
if(!H)
{
ostringstream os;
- os << "cannot open `" << fileH << "': " << strerror(errno);
+ os << "cannot open `" << fileH << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(fileH);
@@ -849,7 +848,7 @@ Slice::Gen::generate(const UnitPtr& p)
if(!C)
{
ostringstream os;
- os << "cannot open `" << fileC << "': " << strerror(errno);
+ os << "cannot open `" << fileC << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(fileC);
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 2c00b5fe5f8..a6b09ad2030 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <IceUtil/Functional.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/FileUtil.h>
@@ -1973,7 +1972,7 @@ Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const st
if(!_out)
{
ostringstream os;
- os << "cannot open `" << file << "': " << strerror(errno);
+ os << "cannot open `" << file << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(file);
@@ -1999,7 +1998,7 @@ Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const st
if(!_impl)
{
ostringstream os;
- os << ": cannot open `" << fileImpl << "': " << strerror(errno);
+ os << ": cannot open `" << fileImpl << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp
index 17340acd502..3a4f1e54314 100644
--- a/cpp/src/slice2html/Gen.cpp
+++ b/cpp/src/slice2html/Gen.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <IceUtil/Functional.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/FileUtil.h>
@@ -1254,7 +1253,7 @@ Slice::GeneratorBase::openStream(const string& path)
if(!_out.isOpen())
{
ostringstream os;
- os << "cannot open file `" << path << "': " << strerror(errno);
+ os << "cannot open file `" << path << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(path);
@@ -1575,7 +1574,7 @@ Slice::GeneratorBase::makeDir(const string& dir)
if(IceUtilInternal::mkdir(dir, 0777) != 0)
{
ostringstream os;
- os << "cannot create directory `" << dir << "': " << strerror(errno);
+ os << "cannot create directory `" << dir << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addDirectory(dir);
@@ -1588,7 +1587,7 @@ Slice::GeneratorBase::readFile(const string& file)
if(!in)
{
ostringstream os;
- os << "cannot open file `" << file << "': " << strerror(errno);
+ os << "cannot open file `" << file << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
@@ -1662,7 +1661,7 @@ Slice::GeneratorBase::readFile(const string& file, string& part1, string& part2)
if(!in)
{
ostringstream os;
- os << "cannot open file `" << file << "': " << strerror(errno);
+ os << "cannot open file `" << file << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp
index 2862cdc254a..7a4e61f3115 100644
--- a/cpp/src/slice2js/Gen.cpp
+++ b/cpp/src/slice2js/Gen.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <IceUtil/Functional.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/InputUtil.h>
@@ -354,7 +353,7 @@ Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const st
if(!_out)
{
ostringstream os;
- os << "cannot open `" << file << "': " << strerror(errno);
+ os << "cannot open `" << file << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(file);
diff --git a/cpp/src/slice2matlab/Main.cpp b/cpp/src/slice2matlab/Main.cpp
index e2ed4c7a072..6704faa27d7 100644
--- a/cpp/src/slice2matlab/Main.cpp
+++ b/cpp/src/slice2matlab/Main.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/IceUtil.h>
#include <IceUtil/InputUtil.h>
@@ -277,7 +276,7 @@ openClass(const string& abs, const string& dir, IceUtilInternal::Output& out)
if(IceUtilInternal::mkdir(path, 0777) != 0)
{
ostringstream os;
- os << "cannot create directory `" << path << "': " << strerror(errno);
+ os << "cannot create directory `" << path << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addDirectory(path);
diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp
index b4696ee3574..d3c0327a09e 100644
--- a/cpp/src/slice2objc/Gen.cpp
+++ b/cpp/src/slice2objc/Gen.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
+#include <IceUtil/StringUtil.h>
#include <IceUtil/Functional.h>
#include "Gen.h"
#include <limits>
@@ -696,7 +696,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c
if(!_H)
{
ostringstream os;
- os << "cannot open `" << fileH << "': " << strerror(errno);
+ os << "cannot open `" << fileH << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(fileH);
@@ -707,7 +707,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c
if(!_M)
{
ostringstream os;
- os << "cannot open `" << fileM << "': " << strerror(errno);
+ os << "cannot open `" << fileM << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(fileM);
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index 780da8f8f29..1905fc40372 100644
--- a/cpp/src/slice2php/Main.cpp
+++ b/cpp/src/slice2php/Main.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/IceUtil.h>
#include <IceUtil/InputUtil.h>
@@ -1857,7 +1856,7 @@ compile(const vector<string>& argv)
if(!out)
{
ostringstream os;
- os << "cannot open`" << file << "': " << strerror(errno);
+ os << "cannot open`" << file << "': " << IceUtilInternal::errorToString(errno);
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(file);