changes
This commit is contained in:
parent
27dea7826d
commit
4e97b4e179
|
@ -42,6 +42,11 @@ struct IO_ERROR
|
||||||
{
|
{
|
||||||
wxString errorText;
|
wxString errorText;
|
||||||
|
|
||||||
|
IO_ERROR( const wxChar* aMsg ) :
|
||||||
|
errorText( aMsg )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
IO_ERROR( const wxString& aMsg ) :
|
IO_ERROR( const wxString& aMsg ) :
|
||||||
errorText( aMsg )
|
errorText( aMsg )
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,6 @@ using namespace SCH;
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -66,6 +65,7 @@ using namespace std;
|
||||||
/// implementation, and to a corresponding LIB_SINK.
|
/// implementation, and to a corresponding LIB_SINK.
|
||||||
/// Core EESCHEMA should never have to see this.
|
/// Core EESCHEMA should never have to see this.
|
||||||
#define SWEET_EXT ".part"
|
#define SWEET_EXT ".part"
|
||||||
|
#define SWEET_EXTZ (sizeof(SWEET_EXT)-1)
|
||||||
|
|
||||||
|
|
||||||
/* __func__ is C99 prescribed, but just in case:
|
/* __func__ is C99 prescribed, but just in case:
|
||||||
|
@ -141,6 +141,12 @@ static const char* strrstr( const char* haystack, const char* needle )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool isDigit( char c )
|
||||||
|
{
|
||||||
|
return c >= '0' && c <= '9';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function endsWithRev
|
* Function endsWithRev
|
||||||
* returns a pointer to the final string segment: "revN[N..]" or NULL if none.
|
* returns a pointer to the final string segment: "revN[N..]" or NULL if none.
|
||||||
|
@ -154,7 +160,7 @@ static const char* endsWithRev( const char* start, const char* tail, char separa
|
||||||
{
|
{
|
||||||
bool sawDigit = false;
|
bool sawDigit = false;
|
||||||
|
|
||||||
while( tail > start && isdigit( *--tail ) )
|
while( tail > start && isDigit( *--tail ) )
|
||||||
{
|
{
|
||||||
sawDigit = true;
|
sawDigit = true;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +243,7 @@ bool DIR_LIB_SOURCE::makePartName( STRING* aPartName, const char* aEntry,
|
||||||
// If versioning, then must find a trailing "revN.." type of string.
|
// If versioning, then must find a trailing "revN.." type of string.
|
||||||
if( useVersioning )
|
if( useVersioning )
|
||||||
{
|
{
|
||||||
const char* rev = endsWithRev( cp + sizeof(SWEET_EXT) - 1, limit, '.' );
|
const char* rev = endsWithRev( cp + SWEET_EXTZ, limit, '.' );
|
||||||
if( rev )
|
if( rev )
|
||||||
{
|
{
|
||||||
if( aCategory.size() )
|
if( aCategory.size() )
|
||||||
|
|
|
@ -171,11 +171,10 @@ const LIB_TABLE::ROW* LIB_TABLE::FindRow( const STRING& aLogicalName )
|
||||||
// ptr_map<> was used instead of ptr_set<>, which would have required
|
// ptr_map<> was used instead of ptr_set<>, which would have required
|
||||||
// instantiating a ROW just to find a ROW.
|
// instantiating a ROW just to find a ROW.
|
||||||
LIB_TABLE* cur = this;
|
LIB_TABLE* cur = this;
|
||||||
ROWS_CITER it;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
it = cur->rows.find( aLogicalName );
|
ROWS_CITER it = cur->rows.find( aLogicalName );
|
||||||
|
|
||||||
if( it != cur->rows.end() )
|
if( it != cur->rows.end() )
|
||||||
{
|
{
|
||||||
|
@ -192,9 +191,11 @@ const LIB_TABLE::ROW* LIB_TABLE::FindRow( const STRING& aLogicalName )
|
||||||
|
|
||||||
bool LIB_TABLE::InsertRow( auto_ptr<ROW>& aRow, bool doReplace )
|
bool LIB_TABLE::InsertRow( auto_ptr<ROW>& aRow, bool doReplace )
|
||||||
{
|
{
|
||||||
ROWS_ITER it = rows.find( aRow->logicalName );
|
// this does not need to be super fast.
|
||||||
|
|
||||||
if( doReplace || it == rows.end() )
|
ROWS_CITER it = rows.find( aRow->logicalName );
|
||||||
|
|
||||||
|
if( it == rows.end() )
|
||||||
{
|
{
|
||||||
// be careful here, key is needed because aRow can be
|
// be careful here, key is needed because aRow can be
|
||||||
// release()ed before logicalName is captured.
|
// release()ed before logicalName is captured.
|
||||||
|
@ -202,6 +203,16 @@ bool LIB_TABLE::InsertRow( auto_ptr<ROW>& aRow, bool doReplace )
|
||||||
rows.insert( key, aRow );
|
rows.insert( key, aRow );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if( doReplace )
|
||||||
|
{
|
||||||
|
rows.erase( aRow->logicalName );
|
||||||
|
|
||||||
|
// be careful here, key is needed because aRow can be
|
||||||
|
// release()ed before logicalName is captured.
|
||||||
|
const STRING& key = aRow->logicalName;
|
||||||
|
rows.insert( key, aRow );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue