mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +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:
@@ -30,8 +30,7 @@ uses Position from Storage,
|
||||
SequenceOfAsciiString from TColStd,
|
||||
SequenceOfExtendedString from TColStd,
|
||||
ExtendedString from TCollection,
|
||||
FStream from FSD,
|
||||
Real2String from OSD
|
||||
FStream from FSD
|
||||
|
||||
raises StreamTypeMismatchError from Storage,
|
||||
StreamFormatError from Storage,
|
||||
@@ -331,6 +330,5 @@ is
|
||||
|
||||
fields
|
||||
|
||||
myStream : FStream from FSD;
|
||||
myRealConv : Real2String from OSD;
|
||||
myStream : FStream from FSD;
|
||||
end;
|
||||
|
@@ -19,8 +19,6 @@
|
||||
#include <FSD_CmpFile.ixx>
|
||||
#include <OSD.hxx>
|
||||
|
||||
#include <OSD_Real2String.hxx>
|
||||
|
||||
#include <Storage_StreamModeError.hxx>
|
||||
#include <Storage_StreamUnknownTypeError.hxx>
|
||||
#include <Standard_PCharacter.hxx>
|
||||
@@ -122,6 +120,7 @@ Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName,const Stora
|
||||
}
|
||||
else {
|
||||
myStream.precision(17);
|
||||
myStream.imbue (std::locale::classic()); // use always C locale
|
||||
SetOpenMode(aMode);
|
||||
}
|
||||
}
|
||||
@@ -529,29 +528,9 @@ Storage_BaseDriver& FSD_CmpFile::PutBoolean(const Standard_Boolean aValue)
|
||||
|
||||
Storage_BaseDriver& FSD_CmpFile::PutReal(const Standard_Real aValue)
|
||||
{
|
||||
#ifdef BUC60808
|
||||
char realbuffer[100];
|
||||
Standard_PCharacter pChar;
|
||||
//
|
||||
pChar=realbuffer;
|
||||
realbuffer[0] = '\0';
|
||||
//
|
||||
if (myRealConv.RealToCString(aValue,pChar)) {
|
||||
myStream << realbuffer << " ";
|
||||
}
|
||||
else {
|
||||
Storage_StreamWriteError::Raise();
|
||||
}
|
||||
if (myStream.bad()) Storage_StreamWriteError::Raise();
|
||||
|
||||
return *this;
|
||||
|
||||
#else
|
||||
myStream << ((Standard_Real)aValue) << " ";
|
||||
|
||||
if (myStream.bad()) Storage_StreamWriteError::Raise();
|
||||
return *this;
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -561,28 +540,9 @@ Storage_BaseDriver& FSD_CmpFile::PutReal(const Standard_Real aValue)
|
||||
|
||||
Storage_BaseDriver& FSD_CmpFile::PutShortReal(const Standard_ShortReal aValue)
|
||||
{
|
||||
#ifdef BUC60808
|
||||
char realbuffer[100];
|
||||
Standard_PCharacter pStr;
|
||||
//
|
||||
pStr=realbuffer;
|
||||
realbuffer[0] = '\0';
|
||||
//
|
||||
if (myRealConv.RealToCString(aValue,pStr)) {
|
||||
myStream << realbuffer << " ";
|
||||
}
|
||||
else {
|
||||
Storage_StreamWriteError::Raise();
|
||||
}
|
||||
if (myStream.bad()) Storage_StreamWriteError::Raise();
|
||||
|
||||
return *this;
|
||||
#else
|
||||
myStream << aValue << " ";
|
||||
|
||||
if (myStream.bad()) Storage_StreamWriteError::Raise();
|
||||
return *this;
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -669,10 +629,9 @@ Storage_BaseDriver& FSD_CmpFile::GetReal(Standard_Real& aValue)
|
||||
cerr << "\t buffer is" << realbuffer<< endl;
|
||||
Storage_StreamTypeMismatchError::Raise();
|
||||
}
|
||||
if (!myRealConv.CStringToReal(realbuffer,aValue)) {
|
||||
if (!OSD::CStringToReal(realbuffer,aValue)) {
|
||||
cerr << "%%%ERROR: read error of double at offset " << myStream.tellg() << endl;
|
||||
cerr << "\t buffer is" << realbuffer<< endl;
|
||||
//if (!OSD::CStringToReal(realbuffer,aValue))
|
||||
Storage_StreamTypeMismatchError::Raise();
|
||||
}
|
||||
|
||||
@@ -697,8 +656,8 @@ Storage_BaseDriver& FSD_CmpFile::GetShortReal(Standard_ShortReal& aValue)
|
||||
|
||||
realbuffer[0] = '\0';
|
||||
if (!(myStream >> realbuffer)) Storage_StreamTypeMismatchError::Raise();
|
||||
// if (!OSD::CStringToReal(realbuffer,r))
|
||||
if (!myRealConv.CStringToReal(realbuffer,r)) Storage_StreamTypeMismatchError::Raise();
|
||||
if (!OSD::CStringToReal(realbuffer,r))
|
||||
Storage_StreamTypeMismatchError::Raise();
|
||||
|
||||
aValue = (Standard_ShortReal)r;
|
||||
|
||||
|
@@ -91,6 +91,7 @@ Storage_Error FSD_File::Open(const TCollection_AsciiString& aName,const Storage_
|
||||
}
|
||||
else {
|
||||
myStream.precision(17);
|
||||
myStream.imbue (std::locale::classic()); // use always C locale
|
||||
SetOpenMode(aMode);
|
||||
}
|
||||
}
|
||||
@@ -461,25 +462,9 @@ Storage_BaseDriver& FSD_File::PutBoolean(const Standard_Boolean aValue)
|
||||
|
||||
Storage_BaseDriver& FSD_File::PutReal(const Standard_Real aValue)
|
||||
{
|
||||
#ifdef USEOSDREAL
|
||||
char realbuffer[100];
|
||||
|
||||
realbuffer[0] = '\0';
|
||||
if (OSD::RealToCString(aValue,realbuffer)) {
|
||||
myStream << realbuffer << " ";
|
||||
}
|
||||
else {
|
||||
Storage_StreamWriteError::Raise();
|
||||
}
|
||||
if (myStream.bad()) Storage_StreamWriteError::Raise();
|
||||
|
||||
return *this;
|
||||
#else
|
||||
myStream << ((Standard_Real)aValue) << " ";
|
||||
|
||||
if (myStream.bad()) Storage_StreamWriteError::Raise();
|
||||
return *this;
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -489,25 +474,9 @@ Storage_BaseDriver& FSD_File::PutReal(const Standard_Real aValue)
|
||||
|
||||
Storage_BaseDriver& FSD_File::PutShortReal(const Standard_ShortReal aValue)
|
||||
{
|
||||
#ifdef USEOSDREAL
|
||||
char realbuffer[100];
|
||||
|
||||
realbuffer[0] = '\0';
|
||||
if (OSD::RealToCString(aValue,realbuffer)) {
|
||||
myStream << realbuffer << " ";
|
||||
}
|
||||
else {
|
||||
Storage_StreamWriteError::Raise();
|
||||
}
|
||||
if (myStream.bad()) Storage_StreamWriteError::Raise();
|
||||
|
||||
return *this;
|
||||
#else
|
||||
myStream << aValue << " ";
|
||||
|
||||
if (myStream.bad()) Storage_StreamWriteError::Raise();
|
||||
return *this;
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
Reference in New Issue
Block a user