When enumerating keys using Get(Private)ProfileString do not include
lines without an '=' character. Added a test that shows the behavior.
This commit is contained in:
parent
2fd19dfb98
commit
4c5832ba65
|
@ -863,6 +863,7 @@ static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name,
|
|||
if (len <= 2) break;
|
||||
if (!*key->name) continue; /* Skip empty lines */
|
||||
if (IS_ENTRY_COMMENT(key->name)) continue; /* Skip comments */
|
||||
if (!key->value) continue; /* Skip lines w.o. '=' */
|
||||
PROFILE_CopyEntry( buffer, key->name, len - 1, 0 );
|
||||
len -= strlenW(buffer) + 1;
|
||||
buffer += strlenW(buffer) + 1;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define KEY "ProfileInt"
|
||||
#define SECTION "Test"
|
||||
#define TESTFILE ".\\testwine.ini"
|
||||
#define TESTFILE2 ".\\testwine2.ini"
|
||||
|
||||
struct _profileInt {
|
||||
LPCSTR section;
|
||||
|
@ -88,7 +89,44 @@ static void test_profile_int(void)
|
|||
DeleteFileA( TESTFILE);
|
||||
}
|
||||
|
||||
void test_profile_string()
|
||||
{
|
||||
HANDLE h;
|
||||
int ret;
|
||||
DWORD count;
|
||||
char buf[100];
|
||||
char *p;
|
||||
/* test that lines without an '=' will not be enumerated */
|
||||
/* in the case below, name2 is a key while name3 is not. */
|
||||
char content[]="[s]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n";
|
||||
DeleteFileA( TESTFILE2);
|
||||
h = CreateFileA( TESTFILE2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", TESTFILE2);
|
||||
if( h == INVALID_HANDLE_VALUE) return;
|
||||
WriteFile( h, content, sizeof(content), &count, NULL);
|
||||
CloseHandle( h);
|
||||
/* enumerate the keys */
|
||||
ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),
|
||||
TESTFILE2);
|
||||
for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
|
||||
p[-1] = ',';
|
||||
/* and test */
|
||||
ok( !strcmp( buf, "name1,name2,name4"), "wrong keys returned: %s\n",
|
||||
buf);
|
||||
/* add a new key to test that the file is quite usable */
|
||||
WritePrivateProfileStringA( "s", "name5", "val5", TESTFILE2);
|
||||
ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),
|
||||
TESTFILE2);
|
||||
for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
|
||||
p[-1] = ',';
|
||||
ok( !strcmp( buf, "name1,name2,name4,name5"), "wrong keys returned: %s\n",
|
||||
buf);
|
||||
DeleteFileA( TESTFILE2);
|
||||
}
|
||||
|
||||
START_TEST(profile)
|
||||
{
|
||||
test_profile_int();
|
||||
test_profile_string();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue