Commit 9428abbf authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

* term.c (tty_menu_show): Never return with unbalanced

specpdl.  Use eassert for debugging check.  Adjust style.
parent 052bac0b
2013-10-11 Dmitry Antipov <dmantipov@yandex.ru>
* term.c (tty_menu_show): Never return with unbalanced
specpdl. Use eassert for debugging check. Adjust style.
2013-10-11 Eli Zaretskii <eliz@gnu.org>
* term.c (read_menu_input): Make selection of menu items
......
......@@ -3561,10 +3561,9 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
int dispwidth, dispheight;
int i, j, lines, maxlines;
int maxwidth;
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
ptrdiff_t specpdl_count;
if (! FRAME_TERMCAP_P (f))
emacs_abort ();
eassert (FRAME_TERMCAP_P (f));
*error_name = 0;
if (menu_items_n_panes == 0)
......@@ -3586,7 +3585,7 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
/* Don't GC while we prepare and show the menu, because we give the
menu functions pointers to the contents of strings. */
inhibit_garbage_collection ();
specpdl_count = inhibit_garbage_collection ();
/* Adjust coordinates to be root-window-relative. */
item_x = x += f->left_pos;
......@@ -3617,7 +3616,8 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
{
tty_menu_destroy (menu);
*error_name = "Can't create pane";
return Qnil;
entry = Qnil;
goto tty_menu_end;
}
i += MENU_ITEMS_PANE_LENGTH;
......@@ -3679,7 +3679,8 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
{
tty_menu_destroy (menu);
*error_name = "Can't add selection to menu";
return Qnil;
entry = Qnil;
goto tty_menu_end;
}
i += MENU_ITEMS_ITEM_LENGTH;
lines++;
......@@ -3696,12 +3697,12 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
x = max (x, 1);
y = max (y, 1);
tty_menu_locate (menu, x, y, &ulx, &uly, &width, &height);
if (ulx+width > dispwidth)
if (ulx + width > dispwidth)
{
x -= (ulx + width) - dispwidth;
ulx = dispwidth - width;
}
if (uly+height > dispheight)
if (uly + height > dispheight)
{
y -= (uly + height) - dispheight;
uly = dispheight - height;
......@@ -3807,8 +3808,9 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
break;
}
unbind_to (specpdl_count, Qnil);
tty_menu_end:
unbind_to (specpdl_count, Qnil);
return entry;
}
......
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