From ccf90beb7d85928630ea9273545ce734edbac175 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 4 Jan 2022 02:22:10 +0300 Subject: [PATCH] public: crtlib: add Q_isspace function --- common/const.h | 1 - public/crtlib.c | 10 ++++++++++ public/crtlib.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common/const.h b/common/const.h index 2533ec09..a7e3d08b 100644 --- a/common/const.h +++ b/common/const.h @@ -725,7 +725,6 @@ typedef int string_t; typedef unsigned short word; #include "xash3d_types.h" -#define Q_isspace( ch ) (ch < 32 || ch > 255) typedef struct { diff --git a/public/crtlib.c b/public/crtlib.c index e92e2d82..73bafdf4 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -61,6 +61,16 @@ qboolean Q_isdigit( const char *str ) 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 len; diff --git a/public/crtlib.h b/public/crtlib.h index 338598db..99752535 100644 --- a/public/crtlib.h +++ b/public/crtlib.h @@ -61,6 +61,7 @@ size_t Q_strncat( char *dst, const char *src, size_t siz ); size_t Q_strncpy( char *dst, const char *src, size_t siz ); uint Q_hashkey( const char *string, uint hashSize, qboolean caseinsensitive ); qboolean Q_isdigit( const char *str ); +qboolean Q_isspace( const char *str ); int Q_atoi( const char *str ); float Q_atof( const char *str ); void Q_atov( float *vec, const char *str, size_t siz );