Eagle import: improve rot field parsing.
This commit is contained in:
@@ -407,11 +407,29 @@ EROT Convert<EROT>( const wxString& aRot )
|
||||
|
||||
value.spin = aRot.find( 'S' ) != aRot.npos;
|
||||
value.mirror = aRot.find( 'M' ) != aRot.npos;
|
||||
value.degrees = strtod( aRot.c_str()
|
||||
+ 1 // skip leading 'R'
|
||||
+ int( value.spin ) // skip optional leading 'S'
|
||||
+ int( value.mirror ), // skip optional leading 'M'
|
||||
nullptr );
|
||||
|
||||
size_t rPos = aRot.find( 'R' );
|
||||
|
||||
if( rPos == wxString::npos )
|
||||
{
|
||||
value.degrees = 0.0;
|
||||
return value;
|
||||
}
|
||||
|
||||
// Calculate the offset after 'R', 'S', and 'M'
|
||||
size_t offset;
|
||||
|
||||
for( offset = 0; offset < aRot.size(); offset++ )
|
||||
{
|
||||
if( wxIsdigit( aRot[offset] ) )
|
||||
break;
|
||||
}
|
||||
|
||||
wxString degreesStr = aRot.Mid( offset );
|
||||
|
||||
// Use locale-independent conversion
|
||||
if( !degreesStr.ToCDouble( &value.degrees ) )
|
||||
value.degrees = 0.0;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user