[assimp] Make sure ctype calls use unsigned char.
Cast to unsigned char as required by C++ (see C++ **[cctype.cyn]** -> ISO C99 section 7.4, [see also](https://en.cppreference.com/w/cpp/string/byte/isspace)). Addresses https://github.com/assimp/assimp/issues/3867 and then some.pull/3880/head
parent
f17d58cadd
commit
2925592c64
|
@ -69,7 +69,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() {
|
||||||
for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) {
|
for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) {
|
||||||
std::string s = mScene->mMaterials[i].mName;
|
std::string s = mScene->mMaterials[i].mName;
|
||||||
for (std::string::iterator it = s.begin(); it != s.end(); ++it) {
|
for (std::string::iterator it = s.begin(); it != s.end(); ++it) {
|
||||||
*it = static_cast<char>(::tolower(*it));
|
*it = static_cast<char>(::tolower(static_cast<unsigned char>(*it)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::string::npos == s.find("default")) continue;
|
if (std::string::npos == s.find("default")) continue;
|
||||||
|
|
|
@ -205,7 +205,7 @@ void AMFImporter::ParseHelper_FixTruncatedFloatString(const char *pInStr, std::s
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ParseHelper_Decode_Base64_IsBase64(const char pChar) {
|
static bool ParseHelper_Decode_Base64_IsBase64(const char pChar) {
|
||||||
return (isalnum(pChar) || (pChar == '+') || (pChar == '/'));
|
return (isalnum((unsigned char)pChar) || (pChar == '+') || (pChar == '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMFImporter::ParseHelper_Decode_Base64(const std::string &pInputBase64, std::vector<uint8_t> &pOutputData) const {
|
void AMFImporter::ParseHelper_Decode_Base64(const std::string &pInputBase64, std::vector<uint8_t> &pOutputData) const {
|
||||||
|
|
|
@ -359,7 +359,7 @@ void BVHLoader::ReadMotion(aiScene * /*pScene*/) {
|
||||||
std::string BVHLoader::GetNextToken() {
|
std::string BVHLoader::GetNextToken() {
|
||||||
// skip any preceding whitespace
|
// skip any preceding whitespace
|
||||||
while (mReader != mBuffer.end()) {
|
while (mReader != mBuffer.end()) {
|
||||||
if (!isspace(*mReader))
|
if (!isspace((unsigned char)*mReader))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// count lines
|
// count lines
|
||||||
|
@ -372,7 +372,7 @@ std::string BVHLoader::GetNextToken() {
|
||||||
// collect all chars till the next whitespace. BVH is easy in respect to that.
|
// collect all chars till the next whitespace. BVH is easy in respect to that.
|
||||||
std::string token;
|
std::string token;
|
||||||
while (mReader != mBuffer.end()) {
|
while (mReader != mBuffer.end()) {
|
||||||
if (isspace(*mReader))
|
if (isspace((unsigned char)*mReader))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
token.push_back(*mReader);
|
token.push_back(*mReader);
|
||||||
|
|
|
@ -420,9 +420,9 @@ void BlenderImporter::ResolveImage(aiMaterial *out, const Material *mat, const M
|
||||||
--s;
|
--s;
|
||||||
}
|
}
|
||||||
|
|
||||||
curTex->achFormatHint[0] = s + 1 > e ? '\0' : (char)::tolower(s[1]);
|
curTex->achFormatHint[0] = s + 1 > e ? '\0' : (char)::tolower((unsigned char)s[1]);
|
||||||
curTex->achFormatHint[1] = s + 2 > e ? '\0' : (char)::tolower(s[2]);
|
curTex->achFormatHint[1] = s + 2 > e ? '\0' : (char)::tolower((unsigned char)s[2]);
|
||||||
curTex->achFormatHint[2] = s + 3 > e ? '\0' : (char)::tolower(s[3]);
|
curTex->achFormatHint[2] = s + 3 > e ? '\0' : (char)::tolower((unsigned char)s[3]);
|
||||||
curTex->achFormatHint[3] = '\0';
|
curTex->achFormatHint[3] = '\0';
|
||||||
|
|
||||||
// tex->mHeight = 0;
|
// tex->mHeight = 0;
|
||||||
|
|
|
@ -234,7 +234,7 @@ void ColladaParser::UriDecodePath(aiString &ss) {
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
||||||
#else
|
#else
|
||||||
if (ss.data[0] == '/' && isalpha(ss.data[1]) && ss.data[2] == ':') {
|
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
||||||
#endif
|
#endif
|
||||||
--ss.length;
|
--ss.length;
|
||||||
::memmove(ss.data, ss.data + 1, ss.length);
|
::memmove(ss.data, ss.data + 1, ss.length);
|
||||||
|
|
|
@ -82,7 +82,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
|
||||||
|
|
||||||
// lower-case shading because Blender (for example) writes "Phong"
|
// lower-case shading because Blender (for example) writes "Phong"
|
||||||
for (size_t i = 0; i < shading.length(); ++i) {
|
for (size_t i = 0; i < shading.length(); ++i) {
|
||||||
shading[i] = static_cast<char>(tolower(shading[i]));
|
shading[i] = static_cast<char>(tolower(static_cast<unsigned char>(shading[i])));
|
||||||
}
|
}
|
||||||
std::string templateName;
|
std::string templateName;
|
||||||
if(shading == "phong") {
|
if(shading == "phong") {
|
||||||
|
|
|
@ -702,7 +702,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
}
|
}
|
||||||
filename = mFile.substr(s), path = mFile.substr(0, s);
|
filename = mFile.substr(s), path = mFile.substr(0, s);
|
||||||
for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) {
|
for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) {
|
||||||
*it = static_cast<char>(tolower(*it));
|
*it = static_cast<char>(tolower(static_cast<unsigned char>(*it)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load multi-part model file, if necessary
|
// Load multi-part model file, if necessary
|
||||||
|
|
|
@ -667,8 +667,8 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
|
||||||
|
|
||||||
// convert to lower case for easier comparison
|
// convert to lower case for easier comparison
|
||||||
for ( unsigned int c = 0; c < sz.length(); ++c ) {
|
for ( unsigned int c = 0; c < sz.length(); ++c ) {
|
||||||
if ( isalpha( sz[ c ] ) ) {
|
if ( isalpha( (unsigned char) sz[ c ] ) ) {
|
||||||
sz[ c ] = (char) tolower( sz[ c ] );
|
sz[ c ] = (char) tolower( (unsigned char) sz[ c ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1245,13 +1245,13 @@ unsigned int XFileParser::ReadInt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// at least one digit expected
|
// at least one digit expected
|
||||||
if (!isdigit(*mP))
|
if (!isdigit((unsigned char)*mP))
|
||||||
ThrowException("Number expected.");
|
ThrowException("Number expected.");
|
||||||
|
|
||||||
// read digits
|
// read digits
|
||||||
unsigned int number = 0;
|
unsigned int number = 0;
|
||||||
while (mP < mEnd) {
|
while (mP < mEnd) {
|
||||||
if (!isdigit(*mP))
|
if (!isdigit((unsigned char)*mP))
|
||||||
break;
|
break;
|
||||||
number = number * 10 + (*mP - 48);
|
number = number * 10 + (*mP - 48);
|
||||||
mP++;
|
mP++;
|
||||||
|
|
|
@ -193,7 +193,7 @@ void BaseImporter::GetExtensionList(std::set<std::string> &extensions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < read; ++i) {
|
for (size_t i = 0; i < read; ++i) {
|
||||||
buffer[i] = static_cast<char>(::tolower(buffer[i]));
|
buffer[i] = static_cast<char>(::tolower((unsigned char)buffer[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not a proper handling of unicode files here ...
|
// It is not a proper handling of unicode files here ...
|
||||||
|
@ -214,7 +214,7 @@ void BaseImporter::GetExtensionList(std::set<std::string> &extensions) {
|
||||||
token.clear();
|
token.clear();
|
||||||
const char *ptr(tokens[i]);
|
const char *ptr(tokens[i]);
|
||||||
for (size_t tokIdx = 0; tokIdx < len; ++tokIdx) {
|
for (size_t tokIdx = 0; tokIdx < len; ++tokIdx) {
|
||||||
token.push_back(static_cast<char>(tolower(*ptr)));
|
token.push_back(static_cast<char>(tolower(static_cast<unsigned char>(*ptr))));
|
||||||
++ptr;
|
++ptr;
|
||||||
}
|
}
|
||||||
const char *r = strstr(buffer, token.c_str());
|
const char *r = strstr(buffer, token.c_str());
|
||||||
|
@ -223,7 +223,7 @@ void BaseImporter::GetExtensionList(std::set<std::string> &extensions) {
|
||||||
}
|
}
|
||||||
// We need to make sure that we didn't accidentially identify the end of another token as our token,
|
// We need to make sure that we didn't accidentially identify the end of another token as our token,
|
||||||
// e.g. in a previous version the "gltf " present in some gltf files was detected as "f "
|
// e.g. in a previous version the "gltf " present in some gltf files was detected as "f "
|
||||||
if (noAlphaBeforeTokens && (r != buffer && isalpha(r[-1]))) {
|
if (noAlphaBeforeTokens && (r != buffer && isalpha(static_cast<unsigned char>(r[-1])))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// We got a match, either we don't care where it is, or it happens to
|
// We got a match, either we don't care where it is, or it happens to
|
||||||
|
|
|
@ -262,7 +262,7 @@ AI_FORCE_INLINE unsigned int tokenize(const string_type &str, std::vector<string
|
||||||
inline std::string ai_stdStrToLower(const std::string &str) {
|
inline std::string ai_stdStrToLower(const std::string &str) {
|
||||||
std::string out(str);
|
std::string out(str);
|
||||||
for (size_t i = 0; i < str.size(); ++i) {
|
for (size_t i = 0; i < str.size(); ++i) {
|
||||||
out[i] = (char) tolower(out[i]);
|
out[i] = (char) tolower((unsigned char)out[i]);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,8 +146,8 @@ inline int ASSIMP_stricmp(const char *s1, const char *s2) {
|
||||||
#else
|
#else
|
||||||
char c1, c2;
|
char c1, c2;
|
||||||
do {
|
do {
|
||||||
c1 = tolower(*s1++);
|
c1 = tolower((unsigned char)*(s1++));
|
||||||
c2 = tolower(*s2++);
|
c2 = tolower((unsigned char)*(s2++));
|
||||||
} while (c1 && (c1 == c2));
|
} while (c1 && (c1 == c2));
|
||||||
return c1 - c2;
|
return c1 - c2;
|
||||||
#endif
|
#endif
|
||||||
|
@ -197,8 +197,8 @@ inline int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n) {
|
||||||
unsigned int p = 0;
|
unsigned int p = 0;
|
||||||
do {
|
do {
|
||||||
if (p++ >= n) return 0;
|
if (p++ >= n) return 0;
|
||||||
c1 = tolower(*s1++);
|
c1 = tolower((unsigned char)*(s1++));
|
||||||
c2 = tolower(*s2++);
|
c2 = tolower((unsigned char)*(s2++));
|
||||||
} while (c1 && (c1 == c2));
|
} while (c1 && (c1 == c2));
|
||||||
|
|
||||||
return c1 - c2;
|
return c1 - c2;
|
||||||
|
|
|
@ -157,7 +157,7 @@ AI_FORCE_INLINE std::string ai_decimal_to_hexa(T toConvert) {
|
||||||
ss >> result;
|
ss >> result;
|
||||||
|
|
||||||
for (size_t i = 0; i < result.size(); ++i) {
|
for (size_t i = 0; i < result.size(); ++i) {
|
||||||
result[i] = (char)toupper(result[i]);
|
result[i] = (char)toupper((unsigned char)result[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue