diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index 47a6d7c4bc..b21a79eb7d 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -148,6 +148,34 @@ void DSNLEXER::SetSpecctraMode( bool aMode ) } } + +bool DSNLEXER::SyncLineReaderWith( DSNLEXER& aLexer ) +{ + // Synchronize the pointers handling the data read by the LINE_READER + // only if aLexer shares the same LINE_READER, because only in this case + // the char buffer can be common + + if( reader != aLexer.reader ) + return false; + + // Be sure the char buffer is common + if( reader->Line() != aLexer.reader->Line() ) + return false; + + // We can synchronize the pointers which handle the data currently read + start = aLexer.start; + next = aLexer.next; + limit = aLexer.limit; + + // Sync these parameters is not mandatory, but could help + // for instance in debug + curText = aLexer.curText; + curOffset = aLexer.curOffset; + + return true; +} + + void DSNLEXER::PushReader( LINE_READER* aLineReader ) { readerStack.push_back( aLineReader ); diff --git a/include/dsnlexer.h b/include/dsnlexer.h index b6f3a87516..6384e47790 100644 --- a/include/dsnlexer.h +++ b/include/dsnlexer.h @@ -71,7 +71,7 @@ enum DSN_SYNTAX_T { /** - * Class DLEXER + * Class DSNLEXER * implements a lexical analyzer for the SPECCTRA DSN file format. It * reads lexical tokens from the current LINE_READER through the NextTok() * function. @@ -215,6 +215,16 @@ public: virtual ~DSNLEXER(); + /** + * Useable only for DSN lexers which share the same LINE_READER + * Synchronizes the pointers handling the data read by the LINE_READER + * Allows 2 DNSLEXER to share the same current line, when switching from a + * DNSLEXER to an other DNSLEXER + * @param aLexer = the model + * @return true if the sync can be made ( at least the same line reader ) + */ + bool SyncLineReaderWith( DSNLEXER& aLexer ); + /** * Function SetSpecctraMode * changes the behavior of this lexer into or out of "specctra mode". If diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 0d53ff9263..1cfc1fb08e 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -1135,12 +1135,14 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) { PCB_PLOT_PARAMS plotParams; PCB_PLOT_PARAMS_PARSER parser( reader ); + // parser must share the same current line as our current PCB parser + // synchronize it. + parser.SyncLineReaderWith( *this ); plotParams.Parse( &parser ); - m_board->SetPlotOptions( plotParams ); + SyncLineReaderWith( parser ); - // I don't know why but this seems to fix a problem in PCB_PLOT_PARAMS::Parse(). - NextTok(); + m_board->SetPlotOptions( plotParams ); } break; diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp index 4855a89c1e..1e04a8b6c5 100644 --- a/pcbnew/pcb_plot_params.cpp +++ b/pcbnew/pcb_plot_params.cpp @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +//#include #include #include #include