summaryrefslogtreecommitdiff
path: root/test/dots_termcap.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2021-10-20 23:22:45 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2021-10-20 23:22:45 +0000
commit332fa27640b1901ac632e6d37a4aa9643d0f8594 (patch)
treebfb5303e24d1cd4ddd22df12f45a013fefb9ca23 /test/dots_termcap.c
parentff448436b2b70771d09b8d5ff34a509dcf02f81b (diff)
downloadncurses-ea4cc38bff50e4c8c1cf3a1b08fc761d03f9aa5d.tar.gz
Diffstat (limited to 'test/dots_termcap.c')
-rw-r--r--test/dots_termcap.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/test/dots_termcap.c b/test/dots_termcap.c
index 0e442b1..5e4c17d 100644
--- a/test/dots_termcap.c
+++ b/test/dots_termcap.c
@@ -30,14 +30,14 @@
/*
* Author: Thomas E. Dickey
*
- * $Id: dots_termcap.c,v 1.20 2020/02/02 23:34:34 tom Exp $
+ * $Id: dots_termcap.c,v 1.26 2020/09/05 17:58:47 juergen Exp $
*
* A simple demo of the termcap interface.
*/
#define USE_TINFO
#include <test.priv.h>
-#if !defined(_WIN32)
+#if !defined(_NC_WINDOWS)
#include <sys/time.h>
#endif
@@ -131,9 +131,10 @@ cleanup(void)
outs(t_cl);
outs(t_ve);
- printf("\n\n%ld total cells, rate %.2f/sec\n",
- total_chars,
- ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
+ fflush(stdout);
+ fprintf(stderr, "\n\n%ld total cells, rate %.2f/sec\n",
+ total_chars,
+ ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
}
static void
@@ -153,8 +154,8 @@ static void
my_napms(int ms)
{
if (ms > 0) {
-#if defined(_WIN32) || !HAVE_GETTIMEOFDAY
- Sleep((DWORD) ms);
+#if defined(_NC_WINDOWS) || !HAVE_GETTIMEOFDAY
+ Sleep((unsigned int) ms);
#else
struct timeval data;
data.tv_sec = 0;
@@ -189,6 +190,7 @@ usage(void)
," -T TERM override $TERM"
," -e allow environment $LINES / $COLUMNS"
," -m SIZE set margin (default: 2)"
+ ," -r SECS self-interrupt/exit after specified number of seconds"
," -s MSECS delay 1% of the time (default: 1 msecs)"
};
size_t n;
@@ -208,6 +210,7 @@ main(int argc, char *argv[])
int num_columns;
int e_option = 0;
int m_option = 2;
+ int r_option = 0;
int s_option = 1;
double r;
double c;
@@ -217,7 +220,7 @@ main(int argc, char *argv[])
size_t need;
char *my_env;
- while ((ch = getopt(argc, argv, "T:em:s:")) != -1) {
+ while ((ch = getopt(argc, argv, "T:em:r:s:")) != -1) {
switch (ch) {
case 'T':
need = 6 + strlen(optarg);
@@ -231,6 +234,9 @@ main(int argc, char *argv[])
case 'm':
m_option = atoi(optarg);
break;
+ case 'r':
+ r_option = atoi(optarg);
+ break;
case 's':
s_option = atoi(optarg);
break;
@@ -247,6 +253,7 @@ main(int argc, char *argv[])
srand((unsigned) time(0));
+ SetupAlarm((unsigned) r_option);
InitAndCatch(ch = tgetent(buffer, name), onsig);
if (ch < 0) {
fprintf(stderr, "terminal description not found\n");
@@ -290,7 +297,8 @@ main(int argc, char *argv[])
tputs(tgoto(t_AF, 0, z), 1, outc);
} else {
tputs(tgoto(t_AB, 0, z), 1, outc);
- my_napms(s_option);
+ if (s_option)
+ my_napms(s_option);
}
} else if (VALID_STRING(t_me)
&& VALID_STRING(t_mr)) {
@@ -298,7 +306,8 @@ main(int argc, char *argv[])
outs((ranf() > 0.6)
? t_mr
: t_me);
- my_napms(s_option);
+ if (s_option)
+ my_napms(s_option);
}
}
outc(p);