]> code.delx.au - gnu-emacs/blobdiff - src/menu.c
Don't set h_errno on MS-Windows except in gethostbyname.
[gnu-emacs] / src / menu.c
index 3b8ebb65d2c7f5fecf9b7bedcf586394db29e486..fdef54dd6578cfd1d68f5d3f0f53965def677820 100644 (file)
@@ -1,7 +1,7 @@
 /* Platform-independent code for terminal communications.
 
-Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2012
-  Free Software Foundation, Inc.
+Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2013 Free Software
+Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -20,7 +20,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
-#include <setjmp.h>
 #include <limits.h> /* for INT_MAX */
 
 #include "lisp.h"
@@ -36,24 +35,17 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "../lwlib/lwlib.h"
 #endif
 
-#ifdef HAVE_X_WINDOWS
-#include "xterm.h"
-#endif
-
-#ifdef HAVE_NS
-#include "nsterm.h"
-#endif
-
-#ifdef USE_GTK
-#include "gtkutil.h"
-#endif
+#ifdef HAVE_WINDOW_SYSTEM
+#include TERM_HEADER
+#endif /* HAVE_WINDOW_SYSTEM */
 
 #ifdef HAVE_NTGUI
-#include "w32term.h"
-
+# ifdef NTGUI_UNICODE
+# define unicode_append_menu AppendMenuW
+# else /* !NTGUI_UNICODE */
 extern AppendMenuW_Proc unicode_append_menu;
+# endif /* NTGUI_UNICODE */
 extern HMENU current_popup_menu;
-
 #endif /* HAVE_NTGUI  */
 
 #include "menu.h"
@@ -339,7 +331,7 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk
 {
   Lisp_Object map, item_string, enabled;
   struct gcpro gcpro1, gcpro2;
-  int res;
+  bool res;
   struct skp *skp = skp_v;
 
   /* Parse the menu item and leave the result in item_properties.  */
@@ -527,14 +519,15 @@ list_of_panes (Lisp_Object menu)
 /* Set up data in menu_items for a menu bar item
    whose event type is ITEM_KEY (with string ITEM_NAME)
    and whose contents come from the list of keymaps MAPS.  */
-int
-parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name, Lisp_Object maps)
+bool
+parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name,
+                     Lisp_Object maps)
 {
   Lisp_Object length;
   EMACS_INT len;
   Lisp_Object *mapvec;
   ptrdiff_t i;
-  int top_level_items = 0;
+  bool top_level_items = 0;
   USE_SAFE_ALLOCA;
 
   length = Flength (maps);
@@ -585,9 +578,9 @@ xmalloc_widget_value (void)
 {
   widget_value *value;
 
-  BLOCK_INPUT;
+  block_input ();
   value = malloc_widget_value ();
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   return value;
 }
@@ -614,9 +607,9 @@ free_menubar_widget_value_tree (widget_value *wv)
       free_menubar_widget_value_tree (wv->next);
       wv->next = (widget_value *) 0xDEADBEEF;
     }
-  BLOCK_INPUT;
+  block_input ();
   free_widget_value (wv);
-  UNBLOCK_INPUT;
+  unblock_input ();
 }
 
 /* Create a tree of widget_value objects
@@ -624,13 +617,13 @@ free_menubar_widget_value_tree (widget_value *wv)
    in menu_items starting at index START, up to index END.  */
 
 widget_value *
-digest_single_submenu (int start, int end, int top_level_items)
+digest_single_submenu (int start, int end, bool top_level_items)
 {
   widget_value *wv, *prev_wv, *save_wv, *first_wv;
   int i;
   int submenu_depth = 0;
   widget_value **submenu_stack;
-  int panes_seen = 0;
+  bool panes_seen = 0;
 
   submenu_stack = alloca (menu_items_used * sizeof *submenu_stack);
   wv = xmalloc_widget_value ();
@@ -676,7 +669,7 @@ digest_single_submenu (int start, int end, int top_level_items)
          Lisp_Object pane_name;
          const char *pane_string;
 
-         panes_seen++;
+         panes_seen = 1;
 
          pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
 
@@ -743,8 +736,8 @@ digest_single_submenu (int start, int end, int top_level_items)
          Lisp_Object help;
 
          /* All items should be contained in panes.  */
-         if (panes_seen == 0)
-           abort ();
+         if (! panes_seen)
+           emacs_abort ();
 
          item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
          enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
@@ -818,7 +811,7 @@ digest_single_submenu (int start, int end, int top_level_items)
          else if (EQ (type, QCtoggle))
            wv->button_type = BUTTON_TYPE_TOGGLE;
          else
-           abort ();
+           emacs_abort ();
 
          wv->selected = !NILP (selected);
          if (! STRINGP (help))
@@ -965,9 +958,9 @@ find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object
 
 #ifdef HAVE_NS
 /* As above, but return the menu selection instead of storing in kb buffer.
-   If keymaps==1, return full prefixes to selection. */
+   If KEYMAPS, return full prefixes to selection. */
 Lisp_Object
-find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
+find_and_return_menu_selection (FRAME_PTR f, bool keymaps, void *client_data)
 {
   Lisp_Object prefix, entry;
   int i;
@@ -976,8 +969,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
 
   prefix = entry = Qnil;
   i = 0;
-  subprefix_stack =
-    (Lisp_Object *)alloca (menu_items_used * sizeof (Lisp_Object));
+  subprefix_stack = alloca (menu_items_used * word_size);
 
   while (i < menu_items_used)
     {
@@ -1006,9 +998,9 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
         {
           entry
             = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
-          if (&AREF (menu_items, i) == client_data)
+          if (aref_addr (menu_items, i) == client_data)
             {
-              if (keymaps != 0)
+              if (keymaps)
                 {
                   int j;
 
@@ -1080,8 +1072,8 @@ no quit occurs and `x-popup-menu' returns nil.  */)
   Lisp_Object selection = Qnil;
   FRAME_PTR f = NULL;
   Lisp_Object x, y, window;
-  int keymaps = 0;
-  int for_click = 0;
+  bool keymaps = 0;
+  bool for_click = 0;
   ptrdiff_t specpdl_count = SPECPDL_INDEX ();
   struct gcpro gcpro1;
 
@@ -1092,7 +1084,7 @@ no quit occurs and `x-popup-menu' returns nil.  */)
 
 #ifdef HAVE_MENUS
   {
-    int get_current_pos_p = 0;
+    bool get_current_pos_p = 0;
     /* FIXME!!  check_w32 (); or check_x (); or check_ns (); */
 
     /* Decode the first argument: find the window and the coordinates.  */
@@ -1326,7 +1318,7 @@ no quit occurs and `x-popup-menu' returns nil.  */)
 #endif
 
   /* Display them in a menu.  */
-  BLOCK_INPUT;
+  block_input ();
 
   /* FIXME: Use a terminal hook!  */
 #if defined HAVE_NTGUI
@@ -1345,7 +1337,7 @@ no quit occurs and `x-popup-menu' returns nil.  */)
                          last_event_timestamp);
 #endif
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 
 #ifdef HAVE_NS
   unbind_to (specpdl_count, Qnil);