Verified Commit b65cbcee authored by Camil Staps's avatar Camil Staps 🚀

Support STDERR_TO_FILE preprocessor argument on non-Windows systems

parent 4c7c9836
......@@ -5,17 +5,16 @@
#include "util.h"
#include "settings.h"
#if defined(WINDOWS) && defined(LINK_CLEAN_RUNTIME)
#if (defined (WINDOWS) && defined (LINK_CLEAN_RUNTIME)) || defined (STDERR_TO_FILE)
char print_buffer[PRINT_BUFFER_SIZE];
# ifdef STDERR_TO_FILE
#endif
#ifdef STDERR_TO_FILE
static FILE *stderr_to_file=NULL;
void stderr_print(int n) {
if (stderr_to_file==NULL)
stderr_to_file=fopen("stderr","w");
fwrite(print_buffer,1,n,stderr_to_file);
}
# endif
#endif
void *safe_malloc(size_t size) {
......
......@@ -47,8 +47,8 @@ ssize_t
char *strsep(char **stringp, const char *delim);
#endif
#define PRINT_BUFFER_SIZE 32768
#if defined(WINDOWS) && defined(LINK_CLEAN_RUNTIME)
# define PRINT_BUFFER_SIZE 32768
extern char print_buffer[];
# ifdef STDERR_TO_FILE
void stderr_print(int);
......@@ -70,8 +70,15 @@ extern void w_print_char(char);
# define EPUTCHAR debugger_putchar
# define PUTCHAR debugger_putchar
#else
# define EPRINTF(...) fprintf(stderr,__VA_ARGS__)
# ifdef STDERR_TO_FILE
extern char print_buffer[];
void stderr_print(int);
# define EPRINTF(...) stderr_print (snprintf (print_buffer,PRINT_BUFFER_SIZE-1,__VA_ARGS__))
# define EPUTCHAR(c) EPRINTF("%c",c)
# else
# define EPRINTF(...) fprintf(stderr,__VA_ARGS__)
# define EPUTCHAR(c) fputc(c,stderr)
# endif
# define PRINTF printf
# define EPUTCHAR(c) fputc(c,stderr)
# define PUTCHAR putchar
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment