Corrected width specifiers and use of buffer arrays in *printf and *scanf functions.
Removed unreferenced variable warning.
Got rid of compiler warning (returning address of local variable or temporary).
void Dynamic_FuzzyDefinitionsDictionary::Creates(const Standard_CString afilename)
{
Standard_Integer fr,i,begin,end,endline;
- char line[255];
- char name[80];
- char type[80];
- char value[80],value1[80],value2[80],value3[80];
+ char line[256];
+ char name[81];
+ char type[81];
+ char value[81],value1[81],value2[81],value3[81];
Handle(Dynamic_FuzzyDefinition) fuzzydefinition;
Handle(Dynamic_Parameter) parameter;
for(;;)
{
- for(i=0; i<255; i++) line[i] = 0;
+ memset(line,0,sizeof(line));
file.getline(line,255);
if(!file)break;
}
}
- for(i=0; i<80; i++)name[i]=0;
+ memset(name,0,sizeof(name));
endline = 0;
for(i=begin+1; i<=end-1; i++)name[endline++] = line[i];
- for(i=0; i<80; i++)type [i] = 0;
- for(i=0; i<80; i++)value [i] = 0;
- for(i=0; i<80; i++)value1 [i] = 0;
- for(i=0; i<80; i++)value2 [i] = 0;
- for(i=0; i<80; i++)value3 [i] = 0;
+ memset(type,0,sizeof(type));
+ memset(value,0,sizeof(value));
+ memset(value1,0,sizeof(value1));
+ memset(value2,0,sizeof(value2));
+ memset(value3,0,sizeof(value3));
-// fr = sscanf(&line[end+1],"%s%80c",&type,&value);
- fr = sscanf(&line[end+1],"%s%80c",type,value);
+ fr = sscanf(&line[end+1],"%80s%80c",type,value);
if(fr == -1) continue;
begin = 0;
{
Standard_Boolean group;
Standard_Integer fr,i,begin,end,endline;
- char line[255];
- char name[80];
- char mode[80];
- char type[80];
- char value[80],value1[80],value2[80],value3[80];
+ char line[256];
+ char name[81];
+ char mode[81];
+ char type[81];
+ char value[81],value1[81],value2[81],value3[81];
Handle(Dynamic_CompiledMethod) methoddefinition;
Handle(Dynamic_Parameter) parameter;
for(;;)
{
- for(i=0; i<255; i++) line[i] = 0;
+ memset(line,0,sizeof(line));
file.getline(line,255);
if(!file)break;
}
}
- for(i=0; i<80; i++)name[i]=0;
+ memset(name,0,sizeof(name));
endline = 0;
for(i=begin+1; i<=end-1; i++)name[endline++] = line[i];
- for(i=0; i<80; i++)mode [i] = 0;
- for(i=0; i<80; i++)type [i] = 0;
- for(i=0; i<80; i++)value [i] = 0;
- for(i=0; i<80; i++)value1 [i] = 0;
- for(i=0; i<80; i++)value2 [i] = 0;
- for(i=0; i<80; i++)value3 [i] = 0;
+ memset(mode, 0x00,sizeof(mode));
+ memset(type, 0x00,sizeof(type));
+ memset(value, 0x00,sizeof(value));
+ memset(value1,0x00,sizeof(value1));
+ memset(value2,0x00,sizeof(value2));
+ memset(value3,0x00,sizeof(value3));
- // fr = sscanf(&line[end+1],"%s%s%80c",&mode,&type,&value);
- fr = sscanf(&line[end+1],"%s%s%80c",mode,type,value);
+ fr = sscanf(&line[end+1],"%80s%80s%80c",mode,type,value);
if(fr == -1) continue;
group = Standard_False;
#include <OSD_Path.hxx>
#include <stdio.h>
-
-static char defmess[30];
+static char defmess[31];
// Fonctions Satisfies offertes en standard ...
}
if (part[0] == 'e') {
Standard_Integer nume = 0;
- sscanf (part,"%s %d",defmess,&nume);
+ sscanf (part,"%30s %d",defmess,&nume);
return stat->EnumVal(nume);
}
if (part[0] == 'i') {
Standard_Integer ilim;
if (!stat->IntegerLimit((part[2] == 'a'),ilim)) return "";
- Sprintf(defmess,"%d",ilim); return defmess;
+ Sprintf(defmess,"%d",ilim); return defmess;
}
if (part[0] == 'r') {
Standard_Real rlim;
if (!stat->RealLimit((part[2] == 'a'),rlim)) return "";
- Sprintf(defmess,"%f",rlim); return defmess;
+ Sprintf(defmess,"%f",rlim); return defmess;
}
if (part[0] == 'u') return stat->UnitDef();
return "";
if (part[1] == 'm') return (match ? 1 : 0);
if (part[1] == 'v') {
char vale[50];
- sscanf (part,"%s %s",defmess,vale);
+ sscanf (part,"%30s %50s",defmess,vale);
return stat->EnumCase (vale);
}
}
const Standard_CString atype,
const Standard_CString avalue) const
{
- Standard_Integer fr,i;
- char value1[80],value2[80],value3[80];
+ Standard_Integer fr;
+ char value1[81],value2[81],value3[81];
Handle(Dynamic_Parameter) parameter;
Handle(Dynamic_ObjectParameter) objectparameter;
if (!strcasecmp(atype,"Materials_Color"))
{
- for(i=0; i<80; i++)value1[i] = 0;
- for(i=0; i<80; i++)value2[i] = 0;
- for(i=0; i<80; i++)value3[i] = 0;
- // fr = sscanf(avalue,"%s%s%s",&value1,&value2,&value3);
- fr = sscanf(avalue,"%s%s%s",value1,value2,value3);
+ memset(value1,0,sizeof(value1));
+ memset(value2,0,sizeof(value2));
+ memset(value3,0,sizeof(value3));
+
+ fr = sscanf(avalue,"%80s%80s%80s",value1,value2,value3);
Handle(Materials_Color) pcolor =
new Materials_Color(Quantity_Color(Atof(value1),
Standard_Integer i,fr,begin,end,lengthname;
//char* filename;
- char line[255];
- char name[80];
- char type[80];
- char value1[80],value2[80],value3[80];
+ char line[256];
+ char name[81];
+ char type[81];
+ char value1[81],value2[81],value3[81];
Handle(Materials_MaterialsSequence) materialssequence;
Handle(Materials_Material) material;
Handle(Materials_Color) pcolor;
for(;;)
{
- for(i=0; i<255; i++) line[i]=0;
+ memset(line,0,sizeof(line));
file.getline(line,255);
if(!file)break;
}
}
- for(i=0; i<80; i++)name[i]=0;
+ memset(name, 0, sizeof(name));
lengthname = 0;
for(i=begin+1; i<=end-1; i++)name[lengthname++] = line[i];
- for(i=0; i<80; i++)type [i] = 0;
- for(i=0; i<80; i++)value1 [i] = 0;
- for(i=0; i<80; i++)value2 [i] = 0;
- for(i=0; i<80; i++)value3 [i] = 0;
+ memset(type, 0,sizeof(type));
+ memset(value1,0,sizeof(value1));
+ memset(value2,0,sizeof(value2));
+ memset(value3,0,sizeof(value3));
- // fr = sscanf(&line[end+1],"%s%s%s%s",&type,&value1,&value2,&value3);
- fr = sscanf(&line[end+1],"%s%s%s%s",type,value1,value2,value3);
+ fr = sscanf(&line[end+1],"%80s%80s%80s%80s",type,value1,value2,value3);
if(fr == -1) continue;
// split line to parts
char chain[31], oper[11], coeff[31];
- for (int i=0; i < 31; i++) chain[i] = '\0';
- for (int i=0; i < 11; i++) oper[i] = '\0';
- for (int i=0; i < 31; i++) coeff[i] = '\0';
+ memset(chain,0x00,sizeof(chain));
+ memset(oper,0x00,sizeof(oper));
+ memset(coeff,0x00,sizeof(coeff));
sscanf (line, "%30c%10c%30c", chain, oper, coeff);
// for basic SI dimensions (mass, length, time, ...)
char name[41];
char MM[11], LL[11], TT[11], II[11], tt[11], NN[11], JJ[11], PP[11], SS[11];
- for (i=0; i < 41; i++) name[i] = '\0';
- for (i=0; i < 11; i++) MM[i] = '\0';
- for (i=0; i < 11; i++) LL[i] = '\0';
- for (i=0; i < 11; i++) TT[i] = '\0';
- for (i=0; i < 11; i++) II[i] = '\0';
- for (i=0; i < 11; i++) tt[i] = '\0';
- for (i=0; i < 11; i++) NN[i] = '\0';
- for (i=0; i < 11; i++) JJ[i] = '\0';
- for (i=0; i < 11; i++) PP[i] = '\0';
- for (i=0; i < 11; i++) SS[i] = '\0';
+ memset(name,0x00,sizeof(name));
+ memset(MM,0x00,sizeof(MM));
+ memset(LL,0x00,sizeof(LL));
+ memset(TT,0x00,sizeof(TT));
+ memset(II,0x00,sizeof(II));
+ memset(tt,0x00,sizeof(tt));
+ memset(NN,0x00,sizeof(NN));
+ memset(JJ,0x00,sizeof(JJ));
+ memset(PP,0x00,sizeof(PP));
+ memset(SS,0x00,sizeof(SS));
sscanf (line, "%40c%10c%10c%10c%10c%10c%10c%10c%10c%10c",
name, MM, LL, TT, II, tt, NN, JJ, PP, SS);
// - factor (27 symbols)
// - base unit (27 symbols)
char unite[52], symbol[28], convert[28], unit2[28];
- for (i=0; i < 52; i++) unite [i] = '\0';
- for (i=0; i < 28; i++) symbol [i] = '\0';
- for (i=0; i < 28; i++) convert[i] = '\0';
- for (i=0; i < 28; i++) unit2 [i] = '\0';
+ memset(unite, 0x00,sizeof(unite));
+ memset(symbol, 0x00,sizeof(symbol));
+ memset(convert,0x00,sizeof(convert));
+ memset(unit2, 0x00,sizeof(unit2));
sscanf (line, "%51c%27c%27c%27c", unite, symbol, convert, unit2);
// Read the header
Standard_Byte type; // 0 - bool, 1 - color, 2 - float
Voxel_VoxelFileFormat format;
- Standard_Character svoxels[8], sformat[8], stype[8];
- fscanf(f, "%s %s %s\n", svoxels, sformat, stype);
+ Standard_Character svoxels[9], sformat[9], stype[9];
+ fscanf(f, "%8s %8s %8s\n", svoxels, sformat, stype);
fclose(f);
// Take format, type of voxels.
FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "r");
if (!f)
return Standard_False;
- Standard_Character line[64], sx[32], sy[32], sz[32];
+ Standard_Character line[65], sx[33], sy[33], sz[33];
// Header: skip it
fgets(line, 64, f);
// Location, size, number of splits
Standard_Integer nbx = 0, nby = 0, nbz = 0;
Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0;
- if (fscanf(f, "%s %s %s\n", sx, sy, sz) != 3)
+ if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3)
{
fclose(f);
return Standard_False;
}
x = Atof(sx); y = Atof(sy); z = Atof(sz);
- if (fscanf(f, "%s %s %s\n", sx, sy, sz) != 3)
+ if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3)
{
fclose(f);
return Standard_False;
FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "r");
if (!f)
return Standard_False;
- Standard_Character line[64], sx[32], sy[32], sz[32];
+ Standard_Character line[65], sx[33], sy[33], sz[33];
// Header: skip it
fgets(line, 64, f);
// Location, size, number of splits
Standard_Integer nbx = 0, nby = 0, nbz = 0;
Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0;
- if (fscanf(f, "%s %s %s\n", sx, sy, sz) != 3)
+ if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3)
{
fclose(f);
return Standard_False;
}
x = Atof(sx); y = Atof(sy); z = Atof(sz);
- if (fscanf(f, "%s %s %s\n", sx, sy, sz) != 3)
+ if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3)
{
fclose(f);
return Standard_False;
FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "r");
if (!f)
return Standard_False;
- Standard_Character line[64], sx[32], sy[32], sz[32];
+ Standard_Character line[65], sx[33], sy[33], sz[33];
// Header: skip it
fgets(line, 64, f);
// Location, size, number of splits
Standard_Integer nbx = 0, nby = 0, nbz = 0;
Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0;
- if (fscanf(f, "%s %s %s\n", sx, sy, sz) != 3)
+ if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3)
{
fclose(f);
return Standard_False;
}
x = Atof(sx); y = Atof(sy); z = Atof(sz);
- if (fscanf(f, "%s %s %s\n", sx, sy, sz) != 3)
+ if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3)
{
fclose(f);
return Standard_False;
fgets(line, 64, f);
if (has_slice(line))
{
- if (sscanf(line, "%d %d %s\n", &i1, &i2, line) != 3)
+ if (sscanf(line, "%d %d %64s\n", &i1, &i2, line) != 3)
{
fclose(f);
return Standard_False;
}
else
{
- if (sscanf(line, "%d %s\n", &i2, line) != 2)
+ if (sscanf(line, "%d %64s\n", &i2, line) != 2)
{
fclose(f);
return Standard_False;
return Standard_False;
// Header: skip it
- Standard_Character line[64];
+ Standard_Character line[65];
fgets(line, 64, f);
// Location, size, number of splits
return Standard_False;
// Header: skip it
- Standard_Character line[64];
+ Standard_Character line[65];
fgets(line, 64, f);
// Location, size, number of splits
return Standard_False;
// Header: skip it
- Standard_Character line[64];
+ Standard_Character line[65];
fgets(line, 64, f);
// Location, size, number of splits