Commit af41f8a8 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

(add_menu_item): Escape `&' characters in menu items and their keybindings.

parent 56dc0646
2007-06-16 Eli Zaretskii <eliz@gnu.org>
* w32menu.c (add_menu_item): Escape `&' characters in menu items
and their keybindings.
2007-06-15 Chong Yidong <cyd@stupidchicken.com> 2007-06-15 Chong Yidong <cyd@stupidchicken.com>
   
* composite.c (update_compositions): Fix last fix. * composite.c (update_compositions): Fix last fix.
......
...@@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA. */ ...@@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA. */
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <mbstring.h>
#include "lisp.h" #include "lisp.h"
#include "termhooks.h" #include "termhooks.h"
#include "keyboard.h" #include "keyboard.h"
...@@ -2261,8 +2262,9 @@ static int ...@@ -2261,8 +2262,9 @@ static int
add_menu_item (HMENU menu, widget_value *wv, HMENU item) add_menu_item (HMENU menu, widget_value *wv, HMENU item)
{ {
UINT fuFlags; UINT fuFlags;
char *out_string; char *out_string, *p, *q;
int return_value; int return_value;
size_t nlen, orig_len;
if (name_is_separator (wv->name)) if (name_is_separator (wv->name))
{ {
...@@ -2286,6 +2288,33 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) ...@@ -2286,6 +2288,33 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
else else
out_string = wv->name; out_string = wv->name;
/* Quote any special characters within the menu item's text and
key binding. */
nlen = orig_len = strlen (out_string);
for (p = out_string; *p; p = _mbsinc (p))
{
if (_mbsnextc (p) == '&')
nlen++;
}
if (nlen > orig_len)
{
p = out_string;
out_string = alloca (nlen + 1);
q = out_string;
while (*p)
{
if (_mbsnextc (p) == '&')
{
_mbsncpy (q, p, 1);
q = _mbsinc (q);
}
_mbsncpy (q, p, 1);
p = _mbsinc (p);
q = _mbsinc (q);
}
*q = '\0';
}
if (item != NULL) if (item != NULL)
fuFlags = MF_POPUP; fuFlags = MF_POPUP;
else if (wv->title || wv->call_data == 0) else if (wv->title || wv->call_data == 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment