X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_menus.c;h=8f19281dfa6945d06119cfbfabac1d8b983b5aa8;hp=4d553e2ea73c98947085f4a5fe02a0bab6057ecd;hb=5ae2721913c0d2adde0d65063e37a723bf8a0987;hpb=48310f11b209169dcbcf4a25fab48d86af8c2017 diff --git a/test/demo_menus.c b/test/demo_menus.c index 4d553e2e..8f19281d 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2005-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 2005-2011,2012 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.28 2008/08/23 20:31:54 tom Exp $ + * $Id: demo_menus.c,v 1.36 2012/11/03 19:27:01 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -109,18 +109,6 @@ static MENU *mpSelect; static bool loaded_file = FALSE; -#if !HAVE_STRDUP -#define strdup my_strdup -static char * -strdup(char *s) -{ - char *p = typeMalloc(char, strlen(s) + 1); - if (p) - strcpy(p, s); - return (p); -} -#endif /* not HAVE_STRDUP */ - /* Common function to allow ^T to toggle trace-mode in the middle of a test * so that trace-files can be made smaller. */ @@ -202,7 +190,7 @@ menu_offset(MenuNo number) #endif /* FIXME: MENU.itemlen seems the only way to get actual width of items */ - result = (number - (eBanner + 1)) * (mpBanner->itemlen + spc_rows); + result = (number - (eBanner + 1)) * (menu_itemwidth(mpBanner) + spc_rows); } return result; } @@ -225,8 +213,8 @@ menu_create(ITEM ** items, int count, int ncols, MenuNo number) result = new_menu(items); if (has_colors()) { - set_menu_fore(result, COLOR_PAIR(1)); - set_menu_back(result, COLOR_PAIR(2)); + set_menu_fore(result, (chtype) COLOR_PAIR(1)); + set_menu_back(result, (chtype) COLOR_PAIR(2)); } set_menu_format(result, maxrow, maxcol); @@ -260,13 +248,13 @@ menu_destroy(MENU * m) { int count; - Trace(("menu_destroy %p", m)); + Trace(("menu_destroy %p", (void *) m)); if (m != 0) { ITEM **items = menu_items(m); const char *blob = 0; count = item_count(m); - Trace(("menu_destroy %p count %d", m, count)); + Trace(("menu_destroy %p count %d", (void *) m, count)); if ((count > 0) && (m == mpSelect)) { blob = item_name(*items); } @@ -368,7 +356,9 @@ build_select_menu(MenuNo number, char *filename) CONST_MENUS char **list = typeCalloc(CONST_MENUS char *, size + 1); items = typeCalloc(ITEM *, size + 1); - Trace(("build_select_menu blob=%p, items=%p", blob, items)); + Trace(("build_select_menu blob=%p, items=%p", + (void *) blob, + (void *) items)); if (blob != 0 && list != 0) { FILE *fp = fopen(filename, "r"); if (fp != 0) { @@ -544,8 +534,8 @@ perform_trace_menu(int cmd) trace(newtrace); Trace(("trace level interactively set to %s", tracetrace(_nc_tracing))); - (void) mvprintw(LINES - 2, 0, - "Trace level is %s\n", tracetrace(_nc_tracing)); + MvPrintw(LINES - 2, 0, + "Trace level is %s\n", tracetrace(_nc_tracing)); refresh(); } } @@ -829,7 +819,7 @@ usage(void) { static const char *const tbl[] = { - "Usage: demo_menus [options]" + "Usage: demo_menus [options] [menu-file]" ,"" ,"Options:" #if HAVE_RIPOFFLINE @@ -865,7 +855,7 @@ main(int argc, char *argv[]) #endif /* HAVE_RIPOFFLINE */ #ifdef TRACE case 't': - trace(strtoul(optarg, 0, 0)); + trace((unsigned) strtoul(optarg, 0, 0)); break; #endif default: