Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8cbf08b5
Commit
8cbf08b5
authored
Aug 10, 2005
by
Richard Cohen
Committed by
Alexandre Julliard
Aug 10, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Fix regression in GetPrivateProfileString16 for key=NULL.
- Check return values in Profile tests.
parent
628939d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
19 deletions
+21
-19
profile.c
dlls/kernel/profile.c
+14
-14
profile.c
dlls/kernel/tests/profile.c
+7
-5
No files found.
dlls/kernel/profile.c
View file @
8cbf08b5
...
...
@@ -832,7 +832,7 @@ static BOOL PROFILE_Open( LPCWSTR filename )
* If return_values is TRUE, also include the corresponding values.
*/
static
INT
PROFILE_GetSection
(
PROFILESECTION
*
section
,
LPCWSTR
section_name
,
LPWSTR
buffer
,
UINT
len
,
BOOL
return_values
)
LPWSTR
buffer
,
UINT
len
,
BOOL
return_values
,
BOOL
return_noequalkeys
)
{
PROFILEKEY
*
key
;
...
...
@@ -850,7 +850,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
(
!
return_values
&&
!
key
->
value
)
continue
;
/* Skip lines w.o. '=' */
if
(
!
return_
noequalkeys
&&
!
return_
values
&&
!
key
->
value
)
continue
;
/* Skip lines w.o. '=' */
PROFILE_CopyEntry
(
buffer
,
key
->
name
,
len
-
1
,
0
);
len
-=
strlenW
(
buffer
)
+
1
;
buffer
+=
strlenW
(
buffer
)
+
1
;
...
...
@@ -947,7 +947,7 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len )
*
*/
static
INT
PROFILE_GetString
(
LPCWSTR
section
,
LPCWSTR
key_name
,
LPCWSTR
def_val
,
LPWSTR
buffer
,
UINT
len
)
LPCWSTR
def_val
,
LPWSTR
buffer
,
UINT
len
,
BOOL
win32
)
{
PROFILEKEY
*
key
=
NULL
;
static
const
WCHAR
empty_strW
[]
=
{
0
};
...
...
@@ -973,7 +973,7 @@ static INT PROFILE_GetString( LPCWSTR section, LPCWSTR key_name,
/* no "else" here ! */
if
(
section
&&
section
[
0
])
{
INT
ret
=
PROFILE_GetSection
(
CurProfile
->
section
,
section
,
buffer
,
len
,
FALSE
);
INT
ret
=
PROFILE_GetSection
(
CurProfile
->
section
,
section
,
buffer
,
len
,
FALSE
,
!
win32
);
if
(
!
buffer
[
0
])
/* no luck -> def_val */
{
PROFILE_CopyEntry
(
buffer
,
def_val
,
len
,
TRUE
);
...
...
@@ -1060,15 +1060,15 @@ UINT WINAPI GetProfileIntW( LPCWSTR section, LPCWSTR entry, INT def_val )
}
/*
* if
allow_section_name_copy is TRUE, allow the copying
:
* -
of
Section names if 'section' is NULL
* -
of
Keys in a Section if 'entry' is NULL
* if
win32, copy
:
* - Section names if 'section' is NULL
* - Keys in a Section if 'entry' is NULL
* (see MSDN doc for GetPrivateProfileString)
*/
static
int
PROFILE_GetPrivateProfileString
(
LPCWSTR
section
,
LPCWSTR
entry
,
LPCWSTR
def_val
,
LPWSTR
buffer
,
UINT
len
,
LPCWSTR
filename
,
BOOL
allow_section_name_copy
)
BOOL
win32
)
{
int
ret
;
LPCWSTR
pDefVal
=
NULL
;
...
...
@@ -1102,16 +1102,16 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
}
}
if
(
!
pDefVal
)
pDefVal
=
(
LPCWSTR
)
def_val
;
pDefVal
=
def_val
;
RtlEnterCriticalSection
(
&
PROFILE_CritSect
);
if
(
PROFILE_Open
(
filename
))
{
if
(
(
allow_section_name_copy
)
&&
(
section
==
NULL
))
if
(
win32
&&
(
section
==
NULL
))
ret
=
PROFILE_GetSectionNames
(
buffer
,
len
);
else
/* PROFILE_GetString
already handles
the 'entry == NULL' case */
ret
=
PROFILE_GetString
(
section
,
entry
,
pDefVal
,
buffer
,
len
);
else
/* PROFILE_GetString
can handle
the 'entry == NULL' case */
ret
=
PROFILE_GetString
(
section
,
entry
,
pDefVal
,
buffer
,
len
,
win32
);
}
else
{
lstrcpynW
(
buffer
,
pDefVal
,
len
);
ret
=
strlenW
(
buffer
);
...
...
@@ -1334,7 +1334,7 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer,
RtlEnterCriticalSection
(
&
PROFILE_CritSect
);
if
(
PROFILE_Open
(
filename
))
ret
=
PROFILE_GetSection
(
CurProfile
->
section
,
section
,
buffer
,
len
,
TRUE
);
ret
=
PROFILE_GetSection
(
CurProfile
->
section
,
section
,
buffer
,
len
,
TRUE
,
FALSE
);
RtlLeaveCriticalSection
(
&
PROFILE_CritSect
);
...
...
dlls/kernel/tests/profile.c
View file @
8cbf08b5
...
...
@@ -106,21 +106,22 @@ static void test_profile_string(void)
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
"
,
ok
(
ret
==
18
&&
!
strcmp
(
buf
,
"name1,name2,name4"
),
"wrong keys returned(%d): %s
\n
"
,
ret
,
buf
);
ret
=
GetPrivateProfileSectionA
(
"s"
,
buf
,
sizeof
(
buf
),
TESTFILE2
);
for
(
p
=
buf
+
strlen
(
buf
)
+
1
;
*
p
;
p
+=
strlen
(
p
)
+
1
)
p
[
-
1
]
=
','
;
/* and test */
ok
(
!
strcmp
(
buf
,
"name1=val1,name2=,name3,name4=val4"
),
"wrong section returned
: %s
\n
"
,
buf
);
ok
(
ret
==
35
&&
!
strcmp
(
buf
,
"name1=val1,name2=,name3,name4=val4"
),
"wrong section returned(%d)
: %s
\n
"
,
ret
,
buf
);
/* add a new key to test that the file is quite usable */
WritePrivateProfileStringA
(
"s"
,
"name5"
,
"val5"
,
TESTFILE2
);
...
...
@@ -128,8 +129,9 @@ static void test_profile_string(void)
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
);
ok
(
ret
==
24
&&
!
strcmp
(
buf
,
"name1,name2,name4,name5"
),
"wrong keys returned(%d): %s
\n
"
,
ret
,
buf
);
DeleteFileA
(
TESTFILE2
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment