aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2007-06-17 22:25:08 +0000
committerJason Rumney2007-06-17 22:25:08 +0000
commitd058c8a14e688f90e547b687686a77efaf996845 (patch)
tree2cfb881cbaf99353bd1399ba5c2d007fa3f162fa /src
parentbe62e9d52d759cb6b352e2b1606dcb9bc9aecbb9 (diff)
downloademacs-d058c8a14e688f90e547b687686a77efaf996845.tar.gz
emacs-d058c8a14e688f90e547b687686a77efaf996845.zip
(add_menu_item): Don't use multibyte string functions on
unicode strings.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/w32menu.c68
2 files changed, 51 insertions, 22 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3f6e43f2bca..7de6155d427 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12007-06-17 Jason Rumney <jasonr@gnu.org>
2
3 * w32menu.c (add_menu_item): Don't use multibyte string functions on
4 unicode strings.
5
12007-06-17 Juanma Barranquero <lekktu@gmail.com> 62007-06-17 Juanma Barranquero <lekktu@gmail.com>
2 7
3 * xdisp.c (syms_of_xdisp) <auto-resize-tool-bars>: 8 * xdisp.c (syms_of_xdisp) <auto-resize-tool-bars>:
diff --git a/src/w32menu.c b/src/w32menu.c
index bcd56c8c88e..d8d6fa186bd 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -2291,29 +2291,53 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
2291 /* Quote any special characters within the menu item's text and 2291 /* Quote any special characters within the menu item's text and
2292 key binding. */ 2292 key binding. */
2293 nlen = orig_len = strlen (out_string); 2293 nlen = orig_len = strlen (out_string);
2294 for (p = out_string; *p; p = _mbsinc (p)) 2294 if (unicode_append_menu)
2295 { 2295 {
2296 if (_mbsnextc (p) == '&') 2296 /* With UTF-8, & cannot be part of a multibyte character. */
2297 nlen++; 2297 for (p = out_string; *p; p++)
2298 } 2298 {
2299 if (*p == '&')
2300 nlen++;
2301 }
2302 }
2303 else
2304 {
2305 /* If encoded with the system codepage, use multibyte string
2306 functions in case of multibyte characters that contain '&'. */
2307 for (p = out_string; *p; p = _mbsinc (p))
2308 {
2309 if (_mbsnextc (p) == '&')
2310 nlen++;
2311 }
2312 }
2313
2299 if (nlen > orig_len) 2314 if (nlen > orig_len)
2300 { 2315 {
2301 p = out_string; 2316 p = out_string;
2302 out_string = alloca (nlen + 1); 2317 out_string = alloca (nlen + 1);
2303 q = out_string; 2318 q = out_string;
2304 while (*p) 2319 while (*p)
2305 { 2320 {
2306 if (_mbsnextc (p) == '&') 2321 if (unicode_append_menu)
2307 { 2322 {
2308 _mbsncpy (q, p, 1); 2323 if (*p == '&')
2309 q = _mbsinc (q); 2324 *q++ = *p;
2310 } 2325 *q++ = *p++;
2311 _mbsncpy (q, p, 1); 2326 }
2312 p = _mbsinc (p); 2327 else
2313 q = _mbsinc (q); 2328 {
2314 } 2329 if (_mbsnextc (p) == '&')
2315 *q = '\0'; 2330 {
2316 } 2331 _mbsncpy (q, p, 1);
2332 q = _mbsinc (q);
2333 }
2334 _mbsncpy (q, p, 1);
2335 p = _mbsinc (p);
2336 q = _mbsinc (q);
2337 }
2338 }
2339 *q = '\0';
2340 }
2317 2341
2318 if (item != NULL) 2342 if (item != NULL)
2319 fuFlags = MF_POPUP; 2343 fuFlags = MF_POPUP;