1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40: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

@@ -448,16 +448,10 @@ void TopTools_ShapeSet::Dump(Standard_OStream& OS)const
void TopTools_ShapeSet::Write(Standard_OStream& OS)
{
// always use C locale for writing shapes
std::locale anOldLocale = OS.imbue (std::locale::classic());
// on sauvegarde l'ancien LC_NUMERIC
char *oldnum,*plocal ;
plocal = setlocale(LC_NUMERIC, NULL) ;
oldnum = new char[strlen(plocal)+1] ;
strcpy(oldnum,plocal);
// on positionne LC_NUMERIC a "C" (point decimal)
setlocale(LC_NUMERIC, "C") ;
// use 15-digit precision
std::streamsize prec = OS.precision(15);
// write the copyright
@@ -470,14 +464,6 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS)
// write the locations
//-----------------------------------------
if (!myProgress.IsNull() && myProgress->UserBreak()) {
cout << "Interrupted by the user"<<endl;
// on remet le LC_NUMERIC a la precedente valeur
setlocale(LC_NUMERIC, oldnum) ;
delete[] oldnum;
return;
}
if ( !myProgress.IsNull() )
myProgress->NewScope ( 10, "Locations" );
myLocations.SetProgress(myProgress);
@@ -487,12 +473,9 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS)
myProgress->Show();
}
if (!myProgress.IsNull() && myProgress->UserBreak()) {
cout << "Interrupted by the user"<<endl;
// on remet le LC_NUMERIC a la precedente valeur
setlocale(LC_NUMERIC, oldnum) ;
delete[] oldnum;
OS << "Interrupted by the user"<<endl;
OS.imbue (anOldLocale);
return;
}
@@ -515,7 +498,6 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS)
Standard_Integer i, nbShapes = myShapes.Extent();
OS << "\nTShapes " << nbShapes << "\n";
// subshapes are written first
//OCC19559
@@ -566,15 +548,15 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS)
OS << endl;
OS.precision(prec);
OS.imbue (anOldLocale);
PS.Relieve();
if (!myProgress.IsNull()) {
myProgress->EndScope();
myProgress->Show();
if (myProgress->UserBreak())
OS << "Interrupted by the user"<<endl;
}
// on remet le LC_NUMERIC a la precedente valeur
setlocale(LC_NUMERIC, oldnum) ;
delete[] oldnum;
}
//=======================================================================
@@ -624,11 +606,8 @@ static TopAbs_ShapeEnum ReadShapeEnum(Standard_IStream& IS)
void TopTools_ShapeSet::Read(Standard_IStream& IS)
{
// on sauvegarde l'ancien LC_NUMERIC
char *oldnum,*plocal ;
plocal = setlocale(LC_NUMERIC, NULL) ;
oldnum = new char[strlen(plocal)+1] ;
strcpy(oldnum,plocal);
// always use C locale for reading shapes
std::locale anOldLocale = IS.imbue (std::locale::classic());
Clear();
@@ -648,9 +627,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS)
} while ( ! IS.fail() && strcmp(vers,Version) && strcmp(vers,Version2) );
if (IS.fail()) {
cout << "File was not written with this version of the topology"<<endl;
// on remet le LC_NUMERIC a la precedente valeur
setlocale(LC_NUMERIC, oldnum) ;
delete[] oldnum;
IS.imbue (anOldLocale);
return;
}
if (strcmp(vers,Version2) == 0) SetFormatNb(2);
@@ -664,8 +641,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS)
if (!myProgress.IsNull() && myProgress->UserBreak()) {
cout << "Interrupted by the user"<<endl;
// on remet le LC_NUMERIC a la precedente valeur
setlocale(LC_NUMERIC, oldnum) ;
delete[] oldnum;
IS.imbue (anOldLocale);
return;
}
if ( !myProgress.IsNull() )
@@ -680,8 +656,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS)
if (!myProgress.IsNull() && myProgress->UserBreak()) {
cout << "Interrupted by the user"<<endl;
// on remet le LC_NUMERIC a la precedente valeur
setlocale(LC_NUMERIC, oldnum) ;
delete[] oldnum;
IS.imbue (anOldLocale);
return;
}
@@ -705,8 +680,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS)
if (strcmp(buffer,"TShapes")) {
cout << "Not a TShape table"<<endl;
// on remet le LC_NUMERIC a la precedente valeur
setlocale(LC_NUMERIC, oldnum) ;
delete[] oldnum;
IS.imbue (anOldLocale);
return;
}
@@ -764,8 +738,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS)
}
// on remet le LC_NUMERIC a la precedente valeur
setlocale(LC_NUMERIC, oldnum) ;
delete[] oldnum;
IS.imbue (anOldLocale);
}
//=======================================================================