From 6bcb98e7797a15b7bf59187971862a9f6f78f4da Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 21 Feb 2026 00:06:30 +0500 Subject: [PATCH] public: replace COM_CheckString and COM_CheckStringEmpty by COM_StringEmptyOrNULL and COM_StringEmpty. Remove legacy macros --- public/crtlib.c | 10 +++++----- public/crtlib.h | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/public/crtlib.c b/public/crtlib.c index 35526a1f..53b1937c 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -68,12 +68,12 @@ int Q_atoi( const char *str ) int val = 0; int c, sign; - if( !COM_CheckString( str )) + if( COM_StringEmptyOrNULL( str )) return 0; str = Q_atoi_strip_whitespace( str ); - if( !COM_CheckString( str )) + if( COM_StringEmptyOrNULL( str )) return 0; if( *str == '-' ) @@ -107,12 +107,12 @@ float Q_atof( const char *str ) double val = 0; int c, sign, decimal, total; - if( !COM_CheckString( str )) + if( COM_StringEmptyOrNULL( str )) return 0; str = Q_atoi_strip_whitespace( str ); - if( !COM_CheckString( str )) + if( COM_StringEmptyOrNULL( str )) return 0; if( *str == '-' ) @@ -468,7 +468,7 @@ void COM_FileBase( const char *in, char *out, size_t size ) const char *dot, *slash, *s; size_t len; - if( unlikely( !COM_CheckString( in ) || size <= 1 )) + if( unlikely( COM_StringEmptyOrNULL( in ) || size <= 1 )) { out[0] = 0; return; diff --git a/public/crtlib.h b/public/crtlib.h index bb80ce40..38118dae 100644 --- a/public/crtlib.h +++ b/public/crtlib.h @@ -94,10 +94,8 @@ const char *COM_FileWithoutPath( const char *in ); void COM_StripExtension( char *path ); void COM_RemoveLineFeed( char *str, size_t bufsize ); void COM_PathSlashFix( char *path ); -// return 0 on empty or null string, 1 otherwise -#define COM_CheckString( string ) ( ( !string || !*string ) ? 0 : 1 ) -#define COM_CheckStringEmpty( string ) ( ( !*string ) ? 0 : 1 ) +// returns true on empty or NULL string, false otherwise #define COM_StringEmpty( string ) (( string )[0] ? false : true ) #define COM_StringEmptyOrNULL( string ) (( string ) && ( string )[0] ? false : true )