kernel32: Fix creation of empty sections in ini files.

This commit is contained in:
Paul Vriens 2009-04-02 12:16:11 +02:00 committed by Alexandre Julliard
parent e09fc21576
commit 9a10234ef2
2 changed files with 12 additions and 30 deletions

View File

@ -202,9 +202,9 @@ static void PROFILE_Save( HANDLE hFile, const PROFILESECTION *section, ENCODING
for ( ; section; section = section->next)
{
int len = 4;
int len = 0;
if (section->name[0]) len += strlenW(section->name);
if (section->name[0]) len += strlenW(section->name) + 4;
for (key = section->key; key; key = key->next)
{
@ -216,15 +216,15 @@ static void PROFILE_Save( HANDLE hFile, const PROFILESECTION *section, ENCODING
if (!buffer) return;
p = buffer;
*p++ = '[';
if (section->name[0])
{
*p++ = '[';
strcpyW( p, section->name );
p += strlenW(p);
*p++ = ']';
*p++ = '\r';
*p++ = '\n';
}
*p++ = ']';
*p++ = '\r';
*p++ = '\n';
for (key = section->key; key; key = key->next)
{

View File

@ -972,10 +972,7 @@ static void test_WritePrivateProfileString(void)
"key5=string5\r\n";
ret = WritePrivateProfileStringA("App3", "key5", "string5", path);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
todo_wine
{
ok(check_file_data(path, data), "File doesn't match\n");
}
ok(check_file_data(path, data), "File doesn't match\n");
/* lpString is NULL, key2 key is deleted */
data = "[App1]\r\n"
@ -987,10 +984,7 @@ static void test_WritePrivateProfileString(void)
"key5=string5\r\n";
ret = WritePrivateProfileStringA("App1", "key2", NULL, path);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
todo_wine
{
ok(check_file_data(path, data), "File doesn't match\n");
}
ok(check_file_data(path, data), "File doesn't match\n");
/* try to delete key2 again */
data = "[App1]\r\n"
@ -1002,10 +996,7 @@ static void test_WritePrivateProfileString(void)
"key5=string5\r\n";
ret = WritePrivateProfileStringA("App1", "key2", NULL, path);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
todo_wine
{
ok(check_file_data(path, data), "File doesn't match\n");
}
ok(check_file_data(path, data), "File doesn't match\n");
/* lpKeyName is NULL, App1 section is deleted */
data = "[App2]\r\n"
@ -1014,29 +1005,20 @@ static void test_WritePrivateProfileString(void)
"key5=string5\r\n";
ret = WritePrivateProfileStringA("App1", NULL, "string1", path);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
todo_wine
{
ok(check_file_data(path, data), "File doesn't match\n");
}
ok(check_file_data(path, data), "File doesn't match\n");
/* lpString is not needed to delete a section */
data = "[App3]\r\n"
"key5=string5\r\n";
ret = WritePrivateProfileStringA("App2", NULL, NULL, path);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
todo_wine
{
ok(check_file_data(path, data), "File doesn't match\n");
}
ok(check_file_data(path, data), "File doesn't match\n");
/* leave just the section */
data = "[App3]\r\n";
ret = WritePrivateProfileStringA("App3", "key5", NULL, path);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
todo_wine
{
ok(check_file_data(path, data), "File doesn't match\n");
}
ok(check_file_data(path, data), "File doesn't match\n");
DeleteFileA(path);
}