diff --git a/code/BoostWorkaround/boost/format.hpp b/code/BoostWorkaround/boost/format.hpp index b453a356f..855d3ef81 100644 --- a/code/BoostWorkaround/boost/format.hpp +++ b/code/BoostWorkaround/boost/format.hpp @@ -31,7 +31,7 @@ namespace boost { // XXX add replacement for boost::lexical_cast? - std::stringstream ss; + std::ostringstream ss; ss << in; // note: ss cannot be an rvalue, or the global operator << (const char*) is not called for T == const char*. chunks.push_back( ss.str()); return *this; diff --git a/code/DefaultLogger.cpp b/code/DefaultLogger.cpp index e859e108d..4484463e3 100644 --- a/code/DefaultLogger.cpp +++ b/code/DefaultLogger.cpp @@ -159,47 +159,49 @@ Logger *DefaultLogger::create(const char* name /*= "AssimpLog.txt"*/, } // ---------------------------------------------------------------------------------- -void Logger::debug(const std::string &message) { +void Logger::debug(const char* message) { - // SECURITY FIX: otherwise it's easy to produce overruns ... - if (message.length()>MAX_LOG_MESSAGE_LENGTH) { + // SECURITY FIX: otherwise it's easy to produce overruns since + // sometimes importers will include data from the input file + // (i.e. node names) in their messages. + if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { ai_assert(false); return; } - return OnDebug(message.c_str()); + return OnDebug(message); } // ---------------------------------------------------------------------------------- -void Logger::info(const std::string &message) { +void Logger::info(const char* message) { - // SECURITY FIX: otherwise it's easy to produce overruns ... - if (message.length()>MAX_LOG_MESSAGE_LENGTH) { + // SECURITY FIX: see above + if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { ai_assert(false); return; } - return OnInfo(message.c_str()); + return OnInfo(message); } // ---------------------------------------------------------------------------------- -void Logger::warn(const std::string &message) { +void Logger::warn(const char* message) { - // SECURITY FIX: otherwise it's easy to produce overruns ... - if (message.length()>MAX_LOG_MESSAGE_LENGTH) { + // SECURITY FIX: see above + if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { ai_assert(false); return; } - return OnWarn(message.c_str()); + return OnWarn(message); } // ---------------------------------------------------------------------------------- -void Logger::error(const std::string &message) { +void Logger::error(const char* message) { - // SECURITY FIX: otherwise it's easy to produce overruns ... - if (message.length()>MAX_LOG_MESSAGE_LENGTH) { + // SECURITY FIX: see above + if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { ai_assert(false); return; } - return OnError(message.c_str()); + return OnError(message); } // ---------------------------------------------------------------------------------- diff --git a/code/LWOLoader.cpp b/code/LWOLoader.cpp index 55ffb49ef..53600d6c4 100644 --- a/code/LWOLoader.cpp +++ b/code/LWOLoader.cpp @@ -1097,7 +1097,8 @@ void LWOImporter::LoadLWO2Clip(unsigned int length) int16_t offset = GetU2(); mFileBuffer+=4; int16_t start = GetU2(); mFileBuffer+=4; - std::string s;std::stringstream ss; + std::string s; + std::ostringstream ss; GetS0(s,head->length); head->length -= (unsigned int)s.length()+1; diff --git a/code/OgreImporter.cpp b/code/OgreImporter.cpp index ccc92fa89..9986d7028 100644 --- a/code/OgreImporter.cpp +++ b/code/OgreImporter.cpp @@ -221,7 +221,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader) { //some info logging: unsigned int NumFaces=GetAttribute(Reader, "count"); - stringstream ss; ss <<"Submesh has " << NumFaces << " Faces."; + ostringstream ss; ss <<"Submesh has " << NumFaces << " Faces."; DefaultLogger::get()->debug(ss.str()); while(XmlRead(Reader) && Reader->getNodeName()==string("face")) @@ -242,7 +242,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader) { //some info logging: unsigned int NumVertices=GetAttribute(Reader, "vertexcount"); - stringstream ss; ss<<"VertexCount: "<debug(ss.str()); //General Informations about vertices diff --git a/code/Q3BSPFileImporter.cpp b/code/Q3BSPFileImporter.cpp index 342cae2ab..32ec5c3b7 100644 --- a/code/Q3BSPFileImporter.cpp +++ b/code/Q3BSPFileImporter.cpp @@ -68,7 +68,7 @@ static const std::string Q3BSPExtension = "pk3"; // Local function to create a material key name. static void createKey( int id1, int id2, std::string &rKey ) { - std::stringstream str; + std::ostringstream str; str << id1 << "." << id2; rKey = str.str(); } diff --git a/include/Logger.h b/include/Logger.h index b11e52e9a..43fba559a 100644 --- a/include/Logger.h +++ b/include/Logger.h @@ -94,22 +94,26 @@ public: // ---------------------------------------------------------------------- /** @brief Writes a debug message * @param message Debug message*/ - void debug(const std::string &message); + void debug(const char* message); + inline void debug(const std::string &message); // ---------------------------------------------------------------------- /** @brief Writes a info message * @param message Info message*/ - void info(const std::string &message); + void info(const char* message); + inline void info(const std::string &message); // ---------------------------------------------------------------------- /** @brief Writes a warning message * @param message Warn message*/ - void warn(const std::string &message); + void warn(const char* message); + inline void warn(const std::string &message); // ---------------------------------------------------------------------- /** @brief Writes an error message * @param message Error message*/ - void error(const std::string &message); + void error(const char* message); + inline void error(const std::string &message); // ---------------------------------------------------------------------- /** @brief Set a new log severity. @@ -227,6 +231,30 @@ inline Logger::LogSeverity Logger::getLogSeverity() const { return m_Severity; } +// ---------------------------------------------------------------------------------- +inline void Logger::debug(const std::string &message) +{ + return debug(message.c_str()); +} + +// ---------------------------------------------------------------------------------- +inline void Logger::error(const std::string &message) +{ + return error(message.c_str()); +} + +// ---------------------------------------------------------------------------------- +inline void Logger::warn(const std::string &message) +{ + return warn(message.c_str()); +} + +// ---------------------------------------------------------------------------------- +inline void Logger::info(const std::string &message) +{ + return info(message.c_str()); +} + // ---------------------------------------------------------------------------------- } // Namespace Assimp diff --git a/include/aiTypes.h b/include/aiTypes.h index ce89c0f33..d79ee81db 100644 --- a/include/aiTypes.h +++ b/include/aiTypes.h @@ -219,7 +219,7 @@ struct aiColor3D * * The character set of an aiString is explicitly defined to be UTF-8. This Unicode * transformation was chosen in the belief that most strings in 3d files are limited - * to the ASCII characters, thus the character set needed to be ASCII compatible. + * to ASCII, thus the character set needed to be strictly ASCII compatible. * * Most text file loaders provide proper Unicode input file handling, special unicode * characters are correctly transcoded to UTF8 and are kept throughout the libraries' @@ -275,7 +275,7 @@ struct aiString return; } length = pString.length(); - ::memcpy( data, pString.c_str(), length); + memcpy( data, pString.c_str(), length); data[length] = 0; } @@ -286,7 +286,7 @@ struct aiString return; } length = len; - ::memcpy( data, sz, len); + memcpy( data, sz, len); data[len] = 0; } @@ -304,17 +304,17 @@ struct aiString /** Comparison operator */ bool operator==(const aiString& other) const { - return (length == other.length && 0 == strcmp(this->data,other.data)); + return (length == other.length && 0 == memcmp(data,other.data,length)); } /** Inverse comparison operator */ bool operator!=(const aiString& other) const { - return (length != other.length || 0 != ::strcmp(this->data,other.data)); + return (length != other.length || 0 != memcmp(data,other.data,length)); } /** Append a string to the string */ void Append (const char* app) { - const size_t len = ::strlen(app); + const size_t len = strlen(app); if (!len) { return; }