pcb parser: ensure the parser is reinitialized before parsing a new fp file
Because the same parser is used to read all footprint files of a library, the parser must be reinitialized (internal variable cleared) before reading a new file, otherwise the previous parser state is applied to the next file. Fixes #7627 https://gitlab.com/kicad/code/kicad/issues/7627
This commit is contained in:
parent
f4905cb1ae
commit
ee5f9034f7
|
@ -146,6 +146,7 @@ DSNLEXER::~DSNLEXER()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void DSNLEXER::SetSpecctraMode( bool aMode )
|
||||
{
|
||||
specctraMode = aMode;
|
||||
|
@ -162,6 +163,16 @@ void DSNLEXER::SetSpecctraMode( bool aMode )
|
|||
}
|
||||
|
||||
|
||||
void DSNLEXER::InitParserState()
|
||||
{
|
||||
curTok = DSN_NONE;
|
||||
prevTok = DSN_NONE;
|
||||
commentsAreTokens = false;
|
||||
|
||||
curOffset = 0;
|
||||
}
|
||||
|
||||
|
||||
bool DSNLEXER::SyncLineReaderWith( DSNLEXER& aLexer )
|
||||
{
|
||||
// Synchronize the pointers handling the data read by the LINE_READER
|
||||
|
|
|
@ -131,6 +131,13 @@ public:
|
|||
|
||||
virtual ~DSNLEXER();
|
||||
|
||||
/**
|
||||
* Reinit variables used during parsing, to ensure od states are not used in a new parsing
|
||||
* must be called before parsing a new file after parsing an old file to avoid
|
||||
* starting with some variables in a non initial state
|
||||
*/
|
||||
void InitParserState();
|
||||
|
||||
/**
|
||||
* Usable only for DSN lexers which share the same #LINE_READER.
|
||||
*
|
||||
|
|
|
@ -265,6 +265,8 @@ void FP_CACHE::Load()
|
|||
FILE_LINE_READER reader( fn.GetFullPath() );
|
||||
|
||||
m_owner->m_parser->SetLineReader( &reader );
|
||||
// Ensure a previous parsing does not interacts with the new parsing:
|
||||
m_owner->m_parser->InitParserState();
|
||||
|
||||
FOOTPRINT* footprint = (FOOTPRINT*) m_owner->m_parser->Parse();
|
||||
wxString fpName = fn.GetName();
|
||||
|
|
|
@ -637,6 +637,9 @@ BOARD_ITEM* PCB_PARSER::Parse()
|
|||
|
||||
token = CurTok();
|
||||
|
||||
if( token == -1 ) // EOF
|
||||
Unexpected( token );
|
||||
|
||||
if( token != T_LEFT )
|
||||
Expecting( T_LEFT );
|
||||
|
||||
|
|
Loading…
Reference in New Issue