Zebediah Figura : kernel32: Call PROFILE_DeleteSection directly from WritePrivateProfile* functions.

Alexandre Julliard julliard at winehq.org
Mon Jun 29 14:59:20 CDT 2020


Module: wine
Branch: master
Commit: 17a3c0964dd1734bbfe7bb6d926d33d6023af434
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=17a3c0964dd1734bbfe7bb6d926d33d6023af434

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Sun Jun 28 13:51:17 2020 -0500

kernel32: Call PROFILE_DeleteSection directly from WritePrivateProfile* functions.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/profile.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c
index dfda24446c..63a400cce6 100644
--- a/dlls/kernel32/profile.c
+++ b/dlls/kernel32/profile.c
@@ -503,11 +503,12 @@ static BOOL PROFILE_DeleteSection( PROFILESECTION **section, LPCWSTR name )
             *section = to_del->next;
             to_del->next = NULL;
             PROFILE_Free( to_del );
+            CurProfile->changed = TRUE;
             return TRUE;
         }
         section = &(*section)->next;
     }
-    return FALSE;
+    return TRUE;
 }
 
 
@@ -971,15 +972,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 +1328,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 +1387,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;




More information about the wine-cvs mailing list