]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/dots.c
ncurses 5.7 - patch 20101113
[ncurses.git] / test / dots.c
index c99fbf4dd7be3449af2eddc907257fc5dda39395..2533c7e3b49d237f1385ab10b569d7042692926a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999-2005,2006 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            *
 /*
  * Author: Thomas E. Dickey <dickey@clark.net> 1999
  *
- * $Id: dots.c,v 1.15 2006/11/04 19:54:42 tom Exp $
+ * $Id: dots.c,v 1.22 2010/11/14 01:00:02 tom Exp $
  *
  * A simple demo of the terminfo interface.
  */
+#define USE_TINFO
 #include <test.priv.h>
 
 #if HAVE_SETUPTERM
@@ -46,15 +47,18 @@ static long total_chars = 0;
 static time_t started;
 
 static int
-outc(int c)
+outc(TPUTS_ARG 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;
+    return rc;
 }
 
 static bool
@@ -78,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
@@ -87,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);
 
@@ -116,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) {