replace sprintf by snprintf (remove warnings), remove old mpi-interface header

This commit is contained in:
Joachim Schoeberl 2022-12-08 15:19:07 +01:00
parent 0a8bef493b
commit c622f39897
10 changed files with 81 additions and 73 deletions

View File

@ -65,18 +65,18 @@ namespace netgen
Point3d pmin = geometry->BoundingBox ().PMin();
Point3d pmax = geometry->BoundingBox ().PMax();
sprintf (buf, "%5.1lf", pmin.X());
snprintf (buf, size(buf), "%5.1lf", pmin.X());
Tcl_SetVar (interp, "::geooptions.minx", buf, 0);
sprintf (buf, "%5.1lf", pmin.Y());
snprintf (buf, size(buf), "%5.1lf", pmin.Y());
Tcl_SetVar (interp, "::geooptions.miny", buf, 0);
sprintf (buf, "%5.1lf", pmin.Z());
snprintf (buf, size(buf), "%5.1lf", pmin.Z());
Tcl_SetVar (interp, "::geooptions.minz", buf, 0);
sprintf (buf, "%5.1lf", pmax.X());
snprintf (buf, size(buf), "%5.1lf", pmax.X());
Tcl_SetVar (interp, "::geooptions.maxx", buf, 0);
sprintf (buf, "%5.1lf", pmax.Y());
snprintf (buf, size(buf), "%5.1lf", pmax.Y());
Tcl_SetVar (interp, "::geooptions.maxy", buf, 0);
sprintf (buf, "%5.1lf", pmax.Z());
snprintf (buf, size(buf), "%5.1lf", pmax.Z());
Tcl_SetVar (interp, "::geooptions.maxz", buf, 0);
}
}
@ -432,17 +432,17 @@ namespace netgen
if (!tlo) return TCL_OK;
char varname[50];
sprintf (varname, "%s(red)", propvar);
snprintf (varname, size(varname), "%s(red)", propvar);
double red = atof (Tcl_GetVar (interp, varname, 0));
sprintf (varname, "%s(blue)", propvar);
snprintf (varname, size(varname), "%s(blue)", propvar);
double blue = atof (Tcl_GetVar (interp, varname, 0));
sprintf (varname, "%s(green)", propvar);
snprintf (varname, size(varname), "%s(green)", propvar);
double green = atof (Tcl_GetVar (interp, varname, 0));
tlo -> SetRGB (red, green, blue);
sprintf (varname, "%s(visible)", propvar);
snprintf (varname, size(varname), "%s(visible)", propvar);
tlo -> SetVisible (bool(atoi (Tcl_GetVar (interp, varname, 0))));
sprintf (varname, "%s(transp)", propvar);
snprintf (varname, size(varname), "%s(transp)", propvar);
tlo -> SetTransparent (bool(atoi (Tcl_GetVar (interp, varname, 0))));
}
@ -460,24 +460,24 @@ namespace netgen
char varname[50], varval[10];
sprintf (varname, "%s(red)", propvar);
sprintf (varval, "%lf", tlo->GetRed());
snprintf (varname, size(varname), "%s(red)", propvar);
snprintf (varval, size(varval), "%lf", tlo->GetRed());
Tcl_SetVar (interp, varname, varval, 0);
sprintf (varname, "%s(green)", propvar);
sprintf (varval, "%lf", tlo->GetGreen());
snprintf (varname, size(varname), "%s(green)", propvar);
snprintf (varval, size(varval), "%lf", tlo->GetGreen());
Tcl_SetVar (interp, varname, varval, 0);
sprintf (varname, "%s(blue)", propvar);
sprintf (varval, "%lf", tlo->GetBlue());
snprintf (varname, size(varname), "%s(blue)", propvar);
snprintf (varval, size(varval), "%lf", tlo->GetBlue());
Tcl_SetVar (interp, varname, varval, 0);
sprintf (varname, "%s(visible)", propvar);
sprintf (varval, "%d", tlo->GetVisible());
snprintf (varname, size(varname), "%s(visible)", propvar);
snprintf (varval, size(varval), "%d", tlo->GetVisible());
Tcl_SetVar (interp, varname, varval, 0);
sprintf (varname, "%s(transp)", propvar);
sprintf (varval, "%d", tlo->GetTransparent());
snprintf (varname, size(varname), "%s(transp)", propvar);
snprintf (varval, size(varval), "%d", tlo->GetTransparent());
Tcl_SetVar (interp, varname, varval, 0);
}

View File

