]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/blue.c
ncurses 6.0 - patch 20170930
[ncurses.git] / test / blue.c
index 45fce074d3c2fe68e42113141d156937a7ea7e7c..9c4108a41a6a6d51717bc4ab8c747bfc136914b1 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2013,2016 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2016,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            *
@@ -36,7 +36,7 @@
  *****************************************************************************/
 
 /*
  *****************************************************************************/
 
 /*
- * $Id: blue.c,v 1.42 2016/04/09 23:55:52 tom Exp $
+ * $Id: blue.c,v 1.51 2017/09/30 17:43:18 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -105,7 +105,7 @@ static int letters[4] =
     'c',                       /* clubs */
 };
 
     'c',                       /* clubs */
 };
 
-#ifdef HAVE_LANGINFO_CODESET
+#if HAVE_LANGINFO_CODESET
 
 #if HAVE_TIGETSTR
 static int glyphs[] =
 
 #if HAVE_TIGETSTR
 static int glyphs[] =
@@ -196,20 +196,24 @@ deal_cards(void)
 static void
 printcard(int value)
 {
 static void
 printcard(int value)
 {
-    (void) addch(' ');
+    AddCh(' ');
     if (value == NOCARD) {
        (void) addstr("   ");
     } else {
        int which = (value / SUIT_LENGTH);
        int isuit = (value % SUIT_LENGTH);
     if (value == NOCARD) {
        (void) addstr("   ");
     } else {
        int which = (value / SUIT_LENGTH);
        int isuit = (value % SUIT_LENGTH);
-       attr_t color = COLOR_PAIR(((which % 2) == 0)
-                                 ? RED_ON_WHITE
-                                 : BLACK_ON_WHITE);
+       chtype color = (chtype) COLOR_PAIR(((which % 2) == 0)
+                                          ? RED_ON_WHITE
+                                          : BLACK_ON_WHITE);
 
 
-       addch(ranks[isuit][0] | (chtype) COLOR_PAIR(BLUE_ON_WHITE));
-       addch(ranks[isuit][1] | (chtype) COLOR_PAIR(BLUE_ON_WHITE));
+       AddCh(ranks[isuit][0] | (chtype) COLOR_PAIR(BLUE_ON_WHITE));
+       AddCh(ranks[isuit][1] | (chtype) COLOR_PAIR(BLUE_ON_WHITE));
 
 
-       attr_on(color, NULL);
+#ifdef NCURSES_VERSION
+       (attron) ((int) color); /* quieter compiler warnings */
+#else
+       attron(color);          /* PDCurses, etc., either no macro or wrong */
+#endif
 #if USE_WIDEC_SUPPORT
        {
            wchar_t values[2];
 #if USE_WIDEC_SUPPORT
        {
            wchar_t values[2];
@@ -218,11 +222,15 @@ printcard(int value)
            addwstr(values);
        }
 #else
            addwstr(values);
        }
 #else
-       addch((chtype) suits[which]);
+       AddCh(suits[which]);
+#endif
+#ifdef NCURSES_VERSION
+       (attroff) ((int) color);
+#else
+       attroff(color);
 #endif
 #endif
-       attr_off(color, NULL);
     }
     }
-    (void) addch(' ');
+    AddCh(' ');
 }
 
 static void
 }
 
 static void
@@ -331,16 +339,16 @@ play_game(void)
            } else {
                char buf[BUFSIZ];
 
            } else {
                char buf[BUFSIZ];
 
-               (void) sprintf(buf,
-                              "Type [%s] to move, r to redraw, q or INTR to quit: ",
-                              live);
+               _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
+                           "Type [%s] to move, r to redraw, q or INTR to quit: ",
+                           live);
 
                do {
                    move(PROMPTROW, 0);
                    (void) addstr(buf);
                    move(PROMPTROW, (int) strlen(buf));
                    clrtoeol();
 
                do {
                    move(PROMPTROW, 0);
                    (void) addstr(buf);
                    move(PROMPTROW, (int) strlen(buf));
                    clrtoeol();
-                   (void) addch(' ');
+                   AddCh(' ');
                } while
                    (((c = (char) getch()) < 'a' || c > 'd')
                     && (c != 'r')
                } while
                    (((c = (char) getch()) < 'a' || c > 'd')
                     && (c != 'r')
@@ -459,13 +467,11 @@ use_pc_display(void)
 int
 main(int argc, char *argv[])
 {
 int
 main(int argc, char *argv[])
 {
-    CATCHALL(die);
-
     setlocale(LC_ALL, "");
 
     use_pc_display();
 
     setlocale(LC_ALL, "");
 
     use_pc_display();
 
-    initscr();
+    InitAndCatch(initscr(), die);
 
     start_color();
     init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE);
 
     start_color();
     init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE);