Skip to content

Commit 3584377

Browse files
authored
Various warning fixes (#381)
* QTV: fix compilation with C23 * CMakeLists.txt: fix empty ELSEIF() * common.c: fix warning * sbar.c: rename CHAR_WIDTH to QCHAR_WIDTH to avoid shadowing * more C23 fixes * hack to fix iqmtool * hack to fix httpserver and plugins
1 parent 8708107 commit 3584377

15 files changed

Lines changed: 40 additions & 65 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ IF(FREETYPE_FOUND)
245245
INCLUDE_DIRECTORIES( ${Fontconfig_INCLUDE_DIRS} )
246246
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};LIBFONTCONFIG_STATIC)
247247
SET(FTE_LIBS ${FTE_LIBS} ${Fontconfig_LIBRARIES})
248-
ELSEIF()
248+
ELSE()
249249
MESSAGE(WARNING "fontconfig library NOT available. I hope you're not using any system fonts.")
250250
ENDIF()
251251
ELSE()

engine/client/cl_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ static void CL_BeginServerConnect(char *chain, int port, qboolean noproxy, enum
17191719
char *e = strchr(arglist, '&');
17201720
if (e)
17211721
*e=0;
1722-
if (!strncasecmp(arglist, "fp=", 3))
1722+
if (!Q_strncasecmp(arglist, "fp=", 3))
17231723
{
17241724
size_t l = 8*Base64_DecodeBlock(arglist+3, arglist+strlen(arglist), connectinfo.peercred.digest, sizeof(connectinfo.peercred.digest));
17251725
if (l <= 160)

engine/client/in_generic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,17 +1170,17 @@ qboolean IN_SetHandPosition(const char *devname, vec3_t org, vec3_t ang, vec3_t
11701170
int dtype;
11711171
int seat;
11721172
struct vrdevinfo_s *dev;
1173-
if (!strncasecmp(devname, "left", 4))
1173+
if (!Q_strncasecmp(devname, "left", 4))
11741174
{
11751175
seat = atoi(devname+4);
11761176
dtype = VRDEV_LEFT;
11771177
}
1178-
else if (!strncasecmp(devname, "right", 5))
1178+
else if (!Q_strncasecmp(devname, "right", 5))
11791179
{
11801180
seat = atoi(devname+5);
11811181
dtype = VRDEV_RIGHT;
11821182
}
1183-
else if (!strncasecmp(devname, "head", 4))
1183+
else if (!Q_strncasecmp(devname, "head", 4))
11841184
{
11851185
seat = atoi(devname+4);
11861186
dtype = VRDEV_HEAD;

engine/client/m_multi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ qboolean MultiBeginGame (union menuoption_s *option,struct emenu_s *menu, int ke
617617
continue;
618618
break;
619619
}
620-
if (*shn || !*hostname || !strcasecmp(hostname, "player") || !strcasecmp(hostname, "unnamed")) //not simple enough...
620+
if (*shn || !*hostname || !Q_strcasecmp(hostname, "player") || !Q_strcasecmp(hostname, "unnamed")) //not simple enough...
621621
Cbuf_AddText(va("sv_public \"/\"\n"), RESTRICT_LOCAL);
622622
else
623623
Cbuf_AddText(va("sv_public \"/%s\"\n", info->hostnameedit->text), RESTRICT_LOCAL);
@@ -802,7 +802,7 @@ void M_Menu_GameOptions_f (void)
802802
info->numplayers = MC_AddCombo (menu, 64, 160, y, localtext("Max players"), (const char **)numplayeroptions, players);y+=8;
803803

804804
info->deathmatch = MC_AddCombo (menu, 64, 160, y, localtext("Deathmatch"), (const char **)deathmatchoptions, deathmatch.value);y+=8;
805-
info->teamplay = MC_AddCombo (menu, 64, 160, y, localtext("Teamplay"), (!strcasecmp(FS_GetGamedir(true), "rogue")?(const char **)teamplayoptions_rogue:(const char **)teamplayoptions), teamplay.value);y+=8;
805+
info->teamplay = MC_AddCombo (menu, 64, 160, y, localtext("Teamplay"), (!Q_strcasecmp(FS_GetGamedir(true), "rogue")?(const char **)teamplayoptions_rogue:(const char **)teamplayoptions), teamplay.value);y+=8;
806806
info->skill = MC_AddCombo (menu, 64, 160, y, localtext("Skill"), (const char **)skilloptions, skill.value);y+=8;
807807
info->rundedicated = MC_AddCheckBox(menu, 64, 160, y, localtext("dedicated"), NULL, 0);y+=8;
808808
y+=8;

engine/client/sbar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static mpic_t *Sbar_Q2CachePic(char *name)
335335

336336
#define ICON_WIDTH 24
337337
#define ICON_HEIGHT 24
338-
#define CHAR_WIDTH 16
338+
#define QCHAR_WIDTH 16
339339
#define ICON_SPACE 8
340340
static void SCR_DrawField (float x, float y, int color, float width, int value)
341341
{
@@ -356,7 +356,7 @@ static void SCR_DrawField (float x, float y, int color, float width, int value)
356356
l = strlen(num);
357357
if (l > width)
358358
l = width;
359-
x += 2 + CHAR_WIDTH*(width - l);
359+
x += 2 + QCHAR_WIDTH*(width - l);
360360

361361
ptr = num;
362362
while (*ptr && l)
@@ -369,7 +369,7 @@ static void SCR_DrawField (float x, float y, int color, float width, int value)
369369
p = Sbar_Q2CachePic(q2sb_nums[color][frame]);
370370
if (p && R_GetShaderSizes(p, &pw, &ph, false)>0)
371371
R2D_ScalePic (x,y,pw, ph, p);
372-
x += CHAR_WIDTH;
372+
x += QCHAR_WIDTH;
373373
ptr++;
374374
l--;
375375
}

engine/common/bothdefs.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,11 +861,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
861861
#define strnicmp _strnicmp
862862
#else
863863
//Posix
864-
#define stricmp strcasecmp
865-
#define strnicmp strncasecmp
864+
#define stricmp Q_strcasecmp
865+
#define strnicmp Q_strncasecmp
866866
#endif
867867
#endif
868868

869+
#if defined(IQMTOOL) || defined(WEBSVONLY) || defined(FTEPLUGIN)
870+
#ifdef _WIN32
871+
//Windows-specific...
872+
#define Q_strcasecmp _stricmp
873+
#define Q_strncasecmp _strnicmp
874+
#else
875+
//Posix
876+
#define Q_strcasecmp strcasecmp
877+
#define Q_strncasecmp strncasecmp
878+
#endif
879+
#endif
869880

870881
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
871882
#define CACHE_SIZE 32 // used to align key data structures

engine/common/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2513,7 +2513,7 @@ vec3_t bytedirs[Q2NUMVERTEXNORMALS] =
25132513
};
25142514
#endif
25152515
#ifdef HAVE_CLIENT
2516-
void MSG_ReadDir (vec3_t dir)
2516+
void MSG_ReadDir (float *dir)
25172517
{
25182518
int b;
25192519

engine/common/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,10 @@ void QDECL Q_strncpyz(char*d, const char*s, int n);
440440

441441
/*replacement functions which do not care for locale in text formatting ('C' locale), or are non-standard*/
442442
char *Q_strcasestr(const char *haystack, const char *needle);
443+
#if !defined(IQMTOOL) && !defined(WEBSVONLY) && !defined(FTEPLUGIN)
443444
int Q_strncasecmp (const char *s1, const char *s2, int n);
444445
int Q_strcasecmp (const char *s1, const char *s2);
446+
#endif
445447
int Q_strstopcasecmp(const char *s1start, const char *s1end, const char *s2);
446448
int Q_atoi (const char *str);
447449
float Q_atof (const char *str);

engine/common/cvar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void *AHash_GetInsensitive(ahashtable_t *table, const char *name)
5252
if (b)
5353
for (i = 0; i < b->numentries; i++)
5454
{
55-
if (!strcasecmp(b->entry[i].string, name))
55+
if (!Q_strcasecmp(b->entry[i].string, name))
5656
return b->entry[i].data;
5757
}
5858
return NULL;
@@ -64,7 +64,7 @@ void AHash_RemoveDataInsensitive(ahashtable_t *table, const char *name, void *da
6464
size_t i;
6565
for (i = 0; i < b->numentries; i++)
6666
{
67-
if (b->entry[i].data == data && !strcasecmp(b->entry[i].string, name))
67+
if (b->entry[i].data == data && !Q_strcasecmp(b->entry[i].string, name))
6868
{
6969
//strip it.
7070
b->numentries--;

engine/common/fs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3923,7 +3923,7 @@ static int QDECL FS_SortWildDataFiles(const void *va, const void *vb)
39233923
return a->mtime > b->mtime;
39243924

39253925
//then fall back and sort by name
3926-
return strcasecmp(na, nb);
3926+
return Q_strcasecmp(na, nb);
39273927
}
39283928
static void FS_LoadWildDataFiles (filelist_t *list, wildpaks_t *wp)
39293929
{
@@ -7741,7 +7741,7 @@ static int QDECL Mods_AddGamedir(const char *fname, qofs_t fsize, time_t mtime,
77417741
desc = NULL;
77427742
for (u = 0; u < Cmd_Argc(); u+=2)
77437743
{
7744-
if (!strcasecmp(Cmd_Argv(u), "game"))
7744+
if (!Q_strcasecmp(Cmd_Argv(u), "game"))
77457745
desc = Cmd_Argv(u+1);
77467746
}
77477747
if (desc)

0 commit comments

Comments
 (0)