]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/demo_new_pair.c
ncurses 6.1 - patch 20191123
[ncurses.git] / test / demo_new_pair.c
index a0beb85c40dbfc2cb7c7c3dff98a4a984fcdff40..a4cbb5370dcbec8ba03fc7db13ba56dced2873c8 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2017 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2017,2018 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            *
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_new_pair.c,v 1.17 2017/09/28 23:17:56 tom Exp $
+ * $Id: demo_new_pair.c,v 1.19 2018/05/12 14:30:04 tom Exp $
  *
  * Demonstrate the alloc_pair() function.
  */
@@ -223,7 +223,7 @@ main(int argc, char *argv[])
 
     if (isatty(fileno(stderr))) {
        output = stderr;
-    } else if ((ch = open("/dev/tty", O_WRONLY)) != 0) {
+    } else if ((ch = open("/dev/tty", O_WRONLY)) >= 0) {
        output = fdopen(ch, "w");
     } else {
        fprintf(stderr, "cannot open terminal for output\n");
@@ -323,7 +323,9 @@ main(int argc, char *argv[])
            break;
        wch[0] = use_wide ? 0xff03 : '#';
        wch[1] = 0;
-       setcchar(&temp, wch, my_attrs, (short) my_pair, NULL);
+       setcchar(&temp, wch, my_attrs,
+                (short) my_pair,
+                (use_init ? NULL : (void *) &my_pair));
        /*
         * At the end of a page, move the cursor to the home position.
         */