From 71c7b1779a7b5a2ae6cd866b4716a7f17e6ec1ee Mon Sep 17 00:00:00 2001 From: Dmitry Kislyuk Date: Sun, 5 Apr 2009 02:00:39 -0500 Subject: kernel32: Set last error when GetPrivateProfileSection can't find section in ini file --- dlls/kernel32/profile.c | 27 ++++++++++++++++++++++++++- dlls/kernel32/tests/profile.c | 1 - 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index 8a787da..f5a9514 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -1073,6 +1073,28 @@ static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name, } +/*********************************************************************** + * PROFILE_SectionExists + * + * Returns whether section exists in profile. + */ +static BOOL PROFILE_SectionExists( PROFILESECTION *section, LPCWSTR section_name ) +{ + BOOL sectionExists = FALSE; + + while (section) + { + if (section->name[0] && !strcmpiW( section->name, section_name )) + { + sectionExists = TRUE; + break; + } + section = section->next; + } + return sectionExists; +} + + /********************* API functions **********************************/ @@ -1363,8 +1385,11 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer, RtlEnterCriticalSection( &PROFILE_CritSect ); if (PROFILE_Open( filename, FALSE )) + { ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, TRUE, FALSE); - + if(!ret && !PROFILE_SectionExists(CurProfile->section, section)) + SetLastError(ERROR_FILE_NOT_FOUND); + } RtlLeaveCriticalSection( &PROFILE_CritSect ); return ret; diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c index 87c0a73..acfcaee 100644 --- a/dlls/kernel32/tests/profile.c +++ b/dlls/kernel32/tests/profile.c @@ -181,7 +181,6 @@ static void test_profile_sections(void) SetLastError(0xdeadbeef); ret = GetPrivateProfileSectionA( "section1", buf, sizeof(buf), NULL ); ok( ret == 0, "expected return size 0, got %d\n", ret ); - todo_wine ok( GetLastError() == ERROR_FILE_NOT_FOUND || broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */ "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); -- 1.5.6.3