2011-05-12 Paul Eggert <eggert@cs.ucla.edu>
+ * xmenu.c (set_frame_menubar): Use int, not EMACS_UINT, for indexes
+ that always fit in int. Use a sentinel instead of a counter, to
+ avoid a temp and to allay GCC's concerns about possible int overflow.
+
* menu.c (grow_menu_items): Check for int overflow.
* xmenu.c (set_frame_menubar): Don't mishandle vectors with no nils.
#endif
Lisp_Object items;
widget_value *wv, *first_wv, *prev_wv = 0;
- EMACS_UINT i, last_i;
+ int i;
int *submenu_start, *submenu_end;
int *submenu_top_level_items, *submenu_n_panes;
Lisp_Object *previous_items
= (Lisp_Object *) alloca (previous_menu_items_used
* sizeof (Lisp_Object));
- EMACS_UINT subitems;
+ int subitems;
/* If we are making a new widget, its contents are empty,
do always reinitialize them. */
menu_items = f->menu_bar_vector;
menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
subitems = ASIZE (items) / 4;
- submenu_start = (int *) alloca (subitems * sizeof (int));
+ submenu_start = (int *) alloca ((subitems + 1) * sizeof (int));
submenu_end = (int *) alloca (subitems * sizeof (int));
submenu_n_panes = (int *) alloca (subitems * sizeof (int));
submenu_top_level_items = (int *) alloca (subitems * sizeof (int));
submenu_end[i] = menu_items_used;
}
- last_i = i;
+ submenu_start[i] = -1;
finish_menu_items ();
/* Convert menu_items into widget_value trees
wv->help = Qnil;
first_wv = wv;
- for (i = 0; i < last_i; i++)
+ for (i = 0; 0 <= submenu_start[i]; i++)
{
menu_items_n_panes = submenu_n_panes[i];
wv = digest_single_submenu (submenu_start[i], submenu_end[i],