public: introduce Q_strnicmpext function
The goal is to provide both string compare with fixed length and simple pattern match
This commit is contained in:
parent
7341a6b020
commit
7f1bb9b4a6
2 changed files with 12 additions and 3 deletions
|
@ -338,12 +338,15 @@ static qboolean Q_starcmp( const char *pattern, const char *text )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean Q_stricmpext( const char *pattern, const char *text )
|
qboolean Q_strnicmpext( const char *pattern, const char *text, size_t minimumlength )
|
||||||
{
|
{
|
||||||
|
size_t i = 0;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
while(( c = *pattern++ ) != '\0' )
|
while(( c = *pattern++ ) != '\0' )
|
||||||
{
|
{
|
||||||
|
i++;
|
||||||
|
|
||||||
switch( c )
|
switch( c )
|
||||||
{
|
{
|
||||||
case '?':
|
case '?':
|
||||||
|
@ -361,7 +364,12 @@ qboolean Q_stricmpext( const char *pattern, const char *text )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ( *text == '\0' );
|
return ( *text == '\0' ) || i == minimumlength;
|
||||||
|
}
|
||||||
|
|
||||||
|
qboolean Q_stricmpext( const char *pattern, const char *text )
|
||||||
|
{
|
||||||
|
return Q_strnicmpext( pattern, text, ~((size_t)0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Q_timestamp( int format )
|
const char* Q_timestamp( int format )
|
||||||
|
|
|
@ -76,7 +76,8 @@ float Q_atof( const char *str );
|
||||||
void Q_atov( float *vec, const char *str, size_t siz );
|
void Q_atov( float *vec, const char *str, size_t siz );
|
||||||
#define Q_strchr strchr
|
#define Q_strchr strchr
|
||||||
#define Q_strrchr strrchr
|
#define Q_strrchr strrchr
|
||||||
qboolean Q_stricmpext( const char *s1, const char *s2 );
|
qboolean Q_stricmpext( const char *pattern, const char *text );
|
||||||
|
qboolean Q_strnicmpext( const char *pattern, const char *text, size_t minimumlen );
|
||||||
const char *Q_timestamp( int format );
|
const char *Q_timestamp( int format );
|
||||||
#define Q_vsprintf( buffer, format, args ) Q_vsnprintf( buffer, 99999, format, args )
|
#define Q_vsprintf( buffer, format, args ) Q_vsnprintf( buffer, 99999, format, args )
|
||||||
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args );
|
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args );
|
||||||
|
|
Loading…
Add table
Reference in a new issue