foxygit / doom Log in
commit 08bc270bb911feacb1607a8d7672e35d458df773
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Feb 3 00:25:29 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Feb 3 00:25:29 2009 +0000

    Fix compiler warnings.

    Subversion-branch: /branches/raven-branch
    Subversion-revision: 1441
---
 src/hexen/p_inter.c  |  8 ++++----
 src/hexen/st_start.c | 27 ++-------------------------
 src/m_argv.c         | 34 ++++++++++++++++++++++++----------
 3 files changed, 30 insertions(+), 39 deletions(-)

diff --git a/src/hexen/p_inter.c b/src/hexen/p_inter.c
index b66042ad..514d92a6 100644
--- a/src/hexen/p_inter.c
+++ b/src/hexen/p_inter.c
@@ -78,8 +78,8 @@ void P_SetMessage(player_t * player, char *message, boolean ultmsg)
     }
     if (strlen(message) > 79)
     {
-        memcpy(player->message, message, 80);
-        player->message[80] = 0;
+        strncpy(player->message, message, 80);
+        player->message[79] = 0;
     }
     else
     {
@@ -112,8 +112,8 @@ void P_SetYellowMessage(player_t * player, char *message, boolean ultmsg)
     }
     if (strlen(message) > 79)
     {
-        memcpy(player->message, message, 80);
-        player->message[80] = 0;
+        strncpy(player->message, message, 80);
+        player->message[79] = 0;
     }
     else
     {
diff --git a/src/hexen/st_start.c b/src/hexen/st_start.c
index cd89484b..1f3cca1f 100644
--- a/src/hexen/st_start.c
+++ b/src/hexen/st_start.c
@@ -271,25 +271,10 @@ void ST_NetDone(void)
 void ST_Message(char *message, ...)
 {
     va_list argptr;
-    char buffer[80];

     va_start(argptr, message);
-    vsprintf(buffer, message, argptr);
+    vprintf(message, argptr);
     va_end(argptr);
-
-    if (strlen(buffer) >= 80)
-    {
-        I_Error("Long debug message has overwritten memory");
-    }
-
-#ifdef __WATCOMC__
-    if (debugmode)
-    {
-        printf(buffer);
-    }
-#else
-    printf(buffer);
-#endif
 }

 //==========================================================================
@@ -301,18 +286,10 @@ void ST_Message(char *message, ...)
 void ST_RealMessage(char *message, ...)
 {
     va_list argptr;
-    char buffer[80];

     va_start(argptr, message);
-    vsprintf(buffer, message, argptr);
+    vprintf(message, argptr);
     va_end(argptr);
-
-    if (strlen(buffer) >= 80)
-    {
-        I_Error("Long debug message has overwritten memory\n");
-    }
-
-    printf(buffer);             // Always print these messages
 }


diff --git a/src/m_argv.c b/src/m_argv.c
index acc15dfd..1d07a196 100644
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -73,7 +73,7 @@ boolean M_ParmExists(char *check)
 }

 #define MAXARGVS        100
-
+
 static void LoadResponseFile(int argv_index)
 {
     FILE *handle;
@@ -86,7 +86,7 @@ static void LoadResponseFile(int argv_index)
     int i, k;

     response_filename = myargv[argv_index] + 1;
-
+
     // Read the response file into memory
     handle = fopen(response_filename, "r");

@@ -102,11 +102,25 @@ static void LoadResponseFile(int argv_index)

     // Read in the entire file
     // Allocate one byte extra - this is incase there is an argument
-    // at the end of the response file, in which case a '\0' will be
+    // at the end of the response file, in which case a '\0' will be
     // needed.

     file = malloc(size + 1);
-    (void) fread(file, size, 1, handle);
+
+    i = 0;
+
+    while (i < size)
+    {
+        k = fread(file + i, 1, size - i, handle);
+
+        if (k < 0)
+        {
+            I_Error("Failed to read full contents of '%s'", response_filename);
+        }
+
+        i += k;
+    }
+
     fclose(handle);

     // Create new arguments list array
@@ -122,7 +136,7 @@ static void LoadResponseFile(int argv_index)
         newargv[i] = myargv[i];
         ++newargc;
     }
-
+
     infile = file;
     k = 0;

@@ -133,7 +147,7 @@ static void LoadResponseFile(int argv_index)
         while(k < size && isspace(infile[k]))
         {
             ++k;
-        }
+        }

         if (k >= size)
         {
@@ -144,7 +158,7 @@ static void LoadResponseFile(int argv_index)
         // the contents as a single argument.  This allows long filenames
         // to be specified.

-        if (infile[k] == '\"')
+        if (infile[k] == '\"')
         {
             // Skip the first character(")
             ++k;
@@ -158,9 +172,9 @@ static void LoadResponseFile(int argv_index)
                 ++k;
             }

-            if (k >= size || infile[k] == '\n')
+            if (k >= size || infile[k] == '\n')
             {
-                I_Error("Quotes unclosed in response file '%s'",
+                I_Error("Quotes unclosed in response file '%s'",
                         response_filename);
             }

@@ -186,7 +200,7 @@ static void LoadResponseFile(int argv_index)

             ++k;
         }
-    }
+    }

     // Add arguments following the response file argument