aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/menu.c')
-rw-r--r--src/menu.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/menu.c b/src/menu.c
index 851f1ac804b..fa31c8a51c1 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -21,6 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h> 23#include <setjmp.h>
24#include <limits.h> /* for INT_MAX */
24 25
25#include "lisp.h" 26#include "lisp.h"
26#include "keyboard.h" 27#include "keyboard.h"
@@ -66,6 +67,9 @@ Lisp_Object menu_items;
66 67
67/* If non-nil, means that the global vars defined here are already in use. 68/* If non-nil, means that the global vars defined here are already in use.
68 Used to detect cases where we try to re-enter this non-reentrant code. */ 69 Used to detect cases where we try to re-enter this non-reentrant code. */
70#if ! (defined USE_GTK || defined USE_MOTIF)
71static
72#endif
69Lisp_Object menu_items_inuse; 73Lisp_Object menu_items_inuse;
70 74
71/* Number of slots currently allocated in menu_items. */ 75/* Number of slots currently allocated in menu_items. */
@@ -176,10 +180,15 @@ save_menu_items (void)
176static void 180static void
177grow_menu_items (void) 181grow_menu_items (void)
178{ 182{
183 if ((INT_MAX - MENU_ITEMS_PANE_LENGTH) / 2 < menu_items_allocated)
184 memory_full (SIZE_MAX);
179 menu_items_allocated *= 2; 185 menu_items_allocated *= 2;
180 menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); 186 menu_items = larger_vector (menu_items, menu_items_allocated, Qnil);
181} 187}
182 188
189#if (defined USE_X_TOOLKIT || defined USE_GTK || defined HAVE_NS \
190 || defined HAVE_NTGUI)
191
183/* Begin a submenu. */ 192/* Begin a submenu. */
184 193
185static void 194static void
@@ -204,6 +213,8 @@ push_submenu_end (void)
204 menu_items_submenu_depth--; 213 menu_items_submenu_depth--;
205} 214}
206 215
216#endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NS || defined HAVE_NTGUI */
217
207/* Indicate boundary between left and right. */ 218/* Indicate boundary between left and right. */
208 219
209static void 220static void
@@ -368,34 +379,34 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk
368 if (skp->notbuttons) 379 if (skp->notbuttons)
369 /* The first button. Line up previous items in this menu. */ 380 /* The first button. Line up previous items in this menu. */
370 { 381 {
371 int index = skp->notbuttons; /* Index for first item this menu. */ 382 int idx = skp->notbuttons; /* Index for first item this menu. */
372 int submenu = 0; 383 int submenu = 0;
373 Lisp_Object tem; 384 Lisp_Object tem;
374 while (index < menu_items_used) 385 while (idx < menu_items_used)
375 { 386 {
376 tem 387 tem
377 = XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME]; 388 = XVECTOR (menu_items)->contents[idx + MENU_ITEMS_ITEM_NAME];
378 if (NILP (tem)) 389 if (NILP (tem))
379 { 390 {
380 index++; 391 idx++;
381 submenu++; /* Skip sub menu. */ 392 submenu++; /* Skip sub menu. */
382 } 393 }
383 else if (EQ (tem, Qlambda)) 394 else if (EQ (tem, Qlambda))
384 { 395 {
385 index++; 396 idx++;
386 submenu--; /* End sub menu. */ 397 submenu--; /* End sub menu. */
387 } 398 }
388 else if (EQ (tem, Qt)) 399 else if (EQ (tem, Qt))
389 index += 3; /* Skip new pane marker. */ 400 idx += 3; /* Skip new pane marker. */
390 else if (EQ (tem, Qquote)) 401 else if (EQ (tem, Qquote))
391 index++; /* Skip a left, right divider. */ 402 idx++; /* Skip a left, right divider. */
392 else 403 else
393 { 404 {
394 if (!submenu && SREF (tem, 0) != '\0' 405 if (!submenu && SREF (tem, 0) != '\0'
395 && SREF (tem, 0) != '-') 406 && SREF (tem, 0) != '-')
396 XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME] 407 XVECTOR (menu_items)->contents[idx + MENU_ITEMS_ITEM_NAME]
397 = concat2 (build_string (" "), tem); 408 = concat2 (build_string (" "), tem);
398 index += MENU_ITEMS_ITEM_LENGTH; 409 idx += MENU_ITEMS_ITEM_LENGTH;
399 } 410 }
400 } 411 }
401 skp->notbuttons = 0; 412 skp->notbuttons = 0;
@@ -662,13 +673,12 @@ digest_single_submenu (int start, int end, int top_level_items)
662 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) 673 else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
663 { 674 {
664 /* Create a new pane. */ 675 /* Create a new pane. */
665 Lisp_Object pane_name, prefix; 676 Lisp_Object pane_name;
666 const char *pane_string; 677 const char *pane_string;
667 678
668 panes_seen++; 679 panes_seen++;
669 680
670 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; 681 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
671 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
672 682
673#ifdef HAVE_NTGUI 683#ifdef HAVE_NTGUI
674 if (STRINGP (pane_name)) 684 if (STRINGP (pane_name))
@@ -796,9 +806,9 @@ digest_single_submenu (int start, int end, int top_level_items)
796 if (!NILP (descrip)) 806 if (!NILP (descrip))
797 wv->lkey = descrip; 807 wv->lkey = descrip;
798 wv->value = 0; 808 wv->value = 0;
799 /* The EMACS_INT cast avoids a warning. There's no problem 809 /* The intptr_t cast avoids a warning. There's no problem
800 as long as pointers have enough bits to hold small integers. */ 810 as long as pointers have enough bits to hold small integers. */
801 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0); 811 wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0);
802 wv->enabled = !NILP (enable); 812 wv->enabled = !NILP (enable);
803 813
804 if (NILP (type)) 814 if (NILP (type))
@@ -907,9 +917,9 @@ find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object
907 else 917 else
908 { 918 {
909 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE]; 919 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE];
910 /* The EMACS_INT cast avoids a warning. There's no problem 920 /* Treat the pointer as an integer. There's no problem
911 as long as pointers have enough bits to hold small integers. */ 921 as long as pointers have enough bits to hold small integers. */
912 if ((int) (EMACS_INT) client_data == i) 922 if ((intptr_t) client_data == i)
913 { 923 {
914 int j; 924 int j;
915 struct input_event buf; 925 struct input_event buf;
@@ -1141,13 +1151,13 @@ no quit occurs and `x-popup-menu' returns nil. */)
1141#else /* not HAVE_X_WINDOWS */ 1151#else /* not HAVE_X_WINDOWS */
1142 Lisp_Object bar_window; 1152 Lisp_Object bar_window;
1143 enum scroll_bar_part part; 1153 enum scroll_bar_part part;
1144 unsigned long time; 1154 Time time;
1145 void (*mouse_position_hook) (struct frame **, int, 1155 void (*mouse_position_hook) (struct frame **, int,
1146 Lisp_Object *, 1156 Lisp_Object *,
1147 enum scroll_bar_part *, 1157 enum scroll_bar_part *,
1148 Lisp_Object *, 1158 Lisp_Object *,
1149 Lisp_Object *, 1159 Lisp_Object *,
1150 unsigned long *) = 1160 Time *) =
1151 FRAME_TERMINAL (new_f)->mouse_position_hook; 1161 FRAME_TERMINAL (new_f)->mouse_position_hook;
1152 1162
1153 if (mouse_position_hook) 1163 if (mouse_position_hook)
@@ -1341,7 +1351,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1341 1351
1342 UNGCPRO; 1352 UNGCPRO;
1343 1353
1344 if (error_name) error (error_name); 1354 if (error_name) error ("%s", error_name);
1345 return selection; 1355 return selection;
1346} 1356}
1347 1357