Ensure file reads always use the C-locale variant
Str2Double assumes current locale. We usually switch the locale when reading files but we should be using the function that explicitly gets the C-locale conversion.
This commit is contained in:
parent
a2041073ee
commit
9f09c3872f
|
@ -144,7 +144,7 @@ double Convert<double>( const wxString& aValue )
|
||||||
{
|
{
|
||||||
double value;
|
double value;
|
||||||
|
|
||||||
if( aValue.ToDouble( &value ) )
|
if( aValue.ToCDouble( &value ) )
|
||||||
return value;
|
return value;
|
||||||
else
|
else
|
||||||
throw XML_PARSER_ERROR( "Conversion to double failed. Original value: '" +
|
throw XML_PARSER_ERROR( "Conversion to double failed. Original value: '" +
|
||||||
|
|
|
@ -149,8 +149,8 @@ int PinNumbers::Compare( const PinNumber& lhs, const PinNumber& rhs )
|
||||||
|
|
||||||
double val1, val2;
|
double val1, val2;
|
||||||
|
|
||||||
comp1.ToDouble( &val1 );
|
comp1.ToCDouble( &val1 );
|
||||||
comp2.ToDouble( &val2 );
|
comp2.ToCDouble( &val2 );
|
||||||
|
|
||||||
if( val1 < val2 )
|
if( val1 < val2 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,6 +162,8 @@ double From_User_Unit( EDA_UNITS aUnit, double aValue, bool aUseMils = false );
|
||||||
/**
|
/**
|
||||||
* Function DoubleValueFromString
|
* Function DoubleValueFromString
|
||||||
* converts \a aTextValue to a double
|
* converts \a aTextValue to a double
|
||||||
|
* @warning This utilizes the current locale and will break if decimal formats differ
|
||||||
|
*
|
||||||
* @param aUnits The units of \a aTextValue.
|
* @param aUnits The units of \a aTextValue.
|
||||||
* @param aTextValue A reference to a wxString object containing the string to convert.
|
* @param aTextValue A reference to a wxString object containing the string to convert.
|
||||||
* @param aUseMils Indicates mils should be used for imperial units (inches).
|
* @param aUseMils Indicates mils should be used for imperial units (inches).
|
||||||
|
@ -173,6 +175,7 @@ double DoubleValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, bool
|
||||||
/**
|
/**
|
||||||
* Function ValueFromString
|
* Function ValueFromString
|
||||||
* converts \a aTextValue in \a aUnits to internal units used by the application.
|
* converts \a aTextValue in \a aUnits to internal units used by the application.
|
||||||
|
* @warning This utilizes the current locale and will break if decimal formats differ
|
||||||
*
|
*
|
||||||
* @param aUnits The units of \a aTextValue.
|
* @param aUnits The units of \a aTextValue.
|
||||||
* @param aTextValue A reference to a wxString object containing the string to convert.
|
* @param aTextValue A reference to a wxString object containing the string to convert.
|
||||||
|
|
|
@ -162,9 +162,9 @@ void ERULES::parse( wxXmlNode* aRules )
|
||||||
psElongationOffset = wxAtoi( value );
|
psElongationOffset = wxAtoi( value );
|
||||||
|
|
||||||
else if( name == "mvStopFrame" )
|
else if( name == "mvStopFrame" )
|
||||||
value.ToDouble( &mvStopFrame );
|
value.ToCDouble( &mvStopFrame );
|
||||||
else if( name == "mvCreamFrame" )
|
else if( name == "mvCreamFrame" )
|
||||||
value.ToDouble( &mvCreamFrame );
|
value.ToCDouble( &mvCreamFrame );
|
||||||
else if( name == "mlMinStopFrame" )
|
else if( name == "mlMinStopFrame" )
|
||||||
mlMinStopFrame = parseEagle( value );
|
mlMinStopFrame = parseEagle( value );
|
||||||
else if( name == "mlMaxStopFrame" )
|
else if( name == "mlMaxStopFrame" )
|
||||||
|
@ -175,7 +175,7 @@ void ERULES::parse( wxXmlNode* aRules )
|
||||||
mlMaxCreamFrame = parseEagle( value );
|
mlMaxCreamFrame = parseEagle( value );
|
||||||
|
|
||||||
else if( name == "srRoundness" )
|
else if( name == "srRoundness" )
|
||||||
value.ToDouble( &srRoundness );
|
value.ToCDouble( &srRoundness );
|
||||||
else if( name == "srMinRoundness" )
|
else if( name == "srMinRoundness" )
|
||||||
srMinRoundness = parseEagle( value );
|
srMinRoundness = parseEagle( value );
|
||||||
else if( name == "srMaxRoundness" )
|
else if( name == "srMaxRoundness" )
|
||||||
|
@ -189,14 +189,14 @@ void ERULES::parse( wxXmlNode* aRules )
|
||||||
psFirst = wxAtoi( value );
|
psFirst = wxAtoi( value );
|
||||||
|
|
||||||
else if( name == "rvPadTop" )
|
else if( name == "rvPadTop" )
|
||||||
value.ToDouble( &rvPadTop );
|
value.ToCDouble( &rvPadTop );
|
||||||
else if( name == "rlMinPadTop" )
|
else if( name == "rlMinPadTop" )
|
||||||
rlMinPadTop = parseEagle( value );
|
rlMinPadTop = parseEagle( value );
|
||||||
else if( name == "rlMaxPadTop" )
|
else if( name == "rlMaxPadTop" )
|
||||||
rlMaxPadTop = parseEagle( value );
|
rlMaxPadTop = parseEagle( value );
|
||||||
|
|
||||||
else if( name == "rvViaOuter" )
|
else if( name == "rvViaOuter" )
|
||||||
value.ToDouble( &rvViaOuter );
|
value.ToCDouble( &rvViaOuter );
|
||||||
else if( name == "rlMinViaOuter" )
|
else if( name == "rlMinViaOuter" )
|
||||||
rlMinViaOuter = parseEagle( value );
|
rlMinViaOuter = parseEagle( value );
|
||||||
else if( name == "rlMaxViaOuter" )
|
else if( name == "rlMaxViaOuter" )
|
||||||
|
|
|
@ -143,7 +143,7 @@ double StrToDoublePrecisionUnits( const wxString& aStr, char aAxe, const wxStrin
|
||||||
|
|
||||||
if( u == wxT( 'm' ) )
|
if( u == wxT( 'm' ) )
|
||||||
{
|
{
|
||||||
ls.ToDouble( &i );
|
ls.ToCDouble( &i );
|
||||||
#ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
|
#ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
|
||||||
if( aActualConversion == wxT( "SCH" )
|
if( aActualConversion == wxT( "SCH" )
|
||||||
|| aActualConversion == wxT( "SCHLIB" ) )
|
|| aActualConversion == wxT( "SCHLIB" ) )
|
||||||
|
@ -153,7 +153,7 @@ double StrToDoublePrecisionUnits( const wxString& aStr, char aAxe, const wxStrin
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ls.ToDouble( &i );
|
ls.ToCDouble( &i );
|
||||||
i = Mils2iu( i );
|
i = Mils2iu( i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ int StrToInt1Units( const wxString& aStr )
|
||||||
{
|
{
|
||||||
double num, precision = 10;
|
double num, precision = 10;
|
||||||
|
|
||||||
aStr.ToDouble( &num );
|
aStr.ToCDouble( &num );
|
||||||
return KiROUND( num * precision );
|
return KiROUND( num * precision );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ bool X3DCOORDS::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict )
|
||||||
|
|
||||||
while( plist.HasMoreTokens() )
|
while( plist.HasMoreTokens() )
|
||||||
{
|
{
|
||||||
if( plist.GetNextToken().ToDouble( &point ) )
|
if( plist.GetNextToken().ToCDouble( &point ) )
|
||||||
{
|
{
|
||||||
// note: coordinates are multiplied by 2.54 to retain
|
// note: coordinates are multiplied by 2.54 to retain
|
||||||
// legacy behavior of 1 X3D unit = 0.1 inch; the SG*
|
// legacy behavior of 1 X3D unit = 0.1 inch; the SG*
|
||||||
|
|
|
@ -263,7 +263,7 @@ bool X3D::ParseSFFloat( const wxString& aSource, float& aResult )
|
||||||
wxStringTokenizer tokens( aSource );
|
wxStringTokenizer tokens( aSource );
|
||||||
|
|
||||||
double x = 0;
|
double x = 0;
|
||||||
bool ret = tokens.GetNextToken().ToDouble( &x );
|
bool ret = tokens.GetNextToken().ToCDouble( &x );
|
||||||
|
|
||||||
aResult = x;
|
aResult = x;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -278,9 +278,9 @@ bool X3D::ParseSFVec3( const wxString& aSource, WRLVEC3F& aResult )
|
||||||
double y = 0;
|
double y = 0;
|
||||||
double z = 0;
|
double z = 0;
|
||||||
|
|
||||||
bool ret = tokens.GetNextToken().ToDouble( &x )
|
bool ret = tokens.GetNextToken().ToCDouble( &x )
|
||||||
&& tokens.GetNextToken().ToDouble( &y )
|
&& tokens.GetNextToken().ToCDouble( &y )
|
||||||
&& tokens.GetNextToken().ToDouble( &z );
|
&& tokens.GetNextToken().ToCDouble( &z );
|
||||||
|
|
||||||
aResult.x = x;
|
aResult.x = x;
|
||||||
aResult.y = y;
|
aResult.y = y;
|
||||||
|
@ -299,10 +299,10 @@ bool X3D::ParseSFRotation( const wxString& aSource, WRLROTATION& aResult )
|
||||||
double z = 0;
|
double z = 0;
|
||||||
double w = 0;
|
double w = 0;
|
||||||
|
|
||||||
bool ret = tokens.GetNextToken().ToDouble( &x )
|
bool ret = tokens.GetNextToken().ToCDouble( &x )
|
||||||
&& tokens.GetNextToken().ToDouble( &y )
|
&& tokens.GetNextToken().ToCDouble( &y )
|
||||||
&& tokens.GetNextToken().ToDouble( &z )
|
&& tokens.GetNextToken().ToCDouble( &z )
|
||||||
&& tokens.GetNextToken().ToDouble( &w );
|
&& tokens.GetNextToken().ToCDouble( &w );
|
||||||
|
|
||||||
aResult.x = x;
|
aResult.x = x;
|
||||||
aResult.y = y;
|
aResult.y = y;
|
||||||
|
|
Loading…
Reference in New Issue