Commit 7fbeb899 authored by Dick Hollenbeck's avatar Dick Hollenbeck

initial work on Bug 578577, partial fix

parent 74cc5a75
This diff is collapsed.
...@@ -535,6 +535,26 @@ bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file ) ...@@ -535,6 +535,26 @@ bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file )
} }
static bool CheckForLineEnd( char buff[GERBER_BUFZ], char*& text, FILE* fp )
{
while( *text == '\n' || !*text )
{
if( *text == '\n' )
++text;
if( !*text )
{
if( fgets( buff, GERBER_BUFZ, fp ) == NULL )
return false;
text = buff;
}
}
return true;
}
bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
char*& text, char*& text,
FILE* gerber_file ) FILE* gerber_file )
...@@ -563,15 +583,8 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -563,15 +583,8 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
if( *text == '*' ) if( *text == '*' )
++text; ++text;
if( *text == '\n' ) if( !CheckForLineEnd( buff, text, gerber_file ) )
++text; return false;
if( !*text )
{
text = buff;
if( fgets( buff, GERBER_BUFZ, gerber_file ) == NULL )
return false;
}
if( *text == '%' ) if( *text == '%' )
break; // exit with text still pointing at % break; // exit with text still pointing at %
...@@ -625,12 +638,15 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -625,12 +638,15 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
} }
int i; int i;
for( i = 0; i < paramCount && *text && *text != '*'; ++i ) for( i = 0; i < paramCount && *text != '*'; ++i )
{ {
prim.params.push_back( DCODE_PARAM() ); prim.params.push_back( DCODE_PARAM() );
DCODE_PARAM& param = prim.params.back(); DCODE_PARAM& param = prim.params.back();
if( !CheckForLineEnd( buff, text, gerber_file ) )
return false;
if( *text == '$' ) if( *text == '$' )
{ {
++text; ++text;
...@@ -647,18 +663,24 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -647,18 +663,24 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
// there are more parameters to read if this is an AMP_OUTLINE // there are more parameters to read if this is an AMP_OUTLINE
if( prim.primitive_id == AMP_OUTLINE ) if( prim.primitive_id == AMP_OUTLINE )
{ {
// so far we have read [0]:exposure, [1]:#points, [2]:X start, [3]: Y start
// Now read all the points, plus trailing rotation in degrees.
// params[1] is a count of polygon points, so it must be given // params[1] is a count of polygon points, so it must be given
// in advance, i.e. be immediate. // in advance, i.e. be immediate.
wxASSERT( prim.params[1].IsImmediate() ); wxASSERT( prim.params[1].IsImmediate() );
paramCount = (int) prim.params[1].GetValue( 0 ) * 2 + 1; paramCount = (int) prim.params[1].GetValue( 0 ) * 2 + 1;
for( int i = 0; i < paramCount && *text && *text != '*'; ++i ) for( int i = 0; i < paramCount && *text != '*'; ++i )
{ {
prim.params.push_back( DCODE_PARAM() ); prim.params.push_back( DCODE_PARAM() );
DCODE_PARAM& param = prim.params.back(); DCODE_PARAM& param = prim.params.back();
if( !CheckForLineEnd( buff, text, gerber_file ) )
return false;
if( *text == '$' ) if( *text == '$' )
{ {
++text; ++text;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment