]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/echochar.c
ncurses 6.0 - patch 20170408
[ncurses.git] / test / echochar.c
index 829d1f2b429605026552bb0ad2509625f600a5b6..b2cf99bbef78f73accb2f7e0fb8f62c1607b1bbd 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 2006-2008,2010 Free Software Foundation, Inc.              *
+ * Copyright (c) 2006-2014,2017 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            *
  *                                                                          *
  * 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.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: echochar.c,v 1.8 2010/11/14 01:00:44 tom Exp $
+ * $Id: echochar.c,v 1.11 2017/04/08 21:53:51 tom Exp $
  *
  * Demonstrate the echochar function (compare to dots.c).
  * Thomas Dickey - 2006/11/4
  *
  * Demonstrate the echochar function (compare to dots.c).
  * Thomas Dickey - 2006/11/4
@@ -69,12 +69,14 @@ static void
 set_color(char *my_pairs, int fg, int bg)
 {
     int pair = (fg * COLORS) + bg;
 set_color(char *my_pairs, int fg, int bg)
 {
     int pair = (fg * COLORS) + bg;
-    if (!my_pairs[pair]) {
-       init_pair((short) pair,
-                 (short) fg,
-                 (short) bg);
+    if (pair < COLOR_PAIRS) {
+       if (!my_pairs[pair]) {
+           init_pair((short) pair,
+                     (short) fg,
+                     (short) bg);
+       }
+       attron(COLOR_PAIR(pair));
     }
     }
-    attron(COLOR_PAIR(pair));
 }
 
 int
 }
 
 int