X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fxmas.c;h=144ccea22aec683b21aed5a07d942bcfb621c6ba;hp=d99b8219c3062bb37f2039cc3ad90e8242b81e6b;hb=25358bc041a5566ce2de4c9c792837e552b35671;hpb=c633e5103a29a38532cf1925257b91cea33fd090 diff --git a/test/xmas.c b/test/xmas.c index d99b8219..144ccea2 100644 --- a/test/xmas.c +++ b/test/xmas.c @@ -92,12 +92,10 @@ /******************************************************************************/ /* - * $Id: xmas.c,v 1.15 2000/09/02 18:45:53 tom Exp $ + * $Id: xmas.c,v 1.22 2006/05/20 15:35:47 tom Exp $ */ #include -#include - #define FROMWHO "Mark Hessling - (M.Hessling@gu.edu.au)" static int my_bg = COLOR_BLACK; @@ -133,6 +131,7 @@ static WINDOW *lookdeer3; static WINDOW *lookdeer4; static WINDOW *w_holiday; static WINDOW *w_del_msg; +static bool *my_pairs; static int boxit(void); static int seas(void); @@ -149,20 +148,18 @@ static int strng5(void); static int reindeer(void); static int blinkit(void); -static RETSIGTYPE -done(int sig) GCC_NORETURN; +static RETSIGTYPE done(int sig) GCC_NORETURN; - static void - set_color(WINDOW *win, chtype color) +static void +set_color(WINDOW *win, chtype color) { if (has_colors()) { - static bool *pairs; int n = (color + 1); - if (pairs == 0) - pairs = (bool *) calloc(COLORS + 1, sizeof(bool)); - if (!pairs[n]) { + if (my_pairs == 0) + my_pairs = (bool *) calloc((unsigned) (COLORS + 1), sizeof(bool)); + if (!my_pairs[n]) { init_pair(n, color, my_bg); - pairs[n] = TRUE; + my_pairs[n] = TRUE; } wattroff(win, A_COLOR); wattron(win, COLOR_PAIR(n)); @@ -191,16 +188,15 @@ main(int argc GCC_UNUSED, char **argv GCC_UNUSED) { int loopy; + setlocale(LC_ALL, ""); + initscr(); noecho(); nonl(); refresh(); - signal(SIGINT, done); - signal(SIGTERM, done); -#if !defined DOS && !defined OS2 - signal(SIGHUP, done); - signal(SIGQUIT, done); -#endif + + CATCHALL(done); + if (has_colors()) { start_color(); #if HAVE_USE_DEFAULT_COLORS @@ -1146,15 +1142,17 @@ reindeer(void) static RETSIGTYPE done(int sig GCC_UNUSED) { - signal(SIGINT, done); - signal(SIGTERM, done); -#if !defined DOS && !defined OS2 - signal(SIGHUP, done); - signal(SIGQUIT, done); -#endif + CATCHALL(done); + move(LINES - 1, 0); refresh(); endwin(); curs_set(1); - exit(EXIT_SUCCESS); + +#if NO_LEAKS + if (my_pairs != 0) + free(my_pairs); +#endif + + ExitProgram(EXIT_SUCCESS); }