Add a few more overbar syntax conversion calls.

Fixes https://gitlab.com/kicad/code/kicad/issues/8606
This commit is contained in:
Jeff Young 2021-06-15 13:08:26 +01:00
parent fbbe723811
commit 4418707e5e
3 changed files with 46 additions and 18 deletions

View File

@ -61,4 +61,5 @@
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210125 // R/W uuids for pins, labels, wires, etc. //#define SEXPR_SCHEMATIC_FILE_VERSION 20210125 // R/W uuids for pins, labels, wires, etc.
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210126 // Fix bug with writing pin uuids. //#define SEXPR_SCHEMATIC_FILE_VERSION 20210126 // Fix bug with writing pin uuids.
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210406 // Add schematic level uuids. //#define SEXPR_SCHEMATIC_FILE_VERSION 20210406 // Add schematic level uuids.
#define SEXPR_SCHEMATIC_FILE_VERSION 20210606 // Change overbar syntax from `~...~` to `~{...}`. //#define SEXPR_SCHEMATIC_FILE_VERSION 20210606 // Change overbar syntax from `~...~` to `~{...}`.
#define SEXPR_SCHEMATIC_FILE_VERSION 20210615 // Update overbar syntax in net names

View File

@ -295,8 +295,8 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText )
wxCHECK_RET( CurTok() == T_effects, wxCHECK_RET( CurTok() == T_effects,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as EDA_TEXT." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as EDA_TEXT." ) );
// In version 20210606 the notation for overbars was changed from `~...~` to `~{...}`. We need to convert // In version 20210606 the notation for overbars was changed from `~...~` to `~{...}`.
// the old syntax to the new one. // We need to convert the old syntax to the new one.
if( m_requiredVersion < 20210606 ) if( m_requiredVersion < 20210606 )
aText->SetText( ConvertToNewOverbarNotation( aText->GetText() ) ); aText->SetText( ConvertToNewOverbarNotation( aText->GetText() ) );
@ -2092,6 +2092,11 @@ void PCB_PARSER::parseNETINFO_ITEM()
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
wxString name = FromUTF8(); wxString name = FromUTF8();
// Convert overbar syntax from `~...~` to `~{...}`. These were left out of the first merge
// so the version is a bit later.
if( m_requiredVersion < 20210615 )
name = ConvertToNewOverbarNotation( name );
NeedRIGHT(); NeedRIGHT();
// net 0 should be already in list, so store this net // net 0 should be already in list, so store this net
@ -2166,7 +2171,14 @@ void PCB_PARSER::parseNETCLASS()
case T_add_net: case T_add_net:
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
nc->Add( FromUTF8() );
// Convert overbar syntax from `~...~` to `~{...}`. These were left out of the
// first merge so the version is a bit later.
if( m_requiredVersion < 20210615 )
nc->Add( ConvertToNewOverbarNotation( FromUTF8() ) );
else
nc->Add( FromUTF8() );
break; break;
default: default:
@ -3968,17 +3980,26 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
// Test validity of the netname in file for netcodes expected having a net name // Test validity of the netname in file for netcodes expected having a net name
if( m_board && pad->GetNetCode() > 0 && if( m_board && pad->GetNetCode() > 0 )
FromUTF8() != m_board->FindNet( pad->GetNetCode() )->GetNetname() )
{ {
pad->SetNetCode( NETINFO_LIST::ORPHANED, /* aNoAssert */ true ); wxString netName( FromUTF8() );
wxLogError( wxString::Format( _( "Net name doesn't match net ID in\n"
"file: '%s'\n" // Convert overbar syntax from `~...~` to `~{...}`. These were left out of the
"line: %d\n" // first merge so the version is a bit later.
"offset: %d" ), if( m_requiredVersion < 20210615 )
CurSource(), netName = ConvertToNewOverbarNotation( netName );
CurLineNumber(),
CurOffset() ) ); if( netName != m_board->FindNet( pad->GetNetCode() )->GetNetname() )
{
pad->SetNetCode( NETINFO_LIST::ORPHANED, /* aNoAssert */ true );
wxLogError( wxString::Format( _( "Net name doesn't match net ID in\n"
"file: '%s'\n"
"line: %d\n"
"offset: %d" ),
CurSource(),
CurLineNumber(),
CurOffset() ) );
}
} }
NeedRIGHT(); NeedRIGHT();

View File

@ -1541,8 +1541,10 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
ReadDelimitedText( buf, data, sizeof(buf) ); ReadDelimitedText( buf, data, sizeof(buf) );
if( m_board ) if( m_board )
{
wxASSERT( m_board->FindNet( getNetCode( netcode ) )->GetNetname() wxASSERT( m_board->FindNet( getNetCode( netcode ) )->GetNetname()
== FROM_UTF8( StrPurge( buf ) ) ); == ConvertToNewOverbarNotation( FROM_UTF8( StrPurge( buf ) ) ) );
}
} }
else if( TESTLINE( "Po" ) ) // (Po)sition else if( TESTLINE( "Po" ) ) // (Po)sition
@ -1791,6 +1793,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( FP_TEXT* aText )
txt_end = data + ReadDelimitedText( &m_field, data ); txt_end = data + ReadDelimitedText( &m_field, data );
m_field.Replace( "%V", "${VALUE}" ); m_field.Replace( "%V", "${VALUE}" );
m_field.Replace( "%R", "${REFERENCE}" ); m_field.Replace( "%R", "${REFERENCE}" );
m_field = ConvertToNewOverbarNotation( m_field );
aText->SetText( m_field ); aText->SetText( m_field );
// after switching to strtok, there's no easy coming back because of the // after switching to strtok, there's no easy coming back because of the
@ -2039,7 +2042,10 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM()
ReadDelimitedText( buf, data, sizeof(buf) ); ReadDelimitedText( buf, data, sizeof(buf) );
if( net == NULL ) if( net == NULL )
net = new NETINFO_ITEM( m_board, FROM_UTF8( buf ), netCode ); {
net = new NETINFO_ITEM( m_board, ConvertToNewOverbarNotation( FROM_UTF8( buf ) ),
netCode );
}
else else
{ {
THROW_IO_ERROR( "Two net definitions in '$EQUIPOT' block" ); THROW_IO_ERROR( "Two net definitions in '$EQUIPOT' block" );
@ -2114,7 +2120,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
if( TESTLINE( "Te" ) ) // Text line (or first line for multi line texts) if( TESTLINE( "Te" ) ) // Text line (or first line for multi line texts)
{ {
ReadDelimitedText( text, line + SZ( "Te" ), sizeof(text) ); ReadDelimitedText( text, line + SZ( "Te" ), sizeof(text) );
pcbtxt->SetText( FROM_UTF8( text ) ); pcbtxt->SetText( ConvertToNewOverbarNotation( FROM_UTF8( text ) ) );
} }
else if( TESTLINE( "nl" ) ) // next line of the current text else if( TESTLINE( "nl" ) ) // next line of the current text
@ -2352,7 +2358,7 @@ void LEGACY_PLUGIN::loadNETCLASS()
{ {
// e.g. "AddNet "V3.3D"\n" // e.g. "AddNet "V3.3D"\n"
ReadDelimitedText( buf, line + SZ( "AddNet" ), sizeof(buf) ); ReadDelimitedText( buf, line + SZ( "AddNet" ), sizeof(buf) );
netname = FROM_UTF8( buf ); netname = ConvertToNewOverbarNotation( FROM_UTF8( buf ) );
nc->Add( netname ); nc->Add( netname );
} }