This also reverses the substitution logic if strcasecmp is missing. --- CMakeModules/config.h.cmake | 8 ++++---- common/class_bitmap_base.cpp | 2 +- eeschema/sch_legacy_plugin.cpp | 8 ++++---- gerbview/excellon_read_drill_file.cpp | 4 ++-- gerbview/rs274x.cpp | 12 ++++++------ include/kicad_string.h | 2 +- pcb_calculator/datafile_read_write.cpp | 4 ++-- pcbnew/legacy_netlist_reader.cpp | 8 ++++---- pcbnew/legacy_plugin.cpp | 4 ++-- pcbnew/librairi.cpp | 8 ++++---- pcbnew/muonde.cpp | 16 ++++++++-------- pcbnew/specctra.cpp | 2 +- 12 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake index 3e60199..01359cc 100644 --- a/CMakeModules/config.h.cmake +++ b/CMakeModules/config.h.cmake @@ -39,12 +39,12 @@ #include <iso646.h> #endif -#if defined( HAVE_STRCASECMP ) -#define stricmp strcasecmp +#if !defined( HAVE_STRCASECMP ) +#define strcasecmp stricmp #endif -#if defined( HAVE_STRNCASECMP ) -#define strnicmp strncasecmp +#if !defined( HAVE_STRNCASECMP ) +#define strncasecmp strnicmp #endif // Use Posix getc_unlocked() instead of getc() when it's available. diff --git a/common/class_bitmap_base.cpp b/common/class_bitmap_base.cpp index 67e9b7a..c563f1f 100644 --- a/common/class_bitmap_base.cpp +++ b/common/class_bitmap_base.cpp @@ -174,7 +174,7 @@ bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg ) line = aLine.Line(); - if( strnicmp( line, "EndData", 4 ) == 0 ) + if( strncasecmp( line, "EndData", 4 ) == 0 ) { // all the PNG date is read. // We expect here m_image and m_bitmap are void diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index c7592e2..3790a04 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -72,7 +72,7 @@ const char* delims = " \t\r\n"; static bool strCompare( const char* aString, const char* aLine, const char** aOutput = NULL ) { size_t len = strlen( aString ); - bool retv = ( strnicmp( aLine, aString, len ) == 0 ) && isspace( aLine[ len ] ); + bool retv = ( strncasecmp( aLine, aString, len ) == 0 ) && isspace( aLine[ len ] ); if( retv && aOutput ) { @@ -1220,7 +1220,7 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader ) const char* strCompare = "Path="; int len = strlen( strCompare ); - if( strnicmp( strCompare, line, len ) != 0 ) + if( strncasecmp( strCompare, line, len ) != 0 ) SCH_PARSE_ERROR( "missing 'Path=' token", aReader, line ); line += len; @@ -1231,7 +1231,7 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader ) strCompare = "Ref="; len = strlen( strCompare ); - if( strnicmp( strCompare, line, len ) != 0 ) + if( strncasecmp( strCompare, line, len ) != 0 ) SCH_PARSE_ERROR( "missing 'Ref=' token", aReader, line ); line+= len; @@ -1240,7 +1240,7 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader ) strCompare = "Part="; len = strlen( strCompare ); - if( strnicmp( strCompare, line, len ) != 0 ) + if( strncasecmp( strCompare, line, len ) != 0 ) SCH_PARSE_ERROR( "missing 'Part=' token", aReader, line ); line+= len; diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index 2042c92..458e953 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -422,9 +422,9 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text ) } text++; // skip separator // Parameter should be ON or OFF - if( strnicmp( text, "OFF", 3 ) == 0 ) + if( strncasecmp( text, "OFF", 3 ) == 0 ) m_Relative = false; - else if( strnicmp( text, "ON", 2 ) == 0 ) + else if( strncasecmp( text, "ON", 2 ) == 0 ) m_Relative = true; else AddMessageToList( _( "ICI command has incorrect parameter" ) ); diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index 77141aa..17308f0 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -369,7 +369,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te case AXIS_SELECT: // command ASAXBY*% or %ASAYBX*% m_SwapAxis = false; - if( strnicmp( text, "AYBX", 4 ) == 0 ) + if( strncasecmp( text, "AYBX", 4 ) == 0 ) m_SwapAxis = true; break; @@ -543,13 +543,13 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te break; case IMAGE_ROTATION: // command IR0* or IR90* or IR180* or IR270* - if( strnicmp( text, "0*", 2 ) == 0 ) + if( strncasecmp( text, "0*", 2 ) == 0 ) m_ImageRotation = 0; - else if( strnicmp( text, "90*", 3 ) == 0 ) + else if( strncasecmp( text, "90*", 3 ) == 0 ) m_ImageRotation = 90; - else if( strnicmp( text, "180*", 4 ) == 0 ) + else if( strncasecmp( text, "180*", 4 ) == 0 ) m_ImageRotation = 180; - else if( strnicmp( text, "270*", 4 ) == 0 ) + else if( strncasecmp( text, "270*", 4 ) == 0 ) m_ImageRotation = 270; else AddMessageToList( _( "RS274X: Command \"IR\" rotation value not allowed" ) ); @@ -683,7 +683,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te break; case IMAGE_POLARITY: - if( strnicmp( text, "NEG", 3 ) == 0 ) + if( strncasecmp( text, "NEG", 3 ) == 0 ) m_ImageNegative = true; else m_ImageNegative = false; diff --git a/include/kicad_string.h b/include/kicad_string.h index 2c17f10..e65486c 100644 --- a/include/kicad_string.h +++ b/include/kicad_string.h @@ -95,7 +95,7 @@ wxString DateAndTime(); * Function StrLenNumCmp * is a routine compatible with qsort() to sort by alphabetical order. * - * This function is equivalent to strncmp() or strnicmp() if \a aIgnoreCase is true + * This function is equivalent to strncmp() or strncasecmp() if \a aIgnoreCase is true * except that strings containing numbers are compared by their integer value not * by their ASCII code. * diff --git a/pcb_calculator/datafile_read_write.cpp b/pcb_calculator/datafile_read_write.cpp index a058a2a..00b09df 100644 --- a/pcb_calculator/datafile_read_write.cpp +++ b/pcb_calculator/datafile_read_write.cpp @@ -255,9 +255,9 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL case T_reg_type: // type: normal or 3 terminal reg token = NextTok(); - if( stricmp( CurText(), regtype_str[0] ) == 0 ) + if( strcasecmp( CurText(), regtype_str[0] ) == 0 ) type = 0; - else if( stricmp( CurText(), regtype_str[1] ) == 0 ) + else if( strcasecmp( CurText(), regtype_str[1] ) == 0 ) type = 1; else Unexpected( CurText() ); diff --git a/pcbnew/legacy_netlist_reader.cpp b/pcbnew/legacy_netlist_reader.cpp index a559c7b..b4af895 100644 --- a/pcbnew/legacy_netlist_reader.cpp +++ b/pcbnew/legacy_netlist_reader.cpp @@ -58,7 +58,7 @@ void LEGACY_NETLIST_READER::LoadNetlist() throw ( IO_ERROR, PARSE_ERROR, boost:: is_comment = true; if( m_loadFootprintFilters && state == 0 - && (strnicmp( line, "{ Allowed footprints", 20 ) == 0) ) + && (strncasecmp( line, "{ Allowed footprints", 20 ) == 0) ) { loadFootprintFilters(); continue; @@ -221,7 +221,7 @@ void LEGACY_NETLIST_READER::loadFootprintFilters() throw( IO_ERROR, PARSE_ERROR while( ( line = m_lineReader->ReadLine() ) != NULL ) { - if( strnicmp( line, "$endlist", 8 ) == 0 ) // end of list for the current component + if( strncasecmp( line, "$endlist", 8 ) == 0 ) // end of list for the current component { wxASSERT( component != NULL ); component->SetFootprintFilters( filters ); @@ -230,11 +230,11 @@ void LEGACY_NETLIST_READER::loadFootprintFilters() throw( IO_ERROR, PARSE_ERROR continue; } - if( strnicmp( line, "$endfootprintlist", 4 ) == 0 ) + if( strncasecmp( line, "$endfootprintlist", 4 ) == 0 ) // End of this section return; - if( strnicmp( line, "$component", 10 ) == 0 ) // New component reference found + if( strncasecmp( line, "$component", 10 ) == 0 ) // New component reference found { cmpRef = FROM_UTF8( line + 11 ); cmpRef.Trim( true ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 41442d3..d5a0988 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -203,10 +203,10 @@ static bool inline isSpace( int c ) { return strchr( delims, c ) != 0; } //-----<BOARD Load Functions>--------------------------------------------------- /// C string compare test for a specific length of characters. -#define TESTLINE( x ) ( !strnicmp( line, x, SZ( x ) ) && isSpace( line[SZ( x )] ) ) +#define TESTLINE( x ) ( !strncasecmp( line, x, SZ( x ) ) && isSpace( line[SZ( x )] ) ) /// C sub-string compare test for a specific length of characters. -#define TESTSUBSTR( x ) ( !strnicmp( line, x, SZ( x ) ) ) +#define TESTSUBSTR( x ) ( !strncasecmp( line, x, SZ( x ) ) ) #if 1 diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 744a3d4..e19fc4c 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -144,24 +144,24 @@ static IO_MGR::PCB_FILE_T detect_file_type( FILE* aFile, const wxFileName& aFile reader.ReadLine(); char* line = reader.Line(); - if( !strnicmp( line, "(module", strlen( "(module" ) ) ) + if( !strncasecmp( line, "(module", strlen( "(module" ) ) ) { file_type = IO_MGR::KICAD; *aName = aFileName.GetName(); } - else if( !strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) ) + else if( !strncasecmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) ) { file_type = IO_MGR::LEGACY; while( reader.ReadLine() ) { - if( !strnicmp( line, "$MODULE", strlen( "$MODULE" ) ) ) + if( !strncasecmp( line, "$MODULE", strlen( "$MODULE" ) ) ) { *aName = FROM_UTF8( StrPurge( line + strlen( "$MODULE" ) ) ); break; } } } - else if( !strnicmp( line, "Element", strlen( "Element" ) ) ) + else if( !strncasecmp( line, "Element", strlen( "Element" ) ) ) { file_type = IO_MGR::GEDA_PCB; *aName = aFileName.GetName(); diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 8fd6ed3..77edb7e 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -924,19 +924,19 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event ) char* param1 = strtok( Line, " =\n\r" ); char* param2 = strtok( NULL, " \t\n\r" ); - if( strnicmp( param1, "Unit", 4 ) == 0 ) + if( strncasecmp( param1, "Unit", 4 ) == 0 ) { - if( strnicmp( param2, "inch", 4 ) == 0 ) + if( strncasecmp( param2, "inch", 4 ) == 0 ) unitconv = IU_PER_MILS*1000; - if( strnicmp( param2, "mm", 2 ) == 0 ) + if( strncasecmp( param2, "mm", 2 ) == 0 ) unitconv = IU_PER_MM; } - if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 ) + if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 ) break; - if( strnicmp( param1, "$COORD", 6 ) == 0 ) + if( strncasecmp( param1, "$COORD", 6 ) == 0 ) { while( reader.ReadLine() ) { @@ -944,7 +944,7 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event ) param1 = strtok( Line, " \t\n\r" ); param2 = strtok( NULL, " \t\n\r" ); - if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 ) + if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 ) break; wxRealPoint coord( atof( param1 ), atof( param2 ) ); @@ -952,10 +952,10 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event ) } } - if( strnicmp( Line, "XScale", 6 ) == 0 ) + if( strncasecmp( Line, "XScale", 6 ) == 0 ) ShapeScaleX = atof( param2 ); - if( strnicmp( Line, "YScale", 6 ) == 0 ) + if( strncasecmp( Line, "YScale", 6 ) == 0 ) ShapeScaleY = atof( param2 ); } diff --git a/pcbnew/specctra.cpp b/pcbnew/specctra.cpp index ef14eee..39ffb90 100644 --- a/pcbnew/specctra.cpp +++ b/pcbnew/specctra.cpp @@ -194,7 +194,7 @@ void SPECCTRA_DB::readTIME( time_t* time_stamp ) throw( IO_ERROR ) mytime.tm_mon = 0; // remains if we don't find a month match. for( int m=0; months[m]; ++m ) { - if( !stricmp( months[m], ptok ) ) + if( !strcasecmp( months[m], ptok ) ) { mytime.tm_mon = m; break;
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp