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
2ac0bfe5
Commit
2ac0bfe5
authored
Jun 03, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve handling of thousands separator
parent
024741b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
include/fmt/format-inl.h
include/fmt/format-inl.h
+3
-1
include/fmt/format.h
include/fmt/format.h
+3
-4
No files found.
include/fmt/format-inl.h
View file @
2ac0bfe5
...
...
@@ -106,7 +106,9 @@ template <typename Locale> Locale locale_ref::get() const {
template
<
typename
Char
>
FMT_FUNC
auto
thousands_sep_impl
(
locale_ref
loc
)
->
thousands_sep_result
<
Char
>
{
auto
&
facet
=
std
::
use_facet
<
std
::
numpunct
<
Char
>>
(
loc
.
get
<
std
::
locale
>
());
return
{
facet
.
grouping
(),
facet
.
thousands_sep
()};
auto
grouping
=
facet
.
grouping
();
auto
thousands_sep
=
grouping
.
empty
()
?
Char
()
:
facet
.
thousands_sep
();
return
{
std
::
move
(
grouping
),
thousands_sep
};
}
template
<
typename
Char
>
FMT_FUNC
Char
decimal_point_impl
(
locale_ref
loc
)
{
return
std
::
use_facet
<
std
::
numpunct
<
Char
>>
(
loc
.
get
<
std
::
locale
>
())
...
...
include/fmt/format.h
View file @
2ac0bfe5
...
...
@@ -1418,11 +1418,10 @@ auto write_int_localized(OutputIt& out, UInt value, unsigned prefix,
static_assert
(
std
::
is_same
<
uint64_or_128_t
<
UInt
>
,
UInt
>::
value
,
""
);
const
auto
sep_size
=
1
;
auto
ts
=
thousands_sep
<
Char
>
(
loc
);
const
std
::
string
&
groups
=
ts
.
grouping
;
Char
sep
=
ts
.
thousands_sep
;
if
(
!
sep
||
groups
.
empty
())
return
false
;
if
(
!
ts
.
thousands_sep
)
return
false
;
int
num_digits
=
count_digits
(
value
);
int
size
=
num_digits
,
n
=
num_digits
;
const
std
::
string
&
groups
=
ts
.
grouping
;
std
::
string
::
const_iterator
group
=
groups
.
cbegin
();
while
(
group
!=
groups
.
cend
()
&&
n
>
*
group
&&
*
group
>
0
&&
*
group
!=
max_value
<
char
>
())
{
...
...
@@ -1437,7 +1436,7 @@ auto write_int_localized(OutputIt& out, UInt value, unsigned prefix,
if
(
prefix
!=
0
)
++
size
;
const
auto
usize
=
to_unsigned
(
size
);
buffer
.
resize
(
usize
);
basic_string_view
<
Char
>
s
(
&
sep
,
sep_size
);
basic_string_view
<
Char
>
s
(
&
ts
.
thousands_
sep
,
sep_size
);
// Index of a decimal digit with the least significant digit having index 0.
int
digit_index
=
0
;
group
=
groups
.
cbegin
();
...
...
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