Skip to content

Commit

Permalink
Q_strisnum shared helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
BjossiAlfreds committed Oct 16, 2024
1 parent aae0524 commit 8d5d86c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/header/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/* ============================================= */

Expand Down
14 changes: 14 additions & 0 deletions src/common/shared/shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 8d5d86c

Please sign in to comment.