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
eddb84cf
Commit
eddb84cf
authored
Jun 03, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting of exotic characters
parent
7e42c65b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
include/fmt/core.h
include/fmt/core.h
+1
-1
include/fmt/format.h
include/fmt/format.h
+4
-3
test/format-test.cc
test/format-test.cc
+18
-0
No files found.
include/fmt/core.h
View file @
eddb84cf
...
...
@@ -771,7 +771,7 @@ FMT_MAKE_VALUE(uint_type, unsigned char, unsigned)
template
<
typename
C
,
typename
Char
,
FMT_ENABLE_IF
(
std
::
is_same
<
typename
C
::
char_type
,
Char
>
::
value
)
>
FMT_CONSTEXPR
init
<
C
,
int
,
char_type
>
make_value
(
Char
val
)
{
return
val
;
return
{
val
}
;
}
template
<
typename
C
,
...
...
include/fmt/format.h
View file @
eddb84cf
...
...
@@ -2025,7 +2025,7 @@ template <typename Char, typename Handler>
FMT_CONSTEXPR
const
Char
*
parse_precision
(
const
Char
*
begin
,
const
Char
*
end
,
Handler
&&
handler
)
{
++
begin
;
auto
c
=
begin
!=
end
?
*
begin
:
0
;
auto
c
=
begin
!=
end
?
*
begin
:
Char
()
;
if
(
'0'
<=
c
&&
c
<=
'9'
)
{
handler
.
on_precision
(
parse_nonnegative_int
(
begin
,
end
,
handler
));
}
else
if
(
c
==
'{'
)
{
...
...
@@ -2763,8 +2763,9 @@ template <typename Range> class basic_writer {
auto
&&
it
=
reserve
(
1
);
*
it
++
=
value
;
}
void
write
(
wchar_t
value
)
{
static_assert
(
std
::
is_same
<
char_type
,
wchar_t
>::
value
,
""
);
template
<
typename
Char
,
FMT_ENABLE_IF
(
std
::
is_same
<
Char
,
char_type
>
::
value
)
>
void
write
(
Char
value
)
{
auto
&&
it
=
reserve
(
1
);
*
it
++
=
value
;
}
...
...
test/format-test.cc
View file @
eddb84cf
...
...
@@ -2492,3 +2492,21 @@ TEST(FormatTest, CharTraitsIsNotAmbiguous) {
(
void
)
lval
;
#endif
}
struct
mychar
{
int
value
;
mychar
()
=
default
;
mychar
(
char
val
)
:
value
(
val
)
{}
operator
int
()
const
{
return
value
;
}
};
FMT_BEGIN_NAMESPACE
template
<
>
struct
is_char
<
mychar
>
:
std
::
true_type
{};
FMT_END_NAMESPACE
TEST
(
FormatTest
,
FormatCustomChar
)
{
const
mychar
format
[]
=
{
'{'
,
'}'
,
0
};
auto
result
=
fmt
::
format
(
format
,
mychar
(
'x'
));
EXPECT_EQ
(
result
.
size
(),
1
);
EXPECT_EQ
(
result
[
0
],
mychar
(
'x'
));
}
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