X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_menus.c;h=34d582ed4a20afa2e7536eca7772ab5e703a9a5b;hp=f38fd287fa21124a05478920082ba3746b799f7b;hb=1078c0231b8a58fbd2dd56b6e0a81b19d6b07f77;hpb=027ae42953e3186daed8f3882da73de48291b606 diff --git a/test/demo_menus.c b/test/demo_menus.c index f38fd287..34d582ed 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 2005-2007,2008 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.20 2006/06/17 17:39:37 tom Exp $ + * $Id: demo_menus.c,v 1.24 2008/04/12 22:03:33 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -112,7 +112,7 @@ static MENU *mpSelect; static char * strdup(char *s) { - char *p = (char *) malloc(strlen(s) + 1); + char *p = typeMalloc(char, strlen(s) + 1); if (p) strcpy(p, s); return (p); @@ -130,14 +130,14 @@ wGetchar(WINDOW *win) while ((c = wgetch(win)) == CTRL('T')) { if (_nc_tracing) { save_trace = _nc_tracing; - _tracef("TOGGLE-TRACING OFF"); + Trace(("TOGGLE-TRACING OFF")); _nc_tracing = 0; } else { _nc_tracing = save_trace; } trace(_nc_tracing); if (_nc_tracing) - _tracef("TOGGLE-TRACING ON"); + Trace(("TOGGLE-TRACING ON")); } #else c = wgetch(win); @@ -270,7 +270,7 @@ menu_destroy(MENU * m) #if 0 if (count > 0) { while (*ip) { - _tracef("freeing item %d:%d", ip - menu_items(m), count); + Trace(("freeing item %d:%d", ip - menu_items(m), count)); free_item(*ip++); } } @@ -291,7 +291,7 @@ menu_display(MENU * m) static void build_file_menu(MenuNo number) { - static const char *labels[] = + static CONST_MENUS char *labels[] = { "Exit", (char *) 0 @@ -299,7 +299,7 @@ build_file_menu(MenuNo number) static ITEM *items[SIZEOF(labels)]; ITEM **ip = items; - const char **ap; + CONST_MENUS char **ap; for (ap = labels; *ap; ap++) *ip++ = new_item(*ap, ""); @@ -319,7 +319,7 @@ perform_file_menu(int cmd) static void build_select_menu(MenuNo number, char *filename) { - static const char *labels[] = + static CONST_MENUS char *labels[] = { "Lions", "Tigers", @@ -339,7 +339,7 @@ build_select_menu(MenuNo number, char *filename) static ITEM **items; ITEM **ip; - const char **ap = 0; + CONST_MENUS char **ap = 0; unsigned count = 0; if (filename != 0) { @@ -349,10 +349,10 @@ build_select_menu(MenuNo number, char *filename) && sb.st_size != 0) { unsigned size = sb.st_size; unsigned j, k; - char *blob = malloc(size + 1); - const char **list = (const char **) calloc(sizeof(*list), size + 1); + char *blob = typeMalloc(char, size + 1); + CONST_MENUS char **list = typeCalloc(CONST_MENUS char *, size + 1); - items = (ITEM **) calloc(sizeof(ITEM *), size + 1); + items = typeCalloc(ITEM *, size + 1); if (blob != 0 && list != 0) { FILE *fp = fopen(filename, "r"); if (fp != 0) { @@ -383,7 +383,7 @@ build_select_menu(MenuNo number, char *filename) } if (ap == 0) { count = SIZEOF(labels) - 1; - items = (ITEM **) calloc(count + 1, sizeof(*items)); + items = typeCalloc(ITEM *, count + 1); ap = labels; } @@ -456,7 +456,7 @@ tracetrace(unsigned tlevel) size_t need = 12; for (n = 0; t_tbl[n].name != 0; n++) need += strlen(t_tbl[n].name) + 2; - buf = (char *) malloc(need); + buf = typeMalloc(char, need); } sprintf(buf, "0x%02x = {", tlevel); if (tlevel == 0) { @@ -523,7 +523,7 @@ perform_trace_menu(int cmd) newtrace |= t_tbl[item_index(*ip)].mask; } trace(newtrace); - _tracef("trace level interactively set to %s", tracetrace(_nc_tracing)); + Trace(("trace level interactively set to %s", tracetrace(_nc_tracing))); (void) mvprintw(LINES - 2, 0, "Trace level is %s\n", tracetrace(_nc_tracing)); @@ -569,7 +569,7 @@ current_menu(void) static void build_menus(char *filename) { - static const char *labels[] = + static CONST_MENUS char *labels[] = { "File", "Select", @@ -581,7 +581,7 @@ build_menus(char *filename) static ITEM *items[SIZEOF(labels)]; ITEM **ip = items; - const char **ap; + CONST_MENUS char **ap; for (ap = labels; *ap; ap++) *ip++ = new_item(*ap, ""); @@ -834,7 +834,7 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); - while ((c = getopt(argc, argv, "a:de:fhmp:s:t:")) != EOF) { + while ((c = getopt(argc, argv, "a:de:fhmp:s:t:")) != -1) { switch (c) { #if HAVE_RIPOFFLINE case 'f':