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
e4b2482e
Commit
e4b2482e
authored
Jun 21, 2020
by
Zebediah Figura
Committed by
Alexandre Julliard
Jun 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Simplify GetPrivateProfileStringW().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
22a6c60e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
80 deletions
+36
-80
profile.c
dlls/kernel32/profile.c
+36
-80
No files found.
dlls/kernel32/profile.c
View file @
e4b2482e
...
...
@@ -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
);
...
...
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