X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdots.c;h=22d81713854f0d29b5dab64ea8f518f4f27cc809;hp=2d6471853e08f7daaba00b2c9dce745e76288e73;hb=e6f4ffe150c7d919792f29a70b4f031cfab5ef06;hpb=4ae6d1c18d0dec956b814865893812655ec3a22c;ds=sidebyside diff --git a/test/dots.c b/test/dots.c index 2d647185..22d81713 100644 --- a/test/dots.c +++ b/test/dots.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 1999-2009,2010 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 +29,7 @@ /* * Author: Thomas E. Dickey 1999 * - * $Id: dots.c,v 1.17 2008/02/09 18:08:50 tom Exp $ + * $Id: dots.c,v 1.23 2011/04/23 19:15:04 tom Exp $ * * A simple demo of the terminfo interface. */ @@ -46,16 +46,19 @@ static bool interrupted = FALSE; static long total_chars = 0; static time_t started; -static int -outc(TPUTS_ARG c) +static +TPUTS_PROTO(outc, c) { + int rc = c; + if (interrupted) { - char tmp = c; - write(STDOUT_FILENO, &tmp, 1); + char tmp = (char) c; + if (write(STDOUT_FILENO, &tmp, 1) == -1) + rc = EOF; } else { - putc(c, stdout); + rc = putc(c, stdout); } - return 0; + TPUTS_RETURN(rc); } static bool @@ -79,7 +82,7 @@ cleanup(void) printf("\n\n%ld total chars, rate %.2f/sec\n", total_chars, - ((double) (total_chars) / (time((time_t *) 0) - started))); + ((double) (total_chars) / (double) (time((time_t *) 0) - started))); } static void @@ -88,21 +91,20 @@ onsig(int n GCC_UNUSED) interrupted = TRUE; } -static float +static double ranf(void) { long r = (rand() & 077777); - return ((float) r / 32768.); + return ((double) r / 32768.); } int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) +main(int argc GCC_UNUSED, + char *argv[]GCC_UNUSED) { int x, y, z, p; - float r; - float c; + double r; + double c; CATCHALL(onsig); @@ -117,8 +119,8 @@ main( max_colors = -1; } - r = (float) (lines - 4); - c = (float) (columns - 4); + r = (double) (lines - 4); + c = (double) (columns - 4); started = time((time_t *) 0); while (!interrupted) {