Redirect error messages to stderr

This commit is contained in:
Martin Lund 2022-05-24 13:35:27 +02:00
parent 9bc6e34e82
commit c7b27b022f
2 changed files with 16 additions and 2 deletions

View file

@ -35,11 +35,11 @@ void error_exit(void)
if (error[0][0] != 0)
{
/* Print error */
tio_printf("Error: %s", error[0]);
tio_error_printf("Error: %s", error[0]);
}
else if ((error[1][0] != 0) && (option.no_autoconnect))
{
/* Print silent error */
tio_printf("Error: %s", error[1]);
tio_error_printf("Error: %s", error[1]);
}
}

View file

@ -36,6 +36,12 @@ extern char ansi_format[];
fflush(stdout); \
}
#define ansi_error_printf(format, args...) \
{ \
fprintf (stderr, "\r%s" format ANSI_RESET "\r\n", ansi_format, ## args); \
fflush(stderr); \
}
#define ansi_printf_raw(format, args...) \
{ \
fprintf (stdout, "%s" format ANSI_RESET, ansi_format, ## args); \
@ -56,6 +62,14 @@ extern char ansi_format[];
print_tainted = false; \
}
#define tio_error_printf(format, args...) \
{ \
if (print_tainted) \
putchar('\n'); \
ansi_error_printf("[%s] " format, current_time(), ## args); \
print_tainted = false; \
}
#define error_printf(format, args...) \
snprintf(error[0], 1000, format, ## args);