/****************************************************************************
- * Copyright (c) 2005-2009,2010 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 *
* authorization. *
****************************************************************************/
/*
- * $Id: demo_menus.c,v 1.30 2010/05/01 19:12:26 tom Exp $
+ * $Id: demo_menus.c,v 1.37 2012/11/18 00:18:54 tom Exp $
*
* Demonstrate a variety of functions from the menu library.
* Thomas Dickey - 2005/4/9
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.
*/
#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;
}
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);
free((char *) blob);
}
free(items);
+ items = 0;
}
#ifdef TRACE
if ((count > 0) && (m == mpTrace)) {
ITEM **ip = items;
- while (*ip)
- free(*ip++);
+ if (ip != 0) {
+ while (*ip)
+ free(*ip++);
+ }
}
#endif
}
}
loaded_file = TRUE;
}
+ if (ap == 0)
+ free(items);
}
}
if (ap == 0) {
Trace(("trace level interactively set to %s", tracetrace(_nc_tracing)));
MvPrintw(LINES - 2, 0,
- "Trace level is %s\n", tracetrace(_nc_tracing));
+ "Trace level is %s\n", tracetrace(_nc_tracing));
refresh();
}
}
{
static const char *const tbl[] =
{
- "Usage: demo_menus [options]"
+ "Usage: demo_menus [options] [menu-file]"
,""
,"Options:"
#if HAVE_RIPOFFLINE
#endif /* HAVE_RIPOFFLINE */
#ifdef TRACE
case 't':
- trace(strtoul(optarg, 0, 0));
+ trace((unsigned) strtoul(optarg, 0, 0));
break;
#endif
default: