From 3fb196fb57fadc94979f8354e2603a38d5b08708 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Wed, 16 Jul 2008 16:27:17 -0500 Subject: [PATCH] kernel32: Return the default value if lpKeyName is empty. --- dlls/kernel32/profile.c | 4 ++-- dlls/kernel32/tests/profile.c | 24 ++++++------------------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index ad436778a38..8209a2a41d1 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -964,8 +964,8 @@ static INT PROFILE_GetString( LPCWSTR section, LPCWSTR key_name, { if (!key_name[0]) { - /* Win95 returns 0 on keyname "". Tested with Likse32 bon 000227 */ - return 0; + PROFILE_CopyEntry(buffer, def_val, len, TRUE); + return strlenW(buffer); } key = PROFILE_Find( &CurProfile->section, section, key_name, FALSE, FALSE); PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val, diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c index 414b5967318..91ff98223c5 100644 --- a/dlls/kernel32/tests/profile.c +++ b/dlls/kernel32/tests/profile.c @@ -447,11 +447,8 @@ static void test_GetPrivateProfileString(void) lstrcpyA(buf, "kumquat"); ret = GetPrivateProfileStringA("section1", "", "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); /* lpKeyName is missing */ lstrcpyA(buf, "kumquat"); @@ -465,30 +462,21 @@ static void test_GetPrivateProfileString(void) ret = GetPrivateProfileStringA("section1", "", NULL, buf, MAX_PATH, filename); ok(ret == 0, "Expected 0, got %d\n", ret); - todo_wine - { - ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf); - } + ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf); /* lpKeyName is empty, lpDefault is empty */ lstrcpyA(buf, "kumquat"); ret = GetPrivateProfileStringA("section1", "", "", buf, MAX_PATH, filename); ok(ret == 0, "Expected 0, got %d\n", ret); - todo_wine - { - ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf); - } + ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf); /* lpKeyName is empty, lpDefault has trailing blank characters */ lstrcpyA(buf, "kumquat"); ret = GetPrivateProfileStringA("section1", "", "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); if (0) /* crashes */ {