Skip to content

Commit

Permalink
Convert remaining occurences of stri[n]cmp to str[n]casecmp.
Browse files Browse the repository at this point in the history
This also reverses the substitution logic if strcasecmp is missing (config.h.cmake)
  • Loading branch information
GyrosGeier authored and msuminsk committed Aug 16, 2016
1 parent f1226af commit bfb6e0b
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 39 deletions.
8 changes: 4 additions & 4 deletions CMakeModules/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion common/class_bitmap_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions eeschema/sch_legacy_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions gerbview/excellon_read_drill_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );
Expand Down
12 changes: 6 additions & 6 deletions gerbview/rs274x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,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;

Expand Down Expand Up @@ -541,13 +541,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" ) );
Expand Down Expand Up @@ -681,7 +681,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;
Expand Down
2 changes: 1 addition & 1 deletion include/kicad_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions pcb_calculator/datafile_read_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down
8 changes: 4 additions & 4 deletions pcbnew/legacy_netlist_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions pcbnew/legacy_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pcbnew/librairi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions pcbnew/muonde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,38 +924,38 @@ 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() )
{
Line = reader.Line();
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 ) );
PolyEdges.push_back( coord );
}
}

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 );
}

Expand Down
2 changes: 1 addition & 1 deletion pcbnew/specctra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bfb6e0b

Please sign in to comment.