public: make simple ctype functions inlined
This commit is contained in:
parent
7f3e62e456
commit
7ccb0b5c02
2 changed files with 43 additions and 47 deletions
|
@ -18,7 +18,6 @@ GNU General Public License for more details.
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "crtlib.h"
|
#include "crtlib.h"
|
||||||
|
@ -38,26 +37,6 @@ void Q_strnlwr( const char *in, char *out, size_t size_out )
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean Q_isdigit( const char *str )
|
|
||||||
{
|
|
||||||
if( str && *str )
|
|
||||||
{
|
|
||||||
while( isdigit( *str )) str++;
|
|
||||||
if( !*str ) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
qboolean Q_isspace( const char *str )
|
|
||||||
{
|
|
||||||
if( str && *str )
|
|
||||||
{
|
|
||||||
while( isspace( *str ) ) str++;
|
|
||||||
if( !*str ) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t Q_colorstr( const char *string )
|
size_t Q_colorstr( const char *string )
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -81,28 +60,6 @@ size_t Q_colorstr( const char *string )
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
char Q_toupper( const char in )
|
|
||||||
{
|
|
||||||
char out;
|
|
||||||
|
|
||||||
if( in >= 'a' && in <= 'z' )
|
|
||||||
out = in + 'A' - 'a';
|
|
||||||
else out = in;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
char Q_tolower( const char in )
|
|
||||||
{
|
|
||||||
char out;
|
|
||||||
|
|
||||||
if( in >= 'A' && in <= 'Z' )
|
|
||||||
out = in + 'a' - 'A';
|
|
||||||
else out = in;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t Q_strncat( char *dst, const char *src, size_t size )
|
size_t Q_strncat( char *dst, const char *src, size_t size )
|
||||||
{
|
{
|
||||||
register char *d = dst;
|
register char *d = dst;
|
||||||
|
|
|
@ -18,6 +18,7 @@ GNU General Public License for more details.
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "xash3d_types.h"
|
#include "xash3d_types.h"
|
||||||
|
|
||||||
|
@ -63,11 +64,7 @@ const char *Q_buildbranch( void );
|
||||||
void Q_strnlwr( const char *in, char *out, size_t size_out );
|
void Q_strnlwr( const char *in, char *out, size_t size_out );
|
||||||
#define Q_strlen( str ) (( str ) ? strlen(( str )) : 0 )
|
#define Q_strlen( str ) (( str ) ? strlen(( str )) : 0 )
|
||||||
size_t Q_colorstr( const char *string );
|
size_t Q_colorstr( const char *string );
|
||||||
char Q_toupper( const char in );
|
|
||||||
char Q_tolower( const char in );
|
|
||||||
size_t Q_strncat( char *dst, const char *src, size_t siz );
|
size_t Q_strncat( char *dst, const char *src, size_t siz );
|
||||||
qboolean Q_isdigit( const char *str );
|
|
||||||
qboolean Q_isspace( const char *str );
|
|
||||||
int Q_atoi( const char *str );
|
int Q_atoi( const char *str );
|
||||||
float Q_atof( const char *str );
|
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 );
|
||||||
|
@ -103,6 +100,48 @@ char *COM_ParseFileSafe( char *data, char *token, const int size, unsigned int f
|
||||||
int matchpattern( const char *in, const char *pattern, qboolean caseinsensitive );
|
int matchpattern( const char *in, const char *pattern, qboolean caseinsensitive );
|
||||||
int matchpattern_with_separator( const char *in, const char *pattern, qboolean caseinsensitive, const char *separators, qboolean wildcard_least_one );
|
int matchpattern_with_separator( const char *in, const char *pattern, qboolean caseinsensitive, const char *separators, qboolean wildcard_least_one );
|
||||||
|
|
||||||
|
static inline char Q_toupper( const char in )
|
||||||
|
{
|
||||||
|
char out;
|
||||||
|
|
||||||
|
if( in >= 'a' && in <= 'z' )
|
||||||
|
out = in + 'A' - 'a';
|
||||||
|
else out = in;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline char Q_tolower( const char in )
|
||||||
|
{
|
||||||
|
char out;
|
||||||
|
|
||||||
|
if( in >= 'A' && in <= 'Z' )
|
||||||
|
out = in + 'a' - 'A';
|
||||||
|
else out = in;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline qboolean Q_isdigit( const char *str )
|
||||||
|
{
|
||||||
|
if( likely( str && *str ))
|
||||||
|
{
|
||||||
|
while( isdigit( *str )) str++;
|
||||||
|
if( !*str ) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline qboolean Q_isspace( const char *str )
|
||||||
|
{
|
||||||
|
if( likely( str && *str ))
|
||||||
|
{
|
||||||
|
while( isspace( *str ) ) str++;
|
||||||
|
if( !*str ) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// libc implementations
|
// libc implementations
|
||||||
static inline int Q_strcmp( const char *s1, const char *s2 )
|
static inline int Q_strcmp( const char *s1, const char *s2 )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue