kernel32: allow profile section and key names of zero length
Claudio Fontana
claudio.fontana at gmail.com
Sun Feb 4 10:43:32 CST 2007
I received confirmation that Windows 95 _does_ accept zero length names
for profile key and section, so this change should work in all cases.
In my opinion, it is now ready to go in.
ChangeLog:
dlls/kernel32/profile.c: allow section and key names of zero length.
dlls/kernel32/tests/profile.c: add testcases where KEY or SECTION are "".
---
dlls/kernel32/profile.c | 10 ++--------
dlls/kernel32/tests/profile.c | 8 ++++++--
2 files changed, 8 insertions(+), 10 deletions(-)
-------------- next part --------------
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c
index 339b852..5ebf3c0 100644
--- a/dlls/kernel32/profile.c
+++ b/dlls/kernel32/profile.c
@@ -599,9 +599,8 @@ static PROFILEKEY *PROFILE_Find( PROFILE
while (*section)
{
- if ( ((*section)->name[0])
- && (!(strncmpiW( (*section)->name, section_name, seclen )))
- && (((*section)->name)[seclen] == '\0') )
+ if (!strncmpiW((*section)->name, section_name, seclen) &&
+ ((*section)->name)[seclen] == '\0')
{
PROFILEKEY **key = &(*section)->key;
@@ -959,11 +958,6 @@ static INT PROFILE_GetString( LPCWSTR se
if (!def_val) def_val = empty_strW;
if (key_name)
{
- if (!key_name[0])
- {
- /* Win95 returns 0 on keyname "". Tested with Likse32 bon 000227 */
- return 0;
- }
key = PROFILE_Find( &CurProfile->section, section, key_name, FALSE, FALSE);
PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val,
len, TRUE );
diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c
index 4379ee2..aeedaad 100644
--- a/dlls/kernel32/tests/profile.c
+++ b/dlls/kernel32/tests/profile.c
@@ -68,6 +68,8 @@ static void test_profile_int(void)
{ SECTION, KEY, "42A94967297", TESTFILE, 1, 42 , 42},
{ SECTION, KEY, "B4294967297", TESTFILE, -1, 0 , 0},
{ SECTION, KEY, "B4294967297", TESTFILE, 1, 0 , 0},
+ { "", KEY, "1", TESTFILE, 0, 1 , 1}, /* 25 */
+ { SECTION, "", "1", TESTFILE, 0, 1 , 1},
};
int i, num_test = (sizeof(profileInt)/sizeof(struct _profileInt));
UINT res;
@@ -76,8 +78,10 @@ static void test_profile_int(void)
for (i=0; i < num_test; i++) {
if (profileInt[i].value)
- WritePrivateProfileStringA(SECTION, KEY, profileInt[i].value,
- profileInt[i].iniFile);
+ WritePrivateProfileStringA(profileInt[i].section,
+ profileInt[i].key,
+ profileInt[i].value,
+ profileInt[i].iniFile);
res = GetPrivateProfileIntA(profileInt[i].section, profileInt[i].key,
profileInt[i].defaultVal, profileInt[i].iniFile);
--
1.3.GIT
More information about the wine-patches
mailing list