From 56c4fb2e72f6a4332adfc58a451ae01fb80f6915 Mon Sep 17 00:00:00 2001 From: sezero Date: Wed, 25 Sep 2013 17:01:40 +0000 Subject: [PATCH] replace all ctype.h functions/macros and strcasecmp/strncasecmp() by locale-insensitive versions, new header q_ctype.h. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@868 af15c1b1-3010-417e-b628-4374ebc0bcbd --- .../Misc/quake_retexturing_project.patch | 2 +- quakespasm/Quake/bgmusic.c | 12 +- quakespasm/Quake/cd_sdl.c | 24 ++-- quakespasm/Quake/cmd.c | 8 +- quakespasm/Quake/common.c | 110 ++++++++++++------ quakespasm/Quake/common.h | 19 ++- quakespasm/Quake/gl_model.c | 4 +- quakespasm/Quake/gl_texmgr.c | 2 +- quakespasm/Quake/host_cmd.c | 18 +-- quakespasm/Quake/keys.c | 2 +- quakespasm/Quake/net_dgrm.c | 12 +- quakespasm/Quake/net_main.c | 6 +- quakespasm/Quake/q_ctype.h | 85 ++++++++++++++ quakespasm/Quake/q_stdinc.h | 58 +++++---- quakespasm/Quake/snd_codec.c | 4 +- quakespasm/Quake/snd_umx.c | 3 +- quakespasm/Quake/sv_user.c | 38 +++--- 17 files changed, 262 insertions(+), 145 deletions(-) create mode 100644 quakespasm/Quake/q_ctype.h diff --git a/quakespasm/Misc/quake_retexturing_project.patch b/quakespasm/Misc/quake_retexturing_project.patch index 20226afb..ed056154 100644 --- a/quakespasm/Misc/quake_retexturing_project.patch +++ b/quakespasm/Misc/quake_retexturing_project.patch @@ -15,7 +15,7 @@ Index: Quake/gl_model.c @@ -438,7 +440,17 @@ void Mod_LoadTextures (lump_t *l) if (!isDedicated) //no texture uploading for dedicated server { - if (!Q_strncasecmp(tx->name,"sky",3)) //sky texture //also note -- was Q_strncmp, changed to match qbsp + if (!q_strncasecmp(tx->name,"sky",3)) //sky texture //also note -- was Q_strncmp, changed to match qbsp + { + //mk -- begin + if (r_externaltexture_fix.value) { diff --git a/quakespasm/Quake/bgmusic.c b/quakespasm/Quake/bgmusic.c index c259d1cf..40c196dd 100644 --- a/quakespasm/Quake/bgmusic.c +++ b/quakespasm/Quake/bgmusic.c @@ -101,13 +101,13 @@ static void BGM_Loop_f (void) { if (Cmd_Argc() == 2) { - if (Q_strcasecmp(Cmd_Argv(1), "0") == 0 || - Q_strcasecmp(Cmd_Argv(1),"off") == 0) + if (q_strcasecmp(Cmd_Argv(1), "0") == 0 || + q_strcasecmp(Cmd_Argv(1),"off") == 0) bgmloop = false; - else if (Q_strcasecmp(Cmd_Argv(1), "1") == 0 || - Q_strcasecmp(Cmd_Argv(1),"on") == 0) + else if (q_strcasecmp(Cmd_Argv(1), "1") == 0 || + q_strcasecmp(Cmd_Argv(1),"on") == 0) bgmloop = true; - else if (Q_strcasecmp(Cmd_Argv(1),"toggle") == 0) + else if (q_strcasecmp(Cmd_Argv(1),"toggle") == 0) bgmloop = !bgmloop; } @@ -248,7 +248,7 @@ void BGM_Play (const char *filename) while (handler) { if (handler->is_available && - !Q_strcasecmp(ext, handler->ext)) + !q_strcasecmp(ext, handler->ext)) break; handler = handler->next; } diff --git a/quakespasm/Quake/cd_sdl.c b/quakespasm/Quake/cd_sdl.c index d0ef7436..dd136a9b 100644 --- a/quakespasm/Quake/cd_sdl.c +++ b/quakespasm/Quake/cd_sdl.c @@ -208,13 +208,13 @@ static void CD_f (void) command = Cmd_Argv (1); - if (Q_strcasecmp(command, "on") == 0) + if (q_strcasecmp(command, "on") == 0) { enabled = true; return; } - if (Q_strcasecmp(command, "off") == 0) + if (q_strcasecmp(command, "off") == 0) { if (playing) CDAudio_Stop(); @@ -222,7 +222,7 @@ static void CD_f (void) return; } - if (Q_strcasecmp(command, "reset") == 0) + if (q_strcasecmp(command, "reset") == 0) { enabled = true; if (playing) @@ -233,7 +233,7 @@ static void CD_f (void) return; } - if (Q_strcasecmp(command, "remap") == 0) + if (q_strcasecmp(command, "remap") == 0) { ret = Cmd_Argc() - 2; if (ret <= 0) @@ -258,37 +258,37 @@ static void CD_f (void) } } - if (Q_strcasecmp(command, "play") == 0) + if (q_strcasecmp(command, "play") == 0) { CDAudio_Play((byte)atoi(Cmd_Argv (2)), false); return; } - if (Q_strcasecmp(command, "loop") == 0) + if (q_strcasecmp(command, "loop") == 0) { CDAudio_Play((byte)atoi(Cmd_Argv (2)), true); return; } - if (Q_strcasecmp(command, "stop") == 0) + if (q_strcasecmp(command, "stop") == 0) { CDAudio_Stop(); return; } - if (Q_strcasecmp(command, "pause") == 0) + if (q_strcasecmp(command, "pause") == 0) { CDAudio_Pause(); return; } - if (Q_strcasecmp(command, "resume") == 0) + if (q_strcasecmp(command, "resume") == 0) { CDAudio_Resume(); return; } - if (Q_strcasecmp(command, "eject") == 0) + if (q_strcasecmp(command, "eject") == 0) { if (playing) CDAudio_Stop(); @@ -297,7 +297,7 @@ static void CD_f (void) return; } - if (Q_strcasecmp(command, "info") == 0) + if (q_strcasecmp(command, "info") == 0) { int current_min, current_sec, current_frame; int length_min, length_sec, length_frame; @@ -482,7 +482,7 @@ int CDAudio_Init(void) } for (i = 0; i < sdl_num_drives; i++) { - if (!Q_strcasecmp(SDL_CDName(i), userdev)) + if (!q_strcasecmp(SDL_CDName(i), userdev)) { cd_dev = i; break; diff --git a/quakespasm/Quake/cmd.c b/quakespasm/Quake/cmd.c index b126db70..5993d154 100644 --- a/quakespasm/Quake/cmd.c +++ b/quakespasm/Quake/cmd.c @@ -715,7 +715,7 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src) // check functions for (cmd=cmd_functions ; cmd ; cmd=cmd->next) { - if (!Q_strcasecmp (cmd_argv[0],cmd->name)) + if (!q_strcasecmp (cmd_argv[0],cmd->name)) { cmd->function (); return; @@ -725,7 +725,7 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src) // check alias for (a=cmd_alias ; a ; a=a->next) { - if (!Q_strcasecmp (cmd_argv[0], a->name)) + if (!q_strcasecmp (cmd_argv[0], a->name)) { Cbuf_InsertText (a->value); return; @@ -758,7 +758,7 @@ void Cmd_ForwardToServer (void) return; // not really connected MSG_WriteByte (&cls.message, clc_stringcmd); - if (Q_strcasecmp(Cmd_Argv(0), "cmd") != 0) + if (q_strcasecmp(Cmd_Argv(0), "cmd") != 0) { SZ_Print (&cls.message, Cmd_Argv(0)); SZ_Print (&cls.message, " "); @@ -787,7 +787,7 @@ int Cmd_CheckParm (const char *parm) Sys_Error ("Cmd_CheckParm: NULL"); for (i = 1; i < Cmd_Argc (); i++) - if (! Q_strcasecmp (parm, Cmd_Argv (i))) + if (! q_strcasecmp (parm, Cmd_Argv (i))) return i; return 0; diff --git a/quakespasm/Quake/common.c b/quakespasm/Quake/common.c index ecb91663..a8baa061 100644 --- a/quakespasm/Quake/common.c +++ b/quakespasm/Quake/common.c @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // common.c -- misc functions used in client and server #include "quakedef.h" +#include "q_ctype.h" #include static char *largv[MAX_NUM_ARGVS + 1]; @@ -149,6 +150,79 @@ void InsertLinkAfter (link_t *l, link_t *after) ============================================================================ */ +int q_strcasecmp(const char * s1, const char * s2) +{ + const char * p1 = s1; + const char * p2 = s2; + char c1, c2; + + if (p1 == p2) + return 0; + + do + { + c1 = q_tolower (*p1++); + c2 = q_tolower (*p2++); + if (c1 == '\0') + break; + } while (c1 == c2); + + return (int)(c1 - c2); +} + +int q_strncasecmp(const char *s1, const char *s2, size_t n) +{ + const char * p1 = s1; + const char * p2 = s2; + char c1, c2; + + if (p1 == p2 || n == 0) + return 0; + + do + { + c1 = q_tolower (*p1++); + c2 = q_tolower (*p2++); + if (c1 == '\0' || c1 != c2) + break; + } while (--n > 0); + + return (int)(c1 - c2); +} + +char *q_strlwr (char *str) +{ + char *c; + c = str; + while (*c) + { + *c = q_tolower(*c); + c++; + } + return str; +} + +char *q_strupr (char *str) +{ + char *c; + c = str; + while (*c) + { + *c = q_toupper(*c); + c++; + } + return str; +} + +/* platform dependant (v)snprintf function names: */ +#if defined(_WIN32) +#define snprintf_func _snprintf +#define vsnprintf_func _vsnprintf +#else +#define snprintf_func snprintf +#define vsnprintf_func vsnprintf +#endif + int q_vsnprintf(char *str, size_t size, const char *format, va_list args) { int ret; @@ -299,42 +373,6 @@ int Q_strncmp (const char *s1, const char *s2, int count) return -1; } -int Q_strncasecmp (const char *s1, const char *s2, int n) -{ - int c1, c2; - - if (s1 == s2 || n <= 0) - return 0; - - while (1) - { - c1 = *s1++; - c2 = *s2++; - - if (!n--) - return 0; // strings are equal until end point - - if (c1 != c2) - { - if (c1 >= 'a' && c1 <= 'z') - c1 -= ('a' - 'A'); - if (c2 >= 'a' && c2 <= 'z') - c2 -= ('a' - 'A'); - } - if (!c1) - return (c2 == 0) ? 0 : -1; - if (c1 < c2) - return -1; - if (c1 > c2) - return 1; - } -} - -int Q_strcasecmp (const char *s1, const char *s2) -{ - return Q_strncasecmp (s1, s2, 99999); -} - int Q_atoi (const char *str) { int val; diff --git a/quakespasm/Quake/common.h b/quakespasm/Quake/common.h index 0ee2f41c..d04ea501 100644 --- a/quakespasm/Quake/common.h +++ b/quakespasm/Quake/common.h @@ -133,24 +133,21 @@ char *Q_strrchr (const char *s, char c); void Q_strcat (char *dest, const char *src); int Q_strcmp (const char *s1, const char *s2); int Q_strncmp (const char *s1, const char *s2, int count); -int Q_strcasecmp (const char *s1, const char *s2); -int Q_strncasecmp (const char *s1, const char *s2, int n); int Q_atoi (const char *str); float Q_atof (const char *str); #include "strl_fn.h" -/* snprintf, vsnprintf : always use our versions. */ -/* platform dependant (v)snprintf function names: */ -#if defined(_WIN32) -#define snprintf_func _snprintf -#define vsnprintf_func _vsnprintf -#else -#define snprintf_func snprintf -#define vsnprintf_func vsnprintf -#endif +/* locale-insensitive strcasecmp replacement functions: */ +extern int q_strcasecmp (const char * s1, const char * s2); +extern int q_strncasecmp (const char *s1, const char *s2, size_t n); +/* locale-insensitive strlwr/upr replacement functions: */ +extern char *q_strlwr (char *str); +extern char *q_strupr (char *str); + +/* snprintf, vsnprintf : always use our versions. */ extern int q_snprintf (char *str, size_t size, const char *format, ...) __attribute__((__format__(__printf__,3,4))); extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args) __attribute__((__format__(__printf__,3,0))); diff --git a/quakespasm/Quake/gl_model.c b/quakespasm/Quake/gl_model.c index 50986a78..13657b4c 100644 --- a/quakespasm/Quake/gl_model.c +++ b/quakespasm/Quake/gl_model.c @@ -437,7 +437,7 @@ void Mod_LoadTextures (lump_t *l) //johnfitz -- lots of changes if (!isDedicated) //no texture uploading for dedicated server { - if (!Q_strncasecmp(tx->name,"sky",3)) //sky texture //also note -- was Q_strncmp, changed to match qbsp + if (!q_strncasecmp(tx->name,"sky",3)) //sky texture //also note -- was Q_strncmp, changed to match qbsp Sky_LoadTexture (tx); else if (tx->name[0] == '*') //warping texture { @@ -1083,7 +1083,7 @@ void Mod_LoadFaces (lump_t *l) out->samples = loadmodel->lightdata + (i * 3); //johnfitz -- lit support via lordhavoc (was "+ i") //johnfitz -- this section rewritten - if (!Q_strncasecmp(out->texinfo->texture->name,"sky",3)) // sky surface //also note -- was Q_strncmp, changed to match qbsp + if (!q_strncasecmp(out->texinfo->texture->name,"sky",3)) // sky surface //also note -- was Q_strncmp, changed to match qbsp { out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED); Mod_PolyForUnlitSurface (out); //no more subdivision diff --git a/quakespasm/Quake/gl_texmgr.c b/quakespasm/Quake/gl_texmgr.c index 17121c56..b8014615 100644 --- a/quakespasm/Quake/gl_texmgr.c +++ b/quakespasm/Quake/gl_texmgr.c @@ -144,7 +144,7 @@ static void TexMgr_TextureMode_f (cvar_t *var) for (i = 0; i < NUM_GLMODES; i++) { - if (!Q_strcasecmp (glmodes[i].name, gl_texturemode.string)) + if (!q_strcasecmp (glmodes[i].name, gl_texturemode.string)) { Cvar_SetQuick (&gl_texturemode, glmodes[i].name); return; diff --git a/quakespasm/Quake/host_cmd.c b/quakespasm/Quake/host_cmd.c index 2c28ec56..03e54a49 100644 --- a/quakespasm/Quake/host_cmd.c +++ b/quakespasm/Quake/host_cmd.c @@ -149,7 +149,7 @@ void Host_Game_f (void) } q_strlcpy (pakfile, va("%s/%s", host_parms->basedir, Cmd_Argv(1)), sizeof(pakfile)); - if (!Q_strcasecmp(pakfile, com_gamedir)) //no change + if (!q_strcasecmp(pakfile, com_gamedir)) //no change { Con_Printf("\"game\" is already \"%s\"\n", COM_SkipPath(com_gamedir)); return; @@ -170,7 +170,7 @@ void Host_Game_f (void) q_strlcpy (com_gamedir, pakfile, sizeof(com_gamedir)); - if (Q_strcasecmp(Cmd_Argv(1), GAMENAME)) //game is not id1 + if (q_strcasecmp(Cmd_Argv(1), GAMENAME)) //game is not id1 { // assign a path_id to this game directory if (com_searchpaths) @@ -242,7 +242,7 @@ void ExtraMaps_Add (const char *name) // insert each entry in alphabetical order if (extralevels == NULL || - Q_strcasecmp(level->name, extralevels->name) < 0) //insert at front + q_strcasecmp(level->name, extralevels->name) < 0) //insert at front { level->next = extralevels; extralevels = level; @@ -251,7 +251,7 @@ void ExtraMaps_Add (const char *name) { prev = extralevels; cursor = extralevels->next; - while (cursor && (Q_strcasecmp(level->name, cursor->name) > 0)) + while (cursor && (q_strcasecmp(level->name, cursor->name) > 0)) { prev = cursor; cursor = cursor->next; @@ -378,7 +378,7 @@ void Modlist_Add (const char *name) //insert each entry in alphabetical order if (modlist == NULL || - Q_strcasecmp(mod->name, modlist->name) < 0) //insert at front + q_strcasecmp(mod->name, modlist->name) < 0) //insert at front { mod->next = modlist; modlist = mod; @@ -387,7 +387,7 @@ void Modlist_Add (const char *name) { prev = modlist; cursor = modlist->next; - while (cursor && (Q_strcasecmp(mod->name, cursor->name) > 0)) + while (cursor && (q_strcasecmp(mod->name, cursor->name) > 0)) { prev = cursor; cursor = cursor->next; @@ -430,7 +430,7 @@ void Modlist_Init (void) { if ((strcmp(mod_dir_t->d_name, ".") == 0) || (strcmp(mod_dir_t->d_name, "..") == 0)) continue; - if (Q_strcasecmp(mod_dir_t->d_name, "progs.dat") == 0) + if (q_strcasecmp(mod_dir_t->d_name, "progs.dat") == 0) progs_found = true; if (strstr(mod_dir_t->d_name, ".pak") || strstr(mod_dir_t->d_name, ".PAK")) pak_found = true; @@ -1430,7 +1430,7 @@ void Host_Tell_f(void) { if (!client->active || !client->spawned) continue; - if (Q_strcasecmp(client->name, Cmd_Argv(1))) + if (q_strcasecmp(client->name, Cmd_Argv(1))) continue; host_client = client; SV_ClientPrintf("%s", text); @@ -1761,7 +1761,7 @@ void Host_Kick_f (void) { if (!host_client->active) continue; - if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0) + if (q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0) break; } } diff --git a/quakespasm/Quake/keys.c b/quakespasm/Quake/keys.c index addd7a73..c4ce129a 100644 --- a/quakespasm/Quake/keys.c +++ b/quakespasm/Quake/keys.c @@ -548,7 +548,7 @@ int Key_StringToKeynum (const char *str) for (kn=keynames ; kn->name ; kn++) { - if (!Q_strcasecmp(str,kn->name)) + if (!q_strcasecmp(str,kn->name)) return kn->keynum; } return -1; diff --git a/quakespasm/Quake/net_dgrm.c b/quakespasm/Quake/net_dgrm.c index 1196cb1f..06b25550 100644 --- a/quakespasm/Quake/net_dgrm.c +++ b/quakespasm/Quake/net_dgrm.c @@ -113,7 +113,7 @@ static void NET_Ban_f (void) break; case 2: - if (Q_strcasecmp(Cmd_Argv(1), "off") == 0) + if (q_strcasecmp(Cmd_Argv(1), "off") == 0) banAddr.s_addr = INADDR_ANY; else banAddr.s_addr = inet_addr(Cmd_Argv(1)); @@ -473,7 +473,7 @@ static void NET_Stats_f (void) { for (s = net_activeSockets; s; s = s->next) { - if (Q_strcasecmp(Cmd_Argv(1), s->address) == 0) + if (q_strcasecmp(Cmd_Argv(1), s->address) == 0) break; } @@ -481,7 +481,7 @@ static void NET_Stats_f (void) { for (s = net_freeSockets; s; s = s->next) { - if (Q_strcasecmp(Cmd_Argv(1), s->address) == 0) + if (q_strcasecmp(Cmd_Argv(1), s->address) == 0) break; } } @@ -598,7 +598,7 @@ static void Test_f (void) { for (n = 0; n < hostCacheCount; n++) { - if (Q_strcasecmp (host, hostcache[n].name) == 0) + if (q_strcasecmp (host, hostcache[n].name) == 0) { if (hostcache[n].driver != myDriverLevel) continue; @@ -732,7 +732,7 @@ static void Test2_f (void) { for (n = 0; n < hostCacheCount; n++) { - if (Q_strcasecmp (host, hostcache[n].name) == 0) + if (q_strcasecmp (host, hostcache[n].name) == 0) { if (hostcache[n].driver != myDriverLevel) continue; @@ -1205,7 +1205,7 @@ static void _Datagram_SearchForHosts (qboolean xmit) { if (i == n) continue; - if (Q_strcasecmp (hostcache[n].name, hostcache[i].name) == 0) + if (q_strcasecmp (hostcache[n].name, hostcache[i].name) == 0) { i = Q_strlen(hostcache[n].name); if (i < 15 && hostcache[n].name[i-1] > '8') diff --git a/quakespasm/Quake/net_main.c b/quakespasm/Quake/net_main.c index c32a39a6..580d04b8 100644 --- a/quakespasm/Quake/net_main.c +++ b/quakespasm/Quake/net_main.c @@ -427,7 +427,7 @@ qsocket_t *NET_Connect (const char *host) if (host) { - if (Q_strcasecmp (host, "local") == 0) + if (q_strcasecmp (host, "local") == 0) { numdrivers = 1; goto JustDoIt; @@ -436,7 +436,7 @@ qsocket_t *NET_Connect (const char *host) if (hostCacheCount) { for (n = 0; n < hostCacheCount; n++) - if (Q_strcasecmp (host, hostcache[n].name) == 0) + if (q_strcasecmp (host, hostcache[n].name) == 0) { host = hostcache[n].cname; break; @@ -464,7 +464,7 @@ qsocket_t *NET_Connect (const char *host) { for (n = 0; n < hostCacheCount; n++) { - if (Q_strcasecmp (host, hostcache[n].name) == 0) + if (q_strcasecmp (host, hostcache[n].name) == 0) { host = hostcache[n].cname; break; diff --git a/quakespasm/Quake/q_ctype.h b/quakespasm/Quake/q_ctype.h new file mode 100644 index 00000000..ffbca4cc --- /dev/null +++ b/quakespasm/Quake/q_ctype.h @@ -0,0 +1,85 @@ +/* Locale insensitive ctype.h functions taken from the RPM library - + * RPM is Copyright (c) 1998 by Red Hat Software, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef Q_CTYPE_H +#define Q_CTYPE_H + +static inline int q_isascii(int c) +{ + return ((c & ~0x7f) == 0); +} + +static inline int q_islower(int c) +{ + return (c >= 'a' && c <= 'z'); +} + +static inline int q_isupper(int c) +{ + return (c >= 'A' && c <= 'Z'); +} + +static inline int q_isalpha(int c) +{ + return (q_islower(c) || q_isupper(c)); +} + +static inline int q_isdigit(int c) +{ + return (c >= '0' && c <= '9'); +} + +static inline int q_isxdigit(int c) +{ + return (q_isdigit(c) || (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F')); +} + +static inline int q_isalnum(int c) +{ + return (q_isalpha(c) || q_isdigit(c)); +} + +static inline int q_isblank(int c) +{ + return (c == ' ' || c == '\t'); +} + +static inline int q_isspace(int c) +{ + return (q_isblank(c) || c == '\n' || c == '\r' || + c == '\f' || c == '\v'); +} + +static inline int q_toascii(int c) +{ + return (c & 0x7f); +} + +static inline int q_tolower(int c) +{ + return ((q_isupper(c)) ? (c | ('a' - 'A')) : c); +} + +static inline int q_toupper(int c) +{ + return ((q_islower(c)) ? (c & ~('a' - 'A')) : c); +} + +#endif /* Q_CTYPE_H */ diff --git a/quakespasm/Quake/q_stdinc.h b/quakespasm/Quake/q_stdinc.h index f0bffe9f..145c8a83 100644 --- a/quakespasm/Quake/q_stdinc.h +++ b/quakespasm/Quake/q_stdinc.h @@ -1,32 +1,30 @@ /* - q_stdinc.h - includes the minimum necessary stdc headers, - defines common and / or missing types. - NOTE: for net stuff use net_sys.h, - for byte order use q_endian.h, - for math stuff use mathlib.h. - - Copyright (C) 1996-1997 Id Software, Inc. - Copyright (C) 2007-2011 O.Sezer - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to: - - Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301 USA -*/ + * q_stdinc.h - includes the minimum necessary stdc headers, + * defines common and / or missing types. + * + * NOTE: for net stuff use net_sys.h, + * for byte order use q_endian.h, + * for math stuff use mathlib.h, + * for locale-insensitive ctype.h functions use q_ctype.h. + * + * Copyright (C) 1996-1997 Id Software, Inc. + * Copyright (C) 2007-2011 O.Sezer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef __QSTDINC_H #define __QSTDINC_H @@ -62,9 +60,6 @@ #include #include #include -#if !defined(_WIN32) -#include /* strcasecmp and strncasecmp */ -#endif /* ! PLATFORM_WINDOWS */ /*==========================================================================*/ @@ -143,6 +138,7 @@ COMPILE_TIME_ASSERT(qboolean, sizeof(qboolean) == 4); /* math */ typedef float vec_t; typedef vec_t vec3_t[3]; +typedef vec_t vec4_t[4]; typedef vec_t vec5_t[5]; typedef int fixed4_t; typedef int fixed8_t; diff --git a/quakespasm/Quake/snd_codec.c b/quakespasm/Quake/snd_codec.c index ea4262b2..243dd3d0 100644 --- a/quakespasm/Quake/snd_codec.c +++ b/quakespasm/Quake/snd_codec.c @@ -165,7 +165,7 @@ snd_stream_t *S_CodecOpenStreamExt (const char *filename) codec = codecs; while (codec) { - if (!Q_strcasecmp(ext, codec->ext)) + if (!q_strcasecmp(ext, codec->ext)) break; codec = codec->next; } @@ -216,7 +216,7 @@ snd_stream_t *S_CodecOpenStreamAny (const char *filename) codec = codecs; while (codec) { - if (!Q_strcasecmp(ext, codec->ext)) + if (!q_strcasecmp(ext, codec->ext)) break; codec = codec->next; } diff --git a/quakespasm/Quake/snd_umx.c b/quakespasm/Quake/snd_umx.c index 872bbe75..89487674 100644 --- a/quakespasm/Quake/snd_umx.c +++ b/quakespasm/Quake/snd_umx.c @@ -29,6 +29,7 @@ #include "snd_umx.h" #define UPKG_HDR_TAG 0x9e2a83c1 + #pragma pack(1) struct upkg_hdr { uint32_t tag; /* UPKG_HDR_TAG */ @@ -244,7 +245,7 @@ static int probe_umx (fshandle_t *f, const struct upkg_hdr *hdr, if (read_typname(f, hdr, t, buf) < 0) return -1; for (i = 0; mustype[i] != NULL; i++) { - if (!strcasecmp(buf, mustype[i])) { + if (!q_strcasecmp(buf, mustype[i])) { t = i; break; } diff --git a/quakespasm/Quake/sv_user.c b/quakespasm/Quake/sv_user.c index 35eb662c..eb9359ab 100644 --- a/quakespasm/Quake/sv_user.c +++ b/quakespasm/Quake/sv_user.c @@ -530,43 +530,43 @@ nextmsg: case clc_stringcmd: s = MSG_ReadString (); ret = 0; - if (Q_strncasecmp(s, "status", 6) == 0) + if (q_strncasecmp(s, "status", 6) == 0) ret = 1; - else if (Q_strncasecmp(s, "god", 3) == 0) + else if (q_strncasecmp(s, "god", 3) == 0) ret = 1; - else if (Q_strncasecmp(s, "notarget", 8) == 0) + else if (q_strncasecmp(s, "notarget", 8) == 0) ret = 1; - else if (Q_strncasecmp(s, "fly", 3) == 0) + else if (q_strncasecmp(s, "fly", 3) == 0) ret = 1; - else if (Q_strncasecmp(s, "name", 4) == 0) + else if (q_strncasecmp(s, "name", 4) == 0) ret = 1; - else if (Q_strncasecmp(s, "noclip", 6) == 0) + else if (q_strncasecmp(s, "noclip", 6) == 0) ret = 1; - else if (Q_strncasecmp(s, "say", 3) == 0) + else if (q_strncasecmp(s, "say", 3) == 0) ret = 1; - else if (Q_strncasecmp(s, "say_team", 8) == 0) + else if (q_strncasecmp(s, "say_team", 8) == 0) ret = 1; - else if (Q_strncasecmp(s, "tell", 4) == 0) + else if (q_strncasecmp(s, "tell", 4) == 0) ret = 1; - else if (Q_strncasecmp(s, "color", 5) == 0) + else if (q_strncasecmp(s, "color", 5) == 0) ret = 1; - else if (Q_strncasecmp(s, "kill", 4) == 0) + else if (q_strncasecmp(s, "kill", 4) == 0) ret = 1; - else if (Q_strncasecmp(s, "pause", 5) == 0) + else if (q_strncasecmp(s, "pause", 5) == 0) ret = 1; - else if (Q_strncasecmp(s, "spawn", 5) == 0) + else if (q_strncasecmp(s, "spawn", 5) == 0) ret = 1; - else if (Q_strncasecmp(s, "begin", 5) == 0) + else if (q_strncasecmp(s, "begin", 5) == 0) ret = 1; - else if (Q_strncasecmp(s, "prespawn", 8) == 0) + else if (q_strncasecmp(s, "prespawn", 8) == 0) ret = 1; - else if (Q_strncasecmp(s, "kick", 4) == 0) + else if (q_strncasecmp(s, "kick", 4) == 0) ret = 1; - else if (Q_strncasecmp(s, "ping", 4) == 0) + else if (q_strncasecmp(s, "ping", 4) == 0) ret = 1; - else if (Q_strncasecmp(s, "give", 4) == 0) + else if (q_strncasecmp(s, "give", 4) == 0) ret = 1; - else if (Q_strncasecmp(s, "ban", 3) == 0) + else if (q_strncasecmp(s, "ban", 3) == 0) ret = 1; if (ret == 1)