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
2d727e7d
Commit
2d727e7d
authored
Oct 28, 2015
by
vitaut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Suppress bogus coverity warnings
parent
522e0e83
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
format.cc
format.cc
+4
-3
format.h
format.h
+2
-1
test/gtest-extra-test.cc
test/gtest-extra-test.cc
+2
-1
No files found.
format.cc
View file @
2d727e7d
...
...
@@ -444,19 +444,20 @@ class BasicArgFormatter : public ArgVisitor<Impl, void> {
typedef
typename
BasicWriter
<
Char
>::
CharPtr
CharPtr
;
Char
fill
=
internal
::
CharTraits
<
Char
>::
cast
(
spec_
.
fill
());
CharPtr
out
=
CharPtr
();
enum
{
CHAR_WIDTH
=
1
}
;
const
int
CHAR_WIDTH
=
1
;
if
(
spec_
.
width_
>
CHAR_WIDTH
)
{
out
=
writer_
.
grow_buffer
(
spec_
.
width_
);
if
(
spec_
.
align_
==
ALIGN_RIGHT
)
{
std
::
fill_n
(
out
,
spec_
.
width_
-
CHAR_WIDTH
,
fill
);
out
+=
spec_
.
width_
-
CHAR_WIDTH
;
}
else
if
(
spec_
.
align_
==
ALIGN_CENTER
)
{
out
=
writer_
.
fill_padding
(
out
,
spec_
.
width_
,
CHAR_WIDTH
,
fill
);
out
=
writer_
.
fill_padding
(
out
,
spec_
.
width_
,
internal
::
check
(
CHAR_WIDTH
),
fill
);
}
else
{
std
::
fill_n
(
out
+
CHAR_WIDTH
,
spec_
.
width_
-
CHAR_WIDTH
,
fill
);
}
}
else
{
out
=
writer_
.
grow_buffer
(
1
);
out
=
writer_
.
grow_buffer
(
CHAR_WIDTH
);
}
*
out
=
internal
::
CharTraits
<
Char
>::
cast
(
value
);
}
...
...
format.h
View file @
2d727e7d
...
...
@@ -921,7 +921,8 @@ struct Conditional<false, T, F> { typedef F type; };
// A helper function to suppress bogus "conditional expression is constant"
// warnings.
inline
bool
check
(
bool
value
)
{
return
value
;
}
template
<
typename
T
>
inline
T
check
(
T
value
)
{
return
value
;
}
// Makes an Arg object from any type.
template
<
typename
Char
>
...
...
test/gtest-extra-test.cc
View file @
2d727e7d
...
...
@@ -42,6 +42,7 @@ using testing::internal::scoped_ptr;
namespace
{
// This is used to suppress coverity warnings about untrusted values.
std
::
string
sanitize
(
const
std
::
string
&
s
)
{
std
::
string
result
;
for
(
std
::
string
::
const_iterator
i
=
s
.
begin
(),
end
=
s
.
end
();
i
!=
end
;
++
i
)
...
...
@@ -385,7 +386,7 @@ TEST(OutputRedirectTest, RestoreAndRead) {
OutputRedirect
redir
(
file
.
get
());
std
::
fprintf
(
file
.
get
(),
"censored"
);
EXPECT_EQ
(
"censored"
,
sanitize
(
redir
.
restore_and_read
()));
EXPECT_EQ
(
""
,
redir
.
restore_and_read
(
));
EXPECT_EQ
(
""
,
sanitize
(
redir
.
restore_and_read
()
));
std
::
fprintf
(
file
.
get
(),
"]]]"
);
file
=
BufferedFile
();
EXPECT_READ
(
read_end
,
"[[[]]]"
);
...
...
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