Reverse commit 4011ed4e31.

This commit was too broad and not cognizant of the purpose of the class
UTF8.

Add MAYBE_VERIFY_UTF8() macro, which can trap non-UTF8 encoded strings in
debug builds.

Use that macro conditionally in class UTF8 to trap non-UTF8 encoded strings
being put into UTF8 instances.
This commit is contained in:
Dick Hollenbeck 2017-07-24 14:02:59 -05:00 committed by Wayne Stambaugh
parent 161045f17d
commit 4e7de8a761
36 changed files with 207 additions and 143 deletions

View File

@ -59,12 +59,12 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
{
LIB_ID fpid;
wxCHECK_MSG( fpid.Parse( TO_UTF8( aFootprintName ) ) < 0, NULL,
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
wxString::Format(
"'%s' is not a valid LIB_ID.", aFootprintName ) );
wxT( "'%s' is not a valid LIB_ID." ), GetChars( aFootprintName ) ) );
wxString libNickname = FROM_UTF8( fpid.GetLibNickname() );
wxString footprintName = FROM_UTF8( fpid.GetLibItemName() );
wxString libNickname = fpid.GetLibNickname();
wxString footprintName = fpid.GetLibItemName();
if( libNickname == fp->GetNickname() && footprintName == fp->GetFootprintName() )
return &*fp;

View File

