From 8d5d86cbafa2225b8ac741eee3929c96cfff9d7b Mon Sep 17 00:00:00 2001 From: BjossiAlfreds Date: Wed, 16 Oct 2024 13:54:38 +0000 Subject: [PATCH] Q_strisnum shared helper function --- src/common/header/shared.h | 1 + src/common/shared/shared.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/common/header/shared.h b/src/common/header/shared.h index 35939b90..492986c1 100644 --- a/src/common/header/shared.h +++ b/src/common/header/shared.h @@ -335,6 +335,7 @@ void Q_strdel(char *s, size_t i, size_t n); /* Insert src into dest starting at index i, total, n is the total size of the buffer */ /* Returns length of src on success, 0 if there is not enough space in dest for src */ size_t Q_strins(char *dest, const char *src, size_t i, size_t n); +qboolean Q_strisnum(const char *s); /* ============================================= */ diff --git a/src/common/shared/shared.c b/src/common/shared/shared.c index 792ffde8..e7521725 100644 --- a/src/common/shared/shared.c +++ b/src/common/shared/shared.c @@ -1190,6 +1190,20 @@ Q_strins(char *dest, const char *src, size_t i, size_t n) return slen; } +qboolean +Q_strisnum(const char *s) +{ + for (; *s != '\0'; s++) + { + if (!isdigit(*s)) + { + return false; + } + } + + return true; +} + /* * An unicode compatible fopen() Wrapper for Windows. */