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
081d25d4
Commit
081d25d4
authored
Aug 05, 2020
by
Piotr Caban
Committed by
Alexandre Julliard
Aug 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Use correct code page in _write when outputing to console.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e0555a74
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
5 deletions
+70
-5
file.c
dlls/msvcrt/file.c
+70
-5
No files found.
dlls/msvcrt/file.c
View file @
081d25d4
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "windef.h"
#include "windef.h"
#include "winbase.h"
#include "winbase.h"
#include "wincon.h"
#include "winternl.h"
#include "winternl.h"
#include "winnls.h"
#include "winnls.h"
#include "msvcrt.h"
#include "msvcrt.h"
...
@@ -3446,6 +3447,7 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
...
@@ -3446,6 +3447,7 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
ioinfo
*
info
=
get_ioinfo
(
fd
);
ioinfo
*
info
=
get_ioinfo
(
fd
);
HANDLE
hand
=
info
->
handle
;
HANDLE
hand
=
info
->
handle
;
DWORD
num_written
,
i
;
DWORD
num_written
,
i
;
BOOL
console
;
if
(
hand
==
INVALID_HANDLE_VALUE
||
fd
==
MSVCRT_NO_CONSOLE_FD
)
if
(
hand
==
INVALID_HANDLE_VALUE
||
fd
==
MSVCRT_NO_CONSOLE_FD
)
{
{
...
@@ -3480,13 +3482,65 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
...
@@ -3480,13 +3482,65 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
return
num_written
;
return
num_written
;
}
}
console
=
MSVCRT__isatty
(
fd
);
for
(
i
=
0
;
i
<
count
;)
for
(
i
=
0
;
i
<
count
;)
{
{
const
char
*
s
=
buf
;
const
char
*
s
=
buf
;
char
lfbuf
[
2048
];
char
lfbuf
[
2048
];
DWORD
j
;
DWORD
j
=
0
;
if
(
!
(
info
->
exflag
&
(
EF_UTF8
|
EF_UTF16
)))
if
(
!
(
info
->
exflag
&
(
EF_UTF8
|
EF_UTF16
))
&&
console
)
{
char
conv
[
sizeof
(
lfbuf
)];
MSVCRT_size_t
len
=
0
;
#if _MSVCR_VER >= 90
if
(
info
->
dbcsBufferUsed
)
{
conv
[
j
++
]
=
info
->
dbcsBuffer
;
info
->
dbcsBufferUsed
=
FALSE
;
conv
[
j
++
]
=
s
[
i
++
];
len
++
;
}
#endif
for
(;
i
<
count
&&
j
<
sizeof
(
conv
)
-
1
;
i
++
,
j
++
,
len
++
)
{
if
(
MSVCRT_isleadbyte
((
unsigned
char
)
s
[
i
]))
{
conv
[
j
++
]
=
s
[
i
++
];
if
(
i
==
count
)
{
#if _MSVCR_VER >= 90
info
->
dbcsBuffer
=
conv
[
j
-
1
];
info
->
dbcsBufferUsed
=
TRUE
;
break
;
#else
*
MSVCRT__errno
()
=
MSVCRT_EINVAL
;
release_ioinfo
(
info
);
return
-
1
;
#endif
}
}
else
if
(
s
[
i
]
==
'\n'
)
{
conv
[
j
++
]
=
'\r'
;
len
++
;
}
conv
[
j
]
=
s
[
i
];
}
len
=
MSVCRT_mbstowcs
((
WCHAR
*
)
lfbuf
,
conv
,
len
);
if
(
len
==
-
1
)
{
msvcrt_set_errno
(
GetLastError
());
release_ioinfo
(
info
);
return
-
1
;
}
j
=
len
*
2
;
}
else
if
(
!
(
info
->
exflag
&
(
EF_UTF8
|
EF_UTF16
)))
{
{
for
(
j
=
0
;
i
<
count
&&
j
<
sizeof
(
lfbuf
)
-
1
;
i
++
,
j
++
)
for
(
j
=
0
;
i
<
count
&&
j
<
sizeof
(
lfbuf
)
-
1
;
i
++
,
j
++
)
{
{
...
@@ -3495,7 +3549,7 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
...
@@ -3495,7 +3549,7 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
lfbuf
[
j
]
=
s
[
i
];
lfbuf
[
j
]
=
s
[
i
];
}
}
}
}
else
if
(
info
->
exflag
&
EF_UTF16
)
else
if
(
info
->
exflag
&
EF_UTF16
||
console
)
{
{
for
(
j
=
0
;
i
<
count
&&
j
<
sizeof
(
lfbuf
)
-
3
;
i
++
,
j
++
)
for
(
j
=
0
;
i
<
count
&&
j
<
sizeof
(
lfbuf
)
-
3
;
i
++
,
j
++
)
{
{
...
@@ -3532,9 +3586,20 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
...
@@ -3532,9 +3586,20 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
}
}
}
}
if
(
!
WriteFile
(
hand
,
lfbuf
,
j
,
&
num_written
,
NULL
)
||
num_written
!=
j
)
if
(
console
)
{
{
TRACE
(
"WriteFile (fd %d, hand %p) failed-last error (%d)
\n
"
,
fd
,
j
=
j
/
2
;
if
(
!
WriteConsoleW
(
hand
,
lfbuf
,
j
,
&
num_written
,
NULL
))
num_written
=
-
1
;
}
else
if
(
!
WriteFile
(
hand
,
lfbuf
,
j
,
&
num_written
,
NULL
))
{
num_written
=
-
1
;
}
if
(
num_written
!=
j
)
{
TRACE
(
"WriteFile/WriteConsoleW (fd %d, hand %p) failed-last error (%d)
\n
"
,
fd
,
hand
,
GetLastError
());
hand
,
GetLastError
());
msvcrt_set_errno
(
GetLastError
());
msvcrt_set_errno
(
GetLastError
());
release_ioinfo
(
info
);
release_ioinfo
(
info
);
...
...
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