ref: 08bc270bb911feacb1607a8d7672e35d458df773
parent: c0cbaafa0b421421c5367cd11d7dfaf6f40aefc7
author: Simon Howard <[email protected]>
date: Mon Feb 2 19:25:29 EST 2009
Fix compiler warnings. Subversion-branch: /branches/raven-branch Subversion-revision: 1441
--- a/src/hexen/p_inter.c
+++ b/src/hexen/p_inter.c
@@ -78,8 +78,8 @@
}
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 @@
}
if (strlen(message) > 79)
{
- memcpy(player->message, message, 80);
- player->message[80] = 0;
+ strncpy(player->message, message, 80);
+ player->message[79] = 0;
}
else
{
--- a/src/hexen/st_start.c
+++ b/src/hexen/st_start.c
@@ -271,25 +271,10 @@
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_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
}
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -73,7 +73,7 @@
}
#define MAXARGVS 100
-
+
static void LoadResponseFile(int argv_index)
{
FILE *handle;
@@ -86,7 +86,7 @@
int i, k;
response_filename = myargv[argv_index] + 1;
-
+
// Read the response file into memory
handle = fopen(response_filename, "r");
@@ -102,11 +102,25 @@
// 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 @@
newargv[i] = myargv[i];
++newargc;
}
-
+
infile = file;
k = 0;
@@ -133,7 +147,7 @@
while(k < size && isspace(infile[k]))
{
++k;
- }
+ }
if (k >= size)
{
@@ -144,7 +158,7 @@
// 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 @@
++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 @@
++k;
}
- }
+ }
// Add arguments following the response file argument