Commit 220731f9 authored by Sean McBride's avatar Sean McBride

Replaced many trivial uses of sprintf with snprintf

snprintf is now part of C++11 and is already simulated for old versions of VS.
parent e6f5918b
......@@ -47,7 +47,7 @@ int TestBoxPlot(int , char* [])
for (int i = 0; i < numParam; i++)
{
char num[10];
sprintf(num, "P%d", i);
snprintf(num, sizeof(num), "P%d", i);
vtkNew<vtkIntArray> arrIndex;
arrIndex->SetName(num);
inputBoxPlotTable->AddColumn(arrIndex.GetPointer());
......
......@@ -55,7 +55,7 @@ int TestBoxPlot2(int , char* [])
for (int i = 0; i < numberOfColumns; ++i)
{
char num[10];
sprintf(num, "Run %d", i + 1);
snprintf(num, sizeof(num), "Run %d", i + 1);
vtkSmartPointer<vtkIntArray> arrIndex =
vtkSmartPointer<vtkIntArray>::New();
arrIndex->SetName(num);
......
......@@ -32,7 +32,7 @@ int doStringArrayTest(ostream& strm, int size)
for (int i = 0; i < SIZE; ++i)
{
char buf[1024];
sprintf(buf, "string entry %d", i);
snprintf(buf, sizeof(buf), "string entry %d", i);
strings[i] = vtkStdString(buf);
}
......
......@@ -28,7 +28,7 @@ int otherFieldData(int,char *[])
char name[128];
for(i=0; i<5; i++)
{
sprintf(name, "Array%d", i);
snprintf(name, sizeof(name), "Array%d", i);
fa = vtkFloatArray::New();
fa->SetName(name);
// the tuples must be set before being read to avoid a UMR
......
......@@ -199,11 +199,11 @@ int vtkPKdTree::AllCheckForFailure(int rc, const char *where, const char *how)
{
if (rc)
{
sprintf(errmsg,"%s on my node (%s)",how, where);
snprintf(errmsg,sizeof(errmsg),"%s on my node (%s)",how, where);
}
else
{
sprintf(errmsg,"%s on a remote node (%s)",how, where);
snprintf(errmsg,sizeof(errmsg),"%s on a remote node (%s)",how, where);
}
VTKWARNING(errmsg);
......
......@@ -197,7 +197,7 @@ void vtkGeoAlignedImageRepresentation::SaveDatabase(const char* path)
storedImage->ShallowCopy(node->GetTexture()->GetInput());
vtkSmartPointer<vtkXMLImageDataWriter> writer = vtkSmartPointer<vtkXMLImageDataWriter>::New();
char fn[512];
sprintf(fn, "%s/tile_%d_%ld.vti", path, node->GetLevel(), node->GetId());
snprintf(fn, sizeof(fn), "%s/tile_%d_%ld.vti", path, node->GetLevel(), node->GetId());
writer->SetFileName(fn);
writer->SetInputData(storedImage);
writer->Write();
......
......@@ -177,7 +177,7 @@ void vtkGeoImageNode::CropImageForTile(
storedImage->SetSpacing(this->LongitudeRange[1], this->LatitudeRange[1], 0);
vtkXMLImageDataWriter* writer = vtkXMLImageDataWriter::New();
char fn[512];
sprintf(fn, "%s/tile_%d_%lu.vti", prefix, this->Level, this->Id);
snprintf(fn, sizeof(fn), "%s/tile_%d_%lu.vti", prefix, this->Level, this->Id);
writer->SetFileName(fn);
writer->SetInputData(storedImage);
writer->Write();
......@@ -191,7 +191,7 @@ void vtkGeoImageNode::LoadAnImage(const char* prefix)
{
vtkXMLImageDataReader* reader = vtkXMLImageDataReader::New();
char fn[512];
sprintf(fn, "%s/tile_%d_%lu.vti", prefix, this->Level, this->Id);
snprintf(fn, sizeof(fn), "%s/tile_%d_%lu.vti", prefix, this->Level, this->Id);
reader->SetFileName(fn);
reader->Update();
vtkImageData* image = reader->GetOutput();
......
......@@ -505,7 +505,7 @@ void vtkGeoTerrain::SaveDatabase(const char* path, int depth)
storedData->ShallowCopy(node->GetModel());
vtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();
char fn[512];
sprintf(fn, "%s/tile_%d_%ld.vtp", path, node->GetLevel(), node->GetId());
snprintf(fn, sizeof(fn), "%s/tile_%d_%ld.vtp", path, node->GetLevel(), node->GetId());
writer->SetFileName(fn);
writer->SetInputData(storedData);
writer->Write();
......
......@@ -168,7 +168,7 @@ void vtkWriter::EncodeString(char* resname, const char* name, bool doublePercent
if ( name[cc] < 33 || name[cc] > 126 ||
name[cc] == '\"' || name[cc] == '%' )
{
sprintf(buffer, "%02X", static_cast<unsigned char>(name[cc]));
snprintf(buffer, sizeof(buffer), "%02X", static_cast<unsigned char>(name[cc]));
if (doublePercent)
{
str << "%%";
......@@ -205,7 +205,7 @@ void vtkWriter::EncodeWriteString(ostream* out, const char* name, bool doublePer
if ( name[cc] < 33 || name[cc] > 126 ||
name[cc] == '\"' || name[cc] == '%' )
{
sprintf(buffer, "%02X", static_cast<unsigned char>(name[cc]));
snprintf(buffer, sizeof(buffer), "%02X", static_cast<unsigned char>(name[cc]));
if (doublePercent)
{
*out << "%%";
......
......@@ -2122,8 +2122,8 @@ void vtkEnSightReader::ReplaceWildcards(char* filename, int num)
else if (numWildcards == 1)
strcpy(pattern, "%d");
else
sprintf(pattern, "%%0%dd", numWildcards);
sprintf(numStr, pattern, num);
snprintf(pattern, sizeof(pattern), "%%0%dd", numWildcards);
snprintf(numStr, sizeof(numStr), pattern, num);
numStrLen = static_cast<int>(strlen(numStr));
len = static_cast<int>(strlen(filename));
cnt = 0;
......
......@@ -3520,7 +3520,7 @@ const char* vtkExodusIIReaderPrivate::GetPartBlockInfo(int idx)
std::vector<int> blkIndices = this->PartInfo[idx].BlockIndices;
for (unsigned int i=0;i<blkIndices.size();i++)
{
sprintf(buffer,"%d, ",blkIndices[i]);
snprintf(buffer,sizeof(buffer),"%d, ",blkIndices[i]);
blocks += buffer;
}
......@@ -4169,7 +4169,7 @@ int vtkExodusIIReaderPrivate::RequestInformation()
blockEntryFileOffset += binfo.Size;
if (binfo.Name.length() == 0)
{
snprintf( tmpName, 255, "Unnamed block ID: %d Type: %s",
snprintf( tmpName, sizeof(tmpName), "Unnamed block ID: %d Type: %s",
ids[obj], binfo.TypeName.length() ? binfo.TypeName.c_str() : "NULL");
binfo.Name = tmpName;
}
......@@ -4299,7 +4299,7 @@ int vtkExodusIIReaderPrivate::RequestInformation()
this->GetInitialObjectStatus(obj_types[i], &sinfo);
if (sinfo.Name.length() == 0)
{
snprintf( tmpName, 255, "Unnamed set ID: %d", ids[obj]);
snprintf( tmpName, sizeof(tmpName), "Unnamed set ID: %d", ids[obj]);
sinfo.Name = tmpName;
}
sortedObjects[sinfo.Id] = (int) this->SetInfo[obj_types[i]].size();
......@@ -4330,8 +4330,8 @@ int vtkExodusIIReaderPrivate::RequestInformation()
}
minfo.Name = obj_names[obj];
if (minfo.Name.length() == 0)
{ // make up a name. FIXME: Possible buffer overflow w/ sprintf
snprintf( tmpName, 255, "Unnamed map ID: %d", ids[obj] );
{
snprintf( tmpName, sizeof(tmpName), "Unnamed map ID: %d", ids[obj] );
minfo.Name = tmpName;
}
sortedObjects[minfo.Id] = (int) this->MapInfo[obj_types[i]].size();
......
......@@ -2418,7 +2418,7 @@ std::string vtkExodusIIWriter::CreateNameForScalarArray(
}
// assume largest for 32 bit decimal representation
char n[11];
sprintf (n, "%10d", component);
snprintf (n, sizeof(n), "%10d", component);
s.append (n);
return s;
}
......
......@@ -77,8 +77,8 @@ void vtkOBJExporter::WriteData()
}
// try opening the files
sprintf(nameObj,"%s.obj",this->FilePrefix);
sprintf(nameMtl,"%s.mtl",this->FilePrefix);
snprintf(nameObj,sizeof(nameObj),"%s.obj",this->FilePrefix);
snprintf(nameMtl,sizeof(nameMtl),"%s.mtl",this->FilePrefix);
fpObj = fopen(nameObj,"w");
if (!fpObj)
{
......
......@@ -1021,7 +1021,7 @@ static void vtkX3DExporterWriteData(vtkPoints *points,
vtkX3DExporterWriter* writer)
{
char indexString[100];
sprintf(indexString, "%04d", index);
snprintf(indexString, sizeof(indexString), "%04d", index);
// write out the points
std::string defString = "VTKcoordinates";
......@@ -1075,7 +1075,7 @@ static void vtkX3DExporterUseData(bool normals, bool tcoords, bool colors, int i
vtkX3DExporterWriter* writer)
{
char indexString[100];
sprintf(indexString, "%04d", index);
snprintf(indexString, sizeof(indexString), "%04d", index);
std::string defString = "VTKcoordinates";
writer->StartNode(Coordinate);
writer->SetField(USE, defString.append(indexString).c_str());
......
......@@ -269,7 +269,7 @@ void vtkX3DExporterXMLWriter::SetField(int attributeID, const int* values, size_
while (i < size)
{
sprintf(buffer,"0x%.8x",values[i]);
snprintf(buffer,sizeof(buffer),"0x%.8x",values[i]);
*this->OutputStream << buffer;
if (j%(8*bpp))
......
......@@ -1724,7 +1724,7 @@ void vtkMFIXReader::CreateVariableNames()
strcpy(vString, "V_s_");
strcpy(wString, "W_s_");
strcpy(svString, "Solids_Velocity_");
sprintf(tempString, "%d", j+1);
snprintf(tempString, sizeof(tempString), "%d", j+1);
strcat(uString, tempString);
strcat(vString, tempString);
strcat(wString, tempString);
......@@ -1755,7 +1755,7 @@ void vtkMFIXReader::CreateVariableNames()
ropString[k]=0;
}
strcpy(ropString, "ROP_s_");
sprintf(tempString, "%d", j+1);
snprintf(tempString, sizeof(tempString), "%d", j+1);
strcat(ropString, tempString);
this->VariableNames->InsertValue(cnt++, ropString);
this->VariableIndexToSPX->InsertValue(cnt-1, 5);
......@@ -1796,7 +1796,7 @@ void vtkMFIXReader::CreateVariableNames()
temperatureString[k]=0;
}
strcpy(temperatureString, "T_s_");
sprintf(tempString, "%d", j+1);
snprintf(tempString, sizeof(tempString), "%d", j+1);
strcat(temperatureString, tempString);
this->VariableNames->InsertValue(cnt++, temperatureString);
this->VariableIndexToSPX->InsertValue(cnt-1, 6);
......@@ -1813,7 +1813,7 @@ void vtkMFIXReader::CreateVariableNames()
variableString[k]=0;
}
strcpy(variableString, "X_g_");
sprintf(tempString, "%d", j+1);
snprintf(tempString, sizeof(tempString), "%d", j+1);
strcat(variableString, tempString);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 7);
......@@ -1831,8 +1831,8 @@ void vtkMFIXReader::CreateVariableNames()
variableString[k]=0;
}
strcpy(variableString, "X_s_");
sprintf(tempString1, "%d", m);
sprintf(tempString2, "%d", j+1);
snprintf(tempString1, sizeof(tempString1), "%d", m);
snprintf(tempString2, sizeof(tempString2), "%d", j+1);
strcat(variableString, tempString1);
strcat(variableString, "_");
strcat(variableString, tempString2);
......@@ -1851,7 +1851,7 @@ void vtkMFIXReader::CreateVariableNames()
variableString[k]=0;
}
strcpy(variableString, "Theta_m_");
sprintf(tempString, "%d", j+1);
snprintf(tempString, sizeof(tempString), "%d", j+1);
strcat(variableString, tempString);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 8);
......@@ -1867,7 +1867,7 @@ void vtkMFIXReader::CreateVariableNames()
variableString[k]=0;
}
strcpy(variableString, "Scalar_");
sprintf(tempString, "%d", j+1);
snprintf(tempString, sizeof(tempString), "%d", j+1);
strcat(variableString, tempString);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 9);
......@@ -1883,7 +1883,7 @@ void vtkMFIXReader::CreateVariableNames()
variableString[k]=0;
}
strcpy(variableString, "RRates_");
sprintf(tempString, "%d", j+1);
snprintf(tempString, sizeof(tempString), "%d", j+1);
strcat(variableString, tempString);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 10);
......
......@@ -214,7 +214,7 @@ void vtkSTLWriter::WriteBinarySTL(
else
{
memset(szHeader, 32, 80); // fill with space (ASCII=>32)
sprintf(szHeader, "%s", this->Header);
snprintf(szHeader, sizeof(szHeader), "%s", this->Header);
}
fwrite (szHeader, 1, 80, fp);
......
......@@ -1641,7 +1641,7 @@ void vtkTecplotReader::ReadFile( vtkMultiBlockDataSet * multZone )
int numNodes = 0;
int numElements = 0;
char untitledZoneName[40];
sprintf( untitledZoneName, "zone%05d", zoneIndex );
snprintf( untitledZoneName, sizeof(untitledZoneName), "zone%05d", zoneIndex );
std::string format = "";
std::string elemType = "";
......
......@@ -189,7 +189,7 @@ void vtkGESignaReader::ExecuteInformation()
return;
}
vtkByteSwap::Swap2BE(&examnumber);
sprintf(tmpStr,"%d",examnumber);
snprintf(tmpStr,sizeof(tmpStr),"%d",examnumber);
//this->SetStudyNumber(tmpStr);
// Patient ID
fseek(fp, examHdrOffset + 84, SEEK_SET);
......@@ -223,7 +223,7 @@ void vtkGESignaReader::ExecuteInformation()
return;
}
vtkByteSwap::Swap2BE(&patientage);
sprintf(tmpStr,"%d",patientage);
snprintf(tmpStr,sizeof(tmpStr),"%d",patientage);
this->GetMedicalImageProperties()->SetPatientAge( tmpStr );
// Patient Sex
fseek(fp, examHdrOffset + 126, SEEK_SET);
......@@ -236,7 +236,7 @@ void vtkGESignaReader::ExecuteInformation()
return;
}
vtkByteSwap::Swap2BE(&patientsex);
sprintf(tmpStr,"%d",patientsex);
snprintf(tmpStr,sizeof(tmpStr),"%d",patientsex);
this->GetMedicalImageProperties()->SetPatientSex( tmpStr );
// Modality
fseek(fp, examHdrOffset + 305, SEEK_SET);
......@@ -262,7 +262,7 @@ void vtkGESignaReader::ExecuteInformation()
return;
}
vtkByteSwap::Swap2BE(&series);
sprintf(tmpStr,"%d",series);
snprintf(tmpStr,sizeof(tmpStr),"%d",series);
this->SetSeries(tmpStr);
// scan protocol name
fseek(fp, seriesHdrOffset + 92, SEEK_SET);
......
......@@ -280,11 +280,11 @@ void vtkVolume16Reader::ReadImage(int sliceNumber,
// build the file name. if there is no prefix, just use the slice number
if (this->FilePrefix)
{
sprintf (filename, this->FilePattern, this->FilePrefix, sliceNumber);
snprintf (filename, sizeof(filename), this->FilePattern, this->FilePrefix, sliceNumber);
}
else
{
sprintf (filename, this->FilePattern, sliceNumber);
snprintf (filename, sizeof(filename), this->FilePattern, sliceNumber);
}
if ( !(fp = fopen(filename,"rb")) )
{
......@@ -346,11 +346,11 @@ void vtkVolume16Reader::ReadVolume(int first, int last,
// build the file name. if there is no prefix, just use the slice number
if (this->FilePattern)
{
sprintf (filename, this->FilePattern, this->FilePrefix, fileNumber);
snprintf (filename, sizeof(filename), this->FilePattern, this->FilePrefix, fileNumber);
}
else
{
sprintf (filename, this->FilePattern, fileNumber);
snprintf (filename, sizeof(filename), this->FilePattern, fileNumber);
}
if ( !(fp = fopen(filename,"rb")) )
{
......
......@@ -24,7 +24,7 @@
* 3D volume.
*
* File names are created using FilePattern and FilePrefix as follows:
* sprintf (filename, FilePattern, FilePrefix, number);
* snprintf (filename, sizeof(filename), FilePattern, FilePrefix, number);
* where number is in the range ImageRange[0] to ImageRange[1]. If
* ImageRange[1] <= ImageRange[0], then slice number ImageRange[0] is
* read. Thus to read an image set ImageRange[0] = ImageRange[1] = slice
......
......@@ -24,7 +24,7 @@
* 3D volume.
*
* File names are created using FilePattern and FilePrefix as follows:
* sprintf (filename, FilePattern, FilePrefix, number);
* snprintf (filename, sizeof(filename), FilePattern, FilePrefix, number);
* where number is in the range ImageRange[0] to ImageRange[1]. If
* ImageRange[1] <= ImageRange[0], then slice number ImageRange[0] is
* read. Thus to read an image set ImageRange[0] = ImageRange[1] = slice
......@@ -64,7 +64,7 @@ public:
//@{
/**
* The sprintf format used to build filename from FilePrefix and number.
* The snprintf format used to build filename from FilePrefix and number.
*/
vtkSetStringMacro(FilePattern);
vtkGetStringMacro(FilePattern);
......
......@@ -140,11 +140,8 @@ int vtkFixedWidthTextReader::RequestData(
for (unsigned int i = 0; i < firstLineFields.size(); ++i)
{
// I know it's not a great idea to use sprintf. It's safe right
// here because an unsigned int will never take up enough
// characters to fill up this buffer.
char fieldName[64];
sprintf(fieldName, "Field %u", i);
snprintf(fieldName, sizeof(fieldName), "Field %u", i);
headers.push_back(fieldName);
}
}
......
......@@ -102,7 +102,7 @@ vtkLSDynaFile_t VTK_LSDYNA_OPENFILE(const char* fname)
if ( number > 0 )
{
char n[4];
sprintf(n, "%02d", number);
snprintf(n, sizeof(n), "%02d", number);
blorb += n;
}
......
......@@ -1828,7 +1828,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
for ( itmp = 2; itmp <= sphAttributes; ++itmp )
{
int numComponents = p->Fam.GetNextWordAsInt();
sprintf( ctmp, "isphfg(%d)", itmp );
snprintf( ctmp, sizeof(ctmp), "isphfg(%d)", itmp );
p->Dict[ ctmp ] = numComponents;
statePerParticle += numComponents;
}
......@@ -2075,7 +2075,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
}
for ( itmp = 3; itmp < p->Dict["_MAXINT_"]; ++itmp )
{
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_STRESS, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_STRESS, itmp + 1 );
p->AddCellArray( LSDynaMetaData::SHELL, ctmp, 6, 1 );
}
}
......@@ -2089,7 +2089,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
}
for ( itmp = 3; itmp < p->Dict["_MAXINT_"]; ++itmp )
{
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_EPSTRAIN, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_EPSTRAIN, itmp + 1 );
p->AddCellArray( LSDynaMetaData::SHELL, ctmp, 1, 1 );
}
}
......@@ -2116,7 +2116,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
}
for ( itmp = 3; itmp < p->Dict["_MAXINT_"]; ++itmp )
{
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_INTEGRATIONPOINT, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_INTEGRATIONPOINT, itmp + 1 );
p->AddCellArray( LSDynaMetaData::SHELL, ctmp, 6, 1 );
}
}
......@@ -2152,7 +2152,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
}
for ( itmp = 3; itmp < p->Dict["_MAXINT_"]; ++itmp )
{
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_STRESS, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_STRESS, itmp + 1 );
p->AddCellArray( LSDynaMetaData::THICK_SHELL, ctmp, 6, 1 );
}
}
......@@ -2166,7 +2166,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
}
for ( itmp = 3; itmp < p->Dict["_MAXINT_"]; ++itmp )
{
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_EPSTRAIN, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_EPSTRAIN, itmp + 1 );
p->AddCellArray( LSDynaMetaData::THICK_SHELL, ctmp, 1, 1 );
}
}
......@@ -2182,7 +2182,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
}
for ( itmp = 3; itmp < p->Dict["_MAXINT_"]; ++itmp )
{
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_INTEGRATIONPOINT, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_INTEGRATIONPOINT, itmp + 1 );
p->AddCellArray( LSDynaMetaData::THICK_SHELL, ctmp, 6, 1 );
}
}
......@@ -2232,7 +2232,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
for (vtkIdType g=0; g < numGroups; ++g)
{
sprintf( ctmp, LS_ARRAYNAME_VOLUME_FRACTION_FMT, static_cast<int>(g+1) );
snprintf( ctmp, sizeof(ctmp), LS_ARRAYNAME_VOLUME_FRACTION_FMT, static_cast<int>(g+1) );
p->AddCellArray( LSDynaMetaData::SOLID, ctmp, 1, 1 );
extraValues--;
}
......@@ -2242,7 +2242,7 @@ int vtkLSDynaReader::ReadHeaderInformation( int curAdapt )
for (vtkIdType g=0; hasMass && (g < numGroups); ++g)
{
sprintf( ctmp, LS_ARRAYNAME_SPECIES_MASS_FMT, static_cast<int>(g+1) );
snprintf( ctmp, sizeof(ctmp), LS_ARRAYNAME_SPECIES_MASS_FMT, static_cast<int>(g+1) );
p->AddCellArray( LSDynaMetaData::SOLID, ctmp, 1, 1 );
extraValues--;
}
......@@ -2824,7 +2824,7 @@ int vtkLSDynaReader::ReadCellStateInfo( vtkIdType vtkNotUsed(step) )
for (vtkIdType g=0; g < numGroups; ++g)
{
sprintf( ctmp, LS_ARRAYNAME_VOLUME_FRACTION_FMT, static_cast<int>(g+1) );
snprintf( ctmp, sizeof(ctmp), LS_ARRAYNAME_VOLUME_FRACTION_FMT, static_cast<int>(g+1) );
VTK_LS_CELLARRAY(1, LSDynaMetaData::SOLID, ctmp, 1);
extraValues--;
}
......@@ -2834,7 +2834,7 @@ int vtkLSDynaReader::ReadCellStateInfo( vtkIdType vtkNotUsed(step) )
for (vtkIdType g=0; hasMass && (g < numGroups); ++g)
{
sprintf( ctmp, LS_ARRAYNAME_SPECIES_MASS_FMT, static_cast<int>(g+1) );
snprintf( ctmp, sizeof(ctmp), LS_ARRAYNAME_SPECIES_MASS_FMT, static_cast<int>(g+1) );
VTK_LS_CELLARRAY(1, LSDynaMetaData::SOLID, ctmp, 1);
extraValues--;
}
......@@ -2883,13 +2883,13 @@ int vtkLSDynaReader::ReadCellStateInfo( vtkIdType vtkNotUsed(step) )
// point values (NEIPS vals).
for ( itmp = 3; itmp < p->Dict["_MAXINT_"]; ++itmp )
{
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_STRESS, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_STRESS, itmp + 1 );
VTK_LS_CELLARRAY(p->Dict["IOSHL(1)"] != 0,LSDynaMetaData::THICK_SHELL,ctmp,6);
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_EPSTRAIN, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_EPSTRAIN, itmp + 1 );
VTK_LS_CELLARRAY(p->Dict["IOSHL(2)"] != 0,LSDynaMetaData::THICK_SHELL,ctmp,1);
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_INTEGRATIONPOINT, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_INTEGRATIONPOINT, itmp + 1 );
VTK_LS_CELLARRAY(p->Dict["NEIPS"] > 0,LSDynaMetaData::THICK_SHELL,ctmp,p->Dict["NEIPS"]);
}
}
......@@ -2936,13 +2936,13 @@ int vtkLSDynaReader::ReadCellStateInfo( vtkIdType vtkNotUsed(step) )
// point values (NEIPS vals).
for ( itmp = 3; itmp < p->Dict["_MAXINT_"]; ++itmp )
{
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_STRESS, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_STRESS, itmp + 1 );
VTK_LS_CELLARRAY(p->Dict["IOSHL(1)"] != 0,LSDynaMetaData::SHELL,ctmp,6);
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_EPSTRAIN, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_EPSTRAIN, itmp + 1 );
VTK_LS_CELLARRAY(p->Dict["IOSHL(2)"] != 0,LSDynaMetaData::SHELL,ctmp,1);
sprintf( ctmp, "%sIntPt%d", LS_ARRAYNAME_INTEGRATIONPOINT, itmp + 1 );
snprintf( ctmp, sizeof(ctmp), "%sIntPt%d", LS_ARRAYNAME_INTEGRATIONPOINT, itmp + 1 );
VTK_LS_CELLARRAY(p->Dict["NEIPS"] > 0,LSDynaMetaData::SHELL,ctmp,p->Dict["NEIPS"]);
}
......@@ -3210,11 +3210,11 @@ void vtkLSDynaReader::ResetPartInfo()
{ \
realMat = mat; \
} \
sprintf( partLabel, fmt " (Matl%d)", mat, realMat ); \
snprintf( partLabel, sizeof(partLabel), fmt " (Matl%d)", mat, realMat ); \
} \
else{ \
realMat = mat; \
sprintf( partLabel, fmt, mat ); \
snprintf( partLabel, sizeof(partLabel), fmt, mat ); \
} \
p->PartNames.push_back( partLabel ); \
p->PartIds.push_back( realMat ); \
......
This diff is collapsed.
......@@ -380,7 +380,7 @@ void vtkMNITagPointWriter::WriteData(vtkPointSet *inputs[2])
{
double point[3];
points[kk]->GetPoint(i, point);
sprintf(text, " %.15g %.15g %.15g", point[0], point[1], point[2]);
snprintf(text, sizeof(text), " %.15g %.15g %.15g", point[0], point[1], point[2]);
outfile << text;
}
}
......@@ -403,7 +403,7 @@ void vtkMNITagPointWriter::WriteData(vtkPointSet *inputs[2])
p = static_cast<int>(dataArrays[2]->GetComponent(i, 0));
}
sprintf(text, " %.15g %d %d", w, s, p);
snprintf(text, sizeof(text), " %.15g %d %d", w, s, p);
outfile << text;
}
......@@ -439,7 +439,7 @@ void vtkMNITagPointWriter::WriteData(vtkPointSet *inputs[2])
}
else
{
sprintf(text, "x%2.2x", (static_cast<int>(*si) & 0x00ff));
snprintf(text, sizeof(text), "x%2.2x", (static_cast<int>(*si) & 0x00ff));
outfile << text;
}
}
......
......@@ -141,11 +141,11 @@ int vtkMNITransformWriter::WriteLinearTransform(
for (int i = 0; i < 3; i++)
{
outfile << "\n";
sprintf(text, " %.15g %.15g %.15g %.15g",
matrix->GetElement(i, 0),
matrix->GetElement(i, 1),
matrix->GetElement(i, 2),
matrix->GetElement(i, 3));
snprintf(text, sizeof(text), " %.15g %.15g %.15g %.15g",
matrix->GetElement(i, 0),
matrix->GetElement(i, 1),
matrix->GetElement(i, 2),
matrix->GetElement(i, 3));
outfile << text;
}
outfile << ";\n";
......@@ -231,7 +231,7 @@ int vtkMNITransformWriter::WriteThinPlateSplineTransform(
for (j = 0; j < ndim; j++)
{
char text[64];
sprintf(text, " %.15g", p[j]);
snprintf(text, sizeof(text), " %.15g", p[j]);
outfile << text;
}
......@@ -319,7 +319,7 @@ int vtkMNITransformWriter::WriteThinPlateSplineTransform(
for (j = 0; j < ndim; j++)
{
char text[64];
sprintf(text, " %.15g", X[j][i]);
snprintf(text, sizeof(text), " %.15g", X[j][i]);
outfile << text;
}
......
......@@ -265,13 +265,13 @@ void vtkMPEG2Writer::Write()
MPEG2_structure* str = this->Internals->GetMPEG2Structure();
char buffer[1024];
sprintf(buffer, str->tplorg, this->Time + str->frame0);
snprintf(buffer, sizeof(buffer), str->tplorg, this->Time + str->frame0);
this->Internals->StoreImage(buffer, input);
int last = MPEG2_putseq_one(this->ActualWrittenTime, this->Time,str);
if ( last >= 0 )
{
sprintf(buffer, str->tplorg, last + str->frame0);
snprintf(buffer, sizeof(buffer), str->tplorg, last + str->frame0);
this->Internals->RemoveImage(buffer);
this->ActualWrittenTime ++;
}
......@@ -331,7 +331,7 @@ void vtkMPEG2Writer::End()
while ( (last = MPEG2_putseq_one(this->ActualWrittenTime, this->Time-1,str)) >= 0 )
{
char buffer[1024];
sprintf(buffer, str->tplorg, last + str->frame0);
snprintf(buffer, sizeof(buffer), str->tplorg, last + str->frame0);
this->Internals->RemoveImage(buffer);
this->ActualWrittenTime ++;
}
......
......@@ -76,7 +76,7 @@ int TestMySQLDatabase( int, char ** const )
for ( int i = 0; i < 40; ++ i )
{
char insertQuery[200];
sprintf( insertQuery, "INSERT INTO people VALUES('John Doe %d', %d, %d)",
snprintf( insertQuery, sizeof(insertQuery), "INSERT INTO people VALUES('John Doe %d', %d, %d)",
i, i, 10*i );
cout << insertQuery << endl;
query->SetQuery( insertQuery );
......
......@@ -84,7 +84,7 @@ int TestODBCDatabase( int, char ** const )
for ( i = 21; i < 40; i++ )
{
char name[20];