1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0022898: IGES import fails in german environment

Added DRAW command dlocale to set and query current locale of the C subsystem
Equivalents of C functions working with conversions of strings to/from reals added in Standard_CString, providing locale-independent behavior (using always "C" locale)
In DRAW packages, calls to atof() and atoi() are replaced by direct calls to Draw::Atof() and Draw::Atoi(), respectively, instead of substituting by #define
Use of atof(), strtod(), and *scanf() involving floating point conversions in OCCT code replaced by locale-independent Atof() and Strtod()
Calls to sprintf() involving floating point in OCCT code are replaced by call to locale-independent Sprintf(), except a few places where converted strings are used immediately for display in the 3d viewer
Changes of global locale are eliminated throughout OCCT code
Proposed correction for GNU libC where v*printf_l functions are absent
Added test case (bugs xde bug22898) for data exchange operations with non-standard locale
Use xlocale on Mac OS X and within glibc
Corrected strtod_l wrapper
Generate error rather than warning
Introduce Standard_CLocaleSentry replacement for removed OSD_Localizer
Standard_CLocaleSentry - copy locale string
Standard_CLocaleSentry - use _configthreadlocale on Windows
Standard_CLocaleSentry::GetCLocale() - return locale_t rather than void*
Corrected misprint in ~Standard_CLocaleSentry()
Use French locale in bug22898 test case
Mark test case as skipped if locale is unavailable on tested system.
Use fr_FR locale for tests on Mac OS X
This commit is contained in:
abv
2013-02-01 18:41:16 +04:00
parent 3bea4c165c
commit 91322f44fd
203 changed files with 2707 additions and 2807 deletions

View File

