Pcbnew: footprint library table fixes.
* Replace illegal file system characters when reading legacy libraries to prevent FPID parsing errors and allow saving to PRETTY file format. * Create validator to filter illegal file system characters from footprint name text edit controls to prevent issues when saving to PRETTY file format. * Add missing source file licenses and some minor coding policy fixes.
This commit is contained in:
@@ -1,3 +1,26 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 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
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file string.cpp
|
||||
* @brief Some useful functions to handle strings.
|
||||
@@ -5,9 +28,18 @@
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <macros.h>
|
||||
#include <richio.h> // StrPrintf
|
||||
#include <kicad_string.h>
|
||||
|
||||
|
||||
/**
|
||||
* Illegal file name characters used to insure file names will be valid on all supported
|
||||
* platforms. This is the list of illegal file name characters for Windows which includes
|
||||
* the illegal file name characters for Linux and OSX.
|
||||
*/
|
||||
static const char illegalFileNameChars[] = "\\/:\"<>|";
|
||||
|
||||
|
||||
int ReadDelimitedText( wxString* aDest, const char* aSource )
|
||||
{
|
||||
std::string utf8; // utf8 but without escapes and quotes.
|
||||
@@ -414,3 +446,34 @@ int SplitString( wxString strToSplit,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
wxString GetIllegalFileNameWxChars()
|
||||
{
|
||||
return FROM_UTF8( illegalFileNameChars );
|
||||
}
|
||||
|
||||
|
||||
bool ReplaceIllegalFileNameChars( std::string* aName )
|
||||
{
|
||||
bool changed = false;
|
||||
std::string result;
|
||||
|
||||
for( std::string::iterator it = aName->begin(); it != aName->end(); ++it )
|
||||
{
|
||||
if( strchr( illegalFileNameChars, *it ) )
|
||||
{
|
||||
StrPrintf( &result, "%%%02x", *it );
|
||||
changed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += *it;
|
||||
}
|
||||
}
|
||||
|
||||
if( changed )
|
||||
*aName = result;
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user