Commit 9a10234e authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

kernel32: Fix creation of empty sections in ini files.

parent e09fc215
......@@ -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';
}
for (key = section->key; key; key = key->next)
{
......
......@@ -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");
}
/* 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");
}
/* 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");
}
/* 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");
}
/* 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");
}
/* 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");
}
DeleteFileA(path);
}
......
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