OK. In line with my previous emails, here is a revised patch. It also works, but by a different approach. It will definitely be better in some regards in light of a few points that were raised, but I'm still not completely comfortable with it--it does seem like a bit of a dirty hack. That said, it probably wouldn't cause things to break--it just feels dirty/dangerous, though it is very safe. What do you think now, guys? Is it looking good, or in need of further improvement?
Ben. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
Index: src/option.c =================================================================== --- src/option.c (revision 728) +++ src/option.c (working copy) @@ -3267,20 +3267,7 @@ } # else # ifdef MACOS_CONVERT - if (mch_getenv((char_u *)"LANG") == NULL) - { - char buf[20]; - if (LocaleRefGetPartString(NULL, - kLocaleLanguageMask | kLocaleLanguageVariantMask | - kLocaleRegionMask | kLocaleRegionVariantMask, - sizeof buf, buf) == noErr && *buf) - { - vim_setenv((char_u *)"LANG", (char_u *)buf); -# ifdef HAVE_LOCALE_H - setlocale(LC_ALL, ""); -# endif - } - } + mac_lang_init(); # endif # endif Index: src/proto/os_mac_conv.pro =================================================================== --- src/proto/os_mac_conv.pro (revision 728) +++ src/proto/os_mac_conv.pro (working copy) @@ -4,8 +4,9 @@ int enc2macroman __ARGS((char_u *from, size_t fromlen, char_u *to, int *tolenp, int maxtolen, char_u *rest, int *restlenp)); void mac_conv_init __ARGS((void)); void mac_conv_cleanup __ARGS((void)); -char_u *mac_utf16_to_enc __ARGS((UniChar *from, size_t fromLen, size_t *actualLen)); -UniChar *mac_enc_to_utf16 __ARGS((char_u *from, size_t fromLen, size_t *actualLen)); -CFStringRef mac_enc_to_cfstring __ARGS((char_u *from, size_t fromLen)); +char_u *mac_utf16_to_enc __ARGS((unsigned short *from, size_t fromLen, size_t *actualLen)); +unsigned short *mac_enc_to_utf16 __ARGS((char_u *from, size_t fromLen, size_t *actualLen)); +void * mac_enc_to_cfstring __ARGS((char_u *from, size_t fromLen)); char_u *mac_precompose_path __ARGS((char_u *decompPath, size_t decompLen, size_t *precompLen)); +void mac_lang_init __ARGS((void)); /* vim: set ft=c : */ Index: src/gui_mac.c =================================================================== --- src/gui_mac.c (revision 728) +++ src/gui_mac.c (working copy) @@ -446,7 +446,7 @@ CFMutableStringRef cleanedName; menuTitleLen = STRLEN(menu->dname); - name = mac_enc_to_cfstring(menu->dname, menuTitleLen); + name = (CFStringRef) mac_enc_to_cfstring(menu->dname, menuTitleLen); if (name) { @@ -5752,7 +5752,7 @@ #ifdef MACOS_CONVERT windowTitleLen = STRLEN(title); - windowTitle = mac_enc_to_cfstring(title, windowTitleLen); + windowTitle = (CFStringRef)mac_enc_to_cfstring(title, windowTitleLen); if (windowTitle) { @@ -6084,7 +6084,7 @@ { get_tabline_label(page, FALSE); #ifdef MACOS_CONVERT - return mac_enc_to_cfstring(NameBuff, STRLEN(NameBuff)); + return (CFStringRef)mac_enc_to_cfstring(NameBuff, STRLEN(NameBuff)); #else // TODO: check internal encoding? return CFStringCreateWithCString(kCFAllocatorDefault, (char *)NameBuff, Index: src/os_mac_conv.c =================================================================== --- src/os_mac_conv.c (revision 728) +++ src/os_mac_conv.c (working copy) @@ -318,10 +318,12 @@ /* * Conversion from UTF-16 UniChars to 'encoding' + * The function signature uses the real type of UniChar (as typedef'ed in + * CFBase.h) to avoid clashes with X11 header files in the .pro file */ char_u * mac_utf16_to_enc(from, fromLen, actualLen) - UniChar *from; + unsigned short *from; size_t fromLen; size_t *actualLen; { @@ -370,8 +372,10 @@ /* * Conversion from 'encoding' to UTF-16 UniChars + * The function return uses the real type of UniChar (as typedef'ed in + * CFBase.h) to avoid clashes with X11 header files in the .pro file */ - UniChar * + unsigned short * mac_enc_to_utf16(from, fromLen, actualLen) char_u *from; size_t fromLen; @@ -428,8 +432,9 @@ /* * Converts from UTF-16 UniChars to CFString + * The void * return type is actually a CFStringRef */ - CFStringRef + void * mac_enc_to_cfstring(from, fromLen) char_u *from; size_t fromLen; @@ -555,4 +560,25 @@ return result; } + +/* + * Sets LANG environment variable in Vim from Mac locale + */ + void +mac_lang_init() { + if (mch_getenv((char_u *)"LANG") == NULL) + { + char buf[20]; + if (LocaleRefGetPartString(NULL, + kLocaleLanguageMask | kLocaleLanguageVariantMask | + kLocaleRegionMask | kLocaleRegionVariantMask, + sizeof buf, buf) == noErr && *buf) + { + vim_setenv((char_u *)"LANG", (char_u *)buf); +# ifdef HAVE_LOCALE_H + setlocale(LC_ALL, ""); +# endif + } + } +} #endif /* MACOS_CONVERT */ Index: src/globals.h =================================================================== --- src/globals.h (revision 728) +++ src/globals.h (working copy) @@ -1172,7 +1172,7 @@ EXTERN int no_hlsearch INIT(= FALSE); #endif -#ifdef FEAT_BEVAL +#if defined(FEAT_BEVAL) && !defined(NO_X11_INCLUDES) EXTERN BalloonEval *balloonEval INIT(= NULL); # if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP) EXTERN int bevalServers INIT(= 0);