From 14200cdd4167b2560a724f66be4316c8635b3434 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 20 Feb 2021 21:09:08 +0100 Subject: [PATCH] quake2,heretic2: attempt to fix undeclared strupr, <3 Kai Attempt to fix this: netradiant/tools/heretic2/h2data/tmix.c:292:5: error: implicit declaration of function 'strupr' is invalid in C99 [-Werror,-Wimplicit-function-declaration] strupr( buffer ); ^ --- tools/heretic2/common/cmdlib.c | 30 ++++++++++++++---------------- tools/heretic2/common/cmdlib.h | 7 ++++++- tools/heretic2/h2data/fmodels.c | 14 -------------- tools/quake2/common/cmdlib.c | 3 ++- tools/quake2/common/cmdlib.h | 5 +++++ tools/quake2/extra/common/cmdlib.c | 4 +++- tools/quake2/extra/common/cmdlib.h | 8 ++++++-- 7 files changed, 36 insertions(+), 35 deletions(-) diff --git a/tools/heretic2/common/cmdlib.c b/tools/heretic2/common/cmdlib.c index 0f9ce0d5..24445227 100644 --- a/tools/heretic2/common/cmdlib.c +++ b/tools/heretic2/common/cmdlib.c @@ -496,22 +496,20 @@ int Q_strcasecmp( const char *s1, const char *s2 ){ return Q_strncasecmp( s1, s2, 99999 ); } -// NOTE TTimo when switching to Multithread DLL (Release/Debug) in the config -// started getting warnings about that function, prolly a duplicate with the runtime function -// maybe we still need to have it in linux builds -/* - char *strupr (char *start) - { - char *in; - in = start; - while (*in) - { - *in = toupper(*in); - in++; - } - return start; - } - */ +// May be already defined with some compilers on Windows +#ifndef strupr +char *strupr (char *start) +{ + char *in; + in = start; + while (*in) + { + *in = toupper(*in); + in++; + } + return start; +} +#endif char *strlower( char *start ){ char *in; diff --git a/tools/heretic2/common/cmdlib.h b/tools/heretic2/common/cmdlib.h index f3624d6b..b9c7de93 100644 --- a/tools/heretic2/common/cmdlib.h +++ b/tools/heretic2/common/cmdlib.h @@ -80,7 +80,12 @@ void *safe_malloc_info( size_t size, char* info ); extern int myargc; extern char **myargv; -char *strlower( char *in ); +// May be already defined with some compilers on Windows +#ifndef strupr +char *strupr (char *start); +#endif + +char *strlower( char *start ); int Q_strncasecmp( const char *s1, const char *s2, int n ); int Q_stricmp( const char *s1, const char *s2 ); int Q_strcasecmp( const char *s1, const char *s2 ); diff --git a/tools/heretic2/h2data/fmodels.c b/tools/heretic2/h2data/fmodels.c index ac04d38b..6e8a263f 100644 --- a/tools/heretic2/h2data/fmodels.c +++ b/tools/heretic2/h2data/fmodels.c @@ -148,20 +148,6 @@ void GetOneGroup( trigroup_t *tris, int grp, triangle_t* triangles ); void ScaleTris( vec3_t min, vec3_t max, int Width, int Height, float* u, float* v, int verts ); void NewDrawLine( int x1, int y1, int x2, int y2, unsigned char* picture, int width, int height ); -#if !GDEF_OS_WINDOWS -char *strupr (char *start) -{ - char *in; - in = start; - while (*in) - { - *in = toupper(*in); - in++; - } - return start; -} -#endif - //============================================================== /* diff --git a/tools/quake2/common/cmdlib.c b/tools/quake2/common/cmdlib.c index 0b65ddaa..fd025691 100644 --- a/tools/quake2/common/cmdlib.c +++ b/tools/quake2/common/cmdlib.c @@ -490,7 +490,8 @@ int Q_strcasecmp( const char *s1, const char *s2 ){ return Q_strncasecmp( s1, s2, 99999 ); } -#if !GDEF_OS_WINDOWS +// May be already defined with some compilers on Windows +#ifndef strupr char *strupr (char *start) { char *in; diff --git a/tools/quake2/common/cmdlib.h b/tools/quake2/common/cmdlib.h index 49f1aeb1..3dbf9682 100644 --- a/tools/quake2/common/cmdlib.h +++ b/tools/quake2/common/cmdlib.h @@ -77,6 +77,11 @@ void *safe_malloc_info( size_t size, char* info ); extern int myargc; extern char **myargv; +// May be already defined with some compilers on Windows +#ifndef strupr +char *strupr (char *start); +#endif + char *strlower( char *in ); int Q_strncasecmp( const char *s1, const char *s2, int n ); int Q_strcasecmp( const char *s1, const char *s2 ); diff --git a/tools/quake2/extra/common/cmdlib.c b/tools/quake2/extra/common/cmdlib.c index 79269079..ab900c90 100644 --- a/tools/quake2/extra/common/cmdlib.c +++ b/tools/quake2/extra/common/cmdlib.c @@ -461,7 +461,8 @@ int Q_strcasecmp (char *s1, char *s2) return Q_strncasecmp (s1, s2, 99999); } - +// May be already defined with some compilers on Windows +#ifndef strupr char *strupr (char *start) { char *in; @@ -473,6 +474,7 @@ char *strupr (char *start) } return start; } +#endif char *strlower (char *start) { diff --git a/tools/quake2/extra/common/cmdlib.h b/tools/quake2/extra/common/cmdlib.h index 0821ce51..afbeb348 100644 --- a/tools/quake2/extra/common/cmdlib.h +++ b/tools/quake2/extra/common/cmdlib.h @@ -56,8 +56,12 @@ typedef unsigned char byte; extern int myargc; extern char **myargv; -char *strupr (char *in); -char *strlower (char *in); +// May be already defined with some compilers on Windows +#ifndef strupr +char *strupr (char *start); +#endif + +char *strlower (char *start); int Q_strncasecmp (char *s1, char *s2, int n); int Q_strcasecmp (char *s1, char *s2); void Q_getwd (char *out); -- 2.39.2