snprintf: change next couple of sprintf to snprintf.
parent
c3d4be1dce
commit
67c258e75d
|
@ -757,7 +757,7 @@ void Discreet3DSImporter::GenerateNodeGraph(aiScene* pcOut)
|
||||||
pcNode->mNumMeshes = 1;
|
pcNode->mNumMeshes = 1;
|
||||||
|
|
||||||
// Build a name for the node
|
// Build a name for the node
|
||||||
pcNode->mName.length = sprintf(pcNode->mName.data,"3DSMesh_%u",i);
|
pcNode->mName.length = snprintf(pcNode->mName.data, MAXLEN, "3DSMesh_%u",i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build dummy nodes for all cameras
|
// Build dummy nodes for all cameras
|
||||||
|
|
|
@ -744,7 +744,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
|
|
||||||
// there shouldn't be more than one world, but we don't care
|
// there shouldn't be more than one world, but we don't care
|
||||||
case Object::World:
|
case Object::World:
|
||||||
node->mName.length = ::sprintf(node->mName.data,"ACWorld_%i",worlds++);
|
node->mName.length = ::snprintf(node->mName.data, MAXLEN, "ACWorld_%i",worlds++);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1167,7 +1167,7 @@ void LWOImporter::LoadLWO2Clip(unsigned int length)
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
GetS0(s,head.length);
|
GetS0(s,head.length);
|
||||||
|
|
||||||
head.length -= (unsigned int)s.length()+1;
|
head.length -= (uint16_t)s.length()+1;
|
||||||
ss << s;
|
ss << s;
|
||||||
ss << std::setw(digits) << offset + start;
|
ss << std::setw(digits) << offset + start;
|
||||||
GetS0(s,head.length);
|
GetS0(s,head.length);
|
||||||
|
@ -1370,7 +1370,7 @@ void LWOImporter::LoadLWO2File()
|
||||||
// if the name is empty, generate a default name
|
// if the name is empty, generate a default name
|
||||||
if (layer.mName.empty()) {
|
if (layer.mName.empty()) {
|
||||||
char buffer[128]; // should be sufficiently large
|
char buffer[128]; // should be sufficiently large
|
||||||
::sprintf(buffer,"Layer_%i", iUnnamed++);
|
::snprintf(buffer, 128, "Layer_%i", iUnnamed++);
|
||||||
layer.mName = buffer;
|
layer.mName = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,11 +323,11 @@ void LWSImporter::SetupNodeName(aiNode* nd, LWS::NodeDesc& src)
|
||||||
else ++s;
|
else ++s;
|
||||||
std::string::size_type t = src.path.substr(s).find_last_of(".");
|
std::string::size_type t = src.path.substr(s).find_last_of(".");
|
||||||
|
|
||||||
nd->mName.length = ::sprintf(nd->mName.data,"%s_(%08X)",src.path.substr(s).substr(0,t).c_str(),combined);
|
nd->mName.length = ::snprintf(nd->mName.data, MAXLEN, "%s_(%08X)",src.path.substr(s).substr(0,t).c_str(),combined);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nd->mName.length = ::sprintf(nd->mName.data,"%s_(%08X)",src.name,combined);
|
nd->mName.length = ::snprintf(nd->mName.data, MAXLEN, "%s_(%08X)",src.name,combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -735,7 +735,7 @@ void MD5Importer::LoadMD5CameraFile ()
|
||||||
for (std::vector<unsigned int>::const_iterator it = cuts.begin(); it != cuts.end()-1; ++it) {
|
for (std::vector<unsigned int>::const_iterator it = cuts.begin(); it != cuts.end()-1; ++it) {
|
||||||
|
|
||||||
aiAnimation* anim = *tmp++ = new aiAnimation();
|
aiAnimation* anim = *tmp++ = new aiAnimation();
|
||||||
anim->mName.length = ::sprintf(anim->mName.data,"anim%u_from_%u_to_%u",(unsigned int)(it-cuts.begin()),(*it),*(it+1));
|
anim->mName.length = ::snprintf(anim->mName.data, MAXLEN, "anim%u_from_%u_to_%u",(unsigned int)(it-cuts.begin()),(*it),*(it+1));
|
||||||
|
|
||||||
anim->mTicksPerSecond = cameraParser.fFrameRate;
|
anim->mTicksPerSecond = cameraParser.fFrameRate;
|
||||||
anim->mChannels = new aiNodeAnim*[anim->mNumChannels = 1];
|
anim->mChannels = new aiNodeAnim*[anim->mNumChannels = 1];
|
||||||
|
|
|
@ -85,7 +85,7 @@ MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize )
|
||||||
|
|
||||||
if ( !DefaultLogger::isNullLogger()) {
|
if ( !DefaultLogger::isNullLogger()) {
|
||||||
char szBuffer[128]; // should be sufficiently large
|
char szBuffer[128]; // should be sufficiently large
|
||||||
::sprintf(szBuffer,"MD5Parser end. Parsed %i sections",(int)mSections.size());
|
::snprintf(szBuffer,128,"MD5Parser end. Parsed %i sections",(int)mSections.size());
|
||||||
DefaultLogger::get()->debug(szBuffer);
|
DefaultLogger::get()->debug(szBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize )
|
||||||
/*static*/ AI_WONT_RETURN void MD5Parser::ReportError (const char* error, unsigned int line)
|
/*static*/ AI_WONT_RETURN void MD5Parser::ReportError (const char* error, unsigned int line)
|
||||||
{
|
{
|
||||||
char szBuffer[1024];
|
char szBuffer[1024];
|
||||||
::sprintf(szBuffer,"[MD5] Line %u: %s",line,error);
|
::snprintf(szBuffer, 1024, "[MD5] Line %u: %s",line,error);
|
||||||
throw DeadlyImportError(szBuffer);
|
throw DeadlyImportError(szBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -942,7 +942,7 @@ void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7** apcOutBones)
|
||||||
|
|
||||||
if (AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE == pcHeader->bone_stc_size) {
|
if (AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE == pcHeader->bone_stc_size) {
|
||||||
// no real name for our poor bone is specified :-(
|
// no real name for our poor bone is specified :-(
|
||||||
pcOutBone->mName.length = ::sprintf(pcOutBone->mName.data,
|
pcOutBone->mName.length = ::snprintf(pcOutBone->mName.data, MAXLEN,
|
||||||
"UnnamedBone_%i",iBone);
|
"UnnamedBone_%i",iBone);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1384,7 +1384,8 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
avOutList[i].reserve(3);
|
avOutList[i].reserve(3);
|
||||||
|
|
||||||
// buffer to held the names of all groups in the file
|
// buffer to held the names of all groups in the file
|
||||||
char* aszGroupNameBuffer = new char[AI_MDL7_MAX_GROUPNAMESIZE*pcHeader->groups_num];
|
const size_t buffersize( AI_MDL7_MAX_GROUPNAMESIZE*pcHeader->groups_num );
|
||||||
|
char* aszGroupNameBuffer = new char[ buffersize ];
|
||||||
|
|
||||||
// read all groups
|
// read all groups
|
||||||
for (unsigned int iGroup = 0; iGroup < (unsigned int)pcHeader->groups_num;++iGroup) {
|
for (unsigned int iGroup = 0; iGroup < (unsigned int)pcHeader->groups_num;++iGroup) {
|
||||||
|
@ -1544,9 +1545,12 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
|
|
||||||
// setup the name of the node
|
// setup the name of the node
|
||||||
char* const szBuffer = &aszGroupNameBuffer[i*AI_MDL7_MAX_GROUPNAMESIZE];
|
char* const szBuffer = &aszGroupNameBuffer[i*AI_MDL7_MAX_GROUPNAMESIZE];
|
||||||
if ('\0' == *szBuffer)
|
if ('\0' == *szBuffer) {
|
||||||
pcNode->mName.length = ::sprintf(szBuffer,"Group_%u",p);
|
const size_t maxSize(buffersize - (i*AI_MDL7_MAX_GROUPNAMESIZE));
|
||||||
else pcNode->mName.length = ::strlen(szBuffer);
|
pcNode->mName.length = ::snprintf(szBuffer, maxSize, "Group_%u", p);
|
||||||
|
} else {
|
||||||
|
pcNode->mName.length = ::strlen(szBuffer);
|
||||||
|
}
|
||||||
::strcpy(pcNode->mName.data,szBuffer);
|
::strcpy(pcNode->mName.data,szBuffer);
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -699,7 +699,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||||
|
|
||||||
// place this as diffuse texture
|
// place this as diffuse texture
|
||||||
char szCurrent[5];
|
char szCurrent[5];
|
||||||
::sprintf(szCurrent,"*%i",this->pScene->mNumTextures);
|
::snprintf(szCurrent,5,"*%i",this->pScene->mNumTextures);
|
||||||
|
|
||||||
aiString szFile;
|
aiString szFile;
|
||||||
const size_t iLen = strlen((const char*)szCurrent);
|
const size_t iLen = strlen((const char*)szCurrent);
|
||||||
|
|
|
@ -862,7 +862,7 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||||
|
|
||||||
// generate a name for the mesh
|
// generate a name for the mesh
|
||||||
::sprintf(currentMesh.name,"sphere_%i",sphere++);
|
::snprintf(currentMesh.name,128,"sphere_%i",sphere++);
|
||||||
}
|
}
|
||||||
// 'dod' - dodecahedron
|
// 'dod' - dodecahedron
|
||||||
else if (TokenMatch(sz,"dod",3))
|
else if (TokenMatch(sz,"dod",3))
|
||||||
|
@ -879,7 +879,7 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||||
|
|
||||||
// generate a name for the mesh
|
// generate a name for the mesh
|
||||||
::sprintf(currentMesh.name,"dodecahedron_%i",dodecahedron++);
|
::snprintf(currentMesh.name,128,"dodecahedron_%i",dodecahedron++);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'oct' - octahedron
|
// 'oct' - octahedron
|
||||||
|
@ -897,7 +897,7 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||||
|
|
||||||
// generate a name for the mesh
|
// generate a name for the mesh
|
||||||
::sprintf(currentMesh.name,"octahedron_%i",octahedron++);
|
::snprintf(currentMesh.name,128,"octahedron_%i",octahedron++);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'tet' - tetrahedron
|
// 'tet' - tetrahedron
|
||||||
|
|
Loading…
Reference in New Issue