Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
79694d42
Commit
79694d42
authored
Sep 27, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix WriteConsole signature
parent
51f2e2ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
include/fmt/format-inl.h
include/fmt/format-inl.h
+5
-4
test/format-impl-test.cc
test/format-impl-test.cc
+11
-1
No files found.
include/fmt/format-inl.h
View file @
79694d42
...
...
@@ -2824,12 +2824,13 @@ FMT_FUNC std::string detail::vformat(string_view format_str, format_args args) {
#ifdef _WIN32
namespace
detail
{
using
dword
=
conditional_t
<
sizeof
(
long
)
==
8
,
unsigned
,
unsigned
long
>
;
extern
"C"
int
__stdcall
WriteConsoleW
(
void
*
hConsoleOutput
,
const
void
*
lpBuffer
,
uint32_t
nNumberOfCharsToWrite
,
uint32_t
*
lpNumberOfCharsWritten
,
dword
nNumberOfCharsToWrite
,
dword
*
lpNumberOfCharsWritten
,
void
*
lpReserved
);
}
}
// namespace detail
#endif
FMT_FUNC
void
vprint
(
std
::
FILE
*
f
,
string_view
format_str
,
format_args
args
)
{
...
...
@@ -2840,7 +2841,7 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) {
auto
fd
=
_fileno
(
f
);
if
(
_isatty
(
fd
))
{
detail
::
utf8_to_utf16
u16
(
string_view
(
buffer
.
data
(),
buffer
.
size
()));
auto
written
=
uint32_t
();
auto
written
=
detail
::
dword
();
if
(
!
detail
::
WriteConsoleW
(
reinterpret_cast
<
void
*>
(
_get_osfhandle
(
fd
)),
u16
.
c_str
(),
static_cast
<
uint32_t
>
(
u16
.
size
()),
&
written
,
nullptr
))
{
...
...
test/format-impl-test.cc
View file @
79694d42
...
...
@@ -19,7 +19,10 @@
#include "gtest-extra.h"
#include "util.h"
#undef max
#ifdef _WIN32
# include <windows.h>
# undef max
#endif
using
fmt
::
detail
::
bigint
;
using
fmt
::
detail
::
fp
;
...
...
@@ -409,3 +412,10 @@ TEST(UtilTest, WriteFallbackUIntPtr) {
fmt
::
detail
::
fallback_uintptr
(
reinterpret_cast
<
void
*>
(
0xface
)),
nullptr
);
EXPECT_EQ
(
s
,
"0xface"
);
}
#ifdef _WIN32
TEST
(
UtilTest
,
WriteConsoleSignature
)
{
decltype
(
WriteConsoleW
)
*
p
=
fmt
::
detail
::
WriteConsoleW
;
(
void
)
p
;
}
#endif
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