Make WritePrivateProfileSectionA care for "" and NULL as the
string argument. New function PROFILE_DeleteAllKeys.
This commit is contained in:
parent
e6ba02e57a
commit
d88fbb7a78
@ -392,6 +392,34 @@ static BOOL PROFILE_DeleteKey( PROFILESECTION **section,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* PROFILE_DeleteAllKeys
|
||||||
|
*
|
||||||
|
* Delete all keys from a profile tree.
|
||||||
|
*/
|
||||||
|
void PROFILE_DeleteAllKeys( LPCSTR section_name)
|
||||||
|
{
|
||||||
|
PROFILESECTION **section= &CurProfile->section;
|
||||||
|
while (*section)
|
||||||
|
{
|
||||||
|
if ((*section)->name && !strcasecmp( (*section)->name, section_name ))
|
||||||
|
{
|
||||||
|
PROFILEKEY **key = &(*section)->key;
|
||||||
|
while (*key)
|
||||||
|
{
|
||||||
|
PROFILEKEY *to_del = *key;
|
||||||
|
*key = to_del->next;
|
||||||
|
if (to_del->name) HeapFree( GetProcessHeap(), 0, to_del->name );
|
||||||
|
if (to_del->value) HeapFree( GetProcessHeap(), 0, to_del->value);
|
||||||
|
HeapFree( GetProcessHeap(), 0, to_del );
|
||||||
|
CurProfile->changed =TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
section = &(*section)->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* PROFILE_Find
|
* PROFILE_Find
|
||||||
*
|
*
|
||||||
@ -1386,9 +1414,13 @@ BOOL WINAPI WritePrivateProfileSectionA( LPCSTR section,
|
|||||||
if (PROFILE_Open( filename )) {
|
if (PROFILE_Open( filename )) {
|
||||||
if (!section && !string && !filename)
|
if (!section && !string && !filename)
|
||||||
PROFILE_ReleaseFile(); /* always return FALSE in this case */
|
PROFILE_ReleaseFile(); /* always return FALSE in this case */
|
||||||
|
else if (!string) /* delete the named section*/
|
||||||
|
ret = PROFILE_SetString(section,NULL,NULL);
|
||||||
else {
|
else {
|
||||||
while(*string){
|
PROFILE_DeleteAllKeys(section);
|
||||||
LPSTR buf=HEAP_strdupA( GetProcessHeap(), 0, string );
|
ret = TRUE;
|
||||||
|
while(*string) {
|
||||||
|
LPSTR buf=HEAP_strdupA( GetProcessHeap(), 0, string );
|
||||||
if((p=strchr( buf, '='))){
|
if((p=strchr( buf, '='))){
|
||||||
*p='\0';
|
*p='\0';
|
||||||
ret = PROFILE_SetString( section, buf, p+1 );
|
ret = PROFILE_SetString( section, buf, p+1 );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user