Commit 9634fa5c authored by Dick Hollenbeck's avatar Dick Hollenbeck

fix 2 corner case bugs in specctra import

parent a26e59d8
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <cctype> #include <cctype>
#include <macros.h> #include <macros.h>
#include <fctsys.h>
#include <dsnlexer.h> #include <dsnlexer.h>
//#include "fctsys.h" //#include "fctsys.h"
...@@ -60,6 +61,8 @@ void DSNLEXER::init() ...@@ -60,6 +61,8 @@ void DSNLEXER::init()
space_in_quoted_tokens = false; space_in_quoted_tokens = false;
commentsAreTokens = false; commentsAreTokens = false;
D(printf( "readerStack::count:%zu\n", readerStack.size() );)
} }
...@@ -102,6 +105,8 @@ DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, ...@@ -102,6 +105,8 @@ DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount,
DSNLEXER::~DSNLEXER() DSNLEXER::~DSNLEXER()
{ {
D(printf( "~readerStack::count:%zu\n", readerStack.size() );)
if( iOwnReaders ) if( iOwnReaders )
{ {
// delete the LINE_READERs from the stack, since I own them. // delete the LINE_READERs from the stack, since I own them.
......
...@@ -744,7 +744,7 @@ T PCB_PARSER::lookUpLayer( const M& aMap ) throw( PARSE_ERROR, IO_ERROR ) ...@@ -744,7 +744,7 @@ T PCB_PARSER::lookUpLayer( const M& aMap ) throw( PARSE_ERROR, IO_ERROR )
if( it == aMap.end() ) if( it == aMap.end() )
{ {
#if 1 && defined(DEBUG) #if 0 && defined(DEBUG)
// dump the whole darn table, there's something wrong with it. // dump the whole darn table, there's something wrong with it.
for( it = aMap.begin(); it != aMap.end(); ++it ) for( it = aMap.begin(); it != aMap.end(); ++it )
{ {
......
...@@ -1870,27 +1870,29 @@ void SPECCTRA_DB::doPLACEMENT( PLACEMENT* growth ) throw( IO_ERROR ) ...@@ -1870,27 +1870,29 @@ void SPECCTRA_DB::doPLACEMENT( PLACEMENT* growth ) throw( IO_ERROR )
{ {
T tok; T tok;
NeedLEFT(); while( (tok = NextTok()) != T_RIGHT )
{
if( tok == T_EOF )
Unexpected( T_EOF );
if( tok != T_LEFT )
Expecting( T_LEFT );
tok = NextTok(); tok = NextTok();
if( tok==T_unit || tok==T_resolution )
switch( tok )
{ {
case T_unit:
case T_resolution:
growth->unit = new UNIT_RES( growth, tok ); growth->unit = new UNIT_RES( growth, tok );
if( tok==T_resolution ) if( tok==T_resolution )
doRESOLUTION( growth->unit ); doRESOLUTION( growth->unit );
else else
doUNIT( growth->unit ); doUNIT( growth->unit );
break;
if( NextTok() != T_LEFT ) case T_place_control:
Expecting( T_LEFT ); NeedRIGHT();
tok = NextTok();
}
if( tok == T_place_control )
{
if( NextTok() != T_LEFT )
Expecting( T_LEFT );
tok = NextTok(); tok = NextTok();
if( tok != T_flip_style ) if( tok != T_flip_style )
Expecting( T_flip_style ); Expecting( T_flip_style );
...@@ -1899,29 +1901,23 @@ void SPECCTRA_DB::doPLACEMENT( PLACEMENT* growth ) throw( IO_ERROR ) ...@@ -1899,29 +1901,23 @@ void SPECCTRA_DB::doPLACEMENT( PLACEMENT* growth ) throw( IO_ERROR )
if( tok==T_mirror_first || tok==T_rotate_first ) if( tok==T_mirror_first || tok==T_rotate_first )
growth->flip_style = tok; growth->flip_style = tok;
else else
Expecting("mirror_first|rotate_first"); Expecting( "mirror_first|rotate_first" );
NeedRIGHT(); NeedRIGHT();
NeedRIGHT(); NeedRIGHT();
NeedLEFT(); break;
tok = NextTok();
}
while( tok == T_component ) case T_component:
{ COMPONENT* component;
COMPONENT* component = new COMPONENT( growth ); component = new COMPONENT( growth );
growth->components.push_back( component ); growth->components.push_back( component );
doCOMPONENT( component ); doCOMPONENT( component );
break;
tok = NextTok(); default:
if( tok == T_RIGHT ) Unexpected( tok );
return; }
else if( tok == T_LEFT )
tok = NextTok();
} }
Unexpected( CurText() );
} }
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -3796,7 +3796,9 @@ public: ...@@ -3796,7 +3796,9 @@ public:
SPECCTRA_DB() : SPECCTRA_DB() :
SPECCTRA_LEXER( 0 ) // LINE_READER* == NULL, no DSNLEXER::PushReader() SPECCTRA_LEXER( 0 ) // LINE_READER* == NULL, no DSNLEXER::PushReader()
{ {
iOwnReaders = true; // if an exception is thrown, close file. // The LINE_READER will be pushed from an automatic instantiation,
// we don't own it:
wxASSERT( !iOwnReaders );
pcb = 0; pcb = 0;
session = 0; session = 0;
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -94,7 +94,6 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) ...@@ -94,7 +94,6 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
return; return;
SPECCTRA_DB db; SPECCTRA_DB db;
LOCALE_IO toggle; LOCALE_IO toggle;
try try
...@@ -118,7 +117,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) ...@@ -118,7 +117,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
/* At this point we should call Compile_Ratsnest() /* At this point we should call Compile_Ratsnest()
* but this could be time consumming. * but this could be time consumming.
* So if incorrect number of Connecred and No connected pads is accepted * So if incorrect number of Connected and No connected pads is accepted
* until Compile_Ratsnest() is called (when track tool selected for instance) * until Compile_Ratsnest() is called (when track tool selected for instance)
* leave the next line commented * leave the next line commented
* Otherwise uncomment this line * Otherwise uncomment this line
...@@ -377,7 +376,6 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet ...@@ -377,7 +376,6 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
} }
// no UI code in this function, throw exception to report problems to the // no UI code in this function, throw exception to report problems to the
// UI handler: void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) // UI handler: void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
......
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