X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Fdots_termcap.c;h=65786c411a4ae1bde374e677bd556fe70fe547c4;hb=2bcad5fdfc4aa83a1479bd1d21dadc32dad8c2a8;hp=aa1d1988780631dd5c5b37d0fda6ab9159a415ab;hpb=6641601a9dd7f34deeaa978899b3730b27635afb;p=ncurses.git diff --git a/test/dots_termcap.c b/test/dots_termcap.c index aa1d1988..65786c41 100644 --- a/test/dots_termcap.c +++ b/test/dots_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2020,2022 Thomas E. Dickey * + * Copyright 2018-2022,2023 Thomas E. Dickey * * Copyright 2013-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -30,7 +30,7 @@ /* * Author: Thomas E. Dickey * - * $Id: dots_termcap.c,v 1.29 2022/12/04 00:40:11 tom Exp $ + * $Id: dots_termcap.c,v 1.32 2023/02/25 18:11:21 tom Exp $ * * A simple demo of the termcap interface. */ @@ -150,11 +150,19 @@ ranf(void) return ((double) r / 32768.); } +/* + * napms is a curses function which happens to be usable without initializing + * the screen, but if this program happened to be build with a "real" termcap + * library, there is nothing like napms. + */ +#if HAVE_NAPMS +#define my_napms(ms) napms(ms) +#else static void my_napms(int ms) { if (ms > 0) { -#if defined(_NC_WINDOWS) || !HAVE_GETTIMEOFDAY +#if defined(_NC_WINDOWS) Sleep((unsigned int) ms); #else struct timeval data; @@ -164,6 +172,7 @@ my_napms(int ms) #endif } } +#endif static int get_number(NCURSES_CONST char *cap, const char *env) @@ -228,9 +237,10 @@ main(int argc, char *argv[]) switch (ch) { case 'T': need = 6 + strlen(optarg); - my_env = malloc(need); - _nc_SPRINTF(my_env, _nc_SLIMIT(need) "TERM=%s", optarg); - putenv(my_env); + if ((my_env = malloc(need)) != NULL) { + _nc_SPRINTF(my_env, _nc_SLIMIT(need) "TERM=%s", optarg); + putenv(my_env); + } break; case 'e': e_option = 1; @@ -326,8 +336,7 @@ main(int argc, char *argv[]) } #else int -main(int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) +main(void) { fprintf(stderr, "This program requires termcap\n"); exit(EXIT_FAILURE);