kernel32: Fix removing trailing spaces from lpDefault for GetPrivateProfileString.
This commit is contained in:
parent
e5705eae84
commit
7e9df53f38
|
@ -1084,17 +1084,14 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
|
||||||
/* strip any trailing ' ' of def_val. */
|
/* strip any trailing ' ' of def_val. */
|
||||||
if (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)
|
while (p > def_val && *p == ' ')
|
||||||
{
|
|
||||||
p--;
|
p--;
|
||||||
if ((*p) != ' ')
|
|
||||||
break;
|
if (p >= def_val)
|
||||||
}
|
|
||||||
if (*p == ' ') /* ouch, contained trailing ' ' */
|
|
||||||
{
|
{
|
||||||
int len = (int)(p - def_val);
|
int len = (int)(p - def_val) + 1;
|
||||||
|
|
||||||
defval_tmp = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
|
defval_tmp = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
|
||||||
memcpy(defval_tmp, def_val, len * sizeof(WCHAR));
|
memcpy(defval_tmp, def_val, len * sizeof(WCHAR));
|
||||||
|
|
|
@ -418,21 +418,15 @@ static void test_GetPrivateProfileString(void)
|
||||||
lstrcpyA(buf, "kumquat");
|
lstrcpyA(buf, "kumquat");
|
||||||
ret = GetPrivateProfileStringA("", "name1", "default ",
|
ret = GetPrivateProfileStringA("", "name1", "default ",
|
||||||
buf, MAX_PATH, filename);
|
buf, MAX_PATH, filename);
|
||||||
todo_wine
|
|
||||||
{
|
|
||||||
ok(ret == 7, "Expected 7, got %d\n", ret);
|
ok(ret == 7, "Expected 7, got %d\n", ret);
|
||||||
ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
|
ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
|
||||||
}
|
|
||||||
|
|
||||||
/* lpAppName is empty, many blank characters in lpDefault */
|
/* lpAppName is empty, many blank characters in lpDefault */
|
||||||
lstrcpyA(buf, "kumquat");
|
lstrcpyA(buf, "kumquat");
|
||||||
ret = GetPrivateProfileStringA("", "name1", "one two ",
|
ret = GetPrivateProfileStringA("", "name1", "one two ",
|
||||||
buf, MAX_PATH, filename);
|
buf, MAX_PATH, filename);
|
||||||
todo_wine
|
|
||||||
{
|
|
||||||
ok(ret == 7, "Expected 7, got %d\n", ret);
|
ok(ret == 7, "Expected 7, got %d\n", ret);
|
||||||
ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
|
ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
|
||||||
}
|
|
||||||
|
|
||||||
/* lpAppName is empty, blank character but not trailing in lpDefault */
|
/* lpAppName is empty, blank character but not trailing in lpDefault */
|
||||||
lstrcpyA(buf, "kumquat");
|
lstrcpyA(buf, "kumquat");
|
||||||
|
|
Loading…
Reference in New Issue