Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let's use the Win32 API more precisely #147

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,13 +1946,19 @@ struct passwd *getpwuid(int uid)
static unsigned initialized;
dscho marked this conversation as resolved.
Show resolved Hide resolved
static char user_name[100];
static struct passwd *p;
wchar_t buf[100];
DWORD len;

if (initialized)
return p;

len = sizeof(user_name);
if (!GetUserName(user_name, &len)) {
len = sizeof(buf);
if (!GetUserNameW(buf, &len)) {
initialized = 1;
return NULL;
}

if (xwcstoutf(user_name, buf, sizeof(user_name)) < 0) {
initialized = 1;
return NULL;
}
Expand Down