X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Finchs.c;h=be3aab86f57829499c1b4d4156414023868dd040;hp=508c4eda748023c8004600a9f760f63d03648bac;hb=ab61bfec8cb0c26638ea53ceadcd17048ee02996;hpb=92e187a3459ab7ce1613a3684ca6642447c73620 diff --git a/test/inchs.c b/test/inchs.c index 508c4eda..be3aab86 100644 --- a/test/inchs.c +++ b/test/inchs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2007,2010 Free Software Foundation, Inc. * + * Copyright (c) 2007-2010,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: inchs.c,v 1.10 2010/05/01 19:13:46 tom Exp $ + * $Id: inchs.c,v 1.12 2012/11/18 01:58:15 tom Exp $ * * Author: Thomas E Dickey */ @@ -50,6 +50,16 @@ #define BASE_Y 7 #define MAX_COLS 1024 +static void +failed(const char *s) +{ + int save = errno; + endwin(); + errno = save; + perror(s); + ExitProgram(EXIT_FAILURE); +} + static bool Quit(int ch) { @@ -87,6 +97,8 @@ test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin) txtwin = stdscr; base_y = BASE_Y; } + if (txtwin == 0) + failed("cannot create txtwin"); keypad(txtwin, TRUE); /* enable keyboard mapping */ (void) cbreak(); /* take input chars one at a time, no wait for \n */ @@ -158,10 +170,10 @@ test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin) if (txtwin != stdscr) { wmove(txtwin, txt_y, txt_x); - if ((ch = winch(txtwin)) != ERR) { + if ((ch = (int) winch(txtwin)) != ERR) { if (waddch(chrwin, (chtype) ch) != ERR) { for (j = txt_x + 1; j < getmaxx(txtwin); ++j) { - if ((ch = mvwinch(txtwin, txt_y, j)) != ERR) { + if ((ch = (int) mvwinch(txtwin, txt_y, j)) != ERR) { if (waddch(chrwin, (chtype) ch) == ERR) { break; } @@ -174,10 +186,10 @@ test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin) } else { move(txt_y, txt_x); - if ((ch = inch()) != ERR) { + if ((ch = (int) inch()) != ERR) { if (waddch(chrwin, (chtype) ch) != ERR) { for (j = txt_x + 1; j < getmaxx(txtwin); ++j) { - if ((ch = mvinch(txt_y, j)) != ERR) { + if ((ch = (int) mvinch(txt_y, j)) != ERR) { if (waddch(chrwin, (chtype) ch) == ERR) { break; }