X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=menu%2Fm_item_new.c;h=1debc2b344012c97af637f319f2aa3d8d7df5d5f;hp=185e2dca6801ecc59583098bd5071878b05b0d3a;hb=cf94c7485f7b40ff7870b5bf9a65e7ab87481a76;hpb=55ccd2b959766810cf7db8d1c4462f338ce0afc8 diff --git a/menu/m_item_new.c b/menu/m_item_new.c index 185e2dca..1debc2b3 100644 --- a/menu/m_item_new.c +++ b/menu/m_item_new.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2009,2010 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 * @@ -39,10 +39,12 @@ #include "menu.priv.h" #if USE_WIDEC_SUPPORT +#if HAVE_WCTYPE_H #include #endif +#endif -MODULE_ID("$Id: m_item_new.c,v 1.25 2005/04/16 22:24:38 tom Exp $") +MODULE_ID("$Id: m_item_new.c,v 1.30 2010/01/23 21:20:11 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -66,13 +68,13 @@ Is_Printable_String(const char *s) assert(s); if (count > 0 - && (temp = typeCalloc(wchar_t, (2 + count))) != 0) + && (temp = typeCalloc(wchar_t, (2 + (unsigned)count))) != 0) { int n; mbstowcs(temp, s, (unsigned)count); for (n = 0; n < count; ++n) - if (!iswprint(temp[n])) + if (!iswprint((wint_t) temp[n])) { result = FALSE; break; @@ -120,7 +122,7 @@ new_item(const char *name, const char *description) } else { - item = (ITEM *) calloc(1, sizeof(ITEM)); + item = typeCalloc(ITEM, 1); if (item) { *item = _nc_Default_Item; /* hope we have struct assignment */ @@ -160,7 +162,7 @@ new_item(const char *name, const char *description) NCURSES_EXPORT(int) free_item(ITEM * item) { - T((T_CALLED("free_item(%p)"), item)); + T((T_CALLED("free_item(%p)"), (void *)item)); if (!item) RETURN(E_BAD_ARGUMENT); @@ -195,7 +197,7 @@ set_menu_mark(MENU * menu, const char *mark) { unsigned l; - T((T_CALLED("set_menu_mark(%p,%s)"), menu, _nc_visbuf(mark))); + T((T_CALLED("set_menu_mark(%p,%s)"), (void *)menu, _nc_visbuf(mark))); if (mark && (*mark != '\0') && Is_Printable_String(mark)) l = strlen(mark); @@ -217,7 +219,7 @@ set_menu_mark(MENU * menu, const char *mark) menu->marklen = l; if (l) { - menu->mark = (char *)malloc(l + 1); + menu->mark = strdup(mark); if (menu->mark) { strcpy(menu->mark, mark); @@ -227,6 +229,7 @@ set_menu_mark(MENU * menu, const char *mark) else { menu->mark = old_mark; + menu->marklen = (old_mark != 0) ? strlen(old_mark) : 0; RETURN(E_SYSTEM_ERROR); } } @@ -265,7 +268,7 @@ set_menu_mark(MENU * menu, const char *mark) NCURSES_EXPORT(const char *) menu_mark(const MENU * menu) { - T((T_CALLED("menu_mark(%p)"), menu)); + T((T_CALLED("menu_mark(%p)"), (const void *)menu)); returnPtr(Normalize_Menu(menu)->mark); }