public: redefine Q_strpbrk to C standard version, add Q_strchrnul

This commit is contained in:
Alibek Omarov 2022-12-17 23:17:32 +03:00
parent 953dd3d1a7
commit 071638794a
2 changed files with 15 additions and 17 deletions

View File

@ -496,22 +496,6 @@ int Q_sprintf( char *buffer, const char *format, ... )
return result;
}
char *Q_strpbrk(const char *s, const char *accept)
{
for( ; *s; s++ )
{
const char *k;
for( k = accept; *k; k++ )
{
if( *s == *k )
return (char*)s;
}
}
return NULL;
}
void COM_StripColors( const char *in, char *out )
{
while ( *in )

View File

@ -83,7 +83,7 @@ const char *Q_timestamp( int format );
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args );
int Q_snprintf( char *buffer, size_t buffersize, const char *format, ... ) _format( 3 );
int Q_sprintf( char *buffer, const char *format, ... ) _format( 2 );
char *Q_strpbrk(const char *s, const char *accept);
#define Q_strpbrk strpbrk
void COM_StripColors( const char *in, char *out );
#define Q_memprint( val ) Q_pretifymem( val, 2 )
char *Q_pretifymem( float value, int digitsafterdecimal );
@ -161,6 +161,20 @@ static inline char *Q_stristr( const char *s1, const char *s2 )
char *Q_stristr( const char *s1, const char *s2 );
#endif // defined( HAVE_STRCASESTR )
#if defined( HAVE_STRCHRNUL )
#define Q_strchrnul strchrnul
#else
static inline const char *Q_strchrnul( const char *s, int c )
{
const char *p = Q_strchr( s, c );
if( p )
return p;
return s + Q_strlen( s );
}
#endif
#ifdef __cplusplus
}
#endif