X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_forms.c;h=e3a11122b8c15a6d170161b5f903611a3a0f66fc;hp=585ddb90275b176693eb71f5888ed54c6f7a3fec;hb=2560bc3dae7f4919060c02c91a593566c908091c;hpb=2e507e7570bd701b27ad8c65adfb612dbc087125 diff --git a/test/demo_forms.c b/test/demo_forms.c index 585ddb90..e3a11122 100644 --- a/test/demo_forms.c +++ b/test/demo_forms.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2003-2012,2013 Free Software Foundation, Inc. * + * Copyright (c) 2003-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 * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_forms.c,v 1.45 2013/09/21 22:51:50 tom Exp $ + * $Id: demo_forms.c,v 1.53 2017/04/10 00:28:54 tom Exp $ * * Demonstrate a variety of functions from the form library. * Thomas Dickey - 2003/4/26 @@ -139,7 +139,7 @@ read_data(const char *filename) 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) { @@ -149,8 +149,8 @@ read_data(const char *filename) 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; @@ -172,6 +172,7 @@ read_data(const char *filename) failed("expected a colon"); } } + fclose(fp); } 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)); - 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); } @@ -226,7 +227,7 @@ make_field(const char *label, int frow, int fcol, int rows, int cols) } static void -display_form(FORM * f) +display_form(FORM *f) { WINDOW *w; int rows, cols; @@ -249,7 +250,7 @@ display_form(FORM * f) } static void -erase_form(FORM * f) +erase_form(FORM *f) { WINDOW *w = form_win(f); WINDOW *s = form_sub(f); @@ -272,7 +273,7 @@ show_insert_mode(bool insert_mode) #define O_SELECTABLE (O_ACTIVE | O_VISIBLE) static FIELD * -another_field(FORM * form, FIELD * field) +another_field(FORM *form, FIELD *field) { FIELD **f = form_fields(form); FIELD *result = 0; @@ -289,7 +290,7 @@ another_field(FORM * form, FIELD * field) } static int -my_form_driver(FORM * form, int c) +my_form_driver(FORM *form, int c) { static bool insert_mode = TRUE; FIELD *field; @@ -336,7 +337,7 @@ my_form_driver(FORM * form, int c) } static void -show_current_field(WINDOW *win, FORM * form) +show_current_field(WINDOW *win, FORM *form) { FIELD *field; FIELDTYPE *type; @@ -398,13 +399,13 @@ show_current_field(WINDOW *win, FORM * form) } 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, '/'); - (void) wattrset(win, (int) field_back(field)); + (void) wattrset(win, AttrArg(field_back(field), 0)); 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]; - 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); @@ -557,8 +559,7 @@ demo_forms(void) free_form(form); } for (c = 0; f[c] != 0; c++) { - void *ptr = field_userptr(f[c]); - free(ptr); + free_edit_field(f[c]); free_field(f[c]); } noraw();