kernel32: Fix incorrect lastpart in GetFullPathNameA with DBCS.
This commit is contained in:
parent
c27af4774e
commit
4aea5ca72b
|
@ -251,12 +251,12 @@ DWORD WINAPI GetFullPathNameA( LPCSTR name, DWORD len, LPSTR buffer,
|
|||
LPSTR *lastpart )
|
||||
{
|
||||
WCHAR *nameW;
|
||||
WCHAR bufferW[MAX_PATH];
|
||||
WCHAR bufferW[MAX_PATH], *lastpartW = NULL;
|
||||
DWORD ret;
|
||||
|
||||
if (!(nameW = FILE_name_AtoW( name, FALSE ))) return 0;
|
||||
|
||||
ret = GetFullPathNameW( nameW, MAX_PATH, bufferW, NULL);
|
||||
ret = GetFullPathNameW( nameW, MAX_PATH, bufferW, &lastpartW);
|
||||
|
||||
if (!ret) return 0;
|
||||
if (ret > MAX_PATH)
|
||||
|
@ -267,14 +267,10 @@ DWORD WINAPI GetFullPathNameA( LPCSTR name, DWORD len, LPSTR buffer,
|
|||
ret = copy_filename_WtoA( bufferW, buffer, len );
|
||||
if (ret < len && lastpart)
|
||||
{
|
||||
LPSTR p = buffer + strlen(buffer) - 1;
|
||||
|
||||
if (*p != '\\')
|
||||
{
|
||||
while ((p > buffer + 2) && (*p != '\\')) p--;
|
||||
*lastpart = p + 1;
|
||||
}
|
||||
else *lastpart = NULL;
|
||||
if (lastpartW)
|
||||
*lastpart = buffer + FILE_name_WtoA( bufferW, lastpartW - bufferW, NULL, 0 );
|
||||
else
|
||||
*lastpart = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1828,6 +1828,7 @@ static void test_GetFullPathNameA(void)
|
|||
char output[MAX_PATH], *filepart;
|
||||
DWORD ret;
|
||||
int i;
|
||||
UINT acp;
|
||||
|
||||
const struct
|
||||
{
|
||||
|
@ -1864,6 +1865,27 @@ static void test_GetFullPathNameA(void)
|
|||
"[%d] Expected GetLastError() to return 0xdeadbeef, got %u\n",
|
||||
i, GetLastError());
|
||||
}
|
||||
|
||||
acp = GetACP();
|
||||
if (acp != 932)
|
||||
skip("Skipping DBCS(Japanese) GetFullPathNameA test in this codepage (%d)\n", acp);
|
||||
else {
|
||||
const struct dbcs_case {
|
||||
const char *input;
|
||||
const char *expected;
|
||||
} testset[] = {
|
||||
{ "c:\\a\\\x95\x5c\x97\xa0.txt", "\x95\x5c\x97\xa0.txt" },
|
||||
{ "c:\\\x83\x8f\x83\x43\x83\x93\\wine.c", "wine.c" },
|
||||
{ "c:\\demo\\\x97\xa0\x95\x5c", "\x97\xa0\x95\x5c" }
|
||||
};
|
||||
for (i = 0; i < sizeof(testset)/sizeof(testset[0]); i++) {
|
||||
ret = GetFullPathNameA(testset[i].input, sizeof(output),
|
||||
output, &filepart);
|
||||
ok(ret, "[%d] GetFullPathName error %u\n", i, GetLastError());
|
||||
ok(!lstrcmpA(filepart, testset[i].expected),
|
||||
"[%d] expected %s got %s\n", i, testset[i].expected, filepart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_GetFullPathNameW(void)
|
||||
|
|
Loading…
Reference in New Issue