]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/hashtest.c
ncurses 6.0 - patch 20160102
[ncurses.git] / test / hashtest.c
index fbbcc725571b7862e2705d2f36b2f9429a063033..849922173c8f43877d8262fc6a5beceeb8232d2c 100644 (file)
@@ -1,19 +1,38 @@
+/****************************************************************************
+ * Copyright (c) 1998-2010,2013 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            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
 /*
  * hashtest.c -- test hash mapping
  *
  * Generate timing statistics for vertical-motion optimization.
  *
- * $Id: hashtest.c,v 1.24 2005/04/16 16:36:54 tom Exp $
+ * $Id: hashtest.c,v 1.32 2013/04/27 19:50:17 tom Exp $
  */
 
-#ifdef TRACE
-#define Trace(p) _tracef p
-#define USE_TRACE 1
-#else
-#define Trace(p)               /* nothing */
-#define USE_TRACE 0
-#endif
-
 #include <test.priv.h>
 
 #define LO_CHAR ' '
@@ -35,7 +54,7 @@ cleanup(void)
     endwin();
 }
 
-static RETSIGTYPE
+static void
 finish(int sig GCC_UNUSED)
 {
     cleanup();
@@ -67,7 +86,8 @@ genlines(int base)
 
     move(head_lines, 0);
     for (i = head_lines; i < LINES - foot_lines; i++) {
-       chtype c = (base - LO_CHAR + i) % (HI_CHAR - LO_CHAR + 1) + LO_CHAR;
+       chtype c = (chtype) ((base - LO_CHAR + i) % (HI_CHAR - LO_CHAR + 1)
+                            + LO_CHAR);
        int hi = (extend_corner || (i < LINES - 1)) ? COLS : COLS - 1;
        for (j = 0; j < hi; j++)
            addch(c);
@@ -121,10 +141,10 @@ run_test(bool optimized GCC_UNUSED)
 #endif
 
     if (reverse_loops)
-       for (ch = hi; ch >= lo; ch--)
+       for (ch = (char) hi; ch >= lo; ch--)
            one_cycle(ch);
     else
-       for (ch = lo; ch <= hi; ch++)
+       for (ch = (char) lo; ch <= hi; ch++)
            one_cycle(ch);
 }
 
@@ -163,7 +183,7 @@ main(int argc, char *argv[])
 
     setlocale(LC_ALL, "");
 
-    while ((c = getopt(argc, argv, "cf:h:l:norsx")) != EOF) {
+    while ((c = getopt(argc, argv, "cf:h:l:norsx")) != -1) {
        switch (c) {
        case 'c':
            continuous = TRUE;
@@ -176,6 +196,7 @@ main(int argc, char *argv[])
            break;
        case 'l':
            test_loops = atoi(optarg);
+           assert(test_loops >= 0);
            break;
        case 'n':
            test_normal = TRUE;
@@ -204,7 +225,7 @@ main(int argc, char *argv[])
     trace(TRACE_TIMES);
 #endif
 
-    (void) signal(SIGINT, finish);     /* arrange interrupts to terminate */
+    CATCHALL(finish);          /* arrange interrupts to terminate */
 
     (void) initscr();          /* initialize the curses library */
     keypad(stdscr, TRUE);      /* enable keyboard mapping */