X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_menus.c;h=ccd48b0b99d51296245dcb6a71341dea47145dc3;hp=803482ecc70c9d153d7a73d95f3b9b8a55f3572f;hb=aefc1659d732acf7e62c0c78a443d6d8352a3c6e;hpb=e6f4ffe150c7d919792f29a70b4f031cfab5ef06 diff --git a/test/demo_menus.c b/test/demo_menus.c index 803482ec..ccd48b0b 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2005-2012,2013 Free Software Foundation, Inc. * + * Copyright (c) 2005-2013,2014 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_menus.c,v 1.50 2013/06/08 21:38:37 tom Exp $ + * $Id: demo_menus.c,v 1.54 2014/09/05 08:34:06 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -97,7 +97,7 @@ typedef enum { #define MENU_Y 1 typedef struct { - const char *name; + NCURSES_CONST char *name; void (*func) (int); unsigned mask; } MENU_DATA; @@ -112,6 +112,8 @@ static WINDOW *status; static bool loaded_file = FALSE; +static char empty[1]; + /* Common function to allow ^T to toggle trace-mode in the middle of a test * so that trace-files can be made smaller. */ @@ -315,7 +317,7 @@ menu_destroy(MENU * m) if ((count > 0) && (m == mpSelect)) { if (blob && loaded_file) { Trace(("freeing blob %p", blob)); - free((char *) blob); + free((void *) blob); } free(items); items = 0; @@ -356,8 +358,8 @@ build_file_menu(MenuNo number) int n; for (n = 0; table[n].name != 0; ++n) { - *ip = new_item(table[n].name, ""); - set_item_userptr(*ip, &table[n]); + *ip = new_item(table[n].name, empty); + set_item_userptr(*ip, (void *) &table[n]); ++ip; } *ip = (ITEM *) 0; @@ -407,7 +409,7 @@ build_select_menu(MenuNo number, char *filename) MENU_DATA *ap = 0; MENU_DATA *myList = 0; int i; - unsigned count = 0; + size_t count = 0; if (filename != 0) { struct stat sb; @@ -464,8 +466,8 @@ build_select_menu(MenuNo number, char *filename) for (i = 0; ap[i].name != 0; ++i) { ap[i].func = call_select; ap[i].mask = (unsigned) i; - *ip = new_item(ap[i].name, ""); - set_item_userptr(*ip, &table[i]); + *ip = new_item(ap[i].name, empty); + set_item_userptr(*ip, (void *) &table[i]); ++ip; } *ip = 0; @@ -526,8 +528,8 @@ build_trace_menu(MenuNo number) int n; for (n = 0; t_tbl[n].name != 0; n++) { - *ip = new_item(t_tbl[n].name, ""); - set_item_userptr(*ip, &t_tbl[n]); + *ip = new_item(t_tbl[n].name, empty); + set_item_userptr(*ip, (void *) &t_tbl[n]); ++ip; } *ip = (ITEM *) 0; @@ -595,7 +597,7 @@ perform_trace_menu(int cmd) int result; for (ip = menu_items(mpTrace); *ip; ip++) { - MENU_DATA *td = item_userptr(*ip); + MENU_DATA *td = (MENU_DATA *) item_userptr(*ip); unsigned mask = td->mask; if (mask == 0) set_item_value(*ip, _nc_tracing == 0); @@ -610,7 +612,7 @@ perform_trace_menu(int cmd) newtrace = 0; for (ip = menu_items(mpTrace); *ip; ip++) { if (item_value(*ip)) { - MENU_DATA *td = item_userptr(*ip); + MENU_DATA *td = (MENU_DATA *) item_userptr(*ip); newtrace |= td->mask; } } @@ -683,8 +685,8 @@ build_menus(char *filename) int n; for (n = 0; table[n].name != 0; ++n) { - *ip = new_item(table[n].name, ""); - set_item_userptr(*ip, &table[n]); + *ip = new_item(table[n].name, empty); + set_item_userptr(*ip, (void *) &table[n]); ++ip; } *ip = (ITEM *) 0; @@ -859,7 +861,7 @@ perform_menus(void) if (code == E_UNKNOWN_COMMAND || code == E_NOT_POSTED) { ITEM *item = current_item(last_menu); - MENU_DATA *td = item_userptr(item); + MENU_DATA *td = (MENU_DATA *) item_userptr(item); td->func((int) td->mask); } if (code == E_REQUEST_DENIED)