Mercurial > hg > nnchat
changeset 223:03af28fb1c38
Show error messages printed out to stderr only after the program has quit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 27 Nov 2010 18:44:55 +0200 |
parents | a1fefbce0b7a |
children | 7ae0719f7763 |
files | nnchat.c |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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);