]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/newdemo.c
ncurses 6.0 - patch 20170107
[ncurses.git] / test / newdemo.c
index 72e1d093c48344150192a64a1838f0842973469f..e056ecb7fd1f7143bd6dffd813cacf82149ba934 100644 (file)
@@ -2,7 +2,7 @@
  *  newdemo.c  -       A demo program using PDCurses. The program illustrate
  *                     the use of colours for text output.
  *
  *  newdemo.c  -       A demo program using PDCurses. The program illustrate
  *                     the use of colours for text output.
  *
- * $Id: newdemo.c,v 1.34 2010/11/13 23:33:42 tom Exp $
+ * $Id: newdemo.c,v 1.43 2016/09/10 21:25:53 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -33,7 +33,7 @@ static CONST_MENUS char *AusMap[16] =
  */
 #define NMESSAGES   6
 
  */
 #define NMESSAGES   6
 
-static NCURSES_CONST char *messages[] =
+static const char *messages[] =
 {
     "Hello from the Land Down Under",
     "The Land of crocs. and a big Red Rock",
 {
     "Hello from the Land Down Under",
     "The Land of crocs. and a big Red Rock",
@@ -47,7 +47,7 @@ static NCURSES_CONST char *messages[] =
 /*
  *  Trap interrupt
  */
 /*
  *  Trap interrupt
  */
-static RETSIGTYPE
+static void
 trap(int sig GCC_UNUSED)
 {
     endwin();
 trap(int sig GCC_UNUSED)
 {
     endwin();
@@ -84,7 +84,7 @@ set_colors(WINDOW *win, int pair, int foreground, int background)
        if (pair > COLOR_PAIRS)
            pair = COLOR_PAIRS;
        init_pair((short) pair, (short) foreground, (short) background);
        if (pair > COLOR_PAIRS)
            pair = COLOR_PAIRS;
        init_pair((short) pair, (short) foreground, (short) background);
-       (void) wattrset(win, (attr_t) COLOR_PAIR(pair));
+       (void) wattrset(win, AttrArg(COLOR_PAIR(pair), 0));
     }
 }
 
     }
 }
 
@@ -96,7 +96,7 @@ use_colors(WINDOW *win, int pair, chtype attrs)
            pair = COLOR_PAIRS;
        attrs |= (chtype) COLOR_PAIR(pair);
     }
            pair = COLOR_PAIRS;
        attrs |= (chtype) COLOR_PAIR(pair);
     }
-    (void) wattrset(win, attrs);
+    (void) wattrset(win, AttrArg(attrs, 0));
     return attrs;
 }
 
     return attrs;
 }
 
@@ -113,12 +113,19 @@ SubWinTest(WINDOW *win)
     getbegyx(win, by, bx);
     sw = w / 3;
     sh = h / 3;
     getbegyx(win, by, bx);
     sw = w / 3;
     sh = h / 3;
-    if ((swin1 = subwin(win, sh, sw, by + 3, bx + 5)) == NULL)
+
+    if ((swin1 = subwin(win, sh, sw, by + 3, bx + 5)) == NULL) {
        return 1;
        return 1;
-    if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL)
+    }
+    if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL) {
+       delwin(swin1);
        return 1;
        return 1;
-    if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL)
+    }
+    if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL) {
+       delwin(swin1);
+       delwin(swin2);
        return 1;
        return 1;
+    }
 
     set_colors(swin1, 8, COLOR_RED, COLOR_BLUE);
     werase(swin1);
 
     set_colors(swin1, 8, COLOR_RED, COLOR_BLUE);
     werase(swin1);
@@ -215,7 +222,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 {
     WINDOW *win;
     int w, x, y, i, j, k;
 {
     WINDOW *win;
     int w, x, y, i, j, k;
-    char buffer[200];
+    char buffer[SIZEOF(messages) * 80];
     const char *message;
     int width, height;
     chtype save[80];
     const char *message;
     int width, height;
     chtype save[80];
@@ -292,11 +299,11 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
        message = messages[j = 0];
        i = 1;
        w = width - 2;
        message = messages[j = 0];
        i = 1;
        w = width - 2;
-       strcpy(buffer, message);
+       _nc_STRCPY(buffer, message, sizeof(buffer));
        while (j < NMESSAGES) {
            while ((int) strlen(buffer) < w) {
        while (j < NMESSAGES) {
            while ((int) strlen(buffer) < w) {
-               strcat(buffer, " ... ");
-               strcat(buffer, messages[++j % NMESSAGES]);
+               _nc_STRCAT(buffer, " ... ", sizeof(buffer));
+               _nc_STRCAT(buffer, messages[++j % NMESSAGES], sizeof(buffer));
            }
 
            if (i < w)
            }
 
            if (i < w)