Mercurial > emacs
comparison src/w32menu.c @ 78022:349c82ee7ef7
(add_menu_item): Don't use multibyte string functions on
unicode strings.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Sun, 17 Jun 2007 22:24:27 +0000 |
parents | cf89ff54912e |
children | 922696f363b0 0ece58f6e0aa 988f1edc9674 |
comparison
equal
deleted
inserted
replaced
78021:e12f9e8fde4d | 78022:349c82ee7ef7 |
---|---|
2289 out_string = wv->name; | 2289 out_string = wv->name; |
2290 | 2290 |
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; |
2320 else if (wv->title || wv->call_data == 0) | 2344 else if (wv->title || wv->call_data == 0) |
2321 { | 2345 { |