Commit 7e9df53f authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

kernel32: Fix removing trailing spaces from lpDefault for GetPrivateProfileString.

parent e5705eae
......@@ -1084,17 +1084,14 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
/* strip any trailing ' ' of def_val. */
if (def_val)
{
LPCWSTR p = &def_val[strlenW(def_val)]; /* even "" works ! */
LPCWSTR p = &def_val[strlenW(def_val) - 1];
while (p > def_val)
{
p--;
if ((*p) != ' ')
break;
}
if (*p == ' ') /* ouch, contained trailing ' ' */
{
int len = (int)(p - def_val);
while (p > def_val && *p == ' ')
p--;
if (p >= def_val)
{
int len = (int)(p - def_val) + 1;
defval_tmp = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
memcpy(defval_tmp, def_val, len * sizeof(WCHAR));
......
......@@ -418,21 +418,15 @@ static void test_GetPrivateProfileString(void)
lstrcpyA(buf, "kumquat");
ret = GetPrivateProfileStringA("", "name1", "default ",
buf, MAX_PATH, filename);
todo_wine
{
ok(ret == 7, "Expected 7, got %d\n", ret);
ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
}
ok(ret == 7, "Expected 7, got %d\n", ret);
ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
/* lpAppName is empty, many blank characters in lpDefault */
lstrcpyA(buf, "kumquat");
ret = GetPrivateProfileStringA("", "name1", "one two ",
buf, MAX_PATH, filename);
todo_wine
{
ok(ret == 7, "Expected 7, got %d\n", ret);
ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
}
ok(ret == 7, "Expected 7, got %d\n", ret);
ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
/* lpAppName is empty, blank character but not trailing in lpDefault */
lstrcpyA(buf, "kumquat");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment