# HG changeset patch # User Matti Hamalainen # Date 1290876295 -7200 # Node ID 03af28fb1c383459318ac7da9b8eb33e181ddd21 # Parent a1fefbce0b7a7eed22b56e5048c55b6734b182b2 Show error messages printed out to stderr only after the program has quit. diff -r a1fefbce0b7a -r 03af28fb1c38 nnchat.c --- a/nnchat.c Sat Nov 27 17:45:20 2010 +0200 +++ b/nnchat.c Sat Nov 27 18:44:55 2010 +0200 @@ -380,8 +380,11 @@ } +char *errorMessages = NULL; + void errorMsg(const char *fmt, ...) { + char *tmp; va_list ap1, ap2; va_start(ap1, fmt); @@ -389,8 +392,16 @@ printMsgV(TRUE, FALSE, fmt, ap1); va_end(ap1); - THERR_V(fmt, ap2); + tmp = th_strdup_vprintf(fmt, ap2); va_end(ap2); + + if (errorMessages != NULL) { + char *tmp2 = th_strdup_printf("%s%s", errorMessages, tmp); + th_free(errorMessages); + th_free(tmp); + errorMessages = tmp2; + } else + errorMessages = tmp; } int handleUser(nn_conn_t *conn, const char *str) @@ -1410,6 +1421,9 @@ THMSG(1, "NCurses deinitialized.\n"); } + if (errorMessages) + THERR("%s", errorMessages); + if (isError) { #ifdef __WIN32 char *tmp = promptRequester("Press enter to quit.\n", FALSE);