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