Browse Source

public: redefine Q_strpbrk to C standard version, add Q_strchrnul

pull/2/head
Alibek Omarov 2 years ago
parent
commit
071638794a
  1. 16
      public/crtlib.c
  2. 16
      public/crtlib.h

16
public/crtlib.c

@ -496,22 +496,6 @@ int Q_sprintf( char *buffer, const char *format, ... )
return result; 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 ) void COM_StripColors( const char *in, char *out )
{ {
while ( *in ) while ( *in )

16
public/crtlib.h

@ -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_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_snprintf( char *buffer, size_t buffersize, const char *format, ... ) _format( 3 );
int Q_sprintf( char *buffer, const char *format, ... ) _format( 2 ); 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 ); void COM_StripColors( const char *in, char *out );
#define Q_memprint( val ) Q_pretifymem( val, 2 ) #define Q_memprint( val ) Q_pretifymem( val, 2 )
char *Q_pretifymem( float value, int digitsafterdecimal ); 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 ); char *Q_stristr( const char *s1, const char *s2 );
#endif // defined( HAVE_STRCASESTR ) #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 #ifdef __cplusplus
} }
#endif #endif

Loading…
Cancel
Save