X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdots.c;h=94d90a13ff90d6474deebe303b6e37f114795491;hp=bd3c30bb71d48358b8281a5e458d08e19eed16cf;hb=790a85dbd4a81d5f5d8dd02a44d84f01512ef443;hpb=efa78d11c3ea7f51c7078b64a34c98b44ecb0e1a diff --git a/test/dots.c b/test/dots.c index bd3c30bb..94d90a13 100644 --- a/test/dots.c +++ b/test/dots.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1999-2017,2019 Free Software Foundation, Inc. * + * Copyright 2019,2020 Thomas E. Dickey * + * Copyright 1999-2013,2017 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 * @@ -29,7 +30,7 @@ /* * Author: Thomas E. Dickey 1999 * - * $Id: dots.c,v 1.35 2019/08/24 21:49:50 tom Exp $ + * $Id: dots.c,v 1.40 2020/05/29 23:04:02 tom Exp $ * * A simple demo of the terminfo interface. */ @@ -78,9 +79,10 @@ cleanup(void) outs(clear_screen); outs(cursor_normal); - 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 @@ -122,6 +124,7 @@ usage(void) #endif ," -f use tigetnum rather than mapping" ," -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; @@ -142,11 +145,12 @@ main(int argc, int my_colors; int f_option = 0; int m_option = 2; + int r_option = 0; int s_option = 1; size_t need; char *my_env; - while ((ch = getopt(argc, argv, "T:efm:s:")) != -1) { + while ((ch = getopt(argc, argv, "T:efm:r:s:")) != -1) { switch (ch) { case 'T': need = 6 + strlen(optarg); @@ -165,6 +169,9 @@ main(int argc, case 'm': m_option = atoi(optarg); break; + case 'r': + r_option = atoi(optarg); + break; case 's': s_option = atoi(optarg); break; @@ -174,6 +181,7 @@ main(int argc, } } + SetupAlarm(r_option); InitAndCatch(setupterm((char *) 0, 1, (int *) 0), onsig); srand((unsigned) time(0)); @@ -206,7 +214,8 @@ main(int argc, tputs(tparm2(set_a_foreground, z), 1, outc); } else { tputs(tparm2(set_a_background, z), 1, outc); - napms(s_option); + if (s_option) + napms(s_option); } } else if (VALID_STRING(exit_attribute_mode) && VALID_STRING(enter_reverse_mode)) { @@ -214,7 +223,8 @@ main(int argc, outs((ranf() > 0.6) ? enter_reverse_mode : exit_attribute_mode); - napms(s_option); + if (s_option) + napms(s_option); } } outc(p);