X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fsavescreen.c;h=da00d7534dc45ec365ddaa95b1c30dfd0dfba474;hp=610b86d041bd1dd07730b7d63fd03099c80ecdbb;hb=9b4c4abadc0a29999c5ddad5aa8d769fee28d687;hpb=9da7d09296c1b625afd18567a6828d8e7ec2ee01 diff --git a/test/savescreen.c b/test/savescreen.c index 610b86d0..da00d753 100644 --- a/test/savescreen.c +++ b/test/savescreen.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2007-2017,2018 Free Software Foundation, Inc. * + * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2006-2017,2018 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,12 +27,13 @@ * authorization. * ****************************************************************************/ /* - * $Id: savescreen.c,v 1.52 2018/02/03 23:18:50 tom Exp $ + * $Id: savescreen.c,v 1.57 2020/02/02 23:34:34 tom Exp $ * * Demonstrate save/restore functions from the curses library. * Thomas Dickey - 2007/7/14 */ +#define NEED_TIME_H #include #include #include @@ -41,17 +43,6 @@ #include #include -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - #if defined(__hpux) #define MyMarker 'X' #else @@ -69,10 +60,12 @@ static wchar_t BaseChar(cchar_t data) { wchar_t my_wchar[CCHARW_MAX]; + wchar_t result = 0; attr_t my_attr; short my_pair; - getcchar(&data, my_wchar, &my_attr, &my_pair, NULL); - return my_wchar[0]; + if (getcchar(&data, my_wchar, &my_attr, &my_pair, NULL) == OK) + result = my_wchar[0]; + return result; } #endif @@ -395,7 +388,7 @@ main(int argc, char *argv[]) while (col++ < cols) { int color = (((r * (g_max + 1)) + g) * (b_max + 1) + b + MAX_ANSI); -#if HAVE_INIT_EXTENDED_COLOR +#if USE_EXTENDED_COLOR init_extended_pair(pair, color, color); #else init_pair(pair, color, color); @@ -503,7 +496,7 @@ main(int argc, char *argv[]) } move(0, 0); } else { - exit_curses(); + stop_curses(); fprintf(stderr, "Cannot open \"%s\"\n", fill_by); ExitProgram(EXIT_FAILURE); } @@ -515,14 +508,14 @@ main(int argc, char *argv[]) * Use the last file as the initial/current screen. */ if (last < 0) { - exit_curses(); + stop_curses(); printf("No screen-dumps given\n"); ExitProgram(EXIT_FAILURE); } which = last; if (load_screen(files[which]) == ERR) { - exit_curses(); + stop_curses(); printf("Cannot load screen-dump %s\n", files[which]); ExitProgram(EXIT_FAILURE); }