Commit c4722e0f authored by Dick Hollenbeck's avatar Dick Hollenbeck

StrPurge(), see mailing list

parent 6e119c2b
......@@ -42,18 +42,17 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
*/
char* StrPurge( char* text )
{
char* ptspace;
const char whitespace[] = " \t\n\r\f\v";
if( text == NULL )
return NULL;
if( text )
{
while( strchr( whitespace, *text ) )
++text;
while( ( *text <= ' ' ) && *text )
text++;
char* cp = text + strlen( text ) - 1;
ptspace = text + strlen( text ) - 1;
while( ( *ptspace <= ' ' ) && *ptspace && ( ptspace >= text ) )
{
*ptspace = 0; ptspace--;
while( cp >= text && strchr( whitespace, *cp ) )
*cp-- = '\0';
}
return text;
......
......@@ -100,7 +100,6 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( )
Footprint_Is_GPCB_Format = true;
else
{
fclose( file );
DisplayError( this, _( "Not a module file" ) );
return NULL;
}
......@@ -211,6 +210,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* aModule, bool aCreateSysLib
fputs( "$EndLIBRARY\n", file );
fclose( file );
SetLocaleTo_Default(); // revert to the current locale
msg.Printf( _( "Module exported in file <%s>" ),
......@@ -238,6 +238,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
/* Confirmation */
msg.Printf( _( "Ok to delete module %s in library %s" ),
GetChars( CmpName ), GetChars( aLibname ) );
if( !IsOK( this, msg ) )
return;
......@@ -587,7 +588,8 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
if( !aOverwrite ) /* Do not save the given footprint: an old
* one exists */
{
fclose( lib_module ); return 1;
fclose( lib_module );
return 1;
}
end = 1; break;
}
......@@ -680,7 +682,8 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
fprintf( dest, "$EndLIBRARY\n" );
aModule->m_TimeStamp = tmp;
fclose( dest ); fclose( lib_module );
fclose( dest );
fclose( lib_module );
SetLocaleTo_Default(); // revert to the current locale
wxEndBusyCursor();
......@@ -826,7 +829,8 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
{
msg = _( "Create error " ) + LibName;
DisplayError( this, msg );
fclose( lib_module ); return -1;
fclose( lib_module );
return -1;
}
fprintf( lib_module, " %s\n", DateAndTime( cbuf ) );
......
......@@ -309,11 +309,16 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module(
Line = reader.Line();
if( Line[0] != '$' )
continue;
if( Line[1] != 'M' )
continue;
if( strnicmp( Line, "$MODULE", 7 ) != 0 )
continue;
/* Read module name. */
StrPurge( Line + 8 );
// Read module name.
Name = CONV_FROM_UTF8( Line + 8 );
if( Name.CmpNoCase( aModuleName ) == 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment