[PATCH 5/6] kernel32: Call PROFILE_DeleteSection directly from WritePrivateProfile* functions.

Zebediah Figura z.figura12 at gmail.com
Sun Jun 21 19:24:13 CDT 2020


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
Similar to patch 4/6, this and the next patch separate writing a value from
deleting a section.

 dlls/kernel32/profile.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c
index dfda24446cb..06a06f7c01f 100644
--- a/dlls/kernel32/profile.c
+++ b/dlls/kernel32/profile.c
@@ -971,15 +971,7 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len )
 static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name,
                                LPCWSTR value, BOOL create_always )
 {
-    if (!key_name)  /* Delete a whole section */
-    {
-        TRACE("(%s)\n", debugstr_w(section_name));
-        CurProfile->changed |= PROFILE_DeleteSection( &CurProfile->section,
-                                                      section_name );
-        return TRUE;         /* Even if PROFILE_DeleteSection() has failed,
-                                this is not an error on application's level.*/
-    }
-    else if (!value)  /* Delete a key */
+    if (!value)  /* Delete a key */
     {
         TRACE("(%s,%s)\n", debugstr_w(section_name), debugstr_w(key_name) );
         CurProfile->changed |= PROFILE_DeleteKey( &CurProfile->section,
@@ -1335,12 +1327,13 @@ BOOL WINAPI WritePrivateProfileStringW( LPCWSTR section, LPCWSTR entry,
     }
     else if (PROFILE_Open( filename, TRUE ))
     {
-        if (!section) {
+        if (!section)
             SetLastError(ERROR_FILE_NOT_FOUND);
-        } else {
+        else if (!entry)
+            ret = PROFILE_DeleteSection( &CurProfile->section, section );
+        else
             ret = PROFILE_SetString( section, entry, string, FALSE);
-            if (ret) ret = PROFILE_FlushFile();
-        }
+        if (ret) ret = PROFILE_FlushFile();
     }
 
     RtlLeaveCriticalSection( &PROFILE_CritSect );
@@ -1393,8 +1386,9 @@ BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section,
         }
     }
     else if (PROFILE_Open( filename, TRUE )) {
-        if (!string) {/* delete the named section*/
-	    ret = PROFILE_SetString(section,NULL,NULL, FALSE);
+        if (!string)
+        {
+            ret = PROFILE_DeleteSection( &CurProfile->section, section );
         } else {
 	    PROFILE_DeleteAllKeys(section);
 	    ret = TRUE;
-- 
2.27.0




More information about the wine-devel mailing list