From e86fc64e7d4e2b45e52960b7423bfe130de63247 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 31 Jul 2020 23:56:42 +0100 Subject: [PATCH] Check envvars as well before flagging as un-resolved. Fixes https://gitlab.com/kicad/code/kicad/issues/4644 --- common/common.cpp | 2 +- eeschema/erc.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index ab5204241c..745859dfec 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -482,7 +482,7 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject ) size_t m = n + 1; wxUniChar str_m = str[m]; - while( m < strlen && ( wxIsalnum( str_m ) || str_m == wxT( '_' ) ) ) + while( m < strlen && ( wxIsalnum( str_m ) || str_m == wxT( '_' ) || str_m == wxT( ':' ) ) ) str_m = str[++m]; wxString strVarName( str.c_str() + n + 1, m - n - 1 ); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 91113a7fd0..e8b7fe689a 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -148,6 +148,12 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet ) { WS_DRAW_ITEM_LIST wsItems; + auto unresolved = [this]( wxString str ) + { + str = ExpandEnvVarSubstitutions( str, &m_schematic->Prj() ); + return str.Matches( wxT( "*${*}*" ) ); + }; + if( aWorksheet ) { wsItems.SetMilsToIUfactor( IU_PER_MILS ); @@ -166,7 +172,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet ) for( SCH_FIELD& field : component->GetFields() ) { - if( field.GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( unresolved( field.GetShownText() ) ) { wxPoint pos = field.GetPosition() - component->GetPosition(); pos = component->GetTransform().TransformCoordinate( pos ); @@ -186,7 +192,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet ) for( SCH_FIELD& field : sheet->GetFields() ) { - if( field.GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( unresolved( field.GetShownText() ) ) { ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); ercItem->SetItems( &field );