Simplify fp-info-cache escaping mechanism.

Fixes https://gitlab.com/kicad/code/kicad/issues/4969
This commit is contained in:
Jeff Young 2020-08-04 23:53:40 +01:00
parent 9cc6a77cc0
commit 0e9714fdba
3 changed files with 5 additions and 11 deletions

View File

@ -82,15 +82,9 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
else
converted += c;
}
else if( aContext == CTX_DELIMITED_STR )
else if( aContext == CTX_LINE )
{
if( c == '{' )
converted += "{brace}";
else if( c == ' ' )
converted += "{space}";
else if( c == '\t' )
converted += "{tab}";
else if( c == '\n' || c == '\r' )
if( c == '\n' || c == '\r' )
converted += "{return}";
else
converted += c;

View File

@ -47,7 +47,7 @@ enum ESCAPE_CONTEXT
CTX_NETNAME,
CTX_LIBID,
CTX_QUOTED_STR,
CTX_DELIMITED_STR,
CTX_LINE,
CTX_FILENAME
};

View File

@ -359,8 +359,8 @@ void FOOTPRINT_LIST_IMPL::WriteCacheToFile( wxTextFile* aCacheFile )
{
aCacheFile->AddLine( fpinfo->GetLibNickname() );
aCacheFile->AddLine( fpinfo->GetName() );
aCacheFile->AddLine( EscapeString( fpinfo->GetDescription(), CTX_DELIMITED_STR ) );
aCacheFile->AddLine( EscapeString( fpinfo->GetKeywords(), CTX_DELIMITED_STR ) );
aCacheFile->AddLine( EscapeString( fpinfo->GetDescription(), CTX_LINE ) );
aCacheFile->AddLine( EscapeString( fpinfo->GetKeywords(), CTX_LINE ) );
aCacheFile->AddLine( wxString::Format( "%d", fpinfo->GetOrderNum() ) );
aCacheFile->AddLine( wxString::Format( "%u", fpinfo->GetPadCount() ) );
aCacheFile->AddLine( wxString::Format( "%u", fpinfo->GetUniquePadCount() ) );