Fix broken LIB_ID library nickname illegal character tests.
During the symbol library table implementation, the legal character tests for the footprint library table were changed and the forward slash '/' character became illegal. This change broke editing some users footprint library tables that already had '/' in library table nicknames. This change split the library nickname and library item name illegal character tests.
This commit is contained in:
parent
79e0bb08d0
commit
8394e2b71e
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2010-2017 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 2010-2018 KiCad Developers, see change_log.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -385,19 +385,7 @@ UTF8 LIB_ID::FixIllegalChars( const UTF8& aLibItemName, LIB_ID_TYPE aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned LIB_ID::FindIllegalChar( const UTF8& aNickname, LIB_ID_TYPE aType )
|
///> Set of characters not accepted library entry names.
|
||||||
{
|
|
||||||
for( unsigned ch : aNickname )
|
|
||||||
{
|
|
||||||
if( !isLegalChar( ch, aType ) )
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///> Set of characters not accepted in library and entry names
|
|
||||||
#define BASE_ILLEGAL_CHARS '\t', '\n', '\r', ':', '/', '\\'
|
#define BASE_ILLEGAL_CHARS '\t', '\n', '\r', ':', '/', '\\'
|
||||||
const unsigned schIllegalChars[] = { BASE_ILLEGAL_CHARS, ' ' };
|
const unsigned schIllegalChars[] = { BASE_ILLEGAL_CHARS, ' ' };
|
||||||
const unsigned pcbIllegalChars[] = { BASE_ILLEGAL_CHARS, 0 };
|
const unsigned pcbIllegalChars[] = { BASE_ILLEGAL_CHARS, 0 };
|
||||||
|
@ -422,6 +410,43 @@ bool LIB_ID::isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned LIB_ID::FindIllegalLibNicknameChar( const UTF8& aNickname, LIB_ID_TYPE aType )
|
||||||
|
{
|
||||||
|
for( unsigned ch : aNickname )
|
||||||
|
{
|
||||||
|
if( !isLegalLibNicknameChar( ch, aType ) )
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///> Set of characters not accepted library nicknames which is different for item names.
|
||||||
|
#define BASE_ILLEGAL_LIB_NICKNAME_CHARS '\t', '\n', '\r', ':', '\\'
|
||||||
|
const unsigned schIllegalLibNicknameChars[] = { BASE_ILLEGAL_LIB_NICKNAME_CHARS, ' ' };
|
||||||
|
const unsigned pcbIllegalLibNicknameChars[] = { BASE_ILLEGAL_LIB_NICKNAME_CHARS, 0 };
|
||||||
|
#define ILL_LIB_NICKNAME_CHAR_SIZE ( sizeof( schIllegalLibNicknameChars ) / sizeof( unsigned ) )
|
||||||
|
|
||||||
|
bool LIB_ID::isLegalLibNicknameChar( unsigned aUniChar, LIB_ID_TYPE aType )
|
||||||
|
{
|
||||||
|
const unsigned (&illegalChars)[ILL_LIB_NICKNAME_CHAR_SIZE] =
|
||||||
|
aType == ID_SCH ? schIllegalLibNicknameChars : pcbIllegalLibNicknameChars;
|
||||||
|
|
||||||
|
for( const unsigned ch : illegalChars )
|
||||||
|
{
|
||||||
|
if( ch == aUniChar )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test for "printable" code (aUniChar is a unicode (32 bits) char, not a ASCII value )
|
||||||
|
if( aUniChar < ' ' )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0 && defined(DEBUG)
|
#if 0 && defined(DEBUG)
|
||||||
|
|
||||||
// build this with Debug CMAKE_BUILD_TYPE
|
// build this with Debug CMAKE_BUILD_TYPE
|
||||||
|
|
|
@ -268,7 +268,7 @@ bool DIALOG_SYMBOL_LIB_TABLE::verifyTables()
|
||||||
// button.
|
// button.
|
||||||
model.DeleteRows( r, 1 );
|
model.DeleteRows( r, 1 );
|
||||||
}
|
}
|
||||||
else if( ( illegalCh = LIB_ID::FindIllegalChar( nick, LIB_ID::ID_SCH ) ) )
|
else if( ( illegalCh = LIB_ID::FindIllegalLibNicknameChar( nick, LIB_ID::ID_SCH ) ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format(
|
wxString msg = wxString::Format(
|
||||||
_( "Illegal character \"%c\" found in Nickname: \"%s\" in row %d" ),
|
_( "Illegal character \"%c\" found in Nickname: \"%s\" in row %d" ),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2010-2017 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 2010-2018 KiCad Developers, see change_log.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -223,25 +223,35 @@ public:
|
||||||
static UTF8 FixIllegalChars( const UTF8& aLibItemName, LIB_ID_TYPE aType );
|
static UTF8 FixIllegalChars( const UTF8& aLibItemName, LIB_ID_TYPE aType );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for characters that are illegal in library and item names.
|
* Looks for characters that are illegal in library nicknames.
|
||||||
*
|
*
|
||||||
* @param aNickname is the logical library name to be tested.
|
* @param aNickname is the logical library name to be tested.
|
||||||
* @param aType is the library identifier type
|
* @param aType is the library identifier type
|
||||||
* @return Invalid character found in the name or 0 is the name is valid.
|
* @return Invalid character found in the name or 0 is the name is valid.
|
||||||
*/
|
*/
|
||||||
static unsigned FindIllegalChar( const UTF8& aNickname, LIB_ID_TYPE aType );
|
static unsigned FindIllegalLibNicknameChar( const UTF8& aNickname, LIB_ID_TYPE aType );
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
static void Test();
|
static void Test();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Tests whether a unicode character is a legal LIB_ID character
|
/**
|
||||||
* note: aUniChar is expected to be a unicode 32 bits char, not a UTF8 char, that use
|
* Tests whether a unicode character is a legal LIB_ID item name character
|
||||||
* a variable lenght coding value
|
*
|
||||||
|
* @note @a aUniChar is expected to be a 32 bit unicode character, not a UTF8 char, that use
|
||||||
|
* a variable length coding value.
|
||||||
*/
|
*/
|
||||||
static bool isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType );
|
static bool isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether a unicode character is a legal LIB_ID library nickname character
|
||||||
|
*
|
||||||
|
* @note @a aUniChar is expected to be a 32 bit unicode character, not a UTF8 char, that use
|
||||||
|
* a variable length coding value.
|
||||||
|
*/
|
||||||
|
static bool isLegalLibNicknameChar( unsigned aUniChar, LIB_ID_TYPE aType );
|
||||||
|
|
||||||
UTF8 nickname; ///< The nickname of the library or empty.
|
UTF8 nickname; ///< The nickname of the library or empty.
|
||||||
UTF8 item_name; ///< The name of the entry in the logical library.
|
UTF8 item_name; ///< The name of the entry in the logical library.
|
||||||
UTF8 revision; ///< The revision of the entry.
|
UTF8 revision; ///< The revision of the entry.
|
||||||
|
|
|
@ -353,7 +353,7 @@ private:
|
||||||
// button.
|
// button.
|
||||||
model.DeleteRows( r, 1 );
|
model.DeleteRows( r, 1 );
|
||||||
}
|
}
|
||||||
else if( ( illegalCh = LIB_ID::FindIllegalChar( nick, LIB_ID::ID_PCB ) ) )
|
else if( ( illegalCh = LIB_ID::FindIllegalLibNicknameChar( nick, LIB_ID::ID_PCB ) ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format(
|
wxString msg = wxString::Format(
|
||||||
_( "Illegal character \"%c\" found in Nickname: \"%s\" in row %d" ),
|
_( "Illegal character \"%c\" found in Nickname: \"%s\" in row %d" ),
|
||||||
|
|
Loading…
Reference in New Issue