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
615c1eef
Commit
615c1eef
authored
Nov 14, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error handling in fmt::fprintf.
parent
8ea9f068
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
format.cc
format.cc
+2
-1
test/printf-test.cc
test/printf-test.cc
+7
-0
No files found.
format.cc
View file @
615c1eef
...
...
@@ -1087,7 +1087,8 @@ void fmt::print_colored(Color c, StringRef format, ArgList args) {
int
fmt
::
fprintf
(
std
::
FILE
*
f
,
StringRef
format
,
ArgList
args
)
{
MemoryWriter
w
;
printf
(
w
,
format
,
args
);
return
std
::
fwrite
(
w
.
data
(),
1
,
w
.
size
(),
f
);
std
::
size_t
size
=
w
.
size
();
return
std
::
fwrite
(
w
.
data
(),
1
,
size
,
f
)
<
size
?
-
1
:
static_cast
<
int
>
(
size
);
}
// Explicit instantiations for char.
...
...
test/printf-test.cc
View file @
615c1eef
...
...
@@ -438,4 +438,11 @@ TEST(PrintfTest, Examples) {
EXPECT_WRITE
(
stdout
,
fmt
::
printf
(
"%1$s, %3$d %2$s"
,
weekday
,
month
,
day
),
"Thursday, 21 August"
);
}
TEST
(
PrintfTest
,
PrintfError
)
{
fmt
::
File
read_end
,
write_end
;
fmt
::
File
::
pipe
(
read_end
,
write_end
);
int
result
=
fmt
::
fprintf
(
read_end
.
fdopen
(
"r"
).
get
(),
"test"
);
EXPECT_LT
(
result
,
0
);
}
#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