From f0c318cafe0cb56ec3ac9120bd47af0b75f91da3 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 27 Feb 2010 08:00:57 +0000 Subject: [PATCH] common.c (Q_strncasecmp): fix it so that it properly returns negative and positive values. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@87 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/common.c | 15 ++++++++------- Quake/host_cmd.c | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Quake/common.c b/Quake/common.c index 9a758c99..530f0616 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -275,6 +275,9 @@ 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++; @@ -289,16 +292,14 @@ int Q_strncasecmp (const char *s1, const char *s2, int n) c1 -= ('a' - 'A'); if (c2 >= 'a' && c2 <= 'z') c2 -= ('a' - 'A'); - if (c1 != c2) - return -1; // strings not equal } if (!c1) - return 0; // strings are equal -// s1++; -// s2++; + return (c2 == 0) ? 0 : -1; + if (c1 < c2) + return -1; + if (c1 > c2) + return 1; } - - return -1; } int Q_strcasecmp (const char *s1, const char *s2) diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index f3ac7be7..ea701094 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -2214,6 +2214,7 @@ void Host_InitCommands (void) Cmd_AddCommand ("maps", Host_Maps_f); //johnfitz Cmd_AddCommand ("game", Host_Game_f); //johnfitz Cmd_AddCommand ("mods", Host_Mods_f); //johnfitz + Cmd_AddCommand ("games", Host_Mods_f); // as an alias to "mods" -- S.A. Cmd_AddCommand ("mapname", Host_Mapname_f); //johnfitz Cmd_AddCommand ("status", Host_Status_f);