]> git.eshelyaron.com Git - emacs.git/commitdiff
* term.c (tty_menu_show): Never return with unbalanced
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 11 Oct 2013 15:30:21 +0000 (19:30 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Fri, 11 Oct 2013 15:30:21 +0000 (19:30 +0400)
specpdl.  Use eassert for debugging check.  Adjust style.

src/ChangeLog
src/term.c

index a11737a31c97162119c9b870083ae76d2b51284b..42650a31c7ae318fd1e1041523ed354b6443f5bc 100644 (file)
@@ -1,3 +1,8 @@
+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
index 71263d41dd2fcb74ad0272db52594420fc5c5a69..b946480cd0cb2f9771acb11119579f47f751f060 100644 (file)
@@ -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;
 }