@ -15,7 +15,7 @@ target_sources(nglib PRIVATE
install(FILES
ngarray.hpp autodiff.hpp autoptr.hpp ngbitarray.hpp
dynamicmem.hpp hashtabl.hpp mpi_interface.hpp myadt.hpp
dynamicmem.hpp hashtabl.hpp myadt.hpp
mystring.hpp netgenout.hpp ngpython.hpp
optmem.hpp parthreads.hpp seti.hpp sort.hpp
spbita2d.hpp stack.hpp table.hpp template.hpp

View File

@ -1,3 +1,8 @@
braucht keiner mehr
#ifdef XXXXXX
#ifndef FILE_PARALLEL
#define FILE_PARALLEL
@ -326,3 +331,6 @@ namespace netgen
}
#endif
#endif

View File

@ -76,7 +76,7 @@ namespace netgen
if (showvolume < 0 || showvolume > occgeometry->NrSolids())
{
char buf[20];
sprintf (buf, "%5i", vispar.occshowvolumenr);
snprintf (buf, size(buf), "%5i", vispar.occshowvolumenr);
Tcl_SetVar (interp, "::occoptions.showvolumenr", buf, 0);
}
else
@ -621,18 +621,18 @@ namespace netgen
int facenr = atoi (argv[2]);
if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
{
sprintf (buf, "%5.2f", occgeometry->GetFaceMaxH(facenr));
snprintf (buf, size(buf), "%5.2f", occgeometry->GetFaceMaxH(facenr));
}
else
{
sprintf (buf, "%5.2f", mparam.maxh);
snprintf (buf, size(buf), "%5.2f", mparam.maxh);
}
Tcl_SetResult (interp, buf, TCL_STATIC);
}
if (strcmp (argv[1], "getactive") == 0)
{
sprintf (buf, "%d", occgeometry->SelectedFace());
snprintf (buf, size(buf), "%d", occgeometry->SelectedFace());
Tcl_SetResult (interp, buf, TCL_STATIC);
}
@ -652,9 +652,9 @@ namespace netgen
if (strcmp (argv[1], "getnfd") == 0)
{
if (occgeometry)
sprintf (buf, "%d", occgeometry->NrFaces());
snprintf (buf, size(buf), "%d", occgeometry->NrFaces());
else
sprintf (buf, "0");
snprintf (buf, size(buf), "0");
Tcl_SetResult (interp, buf, TCL_STATIC);
}
return TCL_OK;

View File

@ -463,12 +463,12 @@ namespace netgen
}
if (strcmp (argv[1], "topology_ok") == 0)
{
sprintf (buf, "%d", stlgeometry->Topology_Ok());
snprintf (buf, size(buf), "%d", stlgeometry->Topology_Ok());
Tcl_SetResult (interp, buf, TCL_STATIC);
}
if (strcmp (argv[1], "orientation_ok") == 0)
{
sprintf (buf, "%d", stlgeometry->Orientation_Ok());
snprintf (buf, size(buf), "%d", stlgeometry->Orientation_Ok());
Tcl_SetResult (interp, buf, TCL_STATIC);
}
}
@ -488,24 +488,24 @@ namespace netgen
sprintf (buf, "%i", (int)data[0]);
snprintf (buf, size(buf), "%i", (int)data[0]);
Tcl_SetVar (interp, argv[1], buf, 0);
sprintf (buf, "%5.3g", data[1]);
snprintf (buf, size(buf), "%5.3g", data[1]);
Tcl_SetVar (interp, argv[2], buf, 0);
sprintf (buf, "%5.3g", data[2]);
snprintf (buf, size(buf), "%5.3g", data[2]);
Tcl_SetVar (interp, argv[3], buf, 0);
sprintf (buf, "%5.3g", data[3]);
snprintf (buf, size(buf), "%5.3g", data[3]);
Tcl_SetVar (interp, argv[4], buf, 0);
sprintf (buf, "%5.3g", data[4]);
snprintf (buf, size(buf), "%5.3g", data[4]);
Tcl_SetVar (interp, argv[5], buf, 0);
sprintf (buf, "%5.3g", data[5]);
snprintf (buf, size(buf), "%5.3g", data[5]);
Tcl_SetVar (interp, argv[6], buf, 0);
sprintf (buf, "%5.3g", data[6]);
snprintf (buf, size(buf), "%5.3g", data[6]);
Tcl_SetVar (interp, argv[7], buf, 0);
sprintf (buf, "%i", (int)data[7]);
snprintf (buf, size(buf), "%i", (int)data[7]);
Tcl_SetVar (interp, argv[8], buf, 0);
return TCL_OK;

View File

@ -285,9 +285,9 @@ void STLTopology :: Save (const filesystem::path & filename) const
fout << "facet normal ";
const Vec3d& n = GetTriangle(i).Normal();
sprintf(buf1,"%1.9g",n.X());
sprintf(buf2,"%1.9g",n.Y());
sprintf(buf3,"%1.9g",n.Z());
snprintf(buf1, size(buf1), "%1.9g",n.X());
snprintf(buf2, size(buf2), "%1.9g",n.Y());
snprintf(buf3, size(buf3), "%1.9g",n.Z());
fout << buf1 << " " << buf2 << " " << buf3 << "\n";
fout << "outer loop\n";
@ -296,9 +296,9 @@ void STLTopology :: Save (const filesystem::path & filename) const
{
const Point3d p = GetPoint(t.PNum(j));
sprintf(buf1,"%1.9g",p.X());
sprintf(buf2,"%1.9g",p.Y());
sprintf(buf3,"%1.9g",p.Z());
snprintf(buf1, size(buf1), "%1.9g",p.X());
snprintf(buf2, size(buf2), "%1.9g",p.Y());
snprintf(buf3, size(buf3), "%1.9g",p.Z());
fout << "vertex " << buf1 << " " << buf2 << " " << buf3 << "\n";
}

View File

@ -714,15 +714,15 @@ namespace netgen
char buf[20];
glRasterPos3d (len, 0.0f, 0.0f);
sprintf (buf, "x");
snprintf (buf, size(buf), "x");
// glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
MyOpenGLText (buf);
glRasterPos3d (0.0f, len, 0.0f);
sprintf (buf, "y");
snprintf (buf, size(buf), "y");
// glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
MyOpenGLText (buf);
glRasterPos3d (0.0f, 0.0f, len);
sprintf (buf, "z");
snprintf (buf, size(buf), "z");
// glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
MyOpenGLText (buf);

View File

@ -91,7 +91,7 @@ namespace netgen
for ( int ii = 0; ii < pointpos; ii++ )
newscalname[ii] = scalname[ii];
newscalname[pointpos] = ':';
sprintf (newscalname+pointpos, "%i", vssolution.scalcomp);
snprintf (newscalname+pointpos, sizeof(newscalname)-pointpos, "%i", vssolution.scalcomp);
if (strcmp (scalname, newscalname) != 0)
Tcl_SetVar ( interp, "::visoptions.scalfunction", newscalname, TCL_GLOBAL_ONLY );
@ -325,22 +325,22 @@ namespace netgen
if (strcmp (argv[1], "getnfieldnames") == 0)
{
sprintf (buf, "%d", vssolution.GetNSolData());
snprintf (buf, size(buf), "%d", vssolution.GetNSolData());
}
if (strcmp (argv[1], "getfieldname") == 0)
{
sprintf (buf, "%s", vssolution.GetSolData(atoi(argv[2])-1)->name.c_str());
snprintf (buf, size(buf), "%s", vssolution.GetSolData(atoi(argv[2])-1)->name.c_str());
}
if (strcmp (argv[1], "iscomplex") == 0)
{
sprintf (buf, "%d", vssolution.GetSolData(atoi(argv[2])-1)->iscomplex);
snprintf (buf, size(buf), "%d", vssolution.GetSolData(atoi(argv[2])-1)->iscomplex);
}
if (strcmp (argv[1], "getfieldcomponents") == 0)
{
sprintf (buf, "%d", vssolution.GetSolData(atoi(argv[2])-1)->components);
snprintf (buf, size(buf), "%d", vssolution.GetSolData(atoi(argv[2])-1)->components);
}
@ -362,13 +362,13 @@ namespace netgen
if (strcmp (argv[1], "getactivefield") == 0)
{
sprintf (buf, "1");
snprintf (buf, size(buf), "1");
}
if (strcmp (argv[1], "getdimension") == 0)
{
auto mesh = vssolution.GetMesh();
sprintf (buf, "%d", mesh->GetDimension());
snprintf (buf, size(buf), "%d", mesh->GetDimension());
}
}

View File