@@ -88,7 +88,7 @@ static Standard_Integer Ascendants (Draw_Interpretor& di, Standard_Integer n, co
Standard_Integer T;
if (n > 3) T = atoi(a[3]);
if (n > 3) T = Draw::Atoi(a[3]);
else T = ND->Transaction ();
//TNaming_OldShapeIterator it (S, T, US);
@@ -97,7 +97,7 @@ static Standard_Integer Ascendants (Draw_Interpretor& di, Standard_Integer n, co
TCollection_AsciiString entry;
for (;it.More (); it.Next ()) {
S = it.Shape ();
sprintf (name,"%s_%s_%d",a[2],"old", i++);
Sprintf (name,"%s_%s_%d",a[2],"old", i++);
DBRep::Set (name,it.Shape());
TDF_Label Label = it.Label ();
TDF_Tool::Entry(Label,entry);
@@ -128,7 +128,7 @@ static Standard_Integer Descendants (Draw_Interpretor& di, Standard_Integer n, c
Standard_Integer T;
if (n > 3) T = atoi(a[3]);
if (n > 3) T = Draw::Atoi(a[3]);
else T = ND->Transaction ();
TNaming_NewShapeIterator it (S, T, ND->Root());
@@ -136,7 +136,7 @@ static Standard_Integer Descendants (Draw_Interpretor& di, Standard_Integer n, c
TCollection_AsciiString entry;
for (;it.More (); it.Next ()) {
S = it.Shape ();
sprintf (name,"%s_%s_%d",a[2],"new", i++);
Sprintf (name,"%s_%s_%d",a[2],"new", i++);
DBRep::Set (name,it.Shape ());
TDF_Label Label = it.Label ();
TDF_Tool::Entry(Label,entry);
@@ -281,7 +281,7 @@ static Standard_Integer Exploreshape (Draw_Interpretor& di, Standard_Integer n,
// ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US);
Standard_Integer Trans = ND->Transaction();
if (n == 5) { Trans = (Standard_Integer ) atof(a[4]);}
if (n == 5) { Trans = (Standard_Integer ) Draw::Atof(a[4]);}
TDF_Label Lab;
DDF::FindLabel(ND,a[2],Lab);
@@ -300,11 +300,11 @@ static Standard_Integer Exploreshape (Draw_Interpretor& di, Standard_Integer n,
for (TNaming_Iterator itL(Lab,Trans) ; itL.More(); itL.Next()) {
if (!itL.OldShape().IsNull()) {
sprintf(name,"%s%s_%d","old",a[3],NbShapes);
Sprintf(name,"%s%s_%d","old",a[3],NbShapes);
DBRep::Set (name,itL.OldShape());
}
if (!itL.NewShape().IsNull()) {
sprintf(name,"%s_%d",a[3],NbShapes);
Sprintf(name,"%s_%d",a[3],NbShapes);
DBRep::Set (name,itL.NewShape());
}
NbShapes++;
@@ -388,7 +388,7 @@ static Standard_Integer Collect (Draw_Interpretor& di,
if (!DDF::GetDF(arg[1],DF)) return 1;
if (!DDF::Find(DF,arg[2],TNaming_NamedShape::GetID(),A)) return 1;
if (nb >= 4) {
OnlyModif = atoi(arg[3]);
OnlyModif = Draw::Atoi(arg[3]);
}
TNaming_Tool::Collect(A,MNS,OnlyModif);
for (TNaming_MapIteratorOfMapOfNamedShape it(MNS); it.More(); it.Next()) {

View File

@@ -17,7 +17,7 @@
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Standard_ErrorHandler.hxx>
#include <DNaming.hxx>
@@ -321,9 +321,9 @@ static Standard_Integer DNaming_AddBox (Draw_Interpretor& theDI,
TDF_Reference::Set(anObj->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here
Standard_Real dx,dy,dz;
dx = atof(theArg[2]);
dy = atof(theArg[3]);
dz = atof(theArg[4]);
dx = Draw::Atof(theArg[2]);
dy = Draw::Atof(theArg[3]);
dz = Draw::Atof(theArg[4]);
DNaming::GetReal(aFun,BOX_DX)->Set(dx);
DNaming::GetReal(aFun,BOX_DY)->Set(dy);
@@ -378,7 +378,7 @@ static Standard_Integer DNaming_BoxDX (Draw_Interpretor& theDI,
Handle(TFunction_Function) aFun = GetFunction(objLabel,funGUID);
if(!aFun.IsNull()) {
Standard_Real value = atof(theArg[3]);
Standard_Real value = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun,BOX_DX)->Set(value);
DDF::ReturnLabel(theDI, DNaming::GetReal(aFun,BOX_DX)->Label());
return 0;
@@ -411,7 +411,7 @@ static Standard_Integer DNaming_BoxDY (Draw_Interpretor& theDI,
Handle(TFunction_Function) aFun = GetFunction(objLabel,funGUID);
if(!aFun.IsNull()) {
Standard_Real value = atof(theArg[3]);
Standard_Real value = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun,BOX_DY)->Set(value);
DDF::ReturnLabel(theDI, DNaming::GetReal(aFun,BOX_DY)->Label());
return 0;
@@ -444,7 +444,7 @@ static Standard_Integer DNaming_BoxDZ (Draw_Interpretor& theDI,
Handle(TFunction_Function) aFun = GetFunction(objLabel,funGUID);
if(!aFun.IsNull()) {
Standard_Real value = atof(theArg[3]);
Standard_Real value = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun,BOX_DZ)->Set(value);
DDF::ReturnLabel(theDI, DNaming::GetReal(aFun,BOX_DZ)->Label());
return 0;
@@ -682,10 +682,10 @@ static Standard_Integer DNaming_AttachShape (Draw_Interpretor& di,
aResultLabel.ForgetAllAttributes(Standard_True);
Standard_Boolean aKeepOrientation(Standard_False);
if (nb >= 6)
aKeepOrientation = (Standard_Boolean) atoi(a[5]);
aKeepOrientation = (Standard_Boolean) Draw::Atoi(a[5]);
Standard_Boolean aGeometry(Standard_False);
if (nb == 7)
aGeometry = (Standard_Boolean) atoi(a[6]);
aGeometry = (Standard_Boolean) Draw::Atoi(a[6]);
Handle(TNaming_NamedShape) aCont = DNaming::GetObjectValue(aContext);
#ifdef DEBUG
if(aCont.IsNull() || aCont->IsEmpty())
@@ -758,10 +758,10 @@ static Standard_Integer DNaming_XAttachShape (Draw_Interpretor& di,
aResultLabel.ForgetAllAttributes(Standard_True);
Standard_Boolean aKeepOrientation(Standard_False);
if (nb >= 5)
aKeepOrientation = (Standard_Boolean) atoi(a[4]);
aKeepOrientation = (Standard_Boolean) Draw::Atoi(a[4]);
Standard_Boolean aGeometry(Standard_False);
if (nb == 6)
aGeometry = (Standard_Boolean) atoi(a[5]);
aGeometry = (Standard_Boolean) Draw::Atoi(a[5]);
Handle(TNaming_NamedShape) aCont = DNaming::GetObjectValue(aContext);
if(aCont.IsNull() || aCont->IsEmpty())
@@ -815,8 +815,8 @@ static Standard_Integer DNaming_AddCylinder (Draw_Interpretor& theDI,
TDF_Reference::Set(anObj->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here
Standard_Real aR, aH;
aR = atof(theArg[2]);
aH = atof(theArg[3]);
aR = Draw::Atof(theArg[2]);
aH = Draw::Atof(theArg[3]);
Handle(TDataStd_UAttribute) Axis;
if (!DDocStd::Find(aDocument, theArg[4], GEOMOBJECT_GUID, Axis)) return 1;
@@ -854,7 +854,7 @@ static Standard_Integer DNaming_CylRad (Draw_Interpretor& theDI,
Handle(TFunction_Function) aFun = GetFunction(objLabel,funGUID);
if(!aFun.IsNull()) {
Standard_Real value = atof(theArg[3]);
Standard_Real value = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun,CYL_RADIUS)->Set(value);
DDF::ReturnLabel(theDI, DNaming::GetReal(aFun,CYL_RADIUS)->Label());
return 0;
@@ -991,7 +991,7 @@ static Standard_Integer DNaming_AddFillet (Draw_Interpretor& theDI,
TDF_Reference::Set(anObject->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here
Standard_Real aRadius = atof(theArg[3]);
Standard_Real aRadius = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun,FILLET_RADIUS)->Set(aRadius);
Handle(TDataStd_UAttribute) aPath;
@@ -1027,13 +1027,13 @@ static Standard_Integer DNaming_PTranslateDXYZ (Draw_Interpretor& di,
TDataStd_Name::Set(aFun->Label(), "ParTranslation");
Standard_Real aDx=0., aDy=0., aDz=0.;
aDx = atof(a[3]);
aDx = Draw::Atof(a[3]);
//cout << "DX = " << aDx<<endl;
if(nb > 4) {
aDy = atof(a[4]);
aDy = Draw::Atof(a[4]);
//cout << "DY = " << aDy<<endl;
if(nb > 5) {
aDz = atof(a[5]);
aDz = Draw::Atof(a[5]);
//cout << "DZ = " << aDz<<endl;
}
}
@@ -1075,7 +1075,7 @@ static Standard_Integer DNaming_PTranslateLine (Draw_Interpretor& di,
TDataStd_Name::Set(aFun->Label(), "ParTranslationAlongLine");
Standard_Real anOff = 0.;
anOff = atof(a[4]);
anOff = Draw::Atof(a[4]);
DNaming::GetReal(aFun,PTRANSF_OFF)->Set(anOff);
DNaming::SetObjectArg(aFun, PTRANSF_LINE, aLine);
@@ -1115,7 +1115,7 @@ static Standard_Integer DNaming_PRotateLine(Draw_Interpretor& di,
TDF_Reference::Set(anObject->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL));
Standard_Real anAngle = 0.;
anAngle = atof(a[4]);
anAngle = Draw::Atof(a[4]);
Standard_Real aK = 2*M_PI/360;
anAngle = anAngle * aK;
DNaming::GetReal(aFun,PTRANSF_ANG)->Set(anAngle);
@@ -1189,9 +1189,9 @@ static Standard_Integer DNaming_AddPrism (Draw_Interpretor& theDI,
Handle(TDataStd_UAttribute) aBasisObj;
if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, aBasisObj)) return 1;
DNaming::SetObjectArg(aFun, PRISM_BASIS, aBasisObj);
Standard_Real height = atof(theArg[3]);
Standard_Real height = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun,PRISM_HEIGHT)->Set(height);
Standard_Integer reverse = atoi(theArg[4]);
Standard_Integer reverse = Draw::Atoi(theArg[4]);
DNaming::GetInteger(aFun,PRISM_DIR)->Set(reverse);
DDF::ReturnLabel(theDI, anObj->Label());
return 0;
@@ -1219,7 +1219,7 @@ static Standard_Integer DNaming_PrismHeight (Draw_Interpretor& theDI,
Handle(TFunction_Function) aFun = GetFunction(objLabel,funGUID);
if(!aFun.IsNull()) {
Standard_Real value = atof(theArg[3]);
Standard_Real value = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun, PRISM_HEIGHT)->Set(value);
DDF::ReturnLabel(theDI, DNaming::GetReal(aFun,PRISM_HEIGHT)->Label());
return 0;
@@ -1277,12 +1277,12 @@ static Standard_Integer DNaming_AddRevol (Draw_Interpretor& theDI,
DNaming::SetObjectArg(aFun, REVOL_AXIS, anAxObj);
if(theNb > 4 ) {
Standard_Real angle = atof(theArg[4]);
Standard_Real angle = Draw::Atof(theArg[4]);
Standard_Real aK = 2*M_PI/360;
angle = angle * aK;
DNaming::GetReal(aFun,REVOL_ANGLE)->Set(angle);
if( theNb == 6) {
Standard_Integer reverse = atoi(theArg[5]);
Standard_Integer reverse = Draw::Atoi(theArg[5]);
DNaming::GetInteger(aFun, REVOL_REV)->Set(reverse);
}
}
@@ -1312,7 +1312,7 @@ static Standard_Integer DNaming_RevolutionAngle (Draw_Interpretor& theDI,
Handle(TFunction_Function) aFun = GetFunction(objLabel,funGUID);
if(!aFun.IsNull()) {
Standard_Real value = atof(theArg[3]);
Standard_Real value = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun, REVOL_ANGLE)->Set(value);
DDF::ReturnLabel(theDI, DNaming::GetReal(aFun,REVOL_ANGLE)->Label());
return 0;
@@ -1351,7 +1351,7 @@ static Standard_Integer DNaming_AddSphere (Draw_Interpretor& theDI,
if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, aCenterObj)) return 1;
DNaming::SetObjectArg(aFun, SPHERE_CENTER, aCenterObj);
Standard_Real aRadius = atof(theArg[3]);
Standard_Real aRadius = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun,SPHERE_RADIUS)->Set(aRadius);
DDF::ReturnLabel(theDI, anObj->Label());
@@ -1380,7 +1380,7 @@ static Standard_Integer DNaming_SphereRadius (Draw_Interpretor& theDI,
Handle(TFunction_Function) aFun = GetFunction(objLabel,funGUID);
if(!aFun.IsNull()) {
Standard_Real value = atof(theArg[3]);
Standard_Real value = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun, SPHERE_RADIUS)->Set(value);
DDF::ReturnLabel(theDI, DNaming::GetReal(aFun, SPHERE_RADIUS)->Label());
return 0;
@@ -1414,9 +1414,9 @@ static Standard_Integer DNaming_AddPoint (Draw_Interpretor& theDI,
TDF_Reference::Set(anObj->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here
Standard_Real x,y,z;
x = atof(theArg[2]);
y = atof(theArg[3]);
z = atof(theArg[4]);
x = Draw::Atof(theArg[2]);
y = Draw::Atof(theArg[3]);
z = Draw::Atof(theArg[4]);
DNaming::GetReal(aFun,PNT_DX)->Set(x);
DNaming::GetReal(aFun,PNT_DY)->Set(y);
@@ -1457,9 +1457,9 @@ static Standard_Integer DNaming_AddPointRlt (Draw_Interpretor& theDI,
if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, aRefPnt)) return 1;
Standard_Real dx,dy,dz;
dx = atof(theArg[3]);
dy = atof(theArg[4]);
dz = atof(theArg[5]);
dx = Draw::Atof(theArg[3]);
dy = Draw::Atof(theArg[4]);
dz = Draw::Atof(theArg[5]);
DNaming::GetReal(aFun,PNT_DX)->Set(dx);
DNaming::GetReal(aFun,PNT_DY)->Set(dy);
@@ -1504,17 +1504,17 @@ static Standard_Integer DNaming_PntOffset (Draw_Interpretor& theDI,
Standard_Real value(0.0);
Standard_Boolean isDX = (strcmp(theArg[3],"skip"));
if(isDX) {
value = atof(theArg[3]);
value = Draw::Atof(theArg[3]);
DNaming::GetReal(aFun,PNT_DX)->Set(value);
}
Standard_Boolean isDY = (strcmp(theArg[4],"skip"));
if(isDY) {
value = atof(theArg[4]);
value = Draw::Atof(theArg[4]);
DNaming::GetReal(aFun,PNT_DY)->Set(value);
}
Standard_Boolean isDZ = (strcmp(theArg[5],"skip"));
if(isDZ) {
value = atof(theArg[5]);
value = Draw::Atof(theArg[5]);
DNaming::GetReal(aFun,PNT_DZ)->Set(value);
}
if(isDX || isDY || isDZ)
@@ -1554,7 +1554,7 @@ static Standard_Integer DNaming_Line3D (Draw_Interpretor& theDI,
TDataStd_Name::Set(aFun->Label(), "Line3D_Function");
TDF_Reference::Set(anObj->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here
Standard_Integer aType = atoi(theArg[2]);
Standard_Integer aType = Draw::Atoi(theArg[2]);
DNaming::GetInteger(aFun,LINE3D_TYPE)->Set(aType);
//LINE3D_PNTNB
@@ -1869,11 +1869,11 @@ static Standard_Integer DNaming_TestSingle (Draw_Interpretor& theDI,
Standard_Boolean XSelection(Standard_False);
Standard_Boolean Geometry(Standard_False);
if(theNb == 4)
Orientation = (Standard_Boolean)atoi(theArg[3]);
Orientation = (Standard_Boolean)Draw::Atoi(theArg[3]);
if(theNb == 5)
XSelection = (Standard_Boolean)atoi(theArg[4]);
XSelection = (Standard_Boolean)Draw::Atoi(theArg[4]);
if (theNb == 6)
Geometry = (Standard_Boolean) atoi(theArg[5]);
Geometry = (Standard_Boolean) Draw::Atoi(theArg[5]);
Handle(TNaming_NamedShape) aNS = DNaming::GetObjectValue( aCntObj);
if(!aNS.IsNull() && !aNS->IsEmpty()) {
@@ -2008,11 +2008,11 @@ static Standard_Integer DNaming_Multiple (Draw_Interpretor& theDI,
Standard_Boolean XSelection(Standard_False);
Standard_Boolean Geometry(Standard_False);
if(theNb == 4)
Orientation = (Standard_Boolean)atoi(theArg[3]);
Orientation = (Standard_Boolean)Draw::Atoi(theArg[3]);
if(theNb == 5)
XSelection = (Standard_Boolean)atoi(theArg[4]);
XSelection = (Standard_Boolean)Draw::Atoi(theArg[4]);
if (theNb == 6)
Geometry = (Standard_Boolean) atoi(theArg[5]);
Geometry = (Standard_Boolean) Draw::Atoi(theArg[5]);
Handle(TNaming_NamedShape) aNS = DNaming::GetObjectValue( aCntObj);
if(!aNS.IsNull() && !aNS->IsEmpty()) {

View File

@@ -129,7 +129,7 @@ static Standard_Integer DNaming_Select (Draw_Interpretor& di, Standard_Integer n
}
if (n > 4) {
Standard_Boolean Orient(Standard_False);
if(n == 6) Orient = (Standard_Boolean)atoi(a[5]);
if(n == 6) Orient = (Standard_Boolean)Draw::Atoi(a[5]);
TopoDS_Shape S = DBRep::Get(a[3], TopAbs_SHAPE);
TopoDS_Shape C = DBRep::Get(a[4], TopAbs_SHAPE);
SL.Select (S, C, geometry, Orient);
@@ -223,7 +223,7 @@ static Standard_Integer DNaming_SolveSelection (Draw_Interpretor& di, Standard_I
if(!isSolved)
di << "!!! Solver is failed" <<"\n";
TopoDS_Shape Res = TNaming_Tool::CurrentShape(SL.NamedShape());
sprintf (name,"%s_%s","new",a[2]);
Sprintf (name,"%s_%s","new",a[2]);
Display (name,Res);
return 0;
}