profile: fix GetPrivateProfileSection

Huw D M Davies h.davies1 at physics.ox.ac.uk
Thu Mar 3 11:25:44 CST 2005


Huw Davies <huw at codeweavers.com>
Fix regression in GetPrivateProfileSection for lines without an '='
Add test.
-- 
Huw Davies
huw at codeweavers.com
Index: dlls/kernel/profile.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/profile.c,v
retrieving revision 1.19
diff -u -p -r1.19 profile.c
--- dlls/kernel/profile.c	2 Mar 2005 10:08:18 -0000	1.19
+++ dlls/kernel/profile.c	3 Mar 2005 17:22:47 -0000
@@ -863,7 +863,7 @@ static INT PROFILE_GetSection( PROFILESE
                 if (len <= 2) break;
                 if (!*key->name) continue;  /* Skip empty lines */
                 if (IS_ENTRY_COMMENT(key->name)) continue;  /* Skip comments */
-                if (!key->value) continue;  /* Skip lines w.o. '=' */
+                if (!return_values && !key->value) continue;  /* Skip lines w.o. '=' */
                 PROFILE_CopyEntry( buffer, key->name, len - 1, 0 );
                 len -= strlenW(buffer) + 1;
                 buffer += strlenW(buffer) + 1;
Index: dlls/kernel/tests/profile.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/profile.c,v
retrieving revision 1.6
diff -u -p -r1.6 profile.c
--- dlls/kernel/tests/profile.c	2 Mar 2005 10:08:18 -0000	1.6
+++ dlls/kernel/tests/profile.c	3 Mar 2005 17:22:47 -0000
@@ -114,6 +114,14 @@ void test_profile_string()
     /* and test */
     ok( !strcmp( buf, "name1,name2,name4"), "wrong keys returned: %s\n",
             buf);
+
+    ret=GetPrivateProfileSectionA("s", buf, sizeof(buf), TESTFILE2);
+    for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1) 
+        p[-1] = ',';
+    /* and test */
+    ok( !strcmp( buf, "name1=val1,name2=,name3,name4=val4"), "wrong section returned: %s\n",
+            buf);
+    
     /* add a new key to test that the file is quite usable */
     WritePrivateProfileStringA( "s", "name5", "val5", TESTFILE2); 
     ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),



More information about the wine-patches mailing list