Commit 17a3c096 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

kernel32: Call PROFILE_DeleteSection directly from WritePrivateProfile* functions.

parent d60b126b
...@@ -503,11 +503,12 @@ static BOOL PROFILE_DeleteSection( PROFILESECTION **section, LPCWSTR name ) ...@@ -503,11 +503,12 @@ static BOOL PROFILE_DeleteSection( PROFILESECTION **section, LPCWSTR name )
*section = to_del->next; *section = to_del->next;
to_del->next = NULL; to_del->next = NULL;
PROFILE_Free( to_del ); PROFILE_Free( to_del );
CurProfile->changed = TRUE;
return TRUE; return TRUE;
} }
section = &(*section)->next; section = &(*section)->next;
} }
return FALSE; return TRUE;
} }
...@@ -971,15 +972,7 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len ) ...@@ -971,15 +972,7 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len )
static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name, static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name,
LPCWSTR value, BOOL create_always ) LPCWSTR value, BOOL create_always )
{ {
if (!key_name) /* Delete a whole section */ if (!value) /* Delete a key */
{
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 */
{ {
TRACE("(%s,%s)\n", debugstr_w(section_name), debugstr_w(key_name) ); TRACE("(%s,%s)\n", debugstr_w(section_name), debugstr_w(key_name) );
CurProfile->changed |= PROFILE_DeleteKey( &CurProfile->section, CurProfile->changed |= PROFILE_DeleteKey( &CurProfile->section,
...@@ -1335,12 +1328,13 @@ BOOL WINAPI WritePrivateProfileStringW( LPCWSTR section, LPCWSTR entry, ...@@ -1335,12 +1328,13 @@ BOOL WINAPI WritePrivateProfileStringW( LPCWSTR section, LPCWSTR entry,
} }
else if (PROFILE_Open( filename, TRUE )) else if (PROFILE_Open( filename, TRUE ))
{ {
if (!section) { if (!section)
SetLastError(ERROR_FILE_NOT_FOUND); SetLastError(ERROR_FILE_NOT_FOUND);
} else { else if (!entry)
ret = PROFILE_DeleteSection( &CurProfile->section, section );
else
ret = PROFILE_SetString( section, entry, string, FALSE); ret = PROFILE_SetString( section, entry, string, FALSE);
if (ret) ret = PROFILE_FlushFile(); if (ret) ret = PROFILE_FlushFile();
}
} }
RtlLeaveCriticalSection( &PROFILE_CritSect ); RtlLeaveCriticalSection( &PROFILE_CritSect );
...@@ -1393,8 +1387,9 @@ BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section, ...@@ -1393,8 +1387,9 @@ BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section,
} }
} }
else if (PROFILE_Open( filename, TRUE )) { else if (PROFILE_Open( filename, TRUE )) {
if (!string) {/* delete the named section*/ if (!string)
ret = PROFILE_SetString(section,NULL,NULL, FALSE); {
ret = PROFILE_DeleteSection( &CurProfile->section, section );
} else { } else {
PROFILE_DeleteAllKeys(section); PROFILE_DeleteAllKeys(section);
ret = TRUE; ret = TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment