Signed-off-by: Zebediah Figura z.figura12@gmail.com --- I actually had a local version of 30ad67dc14 written several months ago. I figure it's at least worth sending the tests I wrote for that.
dlls/kernel32/tests/profile.c | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+)
diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c index 1339b2b20ce..ce82a746e71 100644 --- a/dlls/kernel32/tests/profile.c +++ b/dlls/kernel32/tests/profile.c @@ -1092,6 +1092,77 @@ static void test_WritePrivateProfileString(void) DeleteFileA(path); }
+static void test_profile_struct(void) +{ + static const char expect_data[] = "[s]\r\nkey=616261637573006F\r\n"; + char buffer[20]; + BOOL ret; + + SetLastError(0xdeadbeef); + ret = GetPrivateProfileStructA("s", "key", buffer, sizeof(buffer), "./winetest.ini"); + ok(!ret, "expected failure\n"); + todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError()); + + ret = WritePrivateProfileStructA("s", "key", (void *)"abacus", sizeof("abacus"), "./winetest.ini"); + ok(ret, "got error %u\n", GetLastError()); + ok(check_file_data("./winetest.ini", expect_data), "file doesn't match\n"); + + SetLastError(0xdeadbeef); + ret = GetPrivateProfileStructA("s", "key", buffer, 6, "./winetest.ini"); + ok(!ret, "expected failure\n"); + todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = GetPrivateProfileStructA("s", "key", buffer, 8, "./winetest.ini"); + ok(!ret, "expected failure\n"); + todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError()); + + memset(buffer, 0xcc, sizeof(buffer)); + ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini"); + ok(ret, "got error %u\n", GetLastError()); + ok(!strcmp(buffer, "abacus"), "data didn't match\n"); + + memset(buffer, 0xcc, sizeof(buffer)); + ret = GetPrivateProfileStringA("s", "key", "default", buffer, sizeof(buffer), "./winetest.ini"); + ok(ret == 16, "got size %u\n", ret); + ok(!strcmp(buffer, "616261637573006F"), "got %s\n", debugstr_a(buffer)); + + ret = WritePrivateProfileStringA("s", "key", "636163747573006F", "./winetest.ini"); + ok(ret, "got error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini"); + ok(!ret, "expected failure\n"); + todo_wine ok(GetLastError() == ERROR_INVALID_DATA, "got error %u\n", GetLastError()); + + ret = WritePrivateProfileStringA("s", "key", "6361637475730083", "./winetest.ini"); + ok(ret, "got error %u\n", GetLastError()); + + memset(buffer, 0xcc, sizeof(buffer)); + ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini"); + ok(ret, "got error %u\n", GetLastError()); + ok(!strcmp(buffer, "cactus"), "data didn't match\n"); + + ret = WritePrivateProfileStringA("s", "key", "636163747573008Q", "./winetest.ini"); + ok(ret, "got error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini"); + ok(!ret, "expected failure\n"); + todo_wine ok(GetLastError() == ERROR_INVALID_DATA, "got error %u\n", GetLastError()); + + ret = WritePrivateProfileStringA("s", "key", "16361637475730083", "./winetest.ini"); + ok(ret, "got error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini"); + ok(!ret, "expected failure\n"); + todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError()); + + ret = DeleteFileA("./winetest.ini"); + ok(ret, "got error %u\n", GetLastError()); +} + START_TEST(profile) { test_profile_int(); @@ -1119,4 +1190,5 @@ START_TEST(profile) "[section2]\r", "CR only"); test_WritePrivateProfileString(); + test_profile_struct(); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/kernel32/profile.c | 116 +++++++++++++--------------------------- 1 file changed, 36 insertions(+), 80 deletions(-)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index f7d64f16a5f..02c6fa5efb7 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -949,64 +949,6 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len ) return buf-buffer; }
- -/*********************************************************************** - * PROFILE_GetString - * - * Get a profile string. - * - * Tests with GetPrivateProfileString16, W95a, - * with filled buffer ("****...") and section "set1" and key_name "1" valid: - * section key_name def_val res buffer - * "set1" "1" "x" 43 [data] - * "set1" "1 " "x" 43 [data] (!) - * "set1" " 1 "' "x" 43 [data] (!) - * "set1" "" "x" 1 "x" - * "set1" "" "x " 1 "x" (!) - * "set1" "" " x " 3 " x" (!) - * "set1" NULL "x" 6 "1\02\03\0\0" - * "set1" "" "x" 1 "x" - * NULL "1" "x" 0 "" (!) - * "" "1" "x" 1 "x" - * NULL NULL "" 0 "" - * - * - */ -static INT PROFILE_GetString( LPCWSTR section, LPCWSTR key_name, - LPCWSTR def_val, LPWSTR buffer, UINT len ) -{ - PROFILEKEY *key = NULL; - static const WCHAR empty_strW[] = { 0 }; - - if(!buffer || !len) return 0; - - if (!def_val) def_val = empty_strW; - if (key_name) - { - key = PROFILE_Find( &CurProfile->section, section, key_name, FALSE, FALSE); - PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val, - len, TRUE ); - TRACE("(%s,%s,%s): returning %s\n", - debugstr_w(section), debugstr_w(key_name), - debugstr_w(def_val), debugstr_w(buffer) ); - return strlenW( buffer ); - } - /* no "else" here ! */ - if (section) - { - INT ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, FALSE); - if (!buffer[0]) /* no luck -> def_val */ - { - PROFILE_CopyEntry(buffer, def_val, len, TRUE); - ret = strlenW(buffer); - } - return ret; - } - buffer[0] = '\0'; - return 0; -} - - /*********************************************************************** * PROFILE_SetString * @@ -1087,45 +1029,59 @@ INT WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename ) { + static const WCHAR emptyW[] = {0}; int ret; LPWSTR defval_tmp = NULL; + const WCHAR *p;
TRACE("%s,%s,%s,%p,%u,%s\n", debugstr_w(section), debugstr_w(entry), debugstr_w(def_val), buffer, len, debugstr_w(filename));
+ if (!buffer || !len) return 0; + if (!def_val) def_val = emptyW; + if (!section) return GetPrivateProfileSectionNamesW( buffer, len, filename ); + /* strip any trailing ' ' of def_val. */ - if (def_val) - { - LPCWSTR p = def_val + strlenW(def_val) - 1; + p = def_val + strlenW(def_val) - 1;
- while (p > def_val && *p == ' ') - p--; + while (p > def_val && *p == ' ') p--;
- if (p >= def_val) - { - int vlen = (int)(p - def_val) + 1; + if (p >= def_val) + { + int vlen = (int)(p - def_val) + 1;
- defval_tmp = HeapAlloc(GetProcessHeap(), 0, (vlen + 1) * sizeof(WCHAR)); - memcpy(defval_tmp, def_val, vlen * sizeof(WCHAR)); - defval_tmp[vlen] = '\0'; - def_val = defval_tmp; - } + defval_tmp = HeapAlloc(GetProcessHeap(), 0, (vlen + 1) * sizeof(WCHAR)); + memcpy(defval_tmp, def_val, vlen * sizeof(WCHAR)); + defval_tmp[vlen] = '\0'; + def_val = defval_tmp; }
RtlEnterCriticalSection( &PROFILE_CritSect );
- if (PROFILE_Open( filename, FALSE )) { - if (section == NULL) - ret = PROFILE_GetSectionNames(buffer, len); - else - /* PROFILE_GetString can handle the 'entry == NULL' case */ - ret = PROFILE_GetString( section, entry, def_val, buffer, len ); - } else if (buffer && def_val) { + if (PROFILE_Open( filename, FALSE )) + { + if (entry) + { + PROFILEKEY *key = PROFILE_Find( &CurProfile->section, section, entry, FALSE, FALSE ); + PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val, len, TRUE ); + TRACE("-> %s\n", debugstr_w( buffer )); + ret = strlenW( buffer ); + } + else + { + ret = PROFILE_GetSection( CurProfile->section, section, buffer, len, FALSE ); + if (!buffer[0]) + { + PROFILE_CopyEntry( buffer, def_val, len, TRUE ); + ret = strlenW( buffer ); + } + } + } + else + { lstrcpynW( buffer, def_val, len ); ret = strlenW( buffer ); } - else - ret = 0;
RtlLeaveCriticalSection( &PROFILE_CritSect );
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/kernel32/profile.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index 02c6fa5efb7..7c50fb9a614 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -101,14 +101,13 @@ static const char hex[16] = "0123456789ABCDEF"; * Copy the content of an entry into a buffer, removing quotes, and possibly * translating environment variables. */ -static void PROFILE_CopyEntry( LPWSTR buffer, LPCWSTR value, int len, - BOOL strip_quote ) +static void PROFILE_CopyEntry( LPWSTR buffer, LPCWSTR value, int len ) { WCHAR quote = '\0';
if(!buffer) return;
- if (strip_quote && ((*value == ''') || (*value == '"'))) + if (*value == ''' || *value == '"') { if (value[1] && (value[strlenW(value)-1] == *value)) quote = *value++; } @@ -877,14 +876,14 @@ static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name, if (!*key->name && !key->value) continue; /* Skip empty lines */ if (IS_ENTRY_COMMENT(key->name)) continue; /* Skip comments */ if (!return_values && !key->value) continue; /* Skip lines w.o. '=' */ - PROFILE_CopyEntry( buffer, key->name, len - 1, 0 ); + lstrcpynW( buffer, key->name, len - 1 ); len -= strlenW(buffer) + 1; buffer += strlenW(buffer) + 1; if (len < 2) break; if (return_values && key->value) { buffer[-1] = '='; - PROFILE_CopyEntry ( buffer, key->value, len - 1, 0 ); + lstrcpynW( buffer, key->value, len - 1 ); len -= strlenW(buffer) + 1; buffer += strlenW(buffer) + 1; } @@ -1063,7 +1062,7 @@ INT WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry, if (entry) { PROFILEKEY *key = PROFILE_Find( &CurProfile->section, section, entry, FALSE, FALSE ); - PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val, len, TRUE ); + PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val, len ); TRACE("-> %s\n", debugstr_w( buffer )); ret = strlenW( buffer ); } @@ -1072,7 +1071,7 @@ INT WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry, ret = PROFILE_GetSection( CurProfile->section, section, buffer, len, FALSE ); if (!buffer[0]) { - PROFILE_CopyEntry( buffer, def_val, len, TRUE ); + PROFILE_CopyEntry( buffer, def_val, len ); ret = strlenW( buffer ); } }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73839
Your paranoid android.
=== debiant (32 bit WoW report) ===
kernel32: mailslot.c:327: Test failed: timeout too short 986
=== debiant (64 bit WoW report) ===
kernel32: mailslot.c:327: Test failed: timeout too short 989
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This is some preparatory code, which moves things around so as to more easily implement registry mapping (bug 4096).
The idea here is to separate the operations of "get value" and "get section", since these are fundamentally different operations, both when mapped and when not mapped, and moreover the latter operation may retrieve both registry and .ini values.
dlls/kernel32/profile.c | 62 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 29 deletions(-)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index 7c50fb9a614..dfda24446cb 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -856,16 +856,26 @@ static BOOL PROFILE_Open( LPCWSTR filename, BOOL write_access ) * Returns all keys of a section. * If return_values is TRUE, also include the corresponding values. */ -static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name, +static INT PROFILE_GetSection( const WCHAR *filename, LPCWSTR section_name, LPWSTR buffer, UINT len, BOOL return_values ) { + PROFILESECTION *section; PROFILEKEY *key;
if(!buffer) return 0;
TRACE("%s,%p,%u\n", debugstr_w(section_name), buffer, len);
- while (section) + EnterCriticalSection( &PROFILE_CritSect ); + + if (!PROFILE_Open( filename, FALSE )) + { + LeaveCriticalSection( &PROFILE_CritSect ); + buffer[0] = 0; + return 0; + } + + for (section = CurProfile->section; section; section = section->next) { if (!strcmpiW( section->name, section_name )) { @@ -889,6 +899,9 @@ static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name, } } *buffer = '\0'; + + LeaveCriticalSection( &PROFILE_CritSect ); + if (len <= 1) /*If either lpszSection or lpszKey is NULL and the supplied destination buffer is too small to hold all the strings, @@ -901,9 +914,11 @@ static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name, } return oldlen - len; } - section = section->next; } buffer[0] = buffer[1] = '\0'; + + LeaveCriticalSection( &PROFILE_CritSect ); + return 0; }
@@ -1039,6 +1054,16 @@ INT WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry, if (!buffer || !len) return 0; if (!def_val) def_val = emptyW; if (!section) return GetPrivateProfileSectionNamesW( buffer, len, filename ); + if (!entry) + { + ret = PROFILE_GetSection( filename, section, buffer, len, FALSE ); + if (!buffer[0]) + { + PROFILE_CopyEntry( buffer, def_val, len ); + ret = strlenW( buffer ); + } + return ret; + }
/* strip any trailing ' ' of def_val. */ p = def_val + strlenW(def_val) - 1; @@ -1059,22 +1084,10 @@ INT WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry,
if (PROFILE_Open( filename, FALSE )) { - if (entry) - { - PROFILEKEY *key = PROFILE_Find( &CurProfile->section, section, entry, FALSE, FALSE ); - PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val, len ); - TRACE("-> %s\n", debugstr_w( buffer )); - ret = strlenW( buffer ); - } - else - { - ret = PROFILE_GetSection( CurProfile->section, section, buffer, len, FALSE ); - if (!buffer[0]) - { - PROFILE_CopyEntry( buffer, def_val, len ); - ret = strlenW( buffer ); - } - } + PROFILEKEY *key = PROFILE_Find( &CurProfile->section, section, entry, FALSE, FALSE ); + PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val, len ); + TRACE("-> %s\n", debugstr_w( buffer )); + ret = strlenW( buffer ); } else { @@ -1229,8 +1242,6 @@ UINT WINAPI GetPrivateProfileIntA( LPCSTR section, LPCSTR entry, INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer, DWORD len, LPCWSTR filename ) { - int ret = 0; - if (!section || !buffer) { SetLastError(ERROR_INVALID_PARAMETER); @@ -1239,14 +1250,7 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer,
TRACE("(%s, %p, %d, %s)\n", debugstr_w(section), buffer, len, debugstr_w(filename));
- RtlEnterCriticalSection( &PROFILE_CritSect ); - - if (PROFILE_Open( filename, FALSE )) - ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, TRUE); - - RtlLeaveCriticalSection( &PROFILE_CritSect ); - - return ret; + return PROFILE_GetSection( filename, section, buffer, len, TRUE ); }
/***********************************************************************
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73840
Your paranoid android.
=== debiant (32 bit report) ===
kernel32: mailslot.c:327: Test failed: timeout too short 989
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- Similar to patch 4/6, this and the next patch separate writing a value from deleting a section.
dlls/kernel32/profile.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index dfda24446cb..06a06f7c01f 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -971,15 +971,7 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len ) static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name, LPCWSTR value, BOOL create_always ) { - if (!key_name) /* Delete a whole section */ - { - 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 */ + if (!value) /* Delete a key */ { TRACE("(%s,%s)\n", debugstr_w(section_name), debugstr_w(key_name) ); CurProfile->changed |= PROFILE_DeleteKey( &CurProfile->section, @@ -1335,12 +1327,13 @@ BOOL WINAPI WritePrivateProfileStringW( LPCWSTR section, LPCWSTR entry, } else if (PROFILE_Open( filename, TRUE )) { - if (!section) { + if (!section) SetLastError(ERROR_FILE_NOT_FOUND); - } else { + else if (!entry) + ret = PROFILE_DeleteSection( &CurProfile->section, section ); + else ret = PROFILE_SetString( section, entry, string, FALSE); - if (ret) ret = PROFILE_FlushFile(); - } + if (ret) ret = PROFILE_FlushFile(); }
RtlLeaveCriticalSection( &PROFILE_CritSect ); @@ -1393,8 +1386,9 @@ BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section, } } else if (PROFILE_Open( filename, TRUE )) { - if (!string) {/* delete the named section*/ - ret = PROFILE_SetString(section,NULL,NULL, FALSE); + if (!string) + { + ret = PROFILE_DeleteSection( &CurProfile->section, section ); } else { PROFILE_DeleteAllKeys(section); ret = TRUE;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73841
Your paranoid android.
=== debiant (32 bit report) ===
kernel32: profile.c:948: Test failed: Expected TRUE, got 0 profile.c:1066: Test failed: File doesn't match profile.c:1073: Test failed: File doesn't match profile.c:1079: Test failed: File doesn't match
=== debiant (32 bit Chinese:China report) ===
kernel32: profile.c:948: Test failed: Expected TRUE, got 0 profile.c:1066: Test failed: File doesn't match profile.c:1073: Test failed: File doesn't match profile.c:1079: Test failed: File doesn't match
=== debiant (32 bit WoW report) ===
kernel32: profile.c:948: Test failed: Expected TRUE, got 0 profile.c:1066: Test failed: File doesn't match profile.c:1073: Test failed: File doesn't match profile.c:1079: Test failed: File doesn't match
=== debiant (64 bit WoW report) ===
kernel32: profile.c:948: Test failed: Expected TRUE, got 0 profile.c:1066: Test failed: File doesn't match profile.c:1073: Test failed: File doesn't match profile.c:1079: Test failed: File doesn't match
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/kernel32/profile.c | 112 ++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 49 deletions(-)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index 06a06f7c01f..a93968b9a27 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -488,29 +488,6 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) }
-/*********************************************************************** - * PROFILE_DeleteSection - * - * Delete a section from a profile tree. - */ -static BOOL PROFILE_DeleteSection( PROFILESECTION **section, LPCWSTR name ) -{ - while (*section) - { - if (!strcmpiW( (*section)->name, name )) - { - PROFILESECTION *to_del = *section; - *section = to_del->next; - to_del->next = NULL; - PROFILE_Free( to_del ); - return TRUE; - } - section = &(*section)->next; - } - return FALSE; -} - - /*********************************************************************** * PROFILE_DeleteKey * @@ -922,6 +899,37 @@ static INT PROFILE_GetSection( const WCHAR *filename, LPCWSTR section_name, return 0; }
+static BOOL PROFILE_DeleteSection( const WCHAR *filename, const WCHAR *name ) +{ + PROFILESECTION **section; + + EnterCriticalSection( &PROFILE_CritSect ); + + if (!PROFILE_Open( filename, TRUE )) + { + LeaveCriticalSection( &PROFILE_CritSect ); + return FALSE; + } + + for (section = &CurProfile->section; *section; section = &(*section)->next) + { + if (!strcmpiW( (*section)->name, name )) + { + PROFILESECTION *to_del = *section; + *section = to_del->next; + to_del->next = NULL; + PROFILE_Free( to_del ); + PROFILE_FlushFile(); + LeaveCriticalSection( &PROFILE_CritSect ); + return TRUE; + } + } + + LeaveCriticalSection( &PROFILE_CritSect ); + return FALSE; +} + + /* See GetPrivateProfileSectionNamesA for documentation */ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len ) { @@ -1316,27 +1324,30 @@ BOOL WINAPI WritePrivateProfileStringW( LPCWSTR section, LPCWSTR entry, { BOOL ret = FALSE;
- RtlEnterCriticalSection( &PROFILE_CritSect ); - if (!section && !entry && !string) /* documented "file flush" case */ { + EnterCriticalSection( &PROFILE_CritSect ); if (!filename || PROFILE_Open( filename, TRUE )) { - if (CurProfile) PROFILE_ReleaseFile(); /* always return FALSE in this case */ + if (CurProfile) PROFILE_ReleaseFile(); } + LeaveCriticalSection( &PROFILE_CritSect ); + return FALSE; } - else if (PROFILE_Open( filename, TRUE )) + if (!entry) return PROFILE_DeleteSection( filename, section ); + + EnterCriticalSection( &PROFILE_CritSect ); + + if (PROFILE_Open( filename, TRUE )) { if (!section) SetLastError(ERROR_FILE_NOT_FOUND); - else if (!entry) - ret = PROFILE_DeleteSection( &CurProfile->section, section ); else ret = PROFILE_SetString( section, entry, string, FALSE); if (ret) ret = PROFILE_FlushFile(); }
- RtlLeaveCriticalSection( &PROFILE_CritSect ); + LeaveCriticalSection( &PROFILE_CritSect ); return ret; }
@@ -1376,37 +1387,40 @@ BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section, BOOL ret = FALSE; LPWSTR p;
- RtlEnterCriticalSection( &PROFILE_CritSect ); - if (!section && !string) { + EnterCriticalSection( &PROFILE_CritSect ); if (!filename || PROFILE_Open( filename, TRUE )) { - if (CurProfile) PROFILE_ReleaseFile(); /* always return FALSE in this case */ + if (CurProfile) PROFILE_ReleaseFile(); } + LeaveCriticalSection( &PROFILE_CritSect ); + return FALSE; } - else if (PROFILE_Open( filename, TRUE )) { - if (!string) + if (!string) return PROFILE_DeleteSection( filename, section ); + + EnterCriticalSection( &PROFILE_CritSect ); + + if (PROFILE_Open( filename, TRUE )) + { + PROFILE_DeleteAllKeys(section); + ret = TRUE; + while (*string && ret) { - ret = PROFILE_DeleteSection( &CurProfile->section, section ); - } else { - PROFILE_DeleteAllKeys(section); - ret = TRUE; - while(*string && ret) { - LPWSTR buf = HeapAlloc( GetProcessHeap(), 0, (strlenW(string)+1) * sizeof(WCHAR) ); - strcpyW( buf, string ); - if((p = strchrW( buf, '='))) { - *p='\0'; - ret = PROFILE_SetString( section, buf, p+1, TRUE); - } - HeapFree( GetProcessHeap(), 0, buf ); - string += strlenW(string)+1; + WCHAR *buf = HeapAlloc( GetProcessHeap(), 0, (strlenW( string ) + 1) * sizeof(WCHAR) ); + strcpyW( buf, string ); + if ((p = strchrW( buf, '='))) + { + *p = '\0'; + ret = PROFILE_SetString( section, buf, p+1, TRUE ); } + HeapFree( GetProcessHeap(), 0, buf ); + string += strlenW( string ) + 1; } if (ret) ret = PROFILE_FlushFile(); }
- RtlLeaveCriticalSection( &PROFILE_CritSect ); + LeaveCriticalSection( &PROFILE_CritSect ); return ret; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73842
Your paranoid android.
=== debiant (32 bit report) ===
kernel32: profile.c:948: Test failed: Expected TRUE, got 0 profile.c:1066: Test failed: File doesn't match profile.c:1073: Test failed: File doesn't match profile.c:1079: Test failed: File doesn't match
=== debiant (32 bit Chinese:China report) ===
kernel32: change.c:320: Test failed: should be ready profile.c:948: Test failed: Expected TRUE, got 0 profile.c:1066: Test failed: File doesn't match profile.c:1073: Test failed: File doesn't match profile.c:1079: Test failed: File doesn't match
=== debiant (32 bit WoW report) ===
kernel32: profile.c:948: Test failed: Expected TRUE, got 0 profile.c:1066: Test failed: File doesn't match profile.c:1073: Test failed: File doesn't match profile.c:1079: Test failed: File doesn't match
=== debiant (64 bit WoW report) ===
kernel32: mailslot.c:327: Test failed: timeout too short 987 profile.c:948: Test failed: Expected TRUE, got 0 profile.c:1066: Test failed: File doesn't match profile.c:1073: Test failed: File doesn't match profile.c:1079: Test failed: File doesn't match
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73837
Your paranoid android.
=== debiant (32 bit report) ===
kernel32: profile.c:213: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (32 bit French report) ===
kernel32: profile.c:213: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (32 bit Japanese:Japan report) ===
kernel32: profile.c:213: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (32 bit Chinese:China report) ===
kernel32: profile.c:213: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (32 bit WoW report) ===
kernel32: profile.c:213: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (64 bit WoW report) ===
kernel32: profile.c:213: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2