Fix issue in aperture macro with some strange gerber files.
Fixes: lp:1755623 https://bugs.launchpad.net/kicad/+bug/1755623
This commit is contained in:
parent
66d5d10b49
commit
fa41026f36
|
@ -181,7 +181,12 @@ bool AM_PARAM::ReadParam( char*& aText )
|
|||
{
|
||||
case ',':
|
||||
aText++;
|
||||
|
||||
if( !found ) // happens when a string starts by ',' before any param
|
||||
break; // just skip this separator
|
||||
// fall through
|
||||
case '\n':
|
||||
case '\r':
|
||||
case 0: // EOL
|
||||
case '*': // Terminator in a gerber command
|
||||
end = true;
|
||||
|
|
|
@ -104,12 +104,11 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* size of single line of a text from a gerber file.
|
||||
* warning: some files can have *very long* lines, so the buffer must be large.
|
||||
*/
|
||||
// size of a single line of text from a gerber file.
|
||||
// warning: some files can have *very long* lines, so the buffer must be large.
|
||||
#define GERBER_BUFZ 1000000
|
||||
static char line[GERBER_BUFZ];
|
||||
// A large buffer to store one line
|
||||
static char lineBuffer[GERBER_BUFZ+1];
|
||||
|
||||
bool GERBER_FILE_IMAGE::LoadGerberFile( const wxString& aFullFileName )
|
||||
{
|
||||
|
@ -134,11 +133,11 @@ bool GERBER_FILE_IMAGE::LoadGerberFile( const wxString& aFullFileName )
|
|||
|
||||
while( true )
|
||||
{
|
||||
if( fgets( line, sizeof(line), m_Current_File ) == NULL )
|
||||
if( fgets( lineBuffer, GERBER_BUFZ, m_Current_File ) == NULL )
|
||||
break;
|
||||
|
||||
m_LineNum++;
|
||||
text = StrPurge( line );
|
||||
text = StrPurge( lineBuffer );
|
||||
|
||||
while( text && *text )
|
||||
{
|
||||
|
@ -195,7 +194,7 @@ bool GERBER_FILE_IMAGE::LoadGerberFile( const wxString& aFullFileName )
|
|||
if( m_CommandState != ENTER_RS274X_CMD )
|
||||
{
|
||||
m_CommandState = ENTER_RS274X_CMD;
|
||||
ReadRS274XCommand( line, GERBER_BUFZ, text );
|
||||
ReadRS274XCommand( lineBuffer, GERBER_BUFZ, text );
|
||||
}
|
||||
else //Error
|
||||
{
|
||||
|
|
|
@ -1086,7 +1086,7 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
|
|||
prim.primitive_id = (AM_PRIMITIVE_ID) primitive_type;
|
||||
int ii;
|
||||
|
||||
for( ii = 0; ii < *aText && *aText != '*'; ++ii )
|
||||
for( ii = 0; ii < paramCount && *aText && *aText != '*'; ++ii )
|
||||
{
|
||||
prim.params.push_back( AM_PARAM() );
|
||||
|
||||
|
@ -1106,7 +1106,6 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
|
|||
msg.Printf( wxT( "RS274X: read macro descr type %d: read %d parameters, insufficient parameters\n" ),
|
||||
prim.primitive_id, ii );
|
||||
AddMessageToList( msg );
|
||||
|
||||
}
|
||||
// there are more parameters to read if this is an AMP_OUTLINE
|
||||
if( prim.primitive_id == AMP_OUTLINE )
|
||||
|
|
Loading…
Reference in New Issue