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
e7f9b562
Commit
e7f9b562
authored
Apr 03, 2017
by
Piotr Caban
Committed by
Alexandre Julliard
Apr 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Fix wide characters handling in wscanf functions.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a392e142
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
scanf.h
dlls/msvcrt/scanf.h
+8
-8
scanf.c
dlls/msvcrt/tests/scanf.c
+11
-1
No files found.
dlls/msvcrt/scanf.h
View file @
e7f9b562
...
...
@@ -68,11 +68,11 @@
#undef _EOF_
#define _EOF_ 0
#ifdef STRING_LEN
#ifdef WIDE_
CHAR
#ifdef WIDE_
SCANF
#define _GETC_(file) (consumed==length ? '\0' : (consumed++, *file++))
#else
/* WIDE_
CHAR
*/
#else
/* WIDE_
SCANF
*/
#define _GETC_(file) (consumed==length ? '\0' : (consumed++, (unsigned char)*file++))
#endif
/* WIDE_
CHAR
*/
#endif
/* WIDE_
SCANF
*/
#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
#define _LOCK_FILE_(file) do {} while(0)
#define _UNLOCK_FILE_(file) do {} while(0)
...
...
@@ -90,11 +90,11 @@
#endif
/* SECURE */
#endif
/* WIDE_SCANF */
#else
/* STRING_LEN */
#ifdef WIDE_
CHAR
#ifdef WIDE_
SCANF
#define _GETC_(file) (consumed++, *file++)
#else
/* WIDE_
CHAR
*/
#else
/* WIDE_
SCANF
*/
#define _GETC_(file) (consumed++, (unsigned char)*file++)
#endif
/* WIDE_
CHAR
*/
#endif
/* WIDE_
SCANF
*/
#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
#define _LOCK_FILE_(file) do {} while(0)
#define _UNLOCK_FILE_(file) do {} while(0)
...
...
@@ -685,7 +685,7 @@ _FUNCTION_ {
* use %%." */
while
((
nch
!=
_EOF_
)
&&
_ISSPACE_
(
nch
))
nch
=
_GETC_
(
file
);
if
(
nch
==
*
format
)
{
if
(
(
_CHAR_
)
nch
==
*
format
)
{
suppress
=
1
;
/* whoops no field to be read */
st
=
1
;
/* but we got what we expected */
nch
=
_GETC_
(
file
);
...
...
@@ -699,7 +699,7 @@ _FUNCTION_ {
* a matching non-white-space character. */
else
{
/* check for character match */
if
(
nch
==
(
unsigned
char
)
*
format
)
{
if
(
(
_CHAR_
)
nch
==
*
format
)
{
nch
=
_GETC_
(
file
);
}
else
break
;
}
...
...
dlls/msvcrt/tests/scanf.c
View file @
e7f9b562
...
...
@@ -252,7 +252,7 @@ static void test_sscanf( void )
ok
(
!
strcmp
(
buffer
,
"test"
),
"buf %s
\n
"
,
buffer
);
ok
(
!
strcmp
(
buffer1
,
"value
\xda
"
),
"buf %s
\n
"
,
buffer1
);
ret
=
sscanf
(
"
\x81
test"
,
"
\x81
%s"
,
buffer
);
ret
=
sscanf
(
"
\x81
\x82
test"
,
"
\x81
%
\x82
%s"
,
buffer
);
ok
(
ret
==
1
,
"got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
buffer
,
"test"
),
"buf = %s
\n
"
,
buffer
);
}
...
...
@@ -303,6 +303,8 @@ static void test_swscanf( void )
wchar_t
buffer
[
100
];
int
result
,
ret
;
static
const
WCHAR
formatd
[]
=
{
'%'
,
'd'
,
0
};
const
WCHAR
format2
[]
=
{
'a'
,
0x1234
,
'%'
,
0x1234
,
'%'
,
'c'
,
0
};
WCHAR
c
;
/* check WEOF */
/* WEOF is an unsigned short -1 but swscanf returns int
...
...
@@ -312,6 +314,14 @@ static void test_swscanf( void )
/* msvcrt returns 0 but should return -1 (later versions do) */
ok
(
ret
==
(
short
)
WEOF
||
broken
(
ret
==
0
),
"swscanf returns %x instead of %x
\n
"
,
ret
,
WEOF
);
buffer
[
0
]
=
'a'
;
buffer
[
1
]
=
0x1234
;
buffer
[
2
]
=
0x1234
;
buffer
[
3
]
=
'b'
;
ret
=
swscanf
(
buffer
,
format2
,
&
c
);
ok
(
ret
==
1
,
"swscanf returned %d
\n
"
,
ret
);
ok
(
c
==
'b'
,
"c = %x
\n
"
,
c
);
}
START_TEST
(
scanf
)
...
...
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