kernel32: allow profile section and key names of zero length

Claudio Fontana claudio.fontana at gmail.com
Sun Jan 28 21:28:13 CST 2007


Hello,

following up on the profile changes started on this thread:
http://www.winehq.org/pipermail/wine-devel/2006-December/053009.html

I tried a patch in git format made against latest. First attempt at
using git, that is.

dlls/kernel32/profile.c: allow section and key names of zero length
dlls/kernel32/tests/profile.c: add testcases where KEY or SECTION are "".

Note: still requires testing on a real Windows 95, to determine if that
     version behaves differently.

If you have access to a Windows 95 installation, please help by applying
this patch and:

[optional]
* run the updated tests in wine (all should pass)
* revert changes in dlls/kernel32/profile.c, and run the updated tests
in wine (the two
  new tests should fail)

[important]
* run the updated test program under a real Windows 95.

 If tests pass, then Windows 95 behaves exactly the same as later versions.
 If tests do not pass, then Windows 95 is indeed different, and this patch
 should be modified accordingly.

---

 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-devel mailing list