]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/demo_forms.c
ncurses 6.0 - patch 20170107
[ncurses.git] / test / demo_forms.c
index a1dd592381ff1b2454c1348951a187adc7adf7ff..f891b0407b85ed0067164af9c1c438aaf1317989 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 2003-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright (c) 2003-2014,2016 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: demo_forms.c,v 1.44 2013/06/08 15:21:26 tom Exp $
+ * $Id: demo_forms.c,v 1.52 2016/09/10 21:14:55 tom Exp $
  *
  * Demonstrate a variety of functions from the form library.
  * Thomas Dickey - 2003/4/26
  *
  * Demonstrate a variety of functions from the form library.
  * Thomas Dickey - 2003/4/26
@@ -103,7 +103,7 @@ static int
 trimmed(const char *value)
 {
     int result = (int) strlen(value);
 trimmed(const char *value)
 {
     int result = (int) strlen(value);
-    while (result > 0 && isspace(value[result - 1])) {
+    while (result > 0 && isspace(UChar(value[result - 1]))) {
        --result;
     }
     return result;
        --result;
     }
     return result;
@@ -139,7 +139,7 @@ read_data(const char *filename)
        int more = 0;
        int item = 0;
 
        int more = 0;
        int item = 0;
 
-       my_data = typeCalloc(MY_DATA, 100);     /* FIXME */
+       my_data = typeCalloc(MY_DATA, (size_t) 100);    /* FIXME */
        while (fgets(buffer, sizeof(buffer), fp) != 0) {
            chomp(buffer);
            if (more) {
        while (fgets(buffer, sizeof(buffer), fp) != 0) {
            chomp(buffer);
            if (more) {
@@ -149,8 +149,8 @@ read_data(const char *filename)
                    char *value = typeRealloc(char, need, prior);
                    if (value == 0)
                        failed("realloc");
                    char *value = typeRealloc(char, need, prior);
                    if (value == 0)
                        failed("realloc");
-                   strcat(value, "\n");
-                   strcat(value, buffer);
+                   _nc_STRCAT(value, "\n", need);
+                   _nc_STRCAT(value, buffer, need);
                    my_data[more - 1].value = value;
                } else {
                    more = 0;
                    my_data[more - 1].value = value;
                } else {
                    more = 0;
@@ -172,6 +172,7 @@ read_data(const char *filename)
                failed("expected a colon");
            }
        }
                failed("expected a colon");
            }
        }
+       fclose(fp);
     } else {
        failed(filename);
     }
     } else {
        failed(filename);
     }
@@ -208,7 +209,7 @@ make_field(const char *label, int frow, int fcol, int rows, int cols)
        if (d_option) {
            if (has_colors()) {
                set_field_fore(f, (chtype) COLOR_PAIR(2));
        if (d_option) {
            if (has_colors()) {
                set_field_fore(f, (chtype) COLOR_PAIR(2));
-               set_field_back(f, A_UNDERLINE | COLOR_PAIR(3));
+               set_field_back(f, (A_UNDERLINE | (chtype) COLOR_PAIR(3)));
            } else {
                set_field_fore(f, A_BOLD);
            }
            } else {
                set_field_fore(f, A_BOLD);
            }
@@ -398,13 +399,13 @@ show_current_field(WINDOW *win, FORM * form)
        }
 
        waddch(win, ' ');
        }
 
        waddch(win, ' ');
-       (void) wattrset(win, (int) field_fore(field));
+       (void) wattrset(win, AttrArg(field_fore(field), 0));
        waddstr(win, "fore");
        wattroff(win, (int) field_fore(field));
 
        waddch(win, '/');
 
        waddstr(win, "fore");
        wattroff(win, (int) field_fore(field));
 
        waddch(win, '/');
 
-       (void) wattrset(win, (int) field_back(field));
+       (void) wattrset(win, AttrArg(field_back(field), 0));
        waddstr(win, "back");
        wattroff(win, (int) field_back(field));
 
        waddstr(win, "back");
        wattroff(win, (int) field_back(field));
 
@@ -455,7 +456,8 @@ demo_forms(void)
     memset(f, 0, sizeof(f));
     for (pg = 0; pg < 4; ++pg) {
        char label[80];
     memset(f, 0, sizeof(f));
     for (pg = 0; pg < 4; ++pg) {
        char label[80];
-       sprintf(label, "Sample Form Page %d", pg + 1);
+       _nc_SPRINTF(label, _nc_SLIMIT(sizeof(label))
+                   "Sample Form Page %d", pg + 1);
        f[n++] = make_label(label, 0, 15);
        set_new_page(f[n - 1], TRUE);
 
        f[n++] = make_label(label, 0, 15);
        set_new_page(f[n - 1], TRUE);