diff --git a/gerbview/excellon_image.h b/gerbview/excellon_image.h index edeb61ad0f..4c7d14da64 100644 --- a/gerbview/excellon_image.h +++ b/gerbview/excellon_image.h @@ -96,12 +96,14 @@ private: excellon_state m_State; // state of excellon file analysis bool m_SlotOn; // true during an oblong drill definition + bool m_format_known; // true if number format (2:4, etc) is known public: EXCELLON_IMAGE( int layer ) : GERBER_FILE_IMAGE( layer ) { m_State = READ_HEADER_STATE; m_SlotOn = false; + m_format_known = false; } diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index f444de64c6..5799303ea6 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -547,9 +547,31 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) switch( *text ) { case 'X': - ReadXYCoord( text ); - break; case 'Y': + if( !m_format_known ) + { + // Scan the first entry to decode format + int nbdigits = 0; + int integer = m_GerbMetric ? fmtIntegerMM : fmtIntegerInch; + int mantissa; + char* read = text + 1; + + while( IsNumber( *read ) ) + { + if( (*read >= '0') && (*read <='9') ) + nbdigits++; + + read++; + } + + mantissa = nbdigits - integer; + + m_FmtScale.x = m_FmtScale.y = mantissa; + m_FmtLen.x = m_FmtLen.y = integer + mantissa; + + m_format_known = true; + } + ReadXYCoord( text ); break; case 'G': // G85 is found here for oval holes