@ -26,7 +26,6 @@
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <kiface_i.h>
#include <footprint_info.h>
#include <lib_id.h>
@ -287,12 +286,12 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString&
LIB_ID& fpid = (LIB_ID&) ret->GetFPID();
// Catch any misbehaving plugin, which should be setting internal footprint name properly:
wxASSERT( aFootprintName == FROM_UTF8( fpid.GetLibItemName() ) );
wxASSERT( aFootprintName == (wxString) fpid.GetLibItemName() );
// and clearing nickname
wxASSERT( !fpid.GetLibNickname().size() );
fpid.SetLibNickname( TO_UTF8( row->GetNickName() ) );
fpid.SetLibNickname( row->GetNickName() );
}
return ret;
@ -310,7 +309,7 @@ FP_LIB_TABLE::SAVE_T FP_LIB_TABLE::FootprintSave( const wxString& aNickname,
// Try loading the footprint to see if it already exists, caller wants overwrite
// protection, which is atypical, not the default.
wxString fpname = FROM_UTF8( aFootprint->GetFPID().GetLibItemName() );
wxString fpname = aFootprint->GetFPID().GetLibItemName();
std::unique_ptr<MODULE> footprint( row->plugin->FootprintLoad( row->GetFullURI( true ),
fpname, row->GetProperties() ) );
@ -360,8 +359,8 @@ void FP_LIB_TABLE::FootprintLibCreate( const wxString& aNickname )
MODULE* FP_LIB_TABLE::FootprintLoadWithOptionalNickname( const LIB_ID& aFootprintId )
{
wxString nickname = FROM_UTF8( aFootprintId.GetLibNickname() );
wxString fpname = FROM_UTF8( aFootprintId.GetLibItemName() );
wxString nickname = aFootprintId.GetLibNickname();
wxString fpname = aFootprintId.GetLibItemName();
if( nickname.size() )
{

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2010-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2010-2016 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -169,7 +169,7 @@ int LIB_ID::Parse( const UTF8& aId )
// Some chars can be found in legacy files converted files from an other EDA tools.
std::string fpname = aId.substr( partNdx, revNdx-partNdx );
ReplaceIllegalFileNameChars( &fpname, '_' );
SetLibItemName( fpname );
SetLibItemName( UTF8( fpname ) );
return -1;
}
@ -192,7 +192,7 @@ LIB_ID::LIB_ID( const std::string& aId )
LIB_ID::LIB_ID( const wxString& aId )
{
UTF8 id = TO_UTF8( aId );
UTF8 id = aId;
int offset = Parse( id );
@ -209,9 +209,9 @@ LIB_ID::LIB_ID( const wxString& aId )
LIB_ID::LIB_ID( const wxString& aLibName, const wxString& aLibItemName,
const wxString& aRevision ) :
nickname( TO_UTF8( aLibName ) ),
item_name( TO_UTF8( aLibItemName ) ),
revision( TO_UTF8( aRevision ) )
nickname( aLibName ),
item_name( aLibItemName ),
revision( aRevision )
{
}

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2013-2017 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013-2017 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -23,6 +23,7 @@
*/
#include <utf8.h>
#include <ki_exception.h>
/* THROW_IO_ERROR needs this, but it includes this file, so until some
factoring of THROW_IO_ERROR into a separate header, defer and use the asserts.
@ -31,6 +32,7 @@
#include <assert.h>
/*
These are not inlined so that code space is saved by encapsulating the
creation of intermediate objects and the referencing of wxConvUTF8.
@ -56,10 +58,6 @@ UTF8& UTF8::operator=( const wxString& o )
}
#ifndef THROW_IO_ERROR
#define THROW_IO_ERROR(x) // nothing
#endif
// There is no wxWidgets function that does this, because wchar_t is 16 bits
// on windows and wx wants to encode the output in UTF16 for such.
@ -117,7 +115,7 @@ int UTF8::uni_forward( const unsigned char* aSequence, unsigned* aResult )
ch = ((s[0] & 0x1f) << 6) +
((s[1] & 0x3f) << 0);
assert( ch > 0x007F && ch <= 0x07FF );
// assert( ch > 0x007F && ch <= 0x07FF );
break;
case 3:
@ -134,7 +132,7 @@ int UTF8::uni_forward( const unsigned char* aSequence, unsigned* aResult )
((s[1] & 0x3f) << 6 ) +
((s[2] & 0x3f) << 0 );
assert( ch > 0x07FF && ch <= 0xFFFF );
// assert( ch > 0x07FF && ch <= 0xFFFF );
break;
case 4:
@ -152,7 +150,7 @@ int UTF8::uni_forward( const unsigned char* aSequence, unsigned* aResult )
((s[2] & 0x3f) << 6 ) +
((s[3] & 0x3f) << 0 );
assert( ch > 0xFFFF && ch <= 0x10ffff );
// assert( ch > 0xFFFF && ch <= 0x10ffff );
break;
}
@ -163,6 +161,36 @@ int UTF8::uni_forward( const unsigned char* aSequence, unsigned* aResult )
}
bool IsUTF8( const char* aString )
{
int len = strlen( aString );
if( len )
{
const unsigned char* next = (unsigned char*) aString;
const unsigned char* end = next + len;
try
{
while( next < end )
{
next += UTF8::uni_forward( next, NULL );
}
// uni_forward() should find the exact end if it is truly UTF8
if( next > end )
return false;
}
catch( const IO_ERROR& ioe )
{
return false;
}
}
return true;
}
UTF8::UTF8( const wchar_t* txt ) :
// size initial string safely large enough, then shrink to known size later.
std::string( wcslen( txt ) * 4, 0 )

View File

@ -446,7 +446,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
LIB_ID fpid;
if( fpid.Parse( TO_UTF8( aFootprintName ) ) >= 0 )
if( fpid.Parse( aFootprintName ) >= 0 )
{
DisplayInfoMessage( this, wxString::Format( wxT( "Footprint ID <%s> is not valid." ),
GetChars( aFootprintName ) ) );

View File

@ -104,7 +104,7 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName, int aIndex )
if( !aFootprintName.IsEmpty() )
{
wxCHECK_RET( fpid.Parse( TO_UTF8( aFootprintName ) ) < 0,
wxCHECK_RET( fpid.Parse( aFootprintName ) < 0,
wxString::Format( wxT( "<%s> is not a valid LIB_ID." ),
GetChars( aFootprintName ) ) );
}
@ -143,7 +143,7 @@ static int guessNickname( FP_LIB_TABLE* aTbl, LIB_ID* aFootprintId )
return 0;
wxString nick;
wxString fpname = FROM_UTF8( aFootprintId->GetLibItemName() );
wxString fpname = aFootprintId->GetLibItemName();
std::vector<wxString> nicks = aTbl->GetLogicalLibs();
@ -168,7 +168,7 @@ static int guessNickname( FP_LIB_TABLE* aTbl, LIB_ID* aFootprintId )
if( nick.size() )
{
aFootprintId->SetLibNickname( TO_UTF8( nick ) );
aFootprintId->SetLibNickname( nick );
return 0;
}
@ -248,7 +248,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist )
msg += wxString::Format( _(
"Component '%s' footprint '%s' was <b>not found</b> in any library.\n" ),
GetChars( component->GetReference() ),
GetChars( FROM_UTF8( component->GetFPID().GetLibItemName() ) )
GetChars( component->GetFPID().GetLibItemName() )
);
break;
@ -256,7 +256,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist )
msg += wxString::Format( _(
"Component '%s' footprint '%s' was found in <b>multiple</b> libraries.\n" ),
GetChars( component->GetReference() ),
GetChars( FROM_UTF8( component->GetFPID().GetLibItemName() ) )
GetChars( component->GetFPID().GetLibItemName() )
);
break;
}
@ -337,8 +337,8 @@ bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist )
{
COMPONENT* component = m_netlist.GetComponent( m_indexes[ii] );
wxString cmpfpid = FROM_UTF8( component->GetFPID().Format() );
wxString schfpid = FROM_UTF8( component->GetAltFPID().Format() );
wxString cmpfpid = component->GetFPID().Format();
wxString schfpid = component->GetAltFPID().Format();
dlg.Add( component->GetReference(), schfpid, cmpfpid );
}

View File

@ -403,7 +403,7 @@ LIB_PART* PART_LIBS::FindLibPart( const LIB_ID& aLibId, const wxString& aLibrary
if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
continue;
part = lib.FindPart( FROM_UTF8( aLibId.GetLibItemName() ) );
part = lib.FindPart( aLibId.GetLibItemName() );
if( part )
break;
@ -422,7 +422,7 @@ LIB_ALIAS* PART_LIBS::FindLibraryAlias( const LIB_ID& aLibId, const wxString& aL
if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
continue;
entry = lib.FindAlias( FROM_UTF8( aLibId.GetLibItemName() ) );
entry = lib.FindAlias( aLibId.GetLibItemName() );
if( entry )
break;

View File

@ -343,7 +343,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
tmp.Replace( wxT( " " ), wxT( "_" ) );
id.SetLibItemName( TO_UTF8( tmp ), false );
id.SetLibItemName( tmp, false );
// Save current flags which could be modified by next change settings
STATUS_FLAGS flags = m_cmp->GetFlags();
@ -359,7 +359,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
if( libs->FindLibraryAlias( id ) == NULL )
{
wxString msg = wxString::Format( _( "Component '%s' not found!" ),
GetChars( FROM_UTF8( id.Format() ) ) );
GetChars( id.Format() ) );
DisplayError( this, msg );
}
else // Change component from lib!
@ -1096,7 +1096,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
convertCheckBox->Enable( false );
// Set the component's library name.
chipnameTextCtrl->SetValue( FROM_UTF8( m_cmp->GetLibId().Format() ) );
chipnameTextCtrl->SetValue( m_cmp->GetLibId().Format() );
// Set the component's unique ID time stamp.
m_textCtrlTimeStamp->SetValue( wxString::Format( wxT( "%8.8lX" ),

View File

@ -8,7 +8,7 @@
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2016 Wayne Stambaugh, stambaughw@gmail.com
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -280,8 +280,7 @@ DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent,
const LIB_PART* part = GetParent()->Prj().SchLibs()->FindLibPart( component->GetLibId() );
wxASSERT_MSG( part, wxT( "Library part for component <" ) +
FROM_UTF8( component->GetLibId().Format() ) +
wxT( "> could not be found." ) );
component->GetLibId().Format() + wxT( "> could not be found." ) );
m_isPower = part->IsPower();

View File

@ -159,7 +159,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
int count = 0;
for( SCH_COMPONENT* each_component : *m_Rescuer->GetComponents() )
{
if( each_component->GetLibId().Format() != TO_UTF8( selected_part.GetRequestedName() ) )
if( each_component->GetLibId().Format() != UTF8( selected_part.GetRequestedName() ) )
continue;
SCH_FIELD* valueField = each_component->GetField( 1 );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2017 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -55,8 +55,7 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField )
LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetLibId() );
wxCHECK_RET( part, wxT( "Library part for component <" ) +
FROM_UTF8( component->GetLibId().GetLibItemName() ) +
wxT( "> could not be found." ) );
component->GetLibId().GetLibItemName() + wxT( "> could not be found." ) );
// Save old component in undo list if not already in edit, or moving.
if( aField->GetFlags() == 0 )

View File

@ -236,7 +236,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component(
// alias exists because its root component was found
LIB_ID libId;
libId.SetLibItemName( TO_UTF8( sel.Name ), false );
libId.SetLibItemName( sel.Name, false );
component->SetLibId( libId );
// Be sure the link to the corresponding LIB_PART is OK:

View File

@ -89,7 +89,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
if( !archLib->FindAlias( FROM_UTF8( component->GetLibId().GetLibItemName() ) ) )
if( !archLib->FindAlias( component->GetLibId().GetLibItemName() ) )
{
LIB_PART* part = NULL;
@ -106,7 +106,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
catch( ... /* IO_ERROR ioe */ )
{
msg.Printf( _( "Failed to add symbol %s to library file '%s'" ),
FROM_UTF8( component->GetLibId().GetLibItemName() ), aFileName );
wxString( component->GetLibId().GetLibItemName() ), aFileName );
DisplayError( this, msg );
return false;
}

View File

@ -242,7 +242,7 @@ XNODE* NETLIST_EXPORTER_GENERIC::makeComponents()
xlibsource->AddAttribute( "lib", part->GetLib()->GetLogicalName() );
// We only want the symbol name, not the full LIB_ID.
xlibsource->AddAttribute( "part", FROM_UTF8( comp->GetLibId().GetLibItemName() ) );
xlibsource->AddAttribute( "part", comp->GetLibId().GetLibItemName() );
XNODE* xsheetpath;

View File

@ -1,7 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2015-2017 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -263,7 +264,7 @@ public:
for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) )
{
wxString part_name( FROM_UTF8( each_component->GetLibId().GetLibItemName() ) );
wxString part_name( each_component->GetLibId().GetLibItemName() );
if( last_part_name != part_name )
{
@ -326,12 +327,12 @@ public:
{
for( SCH_COMPONENT* each_component : *aRescuer->GetComponents() )
{
if( each_component->GetLibId().GetLibItemName() != TO_UTF8( m_requested_name ) )
if( each_component->GetLibId().GetLibItemName() != UTF8( m_requested_name ) )
continue;
LIB_ID libId;
libId.SetLibItemName( TO_UTF8( m_new_name ), false );
libId.SetLibItemName( m_new_name, false );
each_component->SetLibId( libId );
each_component->ClearFlags();
aRescuer->LogRescue( each_component, m_requested_name, m_new_name );
@ -372,7 +373,7 @@ public:
for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) )
{
wxString part_name( FROM_UTF8( each_component->GetLibId().GetLibItemName() ) );
wxString part_name( each_component->GetLibId().GetLibItemName() );
if( old_part_name != part_name )
{
@ -461,12 +462,12 @@ public:
for( SCH_COMPONENT* each_component : *aRescuer->GetComponents() )
{
if( each_component->GetLibId().GetLibItemName() != TO_UTF8( m_requested_name ) )
if( each_component->GetLibId().GetLibItemName() != UTF8( m_requested_name ) )
continue;
LIB_ID libId;
libId.SetLibItemName( TO_UTF8( m_new_name ), false );
libId.SetLibItemName( m_new_name, false );
each_component->SetLibId( libId );
each_component->ClearFlags();
aRescuer->LogRescue( each_component, m_requested_name, m_new_name );
@ -542,7 +543,7 @@ void RESCUER::UndoRescues()
{
LIB_ID libId;
libId.SetLibItemName( TO_UTF8( each_logitem.old_name ), false );
libId.SetLibItemName( each_logitem.old_name, false );
each_logitem.component->SetLibId( libId );
each_logitem.component->ClearFlags();
}

View File

@ -1,7 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -133,7 +133,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
m_unit = unit;
m_convert = convert;
m_lib_id.SetLibItemName( TO_UTF8( aPart.GetName() ), false );
m_lib_id.SetLibItemName( aPart.GetName(), false );
m_part = aPart.SharedPtr();
m_currentSheetPath = NULL;
m_fieldsAutoplaced = AUTOPLACED_NO;
@ -193,7 +193,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
SetRef( sheet, msg );
// Use the schematic component name instead of the library value field name.
GetField( VALUE )->SetText( FROM_UTF8( GetLibId().GetLibItemName() ) );
GetField( VALUE )->SetText( GetLibId().GetLibItemName() );
}
@ -1246,7 +1246,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
name1 = toUTFTildaText( GetField( REFERENCE )->GetText() );
}
wxString part_name = FROM_UTF8( GetLibId().GetLibItemName() );
wxString part_name = GetLibId().GetLibItemName();
if( part_name.size() )
{
@ -1391,7 +1391,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( partname != NULL_STRING )
{
m_lib_id.SetLibItemName( TO_UTF8( partname ), false );
m_lib_id.SetLibItemName( partname, false );
if( !newfmt )
GetField( VALUE )->SetText( partname );
@ -1721,7 +1721,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
// part and alias can differ if alias is not the root
if( PART_SPTR part = m_part.lock() )
{
LIB_ALIAS* alias = part->GetAlias( FROM_UTF8( GetLibId().GetLibItemName() ) );
LIB_ALIAS* alias = part->GetAlias( GetLibId().GetLibItemName() );
if( !alias )
return;
@ -1736,8 +1736,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetShownText(), DARKCYAN ) );
// Display component reference in library and library
aList.push_back( MSG_PANEL_ITEM( _( "Component" ), FROM_UTF8( GetLibId().GetLibItemName() ),
BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Component" ), GetLibId().GetLibItemName(), BROWN ) );
if( alias->GetName() != part->GetName() )
aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), part->GetName(), BROWN ) );
@ -1982,8 +1981,7 @@ void SCH_COMPONENT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
{
wxCHECK_RET( 0,
wxT( "Cannot add connection points to list. Cannot find component <" ) +
FROM_UTF8( GetLibId().GetLibItemName() ) +
wxT( "> in any of the loaded libraries." ) );
GetLibId().GetLibItemName() + wxT( "> in any of the loaded libraries." ) );
}
}
@ -2006,7 +2004,7 @@ wxString SCH_COMPONENT::GetSelectMenuText() const
{
wxString tmp;
tmp.Printf( _( "Component %s, %s" ),
FROM_UTF8( GetLibId().GetLibItemName() ),
GetChars( GetLibId().GetLibItemName() ),
GetChars( GetField( REFERENCE )->GetShownText() ) );
return tmp;
}

View File

@ -1682,7 +1682,7 @@ void SCH_LEGACY_PLUGIN::saveComponent( SCH_COMPONENT* aComponent )
name1 = toUTFTildaText( aComponent->GetField( REFERENCE )->GetText() );
}
wxString part_name = FROM_UTF8( aComponent->GetLibId().GetLibItemName() );
wxString part_name = aComponent->GetLibId().GetLibItemName();
if( part_name.size() )
{

View File

@ -271,12 +271,12 @@ LIB_ALIAS* SYMBOL_LIB_TABLE::LoadSymbol( const wxString& aNickname, const wxStri
LIB_ID& id = (LIB_ID&) ret->GetPart()->GetLibId();
// Catch any misbehaving plugin, which should be setting internal alias name properly:
wxASSERT( aAliasName == FROM_UTF8( id.GetLibItemName() ) );
wxASSERT( aAliasName == (wxString) id.GetLibItemName() );
// and clearing nickname
wxASSERT( !id.GetLibNickname().size() );
id.SetLibNickname( TO_UTF8( row->GetNickName() ) );
id.SetLibNickname( row->GetNickName() );
}
return ret;
@ -294,7 +294,7 @@ SYMBOL_LIB_TABLE::SAVE_T SYMBOL_LIB_TABLE::SaveSymbol( const wxString& aNickname
// Try loading the footprint to see if it already exists, caller wants overwrite
// protection, which is atypical, not the default.
wxString name = FROM_UTF8( aSymbol->GetLibId().GetLibItemName() );
wxString name = aSymbol->GetLibId().GetLibItemName();
std::unique_ptr< LIB_ALIAS > symbol( row->plugin->LoadSymbol( row->GetFullURI( true ),
name,
@ -354,8 +354,8 @@ void SYMBOL_LIB_TABLE::CreateSymbolLib( const wxString& aNickname )
LIB_ALIAS* SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname( const LIB_ID& aLibId )
{
wxString nickname = FROM_UTF8( aLibId.GetLibNickname() );
wxString name = FROM_UTF8( aLibId.GetLibItemName() );
wxString nickname = aLibId.GetLibNickname();
wxString name = aLibId.GetLibItemName();
if( nickname.size() )
{

View File

@ -28,6 +28,26 @@
#include <string>
#include <wx/string.h>
#if defined(DEBUG)
#define UTF8_VERIFY // Might someday be a hidden cmake config option
#endif
/**
* Function IsUTF8
* tests a c-string to see if it is UTF8 encoded. BTW an ASCII string is a valid
* UTF8 string.
*/
bool IsUTF8( const char* aString );
#if defined(UTF8_VERIFY)
#define MAYBE_VERIFY_UTF8(x) wxASSERT( IsUTF8(x) )
#else
#define MAYBE_VERIFY_UTF8(x) // nothing
#endif
/**
* Class UTF8
* is an 8 bit std::string that is assuredly encoded in UTF8, and supplies special
@ -61,6 +81,7 @@ public:
UTF8( const char* txt ) :
std::string( txt )
{
MAYBE_VERIFY_UTF8( c_str() );
}
/// For use with _() function on wx 2.8.
@ -70,6 +91,7 @@ public:
UTF8( const std::string& o ) :
std::string( o )
{
MAYBE_VERIFY_UTF8( c_str() );
}
UTF8() :
@ -86,18 +108,24 @@ public:
UTF8& operator=( const std::string& o )
{
std::string::operator=( o );
MAYBE_VERIFY_UTF8( c_str() );
return *this;
}
UTF8& operator=( const char* s )
{
std::string::operator=( s );
MAYBE_VERIFY_UTF8( c_str() );
return *this;
}
UTF8& operator=( char c )
{
std::string::operator=( c );
MAYBE_VERIFY_UTF8( c_str() );
return *this;
}

View File

@ -11,7 +11,7 @@
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
*
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -108,12 +108,12 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
msg.Printf( _( "Adding new component \"%s:%s\" footprint \"%s\".\n" ),
GetChars( aComponent->GetReference() ),
GetChars( aComponent->GetTimeStamp() ),
GetChars( FROM_UTF8( aComponent->GetFPID().Format() ) ) );
GetChars( aComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO );
msg.Printf( _( "Add component %s, footprint: %s.\n" ),
GetChars( aComponent->GetReference() ),
GetChars( FROM_UTF8( aComponent->GetFPID().Format() ) ) );
GetChars( aComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_ACTION );
@ -135,7 +135,7 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
{
msg.Printf( _( "Cannot add component %s due to missing footprint %s.\n" ),
GetChars( aComponent->GetReference() ),
GetChars( FROM_UTF8( aComponent->GetFPID().Format() ) ) );
GetChars( aComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_ERROR );
@ -143,7 +143,7 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
"footprint \"%s\".\n" ),
GetChars( aComponent->GetReference() ),
GetChars( aComponent->GetTimeStamp() ),
GetChars( FROM_UTF8( aComponent->GetFPID().Format() ) ) );
GetChars( aComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO );
++m_errorCount;
@ -168,8 +168,8 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcb
{
msg.Printf( _( "Change component %s footprint from %s to %s.\n"),
GetChars( aPcbComponent->GetReference() ),
GetChars( FROM_UTF8( aPcbComponent->GetFPID().Format() ) ),
GetChars( FROM_UTF8( aNewComponent->GetFPID().Format() ) ) );
GetChars( aPcbComponent->GetFPID().Format() ),
GetChars( aNewComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_ACTION );
@ -177,8 +177,8 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcb
"\"%s\".\n" ),
GetChars( aPcbComponent->GetReference() ),
GetChars( aPcbComponent->GetPath() ),
GetChars( FROM_UTF8( aPcbComponent->GetFPID().Format() ) ),
GetChars( FROM_UTF8( aNewComponent->GetFPID().Format() ) ) );
GetChars( aPcbComponent->GetFPID().Format() ),
GetChars( aNewComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO );
@ -206,7 +206,7 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcb
msg.Printf( _( "Cannot change component %s footprint due to missing "
"footprint %s.\n" ),
GetChars( aPcbComponent->GetReference() ),
GetChars( FROM_UTF8( aNewComponent->GetFPID().Format() ) ) );
GetChars( aNewComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_ERROR );
@ -214,7 +214,7 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcb
"footprint \"%s\".\n" ),
GetChars( aPcbComponent->GetReference() ),
GetChars( aPcbComponent->GetPath() ),
GetChars( FROM_UTF8( aNewComponent->GetFPID().Format() ) ) );
GetChars( aNewComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO );
@ -583,7 +583,7 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist )
msg.Printf( _( "Component %s pad %s not found in footprint %s\n" ),
GetChars( component->GetReference() ),
GetChars( padname ),
GetChars( FROM_UTF8( footprint->GetFPID().Format() ) ) );
GetChars( footprint->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_ERROR );
++m_errorCount;
}
@ -631,7 +631,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
msg.Printf( _( "Processing component \"%s:%s:%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( FROM_UTF8( component->GetFPID().Format() ) ) );
GetChars( component->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO );
if( aNetlist.IsFindByTimeStamp() )

View File

@ -10,7 +10,7 @@
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
*
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -2465,7 +2465,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
msg.Printf( _( "Checking netlist component footprint \"%s:%s:%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( FROM_UTF8( component->GetFPID().Format() ) ) );
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_INFO );
}
@ -2483,7 +2483,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
msg.Printf( _( "Adding new component \"%s:%s\" footprint \"%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( FROM_UTF8( component->GetFPID().Format() ) ) );
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_ACTION );
}
@ -2493,7 +2493,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
"footprint \"%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( FROM_UTF8( component->GetFPID().Format() ) ) );
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_ERROR );
}
@ -2527,8 +2527,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
"\"%s\".\n" ),
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( FROM_UTF8( footprint->GetFPID().Format() ) ),
GetChars( FROM_UTF8( component->GetFPID().Format() ) ) );
GetChars( footprint->GetFPID().Format() ),
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_ACTION );
}
@ -2538,7 +2538,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
"footprint \"%s\".\n" ),
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( FROM_UTF8( component->GetFPID().Format() ) ) );
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_ERROR );
}
@ -2825,7 +2825,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
msg.Printf( _( "Component '%s' pad '%s' not found in footprint '%s'\n" ),
GetChars( component->GetReference() ),
GetChars( padname ),
GetChars( FROM_UTF8( footprint->GetFPID().Format() ) ) );
GetChars( footprint->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_ERROR );
}
}

View File

@ -10,7 +10,7 @@
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -174,8 +174,8 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
m_ValueCtrl->SetValue( m_valueCopy->GetText() );
m_currentFPID = m_currentModule->GetFPID();
m_FootprintNameCtrl->SetValue( FROM_UTF8( m_currentFPID.GetLibItemName() ) );
m_LibraryNicknameCtrl->SetValue( FROM_UTF8( m_currentFPID.GetLibNickname() ) );
m_FootprintNameCtrl->SetValue( m_currentFPID.GetLibItemName() );
m_LibraryNicknameCtrl->SetValue( m_currentFPID.GetLibNickname() );
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non SMD components" ) );
m_AttributsCtrl->SetItemToolTip( 1,

View File

@ -311,8 +311,8 @@ bool DIALOG_EXCHANGE_MODULE::change_1_Module( MODULE* aModule,
// Load module.
line.Printf( _( "Change footprint '%s' (from '%s') to '%s'" ),
GetChars( aModule->GetReference() ),
FROM_UTF8( oldFootprintFPID.Format() ),
FROM_UTF8( aNewFootprintFPID.Format() ) );
oldFootprintFPID.Format().c_str(),
aNewFootprintFPID.Format().c_str() );
m_WinMessages->AppendText( line );
newModule = m_parent->LoadFootprint( aNewFootprintFPID );

View File

@ -4,7 +4,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2016 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -487,7 +487,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
lenRefText = std::max( lenRefText, int(item.m_Reference.length()) );
lenValText = std::max( lenValText, int(item.m_Value.length()) );
lenPkgText = std::max( lenPkgText, int(FROM_UTF8( item.m_Module->GetFPID().GetLibItemName() ).length()) );
lenPkgText = std::max( lenPkgText, int(item.m_Module->GetFPID().GetLibItemName().length()) );
}
if( aFullFileName.IsEmpty() )
@ -524,7 +524,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
line << csv_sep;
line << list[ii].m_Value;
line << csv_sep;
line << FROM_UTF8( list[ii].m_Module->GetFPID().GetLibItemName() );
line << wxString( list[ii].m_Module->GetFPID().GetLibItemName() );
line << csv_sep;
line << wxString::Format( "%f%c%f%c%f",
@ -579,7 +579,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
const wxString& ref = list[ii].m_Reference;
const wxString& val = list[ii].m_Value;
const wxString pkg = FROM_UTF8( list[ii].m_Module->GetFPID().GetLibItemName() );
const wxString& pkg = list[ii].m_Module->GetFPID().GetLibItemName();
fprintf(file, "%-*s %-*s %-*s %9.4f %9.4f %8.4f %s\n",
lenRefText, TO_UTF8( ref ),

View File

@ -24,6 +24,14 @@
/*
Note:
If you are using this plugin without the supporting nginx caching server, then you
will never be happy with its performance. However, it is the fastest plugin in
existence when used with a local nginx and the nginx configuration file in this
directory. Nginx can be running in house on your network anywhere for this statement
to be true.
Comments below pertain to use without nginx, so are not relevant in every case:
While exploring the possibility of local caching of the zip file, I discovered
this command to retrieve the time stamp of the last commit into any particular
@ -40,7 +48,6 @@ slow response is the exception rather than the norm. Normally the response is
down around a 1/3 of a second. The information we would use is in the header
named "Last-Modified" as seen below.
HTTP/1.1 200 OK
Server: GitHub.com
Date: Mon, 27 Jan 2014 15:46:46 GMT
@ -434,7 +441,9 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP
wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() );
// @todo: generalize this name encoding from a PROPERTY (option) later
// Recently the zip standard adopted UTF8 encoded filenames within the
// internal zip directory block. Please only use zip files that conform
// to that standard. Github seems to now, but may not have earlier.
wxZipInputStream zis( mis, wxConvUTF8 );
wxZipEntry* entry;
@ -447,6 +456,8 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP
{
UTF8 fp_name = fn.GetName(); // omit extension & path
wxASSERT( IsUTF8( fp_name.c_str() ) );
m_gh_cache->insert( fp_name, entry );
}
else

View File

@ -5,7 +5,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2011 Jean-Pierre Charras.
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -363,7 +363,7 @@ void KICAD_NETLIST_PARSER::parseComponent()
}
}
if( !footprint.IsEmpty() && fpid.Parse( TO_UTF8( footprint ) ) >= 0 )
if( !footprint.IsEmpty() && fpid.Parse( footprint ) >= 0 )
{
wxString error;
error.Printf( _( "invalid footprint ID in\nfile: <%s>\nline: %d\noffset: %d" ),

View File

@ -304,8 +304,8 @@ void FP_CACHE::Load()
m_owner->m_parser->SetLineReader( &reader );
std::string name = TO_UTF8( fullPath.GetName() );
MODULE* footprint = (MODULE*) m_owner->m_parser->Parse();
UTF8 name = fullPath.GetName();
MODULE* footprint = (MODULE*) m_owner->m_parser->Parse();
// The footprint name is the file name without the extension.
footprint->SetFPID( LIB_ID( fullPath.GetName() ) );
@ -1907,7 +1907,7 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
MODULE_MAP& mods = m_cache->GetModules();
// Quietly overwrite module and delete module file from path for any by same name.
wxFileName fn( aLibraryPath, FROM_UTF8( aFootprint->GetFPID().GetLibItemName() ),
wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetLibItemName(),
KiCadFootprintFileExtension );
if( !fn.IsOk() )

View File

@ -7,7 +7,7 @@
*
* Copyright (C) 1992-2011 Jean-Pierre Charras.
* Copyright (C) 2013-2016 Wayne Stambaugh <stambaughw@verizon.net>.
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -168,7 +168,7 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText )
LIB_ID fpid;
if( !footprintName.IsEmpty() )
fpid.SetLibItemName( TO_UTF8( footprintName ) );
fpid.SetLibItemName( footprintName );
COMPONENT* component = new COMPONENT( fpid, reference, value, timeStamp );
component->SetName( name );

View File

@ -1373,7 +1373,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
wxString msg = wxString::Format(
wxT( "Missing '$EndMODULE' for MODULE '%s'" ),
FROM_UTF8( aModule->GetFPID().GetLibItemName() ) );
GetChars( aModule->GetFPID().GetLibItemName() ) );
THROW_IO_ERROR( msg );
}
@ -1428,7 +1428,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
padchar,
padchar,
m_reader->LineNumber(),
FROM_UTF8( aModule->GetFPID().GetLibItemName() )
GetChars( aModule->GetFPID().GetLibItemName() )
);
THROW_IO_ERROR( m_error );
}
@ -1634,7 +1634,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
(unsigned char) line[1],
(unsigned char) line[1],
m_reader->LineNumber(),
FROM_UTF8( aModule->GetFPID().GetLibItemName() )
GetChars( aModule->GetFPID().GetLibItemName() )
);
THROW_IO_ERROR( m_error );
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -343,7 +343,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule )
if( !aModule )
return;
fn.SetName( FROM_UTF8( aModule->GetFPID().GetLibItemName() ) );
fn.SetName( aModule->GetFPID().GetLibItemName() );
wxString wildcard = wxGetTranslation( KiCadFootprintLibFileWildcard );
@ -539,7 +539,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
return false;
LIB_ID fpid( fpid_txt );
wxString fpname = FROM_UTF8( fpid.GetLibItemName() );
wxString fpname = fpid.GetLibItemName();
// Confirmation
wxString msg = wxString::Format( FMT_OK_DELETE, fpname.GetData(), nickname.GetData() );
@ -653,7 +653,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( const wxString& aLibrary,
}
// Ask what to use as the footprint name in the library
wxString footprintName = FROM_UTF8( aModule->GetFPID().GetLibItemName() );
wxString footprintName = aModule->GetFPID().GetLibItemName();
if( aDisplayDialog )
{

View File

@ -226,7 +226,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
LIB_ID fpid;
wxCHECK_MSG( fpid.Parse( TO_UTF8( moduleName ) ) < 0, NULL,
wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
wxString::Format( wxT( "Could not parse LIB_ID string '%s'." ),
GetChars( moduleName ) ) );
@ -237,7 +237,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
catch( const IO_ERROR& ioe )
{
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
FROM_UTF8( fpid.Format() ), GetChars( ioe.What() ) );
fpid.Format().c_str(), GetChars( ioe.What() ) );
}
if( !module && allowWildSeach ) // Search with wild card
@ -256,7 +256,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
}
else
{
wxCHECK_MSG( fpid.Parse( TO_UTF8( moduleName ) ) < 0, NULL,
wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
wxString::Format( wxT( "Could not parse LIB_ID string '%s'." ),
GetChars( moduleName ) ) );
@ -267,7 +267,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
catch( const IO_ERROR& ioe )
{
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
FROM_UTF8( fpid.Format() ), GetChars( ioe.What() ) );
fpid.Format().c_str(), GetChars( ioe.What() ) );
}
}
}
@ -324,7 +324,7 @@ MODULE* PCB_BASE_FRAME::LoadFootprint( const LIB_ID& aFootprintId )
catch( const IO_ERROR& ioe )
{
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
FROM_UTF8( aFootprintId.Format() ), GetChars( ioe.What() ) );
aFootprintId.Format().c_str(), GetChars( ioe.What() ) );
}
return module;

View File

@ -226,8 +226,8 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
{
LIB_ID id;
id.SetLibNickname( TO_UTF8( getCurNickname() ) );
id.SetLibItemName( TO_UTF8( getCurFootprintName() ) );
id.SetLibNickname( getCurNickname() );
id.SetLibItemName( getCurFootprintName() );
GetBoard()->Add( loadFootprint( id ) );
}
@ -475,8 +475,8 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
GetBoard()->m_Modules.DeleteAll();
LIB_ID id;
id.SetLibNickname( TO_UTF8( getCurNickname() ) );
id.SetLibItemName( TO_UTF8( getCurFootprintName() ) );
id.SetLibNickname( getCurNickname() );
id.SetLibItemName( getCurFootprintName() );
try
{
@ -538,10 +538,10 @@ void FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint( wxCommandEvent& event )
LIB_ID fpid;
fpid.SetLibNickname( TO_UTF8( getCurNickname() ) );
fpid.SetLibItemName( TO_UTF8( fp_name ) );
fpid.SetLibNickname( getCurNickname() );
fpid.SetLibItemName( fp_name );
DismissModal( true, FROM_UTF8( fpid.Format() ) );
DismissModal( true, fpid.Format() );
}
else
{
@ -795,9 +795,9 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
delete oldmodule;
}
setCurFootprintName( FROM_UTF8( module->GetFPID().GetLibItemName() ) );
setCurFootprintName( module->GetFPID().GetLibItemName() );
wxString nickname = FROM_UTF8( module->GetFPID().GetLibNickname() );
wxString nickname = module->GetFPID().GetLibNickname();
if( !getCurNickname() && nickname.size() )
{

View File

@ -7,7 +7,7 @@
* Copyright (C) 1992-2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -273,8 +273,8 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
{
msg.Printf( _( "Footprint of component '%s' changed: board footprint '%s', netlist footprint '%s'\n" ),
GetChars( component->GetReference() ),
GetChars( FROM_UTF8( fpOnBoard->GetFPID().Format() ) ),
GetChars( FROM_UTF8( component->GetFPID().Format() ) ) );
GetChars( fpOnBoard->GetFPID().Format() ),
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_WARNING );
}
@ -303,7 +303,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
msg.Printf( _( "Component '%s' footprint ID '%s' is not "
"valid.\n" ),
GetChars( component->GetReference() ),
GetChars( FROM_UTF8( component->GetFPID().Format() ) ) );
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg, REPORTER::RPT_ERROR );
}
@ -324,7 +324,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
msg.Printf( _( "Component '%s' footprint '%s' was not found in "
"any libraries in the footprint library table.\n" ),
GetChars( component->GetReference() ),
FROM_UTF8( component->GetFPID().GetLibItemName() ) );
GetChars( component->GetFPID().GetLibItemName() ) );
aReporter->Report( msg, REPORTER::RPT_ERROR );
}

View File

@ -6,7 +6,7 @@
*
* Copyright (C) 1992-2011 Jean-Pierre Charras.
* Copyright (C) 2013-2016 Wayne Stambaugh <stambaughw@verizon.net>.
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -175,7 +175,7 @@ bool CMP_READER::Load( NETLIST* aNetlist )
{
LIB_ID fpid;
if( !footprint.IsEmpty() && fpid.Parse( TO_UTF8( footprint ) ) >= 0 )
if( !footprint.IsEmpty() && fpid.Parse( footprint ) >= 0 )
{
wxString error;
error.Printf( _( "invalid footprint ID in\nfile: <%s>\nline: %d" ),

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 CERN
* Copyright (C) 2012-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2012-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -1754,7 +1754,7 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments )
name = FromUTF8();
if( !name.IsEmpty() && fpid.Parse( TO_UTF8( FromUTF8() ) ) >= 0 )
if( !name.IsEmpty() && fpid.Parse( FromUTF8() ) >= 0 )
{
wxString error;
error.Printf( _( "invalid footprint ID in\nfile: <%s>\nline: %d\noffset: %d" ),