Paul Vriens : kernel32: Fix creation of empty sections in ini files.
Alexandre Julliard
julliard at winehq.org
Thu Apr 2 10:42:42 CDT 2009
Module: wine
Branch: master
Commit: 9a10234ef2b5212ba44b82a797c478f190b4dad1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9a10234ef2b5212ba44b82a797c478f190b4dad1
Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date: Thu Apr 2 12:16:11 2009 +0200
kernel32: Fix creation of empty sections in ini files.
---
dlls/kernel32/profile.c | 12 ++++++------
dlls/kernel32/tests/profile.c | 30 ++++++------------------------
2 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c
index d44e819..8a787da 100644
--- a/dlls/kernel32/profile.c
+++ b/dlls/kernel32/profile.c
@@ -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)
{
diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c
index 5120ec7..87c0a73 100644
--- a/dlls/kernel32/tests/profile.c
+++ b/dlls/kernel32/tests/profile.c
@@ -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);
}
More information about the wine-cvs
mailing list