Convert remaining occurences of stri[n]cmp to str[n]casecmp.

This also reverses the substitution logic if strcasecmp is missing (config.h.cmake)
This commit is contained in:
Simon Richter 2016-08-16 10:27:09 +02:00 committed by Maciej Suminski
parent f1226afc89
commit bfb6e0bbb2
12 changed files with 39 additions and 39 deletions

View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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" ) );

View File

@ -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;
@ -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" ) );
@ -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;

View File

@ -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.
*

View File

@ -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() );

View File

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

View File

@ -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

View File

@ -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();

View File

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

View File

@ -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;