From 9428abbf51a05346caf1315130411af1811ba0f7 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 11 Oct 2013 19:30:21 +0400 Subject: [PATCH] * term.c (tty_menu_show): Never return with unbalanced specpdl. Use eassert for debugging check. Adjust style. --- src/ChangeLog | 5 +++++ src/term.c | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a11737a31c9..42650a31c7a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-10-11 Dmitry Antipov + + * term.c (tty_menu_show): Never return with unbalanced + specpdl. Use eassert for debugging check. Adjust style. + 2013-10-11 Eli Zaretskii * term.c (read_menu_input): Make selection of menu items diff --git a/src/term.c b/src/term.c index 71263d41dd2..b946480cd0c 100644 --- a/src/term.c +++ b/src/term.c @@ -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; } -- 2.39.2