1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +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

@@ -157,7 +157,7 @@ VrmlData_ErrorStatus VrmlData_Box::Write (const char * thePrefix) const
if (OK (aStatus, Scene().WriteLine (thePrefix, header, GlobalIndent())))
{
char buf[128];
sprintf (buf, "size %.12g %.12g %.12g", mySize.X(), mySize.Y(), mySize.Z());
Sprintf (buf, "size %.12g %.12g %.12g", mySize.X(), mySize.Y(), mySize.Z());
Scene().WriteLine (buf);
aStatus = WriteClosing();
}
@@ -259,12 +259,12 @@ VrmlData_ErrorStatus VrmlData_Cone::Write (const char * thePrefix) const
{
char buf[128];
if ((myBottomRadius - 1.)*(myBottomRadius - 1.) > Precision::Confusion()) {
sprintf (buf, "bottomRadius %.12g", myBottomRadius);
Sprintf (buf, "bottomRadius %.12g", myBottomRadius);
aStatus = Scene().WriteLine (buf);
}
if (OK(aStatus) &&
(myHeight - 2.)*(myHeight - 2.) > Precision::Confusion()) {
sprintf (buf, "height %.12g", myHeight);
Sprintf (buf, "height %.12g", myHeight);
aStatus = Scene().WriteLine (buf);
}
if (OK(aStatus) && myHasBottom == Standard_False)
@@ -393,12 +393,12 @@ VrmlData_ErrorStatus VrmlData_Cylinder::Write (const char * thePrefix) const
{
char buf[128];
if ((myRadius - 1.)*(myRadius - 1.) > Precision::Confusion()) {
sprintf (buf, "radius %.12g", myRadius);
Sprintf (buf, "radius %.12g", myRadius);
aStatus = Scene().WriteLine (buf);
}
if (OK(aStatus) &&
(myHeight - 2.)*(myHeight - 2.) > Precision::Confusion()) {
sprintf (buf, "height %.12g", myHeight);
Sprintf (buf, "height %.12g", myHeight);
aStatus = Scene().WriteLine (buf);
}
if (OK(aStatus) && myHasBottom == Standard_False)
@@ -494,7 +494,7 @@ VrmlData_ErrorStatus VrmlData_Sphere::Write (const char * thePrefix) const
if (OK (aStatus, Scene().WriteLine (thePrefix, header, GlobalIndent())))
{
char buf[128];
sprintf (buf, "radius %.12g", myRadius);
Sprintf (buf, "radius %.12g", myRadius);
Scene().WriteLine (buf);
aStatus = WriteClosing();
}

View File

@@ -478,13 +478,13 @@ VrmlData_ErrorStatus VrmlData_Group::Write (const char * thePrefix) const
};
// Check that the box is not void
if (aBoxCorner[0].X() < aBoxCorner[1].X() + Precision::Confusion()) {
sprintf (buf, "bboxCenter %.9g %.9g %.9g",
Sprintf (buf, "bboxCenter %.9g %.9g %.9g",
0.5 * (aBoxCorner[0].X() + aBoxCorner[1].X()),
0.5 * (aBoxCorner[0].Y() + aBoxCorner[1].Y()),
0.5 * (aBoxCorner[0].Z() + aBoxCorner[1].Z()));
aStatus = aScene.WriteLine (buf);
if (OK(aStatus)) {
sprintf (buf, "bboxSize %.9g %.9g %.9g",
Sprintf (buf, "bboxSize %.9g %.9g %.9g",
aBoxCorner[1].X() - aBoxCorner[0].X(),
aBoxCorner[1].Y() - aBoxCorner[0].Y(),
aBoxCorner[1].Z() - aBoxCorner[0].Z());
@@ -499,7 +499,7 @@ VrmlData_ErrorStatus VrmlData_Group::Write (const char * thePrefix) const
if ((aScaleFactor - 1.)*(aScaleFactor - 1.) >
0.0001*Precision::Confusion())
{
sprintf (buf, "scale %.12g %.12g %.12g",
Sprintf (buf, "scale %.12g %.12g %.12g",
aScaleFactor, aScaleFactor, aScaleFactor);
aStatus = aScene.WriteLine (buf);
}
@@ -507,7 +507,7 @@ VrmlData_ErrorStatus VrmlData_Group::Write (const char * thePrefix) const
// Output the Translation
const gp_XYZ& aTrans = myTrsf.TranslationPart();
if (aTrans.SquareModulus() > 0.0001*Precision::Confusion()) {
sprintf (buf, "translation %.12g %.12g %.12g",
Sprintf (buf, "translation %.12g %.12g %.12g",
aTrans.X(), aTrans.Y(), aTrans.Z());
aStatus = aScene.WriteLine (buf);
}
@@ -517,7 +517,7 @@ VrmlData_ErrorStatus VrmlData_Group::Write (const char * thePrefix) const
Standard_Real anAngle;
if (myTrsf.GetRotation (anAxis, anAngle)) {
// output the Rotation
sprintf (buf, "rotation %.12g %.12g %.12g %.9g",
Sprintf (buf, "rotation %.12g %.12g %.12g %.9g",
anAxis.X(), anAxis.Y(), anAxis.Z(), anAngle);
aStatus = aScene.WriteLine (buf);
}

View File

@@ -371,7 +371,7 @@ VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Write
aStatus = aScene.WriteLine ("convex FALSE");
if (OK(aStatus) && CreaseAngle() > Precision::Confusion()) {
char buf[64];
sprintf (buf, "%.9g", CreaseAngle());
Sprintf (buf, "%.9g", CreaseAngle());
aStatus = aScene.WriteLine ("creaseAngle", buf);
}

View File

@@ -202,7 +202,7 @@ VrmlData_ErrorStatus VrmlData_Material::Write (const char * thePrefix) const
const Standard_Real aConf (0.001 * Precision::Confusion());
if (OK(aStatus) && fabs(myAmbientIntensity - 0.2) > aConf) {
sprintf (buf, "%.6g", myAmbientIntensity);
Sprintf (buf, "%.6g", myAmbientIntensity);
aStatus = aScene.WriteLine ("ambientIntensity ", buf);
}
if (OK(aStatus)) {
@@ -211,30 +211,30 @@ VrmlData_ErrorStatus VrmlData_Material::Write (const char * thePrefix) const
(val[1] - 0.8) * (val[1] - 0.8) +
(val[2] - 0.8) * (val[2] - 0.8) > 1e-7)
{
sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
Sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
aStatus = aScene.WriteLine ("diffuseColor ", buf);
}
}
if (OK(aStatus)) {
myEmissiveColor.Values (val[0], val[1], val[2], bidType);
if (val[0] * val[0] + val[1] * val[1] + val[2] * val[2] > 1e-7) {
sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
Sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
aStatus = aScene.WriteLine ("emissiveColor ", buf);
}
}
if (OK(aStatus) && fabs(myShininess - 0.2) > aConf) {
sprintf (buf, "%.6g", myShininess);
Sprintf (buf, "%.6g", myShininess);
aStatus = aScene.WriteLine ("shininess ", buf);
}
if (OK(aStatus)) {
mySpecularColor.Values (val[0], val[1], val[2], bidType);
if (val[0] * val[0] + val[1] * val[1] + val[2] * val[2] > 1e-7) {
sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
Sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
aStatus = aScene.WriteLine ("specularColor ", buf);
}
}
if (OK(aStatus) && myTransparency > aConf) {
sprintf (buf, "%.6g", myTransparency);
Sprintf (buf, "%.6g", myTransparency);
aStatus = aScene.WriteLine ("transparency ", buf);
}

View File

@@ -677,7 +677,7 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadReal
VrmlData_ErrorStatus aStatus;
if (VrmlData_Node::OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
char * endptr;
aResult = strtod (theBuffer.LinePtr, &endptr);
aResult = Strtod (theBuffer.LinePtr, &endptr);
if (endptr == theBuffer.LinePtr)
aStatus = VrmlData_NumericInputError;
else if (isOnlyPositive && aResult < 0.001*Precision::Confusion())
@@ -707,7 +707,7 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadXYZ
if (!VrmlData_Node::OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
break;
char * endptr;
aVal[i] = strtod (theBuffer.LinePtr, &endptr);
aVal[i] = Strtod (theBuffer.LinePtr, &endptr);
if (endptr == theBuffer.LinePtr) {
aStatus = VrmlData_NumericInputError;
break;
@@ -746,7 +746,7 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadXY
if (!VrmlData_Node::OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
break;
char * endptr;
aVal[i] = strtod (theBuffer.LinePtr, &endptr);
aVal[i] = Strtod (theBuffer.LinePtr, &endptr);
if (endptr == theBuffer.LinePtr) {
aStatus = VrmlData_NumericInputError;
break;
@@ -871,23 +871,23 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteArrIndex
const Standard_Integer * arrVal = theArrIndex[iBlock]+1;
switch (nVal) {
case 1:
sprintf (buf, "%d,", arrVal[0]);
Sprintf (buf, "%d,", arrVal[0]);
break;
case 2:
sprintf (buf, "%d,%d,", arrVal[0], arrVal[1]);
Sprintf (buf, "%d,%d,", arrVal[0], arrVal[1]);
break;
case 3:
sprintf (buf, "%d,%d,%d,", arrVal[0], arrVal[1], arrVal[2]);
Sprintf (buf, "%d,%d,%d,", arrVal[0], arrVal[1], arrVal[2]);
break;
case 4:
sprintf (buf, "%d,%d,%d,%d,",
Sprintf (buf, "%d,%d,%d,%d,",
arrVal[0], arrVal[1], arrVal[2], arrVal[3]);
break;
default:
if (nVal > 0) {
char * ptr = &buf[0];
for (Standard_Integer i = 0; i < nVal; i++) {
sprintf (ptr, "%d,", arrVal[i]);
Sprintf (ptr, "%d,", arrVal[i]);
ptr = strchr (ptr, ',') + 1;
if ((ptr - &buf[0]) > (ptrdiff_t)aLineLimit) {
WriteLine(buf);
@@ -918,11 +918,11 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteXYZ
char buf[240];
if (IsDummyWrite() == Standard_False)
if (isApplyScale && myLinearScale > Precision::Confusion())
sprintf (buf, "%.12g %.12g %.12g%s", theXYZ.X() / myLinearScale,
Sprintf (buf, "%.12g %.12g %.12g%s", theXYZ.X() / myLinearScale,
theXYZ.Y() / myLinearScale, theXYZ.Z() / myLinearScale,
thePostfix ? thePostfix : "");
else
sprintf (buf, "%.12g %.12g %.12g%s", theXYZ.X(), theXYZ.Y(), theXYZ.Z(),
Sprintf (buf, "%.12g %.12g %.12g%s", theXYZ.X(), theXYZ.Y(), theXYZ.Z(),
thePostfix ? thePostfix : "");
return WriteLine (buf);
}
@@ -1005,7 +1005,7 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteNode
Handle(VrmlData_UnknownNode) bidNode = new VrmlData_UnknownNode;
char buf[32];
do {
sprintf (buf, "_%d",
Sprintf (buf, "_%d",
++const_cast<Standard_Integer&>(myAutoNameCounter));
bidNode->myName = &buf[0];
} while (myNamedNodes.Contains (bidNode));
@@ -1116,7 +1116,7 @@ void dumpNode (Standard_OStream& theStream,
const Handle(VrmlData_Group) aGroup =
Handle(VrmlData_Group)::DownCast (theNode);
char buf[64];
sprintf (buf, "Group (%s)",
Sprintf (buf, "Group (%s)",
aGroup->IsTransform() ? "Transform" : "Group");
dumpNodeHeader (theStream, theIndent, buf, theNode->Name());
if (theIndent.IsEmpty() == Standard_False) {
@@ -1133,7 +1133,7 @@ void dumpNode (Standard_OStream& theStream,
const Standard_Size nCoord = aNode->Coordinates()->Length();
const Standard_Size nPoly = aNode->Polygons (ppDummy);
char buf[64];
sprintf (buf, "IndexedFaceSet (%d vertices, %d polygons)", nCoord, nPoly);
Sprintf (buf, "IndexedFaceSet (%d vertices, %d polygons)", nCoord, nPoly);
dumpNodeHeader (theStream, theIndent, buf, theNode->Name());
} else if (theNode->IsKind(STANDARD_TYPE(VrmlData_IndexedLineSet))) {
const Handle(VrmlData_IndexedLineSet) aNode =
@@ -1142,7 +1142,7 @@ void dumpNode (Standard_OStream& theStream,
const Standard_Size nCoord = aNode->Coordinates()->Length();
const Standard_Size nPoly = aNode->Polygons (ppDummy);
char buf[64];
sprintf (buf, "IndexedLineSet (%d vertices, %d polygons)", nCoord, nPoly);
Sprintf (buf, "IndexedLineSet (%d vertices, %d polygons)", nCoord, nPoly);
dumpNodeHeader (theStream, theIndent, buf, theNode->Name());
} else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Material))) {
// const Handle(VrmlData_Material) aMaterial =
@@ -1159,7 +1159,7 @@ void dumpNode (Standard_OStream& theStream,
const Handle(VrmlData_UnknownNode) anUnknown =
Handle(VrmlData_UnknownNode)::DownCast (theNode);
char buf[64];
sprintf (buf, "Unknown (%s)", anUnknown->GetTitle().ToCString());
Sprintf (buf, "Unknown (%s)", anUnknown->GetTitle().ToCString());
dumpNodeHeader (theStream, theIndent, buf, theNode->Name());
}
}

View File

@@ -155,7 +155,7 @@ VrmlData_ErrorStatus VrmlData_WorldInfo::Write (const char * thePrefix) const
{
char buf[4096];
if (myTitle) {
sprintf (buf, "title \"%s\"", myTitle);
Sprintf (buf, "title \"%s\"", myTitle);
aStatus = aScene.WriteLine (buf);
}
@@ -163,7 +163,7 @@ VrmlData_ErrorStatus VrmlData_WorldInfo::Write (const char * thePrefix) const
if (OK (aStatus, aScene.WriteLine ("info [", 0L, GlobalIndent()))) {
NCollection_List<const char *>::Iterator anIter (myInfo);
while (anIter.More()) {
sprintf (buf, "\"%s\"", anIter.Value());
Sprintf (buf, "\"%s\"", anIter.Value());
anIter.Next();
if (anIter.More())
aStatus = aScene.WriteLine (buf, ",");