Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
08bf605a
Commit
08bf605a
authored
Feb 09, 2020
by
Akihiro Sagawa
Committed by
Alexandre Julliard
Feb 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Fix wsprintfA %S conversion.
Signed-off-by:
Akihiro Sagawa
<
sagawa.aki@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e375f0d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
wsprintf.c
dlls/user32/tests/wsprintf.c
+6
-10
wsprintf.c
dlls/user32/wsprintf.c
+25
-6
No files found.
dlls/user32/tests/wsprintf.c
View file @
08bf605a
...
...
@@ -61,16 +61,14 @@ static void wsprintfATest(void)
const
char
*
fmt
;
const
char
*
str
;
int
rc
;
BOOL
todo_rc
;
BOOL
todo_str
;
}
testcase
[]
=
{
{
starW
,
"%.1S"
,
partial
,
1
,
TRUE
,
TRUE
},
{
starW
,
"%.2S"
,
star
,
2
,
FALSE
,
TRUE
},
{
starW
,
"%.3S"
,
star
,
2
,
FALSE
,
TRUE
},
{
fffeW
,
"%.1S"
,
"?"
,
1
,
FALSE
,
TRUE
},
{
fffeW
,
"%.2S"
,
"?"
,
1
,
FALSE
,
TRUE
},
{
wineW
,
"%.2S"
,
"??"
,
2
,
FALSE
,
TRUE
},
{
starW
,
"%.1S"
,
partial
,
1
},
{
starW
,
"%.2S"
,
star
,
2
},
{
starW
,
"%.3S"
,
star
,
2
},
{
fffeW
,
"%.1S"
,
"?"
,
1
},
{
fffeW
,
"%.2S"
,
"?"
,
1
},
{
wineW
,
"%.2S"
,
"??"
,
2
},
{
star
,
"%.1s"
,
partial
,
1
},
};
CPINFO
cpinfo
;
...
...
@@ -110,12 +108,10 @@ static void wsprintfATest(void)
memset
(
buf
,
0x11
,
sizeof
(
buf
));
rc
=
wsprintfA
(
buf
,
testcase
[
i
].
fmt
,
testcase
[
i
].
input
);
todo_wine_if
(
testcase
[
i
].
todo_rc
)
ok
(
rc
==
testcase
[
i
].
rc
,
"%u: expected %d, got %d
\n
"
,
i
,
testcase
[
i
].
rc
,
rc
);
todo_wine_if
(
testcase
[
i
].
todo_str
)
ok
(
!
strcmp
(
buf
,
testcase
[
i
].
str
),
"%u: expected %s, got %s
\n
"
,
i
,
wine_dbgstr_a
(
testcase
[
i
].
str
),
wine_dbgstr_an
(
buf
,
rc
));
...
...
dlls/user32/wsprintf.c
View file @
08bf605a
...
...
@@ -30,6 +30,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "wine/debug.h"
...
...
@@ -245,7 +246,7 @@ static INT WPRINTF_ParseFormatW( LPCWSTR format, WPRINTF_FORMAT *res )
* WPRINTF_GetLen
*/
static
UINT
WPRINTF_GetLen
(
WPRINTF_FORMAT
*
format
,
WPRINTF_DATA
*
arg
,
LPSTR
number
,
UINT
maxlen
)
LPSTR
number
,
UINT
maxlen
,
BOOL
dst_is_wide
)
{
UINT
len
;
...
...
@@ -264,8 +265,18 @@ static UINT WPRINTF_GetLen( WPRINTF_FORMAT *format, WPRINTF_DATA *arg,
return
(
format
->
precision
=
len
);
case
WPR_WSTRING
:
if
(
!
arg
->
lpcwstr_view
)
arg
->
lpcwstr_view
=
null_stringW
;
for
(
len
=
0
;
!
format
->
precision
||
(
len
<
format
->
precision
);
len
++
)
if
(
!*
(
arg
->
lpcwstr_view
+
len
))
break
;
if
(
dst_is_wide
)
{
for
(
len
=
0
;
!
format
->
precision
||
(
len
<
format
->
precision
);
len
++
)
if
(
!*
(
arg
->
lpcwstr_view
+
len
))
break
;
}
else
{
LPCWSTR
p
=
arg
->
lpcwstr_view
;
for
(
len
=
0
;
(
!
format
->
precision
||
len
<
format
->
precision
)
&&
*
p
;
p
++
)
len
+=
WideCharToMultiByte
(
CP_ACP
,
0
,
p
,
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
format
->
precision
&&
len
>
format
->
precision
)
len
=
format
->
precision
;
}
if
(
len
>
maxlen
)
len
=
maxlen
;
return
(
format
->
precision
=
len
);
case
WPR_SIGNED
:
...
...
@@ -354,7 +365,7 @@ static INT wvsnprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec, __ms_va_list arg
break
;
}
len
=
WPRINTF_GetLen
(
&
format
,
&
argData
,
number
,
maxlen
-
1
);
len
=
WPRINTF_GetLen
(
&
format
,
&
argData
,
number
,
maxlen
-
1
,
FALSE
);
sign
=
0
;
if
(
!
(
format
.
flags
&
WPRINTF_LEFTALIGN
))
for
(
i
=
format
.
precision
;
i
<
format
.
width
;
i
++
,
maxlen
--
)
...
...
@@ -374,7 +385,15 @@ static INT wvsnprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec, __ms_va_list arg
case
WPR_WSTRING
:
{
LPCWSTR
ptr
=
argData
.
lpcwstr_view
;
for
(
i
=
0
;
i
<
len
;
i
++
)
*
p
++
=
(
CHAR
)
*
ptr
++
;
for
(
i
=
0
;
i
<
len
;
ptr
++
)
{
CHAR
mb
[
5
];
/* 5 is MB_LEN_MAX */
int
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
ptr
,
1
,
mb
,
sizeof
(
mb
),
NULL
,
NULL
);
i
+=
ret
;
if
(
i
>
len
)
ret
=
len
-
(
p
-
buffer
);
memcpy
(
p
,
mb
,
ret
);
p
+=
ret
;
}
}
break
;
case
WPR_HEXA
:
...
...
@@ -459,7 +478,7 @@ static INT wvsnprintfW( LPWSTR buffer, UINT maxlen, LPCWSTR spec, __ms_va_list a
break
;
}
len
=
WPRINTF_GetLen
(
&
format
,
&
argData
,
number
,
maxlen
-
1
);
len
=
WPRINTF_GetLen
(
&
format
,
&
argData
,
number
,
maxlen
-
1
,
TRUE
);
sign
=
0
;
if
(
!
(
format
.
flags
&
WPRINTF_LEFTALIGN
))
for
(
i
=
format
.
precision
;
i
<
format
.
width
;
i
++
,
maxlen
--
)
...
...
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