Mercurial > vim
comparison src/os_win32.c @ 5549:32e50f85d2c7 v7.4.123
updated for version 7.4.123
Problem: Win32: Getting user name does not use wide function.
Solution: Use GetUserNameW() if possible. (Ken Takata)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 11 Dec 2013 18:18:06 +0100 |
parents | 270c62fe685a |
children | 9faba192ea90 |
comparison
equal
deleted
inserted
replaced
5548:90f26849f78a | 5549:32e50f85d2c7 |
---|---|
2766 int len) | 2766 int len) |
2767 { | 2767 { |
2768 char szUserName[256 + 1]; /* UNLEN is 256 */ | 2768 char szUserName[256 + 1]; /* UNLEN is 256 */ |
2769 DWORD cch = sizeof szUserName; | 2769 DWORD cch = sizeof szUserName; |
2770 | 2770 |
2771 #ifdef FEAT_MBYTE | |
2772 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | |
2773 { | |
2774 WCHAR wszUserName[256 + 1]; /* UNLEN is 256 */ | |
2775 DWORD wcch = sizeof(wszUserName) / sizeof(WCHAR); | |
2776 | |
2777 if (GetUserNameW(wszUserName, &wcch)) | |
2778 { | |
2779 char_u *p = utf16_to_enc(wszUserName, NULL); | |
2780 | |
2781 if (p != NULL) | |
2782 { | |
2783 vim_strncpy(s, p, len - 1); | |
2784 vim_free(p); | |
2785 return OK; | |
2786 } | |
2787 } | |
2788 /* Retry with non-wide function (for Windows 98). */ | |
2789 } | |
2790 #endif | |
2771 if (GetUserName(szUserName, &cch)) | 2791 if (GetUserName(szUserName, &cch)) |
2772 { | 2792 { |
2773 vim_strncpy(s, szUserName, len - 1); | 2793 vim_strncpy(s, szUserName, len - 1); |
2774 return OK; | 2794 return OK; |
2775 } | 2795 } |