Commit 3e26f69c authored by Paul Eggert's avatar Paul Eggert
Browse files

* 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.
parent 5cc152c0
2011-05-12 Paul Eggert <eggert@cs.ucla.edu> 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. * menu.c (grow_menu_items): Check for int overflow.
* xmenu.c (set_frame_menubar): Don't mishandle vectors with no nils. * xmenu.c (set_frame_menubar): Don't mishandle vectors with no nils.
......
...@@ -922,7 +922,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) ...@@ -922,7 +922,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
#endif #endif
Lisp_Object items; Lisp_Object items;
widget_value *wv, *first_wv, *prev_wv = 0; widget_value *wv, *first_wv, *prev_wv = 0;
EMACS_UINT i, last_i; int i;
int *submenu_start, *submenu_end; int *submenu_start, *submenu_end;
int *submenu_top_level_items, *submenu_n_panes; int *submenu_top_level_items, *submenu_n_panes;
...@@ -966,7 +966,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) ...@@ -966,7 +966,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
Lisp_Object *previous_items Lisp_Object *previous_items
= (Lisp_Object *) alloca (previous_menu_items_used = (Lisp_Object *) alloca (previous_menu_items_used
* sizeof (Lisp_Object)); * sizeof (Lisp_Object));
EMACS_UINT subitems; int subitems;
/* If we are making a new widget, its contents are empty, /* If we are making a new widget, its contents are empty,
do always reinitialize them. */ do always reinitialize them. */
...@@ -1012,7 +1012,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) ...@@ -1012,7 +1012,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
menu_items = f->menu_bar_vector; menu_items = f->menu_bar_vector;
menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
subitems = ASIZE (items) / 4; 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_end = (int *) alloca (subitems * sizeof (int));
submenu_n_panes = (int *) alloca (subitems * sizeof (int)); submenu_n_panes = (int *) alloca (subitems * sizeof (int));
submenu_top_level_items = (int *) alloca (subitems * sizeof (int)); submenu_top_level_items = (int *) alloca (subitems * sizeof (int));
...@@ -1037,7 +1037,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) ...@@ -1037,7 +1037,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
submenu_end[i] = menu_items_used; submenu_end[i] = menu_items_used;
} }
last_i = i; submenu_start[i] = -1;
finish_menu_items (); finish_menu_items ();
/* Convert menu_items into widget_value trees /* Convert menu_items into widget_value trees
...@@ -1051,7 +1051,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) ...@@ -1051,7 +1051,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
wv->help = Qnil; wv->help = Qnil;
first_wv = wv; 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]; menu_items_n_panes = submenu_n_panes[i];
wv = digest_single_submenu (submenu_start[i], submenu_end[i], wv = digest_single_submenu (submenu_start[i], submenu_end[i],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment