Make Sys_Error repeat it's message to stderr to increase the changes of the

error being seen. (Closes: #39)
This commit is contained in:
Bill Currie 2002-08-07 15:31:56 +00:00
parent 5c60be3a49
commit e171146582

View file

@ -370,17 +370,36 @@ Sys_Quit (void)
exit (0); exit (0);
} }
#if defined (HAVE_VA_COPY)
# define VA_COPY(a,b) va_copy (a, b)
#elif defined (HAVE__VA_COPY)
# define VA_COPY(a,b) __va_copy (a, b)
#else
# define VA_COPY memcpy (a, b, sizeof (a))
#endif
void void
Sys_Error (const char *error, ...) Sys_Error (const char *error, ...)
{ {
va_list argptr; va_list args;
#ifdef VA_LIST_IS_ARRAY
va_list tmp_args;
VA_COPY (tmp_args, args);
#endif
va_start (argptr, error); va_start (args, error);
sys_err_printf_function (error, argptr); sys_err_printf_function (error, args);
va_end (argptr); va_end (args);
Sys_Shutdown (); Sys_Shutdown ();
// print the message again using the default error printer to increase the
// chances of the error being seen.
#ifdef VA_LIST_IS_ARRAY
VA_COPY (args, tmp_args);
#endif
Sys_ErrPrintf (error, args);
exit (1); exit (1);
} }
@ -434,15 +453,15 @@ Sys_PageIn (void *ptr, int size)
void void
Sys_DebugLog (const char *file, const char *fmt, ...) Sys_DebugLog (const char *file, const char *fmt, ...)
{ {
va_list argptr; va_list args;
static char data[1024]; // why static ? dstring_t *data = dstring_newstr ();
int fd; int fd;
va_start (argptr, fmt); va_start (args, fmt);
vsnprintf (data, sizeof (data), fmt, argptr); dvsprintf (data, fmt, args);
va_end (argptr); va_end (args);
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666); fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
write (fd, data, strlen (data)); write (fd, data->str, data->size - 1);
close (fd); close (fd);
} }