]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/ncurses.c
ncurses 5.9 - patch 20120721
[ncurses.git] / test / ncurses.c
index 5a422cf1a8cd5f92f7dbb048f3a7c3749e551e27..f5c78dbe717cdb603dcdf63dfb85ba6ea49f1232 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2011,2012 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            *
@@ -40,7 +40,7 @@ AUTHOR
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.365 2011/01/22 19:48:33 tom Exp $
+$Id: ncurses.c,v 1.373 2012/07/21 17:40:21 tom Exp $
 
 ***************************************************************************/
 
@@ -490,7 +490,7 @@ ShellOut(bool message)
 #ifdef __MINGW32__
     system("cmd.exe");
 #else
-    system("sh");
+    IGNORE_RC(system("sh"));
 #endif
     if (message)
        addstr("returned from shellout.\n");
@@ -777,12 +777,21 @@ resize_boxes(unsigned level, WINDOW *win)
     }
     doupdate();
 }
-#endif /* resize_boxes */
+#endif /* resize_boxes */
 #else
 #define forget_boxes()         /* nothing */
 #define remember_boxes(level,text,frame)       /* nothing */
 #endif
 
+/*
+ * Return-code is OK/ERR or a keyname.
+ */
+static const char *
+ok_keyname(int code)
+{
+    return ((code == OK) ? "OK" : ((code == ERR) ? "ERR" : keyname(code)));
+}
+
 static void
 wgetch_test(unsigned level, WINDOW *win, int delay)
 {
@@ -824,9 +833,11 @@ wgetch_test(unsigned level, WINDOW *win, int delay)
        } else if (c == 'g') {
            waddstr(win, "getstr test: ");
            echo();
-           wgetnstr(win, buf, sizeof(buf) - 1);
+           c = wgetnstr(win, buf, sizeof(buf) - 1);
            noecho();
-           wprintw(win, "I saw %d characters:\n\t`%s'.", (int) strlen(buf), buf);
+           wprintw(win, "I saw %d characters:\n\t`%s' (%s).",
+                   (int) strlen(buf), buf,
+                   ok_keyname(c));
            wclrtoeol(win);
            wgetch_wrap(win, first_y);
        } else if (c == 'k') {
@@ -1394,7 +1405,7 @@ show_attr(int row, int skip, bool arrow, chtype attr, const char *name)
        if (!(termattrs() & test)) {
            printw(" (N/A)");
        } else {
-           if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) {
+           if (ncv > 0 && stdscr && (getbkgd(stdscr) & A_COLOR)) {
                static const chtype table[] =
                {
                    A_STANDOUT,
@@ -1675,8 +1686,8 @@ wide_show_attr(int row, int skip, bool arrow, chtype attr, short pair, const cha
            add_wch(&ch);
        }
     } else {
-       attr_t old_attr;
-       short old_pair;
+       attr_t old_attr = 0;
+       short old_pair = 0;
 
        (void) attr_get(&old_attr, &old_pair, 0);
        (void) attr_set(attr, pair, 0);
@@ -2972,7 +2983,7 @@ wide_slk_test(void)
 #endif
        default:
            if (cycle_attr(c, &at_code, &attr)) {
-               slk_attr_set(attr, (fg || bg), NULL);
+               slk_attr_set(attr, (short) (fg || bg), NULL);
                slk_touch();
                slk_noutrefresh();
                break;
@@ -3360,6 +3371,7 @@ show_upper_widechars(int first, int repeat, int space, attr_t attr, short pair)
             * The repeat-count may make text wrap - avoid that.
             */
            getyx(stdscr, y, x);
+           (void) y;
            if (x >= col + (COLS / 2) - 2)
                break;
        } while (--count > 0);
@@ -4269,8 +4281,10 @@ acs_and_scroll(void)
 
                    neww->next = current ? current->next : 0;
                    neww->last = current;
-                   neww->last->next = neww;
-                   neww->next->last = neww;
+                   if (neww->last != 0)
+                       neww->last->next = neww;
+                   if (neww->next != 0)
+                       neww->next->last = neww;
 
                    neww->wind = getwin(fp);
 
@@ -5226,7 +5240,7 @@ flushinp_test(WINDOW *win)
 #ifdef A_COLOR
     if (use_colors) {
        init_pair(2, COLOR_CYAN, COLOR_BLUE);
-       wbkgd(subWin, COLOR_PAIR(2) | ' ');
+       wbkgd(subWin, (chtype) (COLOR_PAIR(2) | ' '));
     }
 #endif
     (void) wattrset(subWin, A_BOLD);
@@ -6056,11 +6070,11 @@ overlap_test_1_attr(WINDOW *win, int flavor, int col)
        break;
     case 2:
        init_pair(cpair, COLOR_BLUE, COLOR_WHITE);
-       (void) wattrset(win, (attr_t) COLOR_PAIR(cpair) | A_NORMAL);
+       (void) wattrset(win, (int) (COLOR_PAIR(cpair) | A_NORMAL));
        break;
     case 3:
        init_pair(cpair, COLOR_WHITE, COLOR_BLUE);
-       (void) wattrset(win, (attr_t) COLOR_PAIR(cpair) | A_BOLD);
+       (void) wattrset(win, (int) (COLOR_PAIR(cpair) | A_BOLD));
        break;
     }
 }
@@ -6483,6 +6497,7 @@ usage(void)
        ,"  -a f,b   set default-colors (assumed white-on-black)"
        ,"  -d       use default-colors if terminal supports them"
 #endif
+       ,"  -E       call use_env(FALSE) to ignore $LINES and $COLUMNS"
 #if USE_SOFTKEYS
        ,"  -e fmt   specify format for soft-keys test (e)"
 #endif
@@ -6495,6 +6510,9 @@ usage(void)
 #if USE_LIBPANEL
        ,"  -s msec  specify nominal time for panel-demo (default: 1, to hold)"
 #endif
+#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714)
+       ,"  -T       call use_tioctl(TRUE) to allow SIGWINCH to override environment"
+#endif
 #ifdef TRACE
        ,"  -t mask  specify default trace-level (may toggle with ^T)"
 #endif
@@ -6681,7 +6699,7 @@ main(int argc, char *argv[])
 
     setlocale(LC_ALL, "");
 
-    while ((c = getopt(argc, argv, "a:de:fhmp:s:t:")) != -1) {
+    while ((c = getopt(argc, argv, "a:dEe:fhmp:s:Tt:")) != -1) {
        switch (c) {
 #ifdef NCURSES_VERSION
        case 'a':
@@ -6692,6 +6710,9 @@ main(int argc, char *argv[])
            default_colors = TRUE;
            break;
 #endif
+       case 'E':
+           use_env(FALSE);
+           break;
        case 'e':
            my_e_param = atoi(optarg);
 #ifdef NCURSES_VERSION
@@ -6721,6 +6742,11 @@ main(int argc, char *argv[])
            nap_msec = (int) atol(optarg);
            break;
 #endif
+#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714)
+       case 'T':
+           use_tioctl(TRUE);
+           break;
+#endif
 #ifdef TRACE
        case 't':
            save_trace = (unsigned) strtol(optarg, 0, 0);
@@ -6772,7 +6798,7 @@ main(int argc, char *argv[])
            use_default_colors();
            min_colors = -1;
        }
-#if NCURSES_VERSION_PATCH >= 20000708
+#if HAVE_ASSUME_DEFAULT_COLORS
        if (assumed_colors)
            assume_default_colors(default_fg, default_bg);
 #endif