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
79209598
Commit
79209598
authored
Jul 07, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core_format_specs -> sprintf_specs
parent
5488d0b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
36 deletions
+36
-36
include/fmt/format-inl.h
include/fmt/format-inl.h
+1
-1
include/fmt/format.h
include/fmt/format.h
+33
-33
src/format.cc
src/format.cc
+2
-2
No files found.
include/fmt/format-inl.h
View file @
79209598
...
@@ -754,7 +754,7 @@ FMT_API bool grisu_format(Double value, buffer<char>& buf, int precision,
...
@@ -754,7 +754,7 @@ FMT_API bool grisu_format(Double value, buffer<char>& buf, int precision,
template
<
typename
Double
>
template
<
typename
Double
>
char
*
sprintf_format
(
Double
value
,
internal
::
buffer
<
char
>&
buf
,
char
*
sprintf_format
(
Double
value
,
internal
::
buffer
<
char
>&
buf
,
core_format
_specs
specs
)
{
sprintf
_specs
specs
)
{
// Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail.
// Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail.
FMT_ASSERT
(
buf
.
capacity
()
!=
0
,
"empty buffer"
);
FMT_ASSERT
(
buf
.
capacity
()
!=
0
,
"empty buffer"
);
...
...
include/fmt/format.h
View file @
79209598
...
@@ -954,38 +954,6 @@ using format_specs = basic_format_specs<char>;
...
@@ -954,38 +954,6 @@ using format_specs = basic_format_specs<char>;
namespace
internal
{
namespace
internal
{
struct
core_format_specs
{
int
precision
;
char
type
;
bool
alt
:
1
;
template
<
typename
Char
>
constexpr
core_format_specs
(
basic_format_specs
<
Char
>
specs
)
:
precision
(
specs
.
precision
),
type
(
specs
.
type
),
alt
(
specs
.
alt
)
{}
constexpr
bool
has_precision
()
const
{
return
precision
>=
0
;
}
};
namespace
grisu_options
{
enum
{
fixed
=
1
,
grisu3
=
2
};
}
// Formats value using the Grisu algorithm:
// https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf
template
<
typename
Double
,
FMT_ENABLE_IF
(
sizeof
(
Double
)
==
sizeof
(
uint64_t
))>
FMT_API
bool
grisu_format
(
Double
,
buffer
<
char
>&
,
int
,
unsigned
,
int
&
);
template
<
typename
Double
,
FMT_ENABLE_IF
(
sizeof
(
Double
)
!=
sizeof
(
uint64_t
))>
inline
bool
grisu_format
(
Double
,
buffer
<
char
>&
,
int
,
unsigned
,
int
&
)
{
return
false
;
}
struct
gen_digits_params
{
int
num_digits
;
bool
fixed
;
bool
upper
;
bool
trailing_zeros
;
};
// Writes the exponent exp in the form "[+-]d{2,3}" to buffer.
// Writes the exponent exp in the form "[+-]d{2,3}" to buffer.
template
<
typename
Char
,
typename
It
>
It
write_exponent
(
int
exp
,
It
it
)
{
template
<
typename
Char
,
typename
It
>
It
write_exponent
(
int
exp
,
It
it
)
{
FMT_ASSERT
(
-
1000
<
exp
&&
exp
<
1000
,
"exponent out of range"
);
FMT_ASSERT
(
-
1000
<
exp
&&
exp
<
1000
,
"exponent out of range"
);
...
@@ -1009,6 +977,13 @@ template <typename Char, typename It> It write_exponent(int exp, It it) {
...
@@ -1009,6 +977,13 @@ template <typename Char, typename It> It write_exponent(int exp, It it) {
return
it
;
return
it
;
}
}
struct
gen_digits_params
{
int
num_digits
;
bool
fixed
;
bool
upper
;
bool
trailing_zeros
;
};
// The number is given as v = digits * pow(10, exp).
// The number is given as v = digits * pow(10, exp).
template
<
typename
Char
,
typename
It
>
template
<
typename
Char
,
typename
It
>
It
grisu_prettify
(
const
char
*
digits
,
int
size
,
int
exp
,
It
it
,
It
grisu_prettify
(
const
char
*
digits
,
int
size
,
int
exp
,
It
it
,
...
@@ -1072,8 +1047,33 @@ It grisu_prettify(const char* digits, int size, int exp, It it,
...
@@ -1072,8 +1047,33 @@ It grisu_prettify(const char* digits, int size, int exp, It it,
return
it
;
return
it
;
}
}
namespace
grisu_options
{
enum
{
fixed
=
1
,
grisu3
=
2
};
}
// Formats value using the Grisu algorithm:
// https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf
template
<
typename
Double
,
FMT_ENABLE_IF
(
sizeof
(
Double
)
==
sizeof
(
uint64_t
))>
FMT_API
bool
grisu_format
(
Double
,
buffer
<
char
>&
,
int
,
unsigned
,
int
&
);
template
<
typename
Double
,
FMT_ENABLE_IF
(
sizeof
(
Double
)
!=
sizeof
(
uint64_t
))>
inline
bool
grisu_format
(
Double
,
buffer
<
char
>&
,
int
,
unsigned
,
int
&
)
{
return
false
;
}
struct
sprintf_specs
{
int
precision
;
char
type
;
bool
alt
:
1
;
template
<
typename
Char
>
constexpr
sprintf_specs
(
basic_format_specs
<
Char
>
specs
)
:
precision
(
specs
.
precision
),
type
(
specs
.
type
),
alt
(
specs
.
alt
)
{}
constexpr
bool
has_precision
()
const
{
return
precision
>=
0
;
}
};
template
<
typename
Double
>
template
<
typename
Double
>
char
*
sprintf_format
(
Double
,
internal
::
buffer
<
char
>&
,
core_format
_specs
);
char
*
sprintf_format
(
Double
,
internal
::
buffer
<
char
>&
,
sprintf
_specs
);
template
<
typename
Handler
>
template
<
typename
Handler
>
FMT_CONSTEXPR
void
handle_int_type_spec
(
char
spec
,
Handler
&&
handler
)
{
FMT_CONSTEXPR
void
handle_int_type_spec
(
char
spec
,
Handler
&&
handler
)
{
...
...
src/format.cc
View file @
79209598
...
@@ -36,10 +36,10 @@ template FMT_API format_context::iterator internal::vformat_to(
...
@@ -36,10 +36,10 @@ template FMT_API format_context::iterator internal::vformat_to(
internal
::
buffer
<
char
>
&
,
string_view
,
basic_format_args
<
format_context
>);
internal
::
buffer
<
char
>
&
,
string_view
,
basic_format_args
<
format_context
>);
template
FMT_API
char
*
internal
::
sprintf_format
(
double
,
internal
::
buffer
<
char
>
&
,
template
FMT_API
char
*
internal
::
sprintf_format
(
double
,
internal
::
buffer
<
char
>
&
,
core_format
_specs
);
sprintf
_specs
);
template
FMT_API
char
*
internal
::
sprintf_format
(
long
double
,
template
FMT_API
char
*
internal
::
sprintf_format
(
long
double
,
internal
::
buffer
<
char
>
&
,
internal
::
buffer
<
char
>
&
,
core_format
_specs
);
sprintf
_specs
);
// Explicit instantiations for wchar_t.
// Explicit instantiations for wchar_t.
...
...
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