Tier1: add V_IsAllDigit()

This function checks if a string consists of only numeric characters.
This commit is contained in:
Kawe Mazidjatari 2024-02-04 12:52:46 +01:00
parent 8da31dd15c
commit 0dd19ab2dd
2 changed files with 16 additions and 0 deletions

View File

@ -67,6 +67,7 @@ const char* V_strnchr(const char* pStr, char c, ssize_t n);
bool V_isspace(int c);
inline bool V_isalnum(char c) { return isalnum((unsigned char)c) != 0; }
bool V_IsAllDigit(const char* pString);
// this is locale-unaware and therefore faster version of standard isdigit()
// It also avoids sign-extension errors.

View File

@ -242,6 +242,21 @@ bool V_isspace(int c)
#endif
}
bool V_IsAllDigit(const char* pString)
{
while (*pString)
{
if (!V_isdigit(*pString))
{
return false;
}
pString++;
}
return true;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *in -