lib symbols: make fp filter tolerant to spaces in names.

For historical reasons they are stored in a string using spaces as separators.
So each fp filter is now escaped to remove spaces (replaced by {space})
Fixes #9009
https://gitlab.com/kicad/code/kicad/issues/9009
This commit is contained in:
jean-pierre charras 2021-08-23 17:59:36 +02:00
parent 9f22baf109
commit 4ac2aa675a
4 changed files with 20 additions and 4 deletions

View File

@ -211,6 +211,15 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
else else
converted += c; converted += c;
} }
else if( aContext == CTX_NO_SPACE )
{
if( c == ' ' )
converted += "{space}";
else if( c == '{' )
converted += "{brace}";
else
converted += c;
}
else else
converted += c; converted += c;
} }

View File

@ -851,7 +851,10 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol
wxStringTokenizer tokenizer( value ); wxStringTokenizer tokenizer( value );
while( tokenizer.HasMoreTokens() ) while( tokenizer.HasMoreTokens() )
filters.Add( tokenizer.GetNextToken() ); {
wxString curr_token = UnescapeString( tokenizer.GetNextToken() );
filters.Add( curr_token );
}
aSymbol->SetFPFilters( filters ); aSymbol->SetFPFilters( filters );
return nullptr; return nullptr;

View File

@ -1750,10 +1750,13 @@ void SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFOR
for( auto filter : fpFilters ) for( auto filter : fpFilters )
{ {
// Spaces are not handled in fp filter names so escape spaces if any
wxString curr_filter = EscapeString( filter, ESCAPE_CONTEXT::CTX_NO_SPACE );
if( tmp.IsEmpty() ) if( tmp.IsEmpty() )
tmp = filter; tmp = curr_filter;
else else
tmp += " " + filter; tmp += " " + curr_filter;
} }
LIB_FIELD description( -1, wxString( "ki_fp_filters" ) ); LIB_FIELD description( -1, wxString( "ki_fp_filters" ) );

View File

@ -55,7 +55,8 @@ enum ESCAPE_CONTEXT
CTX_LIBID, CTX_LIBID,
CTX_QUOTED_STR, CTX_QUOTED_STR,
CTX_LINE, CTX_LINE,
CTX_FILENAME CTX_FILENAME,
CTX_NO_SPACE // to replace spaces in names that do not accept spaces
}; };
/** /**