diff options
| author | Eli Zaretskii | 2007-06-16 18:13:15 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2007-06-16 18:13:15 +0000 |
| commit | af41f8a8d6660ad1fefad5bda69d1acb8e40b4d1 (patch) | |
| tree | f6004d2b27eee046cba409e787038be608663622 /src | |
| parent | 56dc064678fdb3aa9b38113288cbbdcd7f6e4fef (diff) | |
| download | emacs-af41f8a8d6660ad1fefad5bda69d1acb8e40b4d1.tar.gz emacs-af41f8a8d6660ad1fefad5bda69d1acb8e40b4d1.zip | |
(add_menu_item): Escape `&' characters in menu items and their keybindings.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/w32menu.c | 31 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a99b18713bc..4d2e7ccb375 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2007-06-16 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * w32menu.c (add_menu_item): Escape `&' characters in menu items | ||
| 4 | and their keybindings. | ||
| 5 | |||
| 1 | 2007-06-15 Chong Yidong <cyd@stupidchicken.com> | 6 | 2007-06-15 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 7 | ||
| 3 | * composite.c (update_compositions): Fix last fix. | 8 | * composite.c (update_compositions): Fix last fix. |
diff --git a/src/w32menu.c b/src/w32menu.c index ba29c6ae433..bcd56c8c88e 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA. */ | |||
| 23 | #include <signal.h> | 23 | #include <signal.h> |
| 24 | 24 | ||
| 25 | #include <stdio.h> | 25 | #include <stdio.h> |
| 26 | #include <mbstring.h> | ||
| 26 | #include "lisp.h" | 27 | #include "lisp.h" |
| 27 | #include "termhooks.h" | 28 | #include "termhooks.h" |
| 28 | #include "keyboard.h" | 29 | #include "keyboard.h" |
| @@ -2261,8 +2262,9 @@ static int | |||
| 2261 | add_menu_item (HMENU menu, widget_value *wv, HMENU item) | 2262 | add_menu_item (HMENU menu, widget_value *wv, HMENU item) |
| 2262 | { | 2263 | { |
| 2263 | UINT fuFlags; | 2264 | UINT fuFlags; |
| 2264 | char *out_string; | 2265 | char *out_string, *p, *q; |
| 2265 | int return_value; | 2266 | int return_value; |
| 2267 | size_t nlen, orig_len; | ||
| 2266 | 2268 | ||
| 2267 | if (name_is_separator (wv->name)) | 2269 | if (name_is_separator (wv->name)) |
| 2268 | { | 2270 | { |
| @@ -2286,6 +2288,33 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 2286 | else | 2288 | else |
| 2287 | out_string = wv->name; | 2289 | out_string = wv->name; |
| 2288 | 2290 | ||
| 2291 | /* Quote any special characters within the menu item's text and | ||
| 2292 | key binding. */ | ||
| 2293 | nlen = orig_len = strlen (out_string); | ||
| 2294 | for (p = out_string; *p; p = _mbsinc (p)) | ||
| 2295 | { | ||
| 2296 | if (_mbsnextc (p) == '&') | ||
| 2297 | nlen++; | ||
| 2298 | } | ||
| 2299 | if (nlen > orig_len) | ||
| 2300 | { | ||
| 2301 | p = out_string; | ||
| 2302 | out_string = alloca (nlen + 1); | ||
| 2303 | q = out_string; | ||
| 2304 | while (*p) | ||
| 2305 | { | ||
| 2306 | if (_mbsnextc (p) == '&') | ||
| 2307 | { | ||
| 2308 | _mbsncpy (q, p, 1); | ||
| 2309 | q = _mbsinc (q); | ||
| 2310 | } | ||
| 2311 | _mbsncpy (q, p, 1); | ||
| 2312 | p = _mbsinc (p); | ||
| 2313 | q = _mbsinc (q); | ||
| 2314 | } | ||
| 2315 | *q = '\0'; | ||
| 2316 | } | ||
| 2317 | |||
| 2289 | if (item != NULL) | 2318 | if (item != NULL) |
| 2290 | fuFlags = MF_POPUP; | 2319 | fuFlags = MF_POPUP; |
| 2291 | else if (wv->title || wv->call_data == 0) | 2320 | else if (wv->title || wv->call_data == 0) |