* path.cc (from_fstab): Use wcstombs/mbstowcs instead of

WideCharToMultiByte/MultiByteToWideChar to accommodate current locale.
This commit is contained in:
Corinna Vinschen 2009-03-14 14:58:05 +00:00
parent 26fb7ef5e4
commit 5c8c49cc43
2 changed files with 8 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2009-03-14 Corinna Vinschen <corinna@vinschen.de>
* path.cc (from_fstab): Use wcstombs/mbstowcs instead of
WideCharToMultiByte/MultiByteToWideChar to accommodate current locale.
2009-03-14 Corinna Vinschen <corinna@vinschen.de> 2009-03-14 Corinna Vinschen <corinna@vinschen.de>
* wide_path.h (class wide_path): New class to convert Windows path * wide_path.h (class wide_path): New class to convert Windows path

View File

@ -1,6 +1,6 @@
/* path.cc /* path.cc
Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008 Red Hat, Inc. Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -435,8 +435,7 @@ from_fstab (bool user, PWCHAR path, PWCHAR path_end)
if (!user) if (!user)
{ {
/* Create a default root dir from path. */ /* Create a default root dir from path. */
WideCharToMultiByte (GetACP (), 0, path, -1, buf, BUFSIZE, wcstombs (buf, path, BUFSIZE);
NULL, NULL);
unconvert_slashes (buf); unconvert_slashes (buf);
char *native_path = buf; char *native_path = buf;
if (!strncmp (native_path, "\\\\?\\", 4)) if (!strncmp (native_path, "\\\\?\\", 4))
@ -459,8 +458,7 @@ from_fstab (bool user, PWCHAR path, PWCHAR path_end)
PWCHAR u = wcscpy (path_end, L"\\etc\\fstab") + 10; PWCHAR u = wcscpy (path_end, L"\\etc\\fstab") + 10;
if (user) if (user)
MultiByteToWideChar (GetACP (), 0, get_user (), -1, mbstowcs (wcscpy (u, L".d\\") + 3, get_user (), BUFSIZE - (u - path));
wcscpy (u, L".d\\") + 3, BUFSIZE - (u - path));
HANDLE h = CreateFileW (path, GENERIC_READ, FILE_SHARE_READ, NULL, HANDLE h = CreateFileW (path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)