@ -624,21 +624,21 @@ namespace netgen
{
if (prev_np != mesh->GetNP())
{
sprintf (buf, "%u", unsigned(mesh->GetNP()));
snprintf (buf, size(buf), "%u", unsigned(mesh->GetNP()));
Tcl_SetVar (interp, "::status_np", buf, 0);
prev_np = mesh->GetNP();
}
if (prev_ne != mesh->GetNE())
{
sprintf (buf, "%u", unsigned(mesh->GetNE()));
snprintf (buf, size(buf), "%u", unsigned(mesh->GetNE()));
Tcl_SetVar (interp, "::status_ne", buf, 0);
prev_ne = mesh->GetNE();
}
if (prev_nse != mesh->GetNSE())
{
sprintf (buf, "%u", unsigned(mesh->GetNSE()));
snprintf (buf, size(buf), "%u", unsigned(mesh->GetNSE()));
Tcl_SetVar (interp, "::status_nse", buf, 0);
prev_nse = mesh->GetNSE();
}
@ -647,7 +647,7 @@ namespace netgen
lstring[0] = 0;
for (int i = 0; i < tets_in_qualclass.Size(); i++)
{
sprintf (buf, " %d", tets_in_qualclass[i]);
snprintf (buf, size(buf), " %d", tets_in_qualclass[i]);
strcat (lstring, buf);
}
for (int i = tets_in_qualclass.Size(); i < 20; i++)
@ -702,7 +702,7 @@ namespace netgen
if (prev_percent != multithread.percent)
{
prev_percent = multithread.percent;
sprintf (buf, "%lf", prev_percent);
snprintf (buf, size(buf), "%lf", prev_percent);
Tcl_SetVar (interp, "::status_percent", buf, 0);
}
@ -780,7 +780,7 @@ namespace netgen
int facenr = atoi (argv[2]);
if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
{
sprintf (buf, "%d", mesh->GetFaceDescriptor(facenr).BCProperty());
snprintf (buf, size(buf), "%d", mesh->GetFaceDescriptor(facenr).BCProperty());
}
else
{
@ -794,7 +794,7 @@ namespace netgen
int facenr = atoi (argv[2]);
if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
{
sprintf (buf, "%s", mesh->GetFaceDescriptor(facenr).GetBCName().c_str());
snprintf (buf, size(buf), "%s", mesh->GetFaceDescriptor(facenr).GetBCName().c_str());
}
else
{
@ -806,7 +806,7 @@ namespace netgen
if (strcmp (argv[1], "getactive") == 0)
{
sprintf (buf, "%d", vsmesh.SelectedFace());
snprintf (buf, size(buf), "%d", vsmesh.SelectedFace());
Tcl_SetResult (interp, buf, TCL_STATIC);
}
@ -822,9 +822,9 @@ namespace netgen
if (strcmp (argv[1], "getnfd") == 0)
{
if (mesh)
sprintf (buf, "%d", mesh->GetNFD());
snprintf (buf, size(buf), "%d", mesh->GetNFD());
else
sprintf (buf, "0");
snprintf (buf, size(buf), "0");
Tcl_SetResult (interp, buf, TCL_STATIC);
}
@ -1311,7 +1311,7 @@ namespace netgen
const_cast<char*>(parameters.GetStringFlag (argv[1], NULL).c_str()), TCL_VOLATILE);
else if (parameters.NumFlagDefined (argv[1]))
{
sprintf (buf, "%lf", parameters.GetNumFlag (argv[1], 0));
snprintf (buf, size(buf), "%lf", parameters.GetNumFlag (argv[1], 0));
Tcl_SetResult (interp, buf, TCL_STATIC);
}
else if (parameters.GetDefineFlag (argv[1]))
@ -1586,13 +1586,13 @@ namespace netgen
{
angles[0] = angles[1] = angles[2] = angles[3] = 0;
}
sprintf (buf, "%5.1lf", angles[0]);
snprintf (buf, size(buf), "%5.1lf", angles[0]);
Tcl_SetVar (interp, argv[1], buf, 0);
sprintf (buf, "%5.1lf", angles[1]);
snprintf (buf, size(buf), "%5.1lf", angles[1]);
Tcl_SetVar (interp, argv[2], buf, 0);
sprintf (buf, "%5.1lf", angles[2]);
snprintf (buf, size(buf), "%5.1lf", angles[2]);
Tcl_SetVar (interp, argv[3], buf, 0);
sprintf (buf, "%5.1lf", angles[3]);
snprintf (buf, size(buf), "%5.1lf", angles[3]);
Tcl_SetVar (interp, argv[4], buf, 0);
return TCL_OK;
@ -2415,7 +2415,7 @@ namespace netgen
void SelectFaceInOCCDialogTree (int facenr)
{
char script[50];
sprintf (script, "selectentity {Face %i}", facenr);
snprintf (script, size(script), "selectentity {Face %i}", facenr);
Tcl_GlobalEval (tcl_interp, script);
}
@ -2448,7 +2448,7 @@ namespace netgen
// #ifdef OPENGL
// #ifndef NOTCL
char buf[100];
sprintf (buf, "visoptions.%s", name);
snprintf (buf, size(buf), "visoptions.%s", name);
if (printmessage_importance>0)
{
cout << "name = " << name << ", value = " << value << endl;
@ -2504,7 +2504,7 @@ void PlayAnimFile(const char* name, int speed, int maxcnt)
int rti = (animcnt%(maxcnt-1)) + 1;
animcnt+=speed;
sprintf(str2,"%05i.sol",rti);
snprintf(str2, sizeof(str2), "%05i.sol",rti);
strcpy(str,"mbssol/");
strcat(str,name);
strcat(str,str2);