emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/w32menu.c,v


From: Eli Zaretskii
Subject: [Emacs-diffs] Changes to emacs/src/w32menu.c,v
Date: Sat, 16 Jun 2007 18:12:19 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Eli Zaretskii <eliz>    07/06/16 18:12:18

Index: w32menu.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32menu.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -b -r1.88 -r1.89
--- w32menu.c   22 Feb 2007 23:47:43 -0000      1.88
+++ w32menu.c   16 Jun 2007 18:12:18 -0000      1.89
@@ -23,6 +23,7 @@
 #include <signal.h>
 
 #include <stdio.h>
+#include <mbstring.h>
 #include "lisp.h"
 #include "termhooks.h"
 #include "keyboard.h"
@@ -2261,8 +2262,9 @@
 add_menu_item (HMENU menu, widget_value *wv, HMENU item)
 {
   UINT fuFlags;
-  char *out_string;
+  char *out_string, *p, *q;
   int return_value;
+  size_t nlen, orig_len;
 
   if (name_is_separator (wv->name))
     {
@@ -2286,6 +2288,33 @@
       else
        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)
        fuFlags = MF_POPUP;
       else if (wv->title || wv->call_data == 0)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]