From: Holger Schemel Date: Thu, 22 Feb 2024 21:50:23 +0000 (+0100) Subject: added function to convert string to all uppercase characters X-Git-Tag: 4.4.0.0-test-1~318 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e1342541fd884143a3d43a5cc7a44de99aa7c715;p=rocksndiamonds.git added function to convert string to all uppercase characters --- diff --git a/src/libgame/misc.c b/src/libgame/misc.c index c84cefc0..5fd8e3c2 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1220,6 +1220,18 @@ char *getStringCopyNStatic(const char *s, int n) return s_copy; } +char *getStringToUpper(const char *s) +{ + char *s_copy = checked_malloc(strlen(s) + 1); + char *s_ptr = s_copy; + + while (*s) + *s_ptr++ = toupper(*s++); + *s_ptr = '\0'; + + return s_copy; +} + char *getStringToLower(const char *s) { char *s_copy = checked_malloc(strlen(s) + 1); diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 46820c1e..e78185c5 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -179,6 +179,7 @@ char *getImg3(const char *, const char *, const char *); char *getStringCopy(const char *); char *getStringCopyN(const char *, int); char *getStringCopyNStatic(const char *, int); +char *getStringToUpper(const char *); char *getStringToLower(const char *); void setString(char **, const char *); char **getSplitStringArray(const char *s, const char *, int);