Added va_list support to curses os_fatal() - taken from os_warn().
authorDavid Griffith <dave@661.org>
Sat, 29 Apr 2023 03:27:38 +0000 (20:27 -0700)
committerDavid Griffith <dave@661.org>
Sat, 29 Apr 2023 05:50:45 +0000 (22:50 -0700)
src/curses/ux_init.c

index 7d810d1ec6110970eee3325e96b5fe615fe5ad66..5dcefa0d5ee374eec02c001fe056ca83a1cbb397 100644 (file)
@@ -156,14 +156,23 @@ void os_warn (const char *s, ...)
  */
 void os_fatal (const char *s, ...)
 {
+       va_list m;
+       char errorstring[81];
+       int style;
+
+       va_start(m, s);
+       vsnprintf(errorstring, sizeof(char) * 80, s, m);
+       va_end(m);
+
        if (u_setup.curses_active) {
                /* Solaris 2.6's cc complains if the below cast is missing */
                print_c_string("\n\n");
                os_beep(BEEP_HIGH);
+               style = u_setup.current_text_style;
                os_set_text_style(BOLDFACE_STYLE);
                print_c_string("Fatal error: ");
-               os_set_text_style(0);
-               print_c_string(s);
+               os_set_text_style(style);
+               print_c_string(errorstring);
                print_c_string("\n");
                new_line();
                if (f_setup.ignore_errors) {
@@ -182,9 +191,9 @@ void os_fatal (const char *s, ...)
        }
 
        fputs ("\nFatal error: ", stderr);
-       fputs (s, stderr);
+       fputs (errorstring, stderr);
        if (f_setup.ignore_errors) {
-               fputs ("\n\rContinuing anyway", stderr);
+               fputs ("\n\rContinuing anyway...", stderr);
                return;
        }