kernel32: Fix handling lines with only values in GetPrivateProfileSection.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2c925f2320
commit
aa16304c19
|
@ -879,7 +879,7 @@ static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name,
|
|||
for (key = section->key; key; key = key->next)
|
||||
{
|
||||
if (len <= 2) break;
|
||||
if (!*key->name) continue; /* Skip empty lines */
|
||||
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 );
|
||||
|
|
|
@ -171,7 +171,7 @@ static void test_profile_sections(void)
|
|||
DWORD count;
|
||||
char buf[100];
|
||||
char *p;
|
||||
static const char content[]="[section1]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n[section2]\r\n";
|
||||
static const char content[]="[section1]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n[section2]\r\n[section3]\r\n=val5\r\n";
|
||||
static const char testfile4[]=".\\testwine4.ini";
|
||||
BOOL on_win98 = FALSE;
|
||||
|
||||
|
@ -241,6 +241,19 @@ static void test_profile_sections(void)
|
|||
broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
|
||||
"expected ERROR_SUCCESS, got %d\n", GetLastError());
|
||||
|
||||
/* Existing section with no keys but has values */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret=GetPrivateProfileSectionA("section3", buf, sizeof(buf), testfile4);
|
||||
trace("section3 return: %s\n", buf);
|
||||
for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
|
||||
p[-1] = ',';
|
||||
ok( ret == 6 && !strcmp( buf, "=val5"), "wrong section returned(%d): %s\n",
|
||||
ret, buf);
|
||||
ok( buf[ret-1] == 0 && buf[ret] == 0, "returned buffer not terminated with double-null\n" );
|
||||
ok( GetLastError() == ERROR_SUCCESS ||
|
||||
broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
|
||||
"expected ERROR_SUCCESS, got %d\n", GetLastError());
|
||||
|
||||
/* Overflow*/
|
||||
ret=GetPrivateProfileSectionA("section1", buf, 24, testfile4);
|
||||
for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
|
||||
|
|
Loading…
Reference in New Issue