From 378b7ef2cb58b1599e36e5dbebf99b2bc0d82765 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sat, 18 Oct 2025 18:28:48 +0300 Subject: [PATCH] Eagle import: improve rot field parsing. --- common/io/eagle/eagle_parser.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/common/io/eagle/eagle_parser.cpp b/common/io/eagle/eagle_parser.cpp index 987bff8503..30b0c60cf2 100644 --- a/common/io/eagle/eagle_parser.cpp +++ b/common/io/eagle/eagle_parser.cpp @@ -407,11 +407,29 @@ EROT Convert( 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; }