Commit Graph

716 Commits

Author SHA1 Message Date
Victor Zverovich
cbb4cb8991 Remove undocumented deprecated APIs 2020-05-02 21:34:44 -07:00
Victor Zverovich
d6abb2fa03 Reduce library size 2020-05-01 17:23:45 -07:00
Victor Zverovich
7ca89bf87a Reduce template bloat in write_int 2020-05-01 07:56:57 -07:00
Victor Zverovich
bca82719ab Pass iterator by value 2020-04-30 21:06:17 -07:00
Victor Zverovich
99da389627 Make write_padded non-members 2020-04-30 16:05:30 -07:00
Victor Zverovich
f19d667943 Bump fuzzer allocation limit 2020-04-30 08:45:50 -07:00
Victor Zverovich
3e69847616 Reduce branching in write_padded 2020-04-30 06:33:45 -07:00
Victor Zverovich
9ac1eebd47 Reduce library size 2020-04-29 17:37:05 -07:00
asraa
e2ff910675
Replace FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION with fmt-specific macro (#1650)
Signed-off-by: Asra Ali <asraa@google.com>
2020-04-29 09:12:43 -07:00
Victor Zverovich
9dde9f0131 Reduce library size 2020-04-27 20:43:30 -07:00
Victor Zverovich
b1af642d1d Reduce library size 2020-04-27 18:50:49 -07:00
Victor Zverovich
6f435f55c8 Improve compile time by using extern template (#1452) 2020-04-26 14:02:15 -07:00
Victor Zverovich
1e1ac6e964 Check dynamic width/precision id at compile time (#1614) 2020-04-25 08:36:24 -07:00
Victor Zverovich
e51c449fe6 Revert "Check dynamic widht/precision id at compile time (#1614)"
This reverts commit 7d748a6f82.
2020-04-25 07:43:56 -07:00
Victor Zverovich
7d748a6f82 Check dynamic widht/precision id at compile time (#1614) 2020-04-22 14:45:37 -07:00
Victor Zverovich
2b75bd7ce6 Get rid of do_check_format_string 2020-04-22 12:15:29 -07:00
Victor Zverovich
4a1d5931cb Simplify udl_formatter with FMT_STRING 2020-04-22 11:26:05 -07:00
Victor Zverovich
56bc86ffac Suppress bogus MSVC analysis warnings 2020-04-22 07:51:25 -07:00
Victor Zverovich
e253b371b2 Don't generate RTTI for allocator 2020-04-19 15:57:48 -07:00
Victor Zverovich
c9a57b9a81 Fix incorrect assumptions about nul termination 2020-04-18 06:51:52 -07:00
Victor Zverovich
f46f5ecaf0 Reenable constexpr _compile on GCC 9 2020-04-17 06:10:57 -07:00
Johan Norberg
84898b4626 Remove warning in format.h when compiling with gcc and -Wshadow
build/_deps/fmt-src/include/fmt/format.h: In member function ‘decltype (ctx.out()) fmt::v6::formatter<fmt::v6::bytes>::format(fmt::v6::bytes, FormatContext&)’:
build/_deps/fmt-src/include/fmt/format.h:3251:58: error: declaration of ‘writer’ shadows a global declaration [-Werror=shadow]
     internal::basic_writer<range_type> writer(range_type(ctx.out()));
                                                          ^~~
build/_deps/fmt-src/include/fmt/format.h:2741:53: note: shadowed declaration is here
 using writer FMT_DEPRECATED_ALIAS = internal::writer;
2020-04-15 07:31:24 -07:00
Victor Zverovich
8a4630686e Improve handling of named arguments 2020-04-14 11:56:55 -07:00
Victor Zverovich
e30d8391e4 Suppress an MSVC warning (#1622) 2020-04-11 07:49:00 -07:00
Victor Zverovich
8cd8ef03eb Simplify warning suppression 2020-04-11 06:17:31 -07:00
Victor Zverovich
bbb6b357c7 Add floating-point L specifier (#1624) 2020-04-10 07:16:20 -07:00
Victor Zverovich
d1d653d895 Implement the L specifier 2020-04-02 06:58:38 -07:00
Victor Zverovich
1a62711d01 Reduce binary size 2020-03-31 08:07:11 -07:00
Victor Zverovich
2864e8432a Update readme and add compatibility option 2020-03-26 07:18:27 -07:00
Victor Zverovich
96c68afe69 Fix -Wsign-conversion warnings 2020-03-25 07:46:00 -07:00
Scott Ramsby
664dd88e31 Enable FMT_STRING() use with types other than string literals 2020-03-24 12:56:21 -07:00
Victor Zverovich
69779b4ed6 Fix handling of small precision in general format 2020-03-24 09:01:57 -07:00
Victor Zverovich
2951169481 Move FMT_USE_FLOAT and friends to fmt/format.h 2020-03-20 07:55:43 -07:00
Alberto Aguirre
d3e668418f
Allow disabling floating point support (#1590)
* Allow disabling floating point support

Add FMT_USE_FLOAT, FMT_USE_DOUBLE and FMT_USE_LONG_DOUBLE to allow a
user of the library to configure the float types they want to allow.
This is specially useful in embedded environements where code size is
important.

* Avoid conditional macros to disable float support

* Add is_supported_floating_point constexpr function

* Fix empty-body warning
2020-03-20 06:46:31 -07:00
Vladimir Solontsov
6012dc9ab4
Dynamic arguments storage. Implementation of enhancement from issue #1170. (#1584) 2020-03-16 07:00:29 -07:00
Victor Zverovich
ff486a72a7 Allow leading zeros in precision (#1579) 2020-03-14 11:37:38 -07:00
Victor Zverovich
678341275b Deprecate fmt::char8_t 2020-03-14 10:32:34 -07:00
Dair Grant
02bfd8a9a5 Add FMT_HAS_CPP14_ATTRIBUTE / FMT_HAS_CPP17_ATTRIBUTE to test for language-specific attributes.
FMT_DEPRECATED is now defined as FMT_HAS_CPP14_ATTRIBUTE(deprecated), as this attribute was introduced in C++14.

FMT_FALLTHROUGH is now defined as FMT_HAS_CPP17_ATTRIBUTE(fallthrough), as this attribute was introduced in C++17.

FMT_MAYBE_UNUSED is defined as FMT_HAS_CPP17_ATTRIBUTE(maybe_unused), as this attribute was introduced in C++17.

FMT_MAYBE_UNUSED has been applied to fix a couple of -Wunused-member-function warnings from clang.
2020-03-13 09:03:52 -07:00
Victor Zverovich
941d5e147a Workaround broken fallthrough attribute in the PGI compiler (#1583) 2020-03-11 07:56:23 -07:00
Dair Grant
29a1ea795a Fix clang -Wdisabled-macro-expansion warning from FMT_STRING_IMPL.
FMT_STRING_IMPL has an internal helper named FMT_STRING, however FMT_STRING is also the name of the macro that invokes FMT_STRING_IMPL.

Renaming this helper avoids the appearance of a recursive macro.
2020-03-06 07:00:47 -08:00
Victor Zverovich
153f753bde Deprecate undocumented _u suffix 2020-03-04 19:20:19 -08:00
Victor Zverovich
eafd079868 Improve width computation 2020-03-04 17:17:34 -08:00
Victor Zverovich
1e8493196e Make compile-time checks in format_to handle references 2020-03-01 07:57:34 -08:00
refnum
75a4525e5f
Move FMT_CLANG_VERSION definition to core.h (#1568)
Previously format.h defined FMT_CLANG_VERSION after including core.h, however core.h tests FMT_CLANG_VERSION when it defines FMT_API.
2020-02-29 17:19:34 -08:00
fghzxm
2161a73f2b
Fix FMT_FORMAT_AS const specifier position (#1554)
The current `FMT_FORMAT_AS` macro will make `formatter<Char *>::format`
have the first argument type `const Char *&` which is incorrect an
should be `Char *const &`.  This pull request fixes that by changing the
first argument type in the macro definition body from `const Type &` to
`Type const &`.
2020-02-23 07:27:22 -08:00
IkarusDeveloper
e00997b004
improved use of find (#1560)
* improved use of find

*begin is supposed to be different from '{' when this find is used, so we can avoid checking it.
2020-02-21 14:43:06 -08:00
Victor Zverovich
3bafd0749b Fix to_string docs 2020-02-15 09:51:35 +01:00
Victor Zverovich
dc22360c34 Workaround broken UDL templates in GCC < 6.4 2020-02-10 17:08:14 +01:00
Victor Zverovich
24924128e3 Fix a link error in gcc8 (#1548) 2020-02-07 18:34:05 -08:00
Victor Zverovich
09a13244c8 Disallow passing non-string-literals to FMT_STRING 2020-01-22 21:05:46 -08:00
Victor Zverovich
419db8baa1 Fix length computation of constexpr C strings 2020-01-22 18:25:07 -08:00
Victor Zverovich
fd1cabe464 Workaround a bogus MSVC warning 2020-01-20 06:56:22 -08:00
Victor Zverovich
b4218aa0f8 Test invalid fill 2020-01-19 16:52:36 -08:00
Victor Zverovich
e5f2f8ce7a Add variable-width fill support (#1109) 2020-01-19 14:49:51 -08:00
Victor Zverovich
1f110702a1 Remove redundant braces 2020-01-15 15:07:30 -08:00
Victor Zverovich
c8dd9cc99d Use type_identity to block unnecessary template argument deduction (thanks Tim Song) 2020-01-15 10:27:50 -08:00
Greg Sjaardema
ae3ea156ea Fix for older versions of intel compiler
The intel-17 and intel-18 compilers seem to require that `u` be `const`:
```
/src/fmt/format.h(226): warning #437: reference to local variable of enclosing function is not allowed
        char data[sizeof(u)];
```
If `u` is declared as `const auto u =1u` instead of just `auto u=1u`, the file compiles with no warnings.
2020-01-14 17:56:06 -08:00
Tobias Hammer
77165fdf85 Use FMT_NOEXCEPT instead of noexcept directly
Otherwise breaks on compilers without noexcept support
2020-01-14 09:31:31 -08:00
Victor Zverovich
65ac626c58 Improve join docs 2020-01-12 07:26:16 -08:00
torsten
cd0b3f9695 check if _SECURE_SCL is defined not equal to 0 2020-01-09 15:01:48 -08:00
Victor Zverovich
9e3f3e8cff Fix handling of output iterators in format_to_n (#1506) 2020-01-05 09:59:01 -10:00
Victor Zverovich
b3fd0005dd Suppress a bogus -Wdouble-promotion warning 2020-01-03 06:57:14 -10:00
Victor Zverovich
c85efef312 More showpoint fixes and tests (#1498) 2019-12-30 13:08:35 -10:00
Victor Zverovich
f219dcd59b Add fmt::bytes 2019-12-24 10:45:15 -08:00
Victor Zverovich
dea7fde8b7 Deprecate u8string_view 2019-12-24 09:44:57 -08:00
Victor Zverovich
74532c23a3 Make type a scoped enum 2019-12-21 12:22:17 -08:00
Victor Zverovich
8b41362a0a Add trailing decimal point if # is specified (#1476) 2019-12-18 12:41:56 -08:00
Victor Zverovich
1b1c70108a trailing_zeros -> showpoint 2019-12-18 12:12:09 -08:00
Victor Zverovich
d7e72a09e0 Simplify FMT_STRING_IMPL 2019-12-18 11:50:47 -08:00
Victor Zverovich
2201890d7a Apply clang-format and update inclusion guards 2019-12-18 11:17:36 -08:00
Greg Sjaardema
6100ed4bb3 Eliminate NVCC NVidia compiler emits unreachable code warnings
Similar to the MSC Compiler, the NVidia NVCC compiler also
emits unreachable code warnings when there is a return
statement following an exception.  These changes eliminate
those warnings.
2019-12-18 10:39:40 -08:00
Victor Zverovich
35959a31d7 Move OS-specific APIs to a separate header 2019-12-15 11:46:45 -08:00
Victor Zverovich
ec2463c905 Implement utf8_to_utf16 using utf8_decode 2019-12-15 09:35:26 -08:00
Victor Zverovich
9e450911fa Give an error on precision overflow 2019-12-14 07:45:27 -08:00
Victor Zverovich
068d20bc31 Avoid shadowing warnings in FMT_STRING 2019-12-14 07:00:08 -08:00
iPherian
8ab1c5c6e8 Squelch MSVC warning exporting subclasses of runtime_error (fix for PR #1433) (#1470)
* Squelch MSVC warning exporting subclasses of runtime_error

When compiling {fmt} as a DLL, MSVC complains that we are exporting
classes that inherit from "std::runtime_error", which we are not
exporting.

In this case, it's not really a problem because that symbol is already
exported via the C++ stdlib. So we just add a pragma to silence the
warning.

* Fix compilation with MinGW

Commit 3bc28fcc6b ("Squelch MSVC warning exporting subclasses of
runtime_error", 2019-11-29) silenced a MSVC warning under. The MinGW
compiler also defines _WIN32, but does not support the "warning" pragma.

Introduce a helper macro to squelch the MSVC warning only when using the
Microsoft compiler.

Signed-off-by: Beat Bolli <dev@drbeat.li>

* Fix compilation with VS2015 (#1450)

VS2015 does not support the __pragma(...) syntax in the midst of a
class declaration, so move it to just before the declaration.
2019-12-13 12:16:36 -08:00
Ivan Shynkarenka
598e6042d1 warning C4468: 'fallthrough': attribute must be followed by a case label or a default label 2019-12-12 06:25:33 -08:00
Federico
b272fb3605 Extend FMT_FALLTHROUGH compatibily to gcc and clang pre-C++17 (#1469) 2019-12-11 14:28:20 -08:00
Florin Iucha
72879db40e Clean-up sign-conversion warnings in public headers 2019-12-08 16:07:55 -08:00
Victor Zverovich
f443bd3baf Ditch decimal_formatter (#1363) 2019-12-05 19:07:45 -08:00
Victor Zverovich
1219b65f21 Relax fallthrough attribute detection 2019-12-05 10:40:15 -08:00
Victor Zverovich
8bbe76af3a Add a missing decimal point in exponent notation with trailing zeros 2019-12-02 11:36:33 -08:00
Victor Zverovich
4b120b68ae Clean up includes 2019-12-01 10:19:07 -08:00
Victor Zverovich
62da1db62a Avoid wchar_t instantiations 2019-12-01 07:34:09 -08:00
Victor Zverovich
ba6e330fd3 digits -> num_bits 2019-11-30 08:41:07 -08:00
Victor Zverovich
fafb03fa6d Fix handling of fallback_uintptr 2019-11-30 07:31:38 -08:00
Victor Zverovich
2f9acd1838 Remove dependency on <cassert> 2019-11-29 09:37:18 -08:00
Victor Zverovich
aaf829bfb1 Fix fallback pointer formatting on big endian, take 2 2019-11-29 07:07:08 -08:00
Victor Zverovich
bb205d940d Fix fallback pointer formatting on big endian 2019-11-29 05:15:59 -08:00
Florin Iucha
9cbf4b087c Fix -Wconversion warnings 2019-11-28 06:43:08 -08:00
Victor Zverovich
c3be0f593d Refactor floating-point formatting 2019-11-27 08:08:22 -08:00
Victor Zverovich
c68703c9f4 float_spec -> float_specs 2019-11-26 15:53:24 -08:00
Victor Zverovich
9a21728b0a Remove gen_digits_params 2019-11-26 11:27:53 -08:00
Victor Zverovich
28d7191c27 Don't print trailing zero with fixed, precision=0, and showpoint (#1417) 2019-11-24 08:23:10 -08:00
Victor Zverovich
4cf59ce734 Integrate Grisu and sprintf digit generators 2019-11-23 06:56:29 -08:00
Victor Zverovich
7395472dde Refactor floating-point formatting 2019-11-22 18:49:19 -08:00
Victor Zverovich
ded1e7679e Refactor floating point formatting 2019-11-22 08:22:22 -08:00
Victor Zverovich
c7edd8e570 Cleanup FP formatting 2019-11-20 13:17:03 -08:00
Victor Zverovich
75108a56f6 Don't print % for nan and inf 2019-11-20 12:26:48 -08:00
Victor Zverovich
3e1f70fe02 Merge write_fp into write 2019-11-20 12:20:17 -08:00
Victor Zverovich
4de41aa655 Move basic_writer::write_fp to where it belongs 2019-11-20 08:22:34 -08:00
Victor Zverovich
404a880bd4 Make parse_arg_id more readable 2019-11-20 08:12:23 -08:00
Victor Zverovich
093e554211 Remove redundant qualification 2019-11-20 07:44:34 -08:00
Ivan Shynkarenka
d0696b0aa6 warning C4456: declaration of 'num_digits' hides previous local declaration 2019-11-20 06:43:46 -08:00
Victor Zverovich
66d7746bb3 Use grisu for exponent notation 2019-11-19 16:55:11 -08:00
Victor Zverovich
e9bff78814 Don't parse % unless FMT_DEPRECATED_PERCENT is set 2019-11-19 11:54:18 -08:00
Victor Zverovich
57b6f2966d Deprecate the fmt macro 2019-11-19 11:28:17 -08:00
Victor Zverovich
d79493e5ee Remove Grisu2 2019-11-19 09:50:59 -08:00
Victor Zverovich
5420bcce2d Make % an opt-in to improve compatibility with std::format 2019-11-18 08:04:43 -08:00
Victor Zverovich
56a2e2075c Refactor float spec parsing 2019-11-18 07:37:36 -08:00
Victor Zverovich
ed117baa4f Replace bool with float_format and add exponential 2019-11-17 15:52:13 -08:00
Victor Zverovich
f26446290b Move float_spec_handler to internal namespace and update asserts 2019-11-17 13:47:00 -08:00
Victor Zverovich
f67783d7e6 Clarify that numeric alignment is deprecated 2019-11-17 10:24:55 -08:00
Rosen Penev
6868f888b2 [clang-tidy] Add missing override
Found with hicpp-use-override

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
Rosen Penev
87cd545a1e [clang-tidy] Replace {} with = default
Found with hicpp-use-equals-default

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
Rosen Penev
12f9437e22 [clang-tidy] Use auto
Found with hicpp-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
Rosen Penev
bb0c8bfea8 [clang-tidy] Add noexcept where move is used
Found with performance-noexcept-move-constructor

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
Rosen Penev
a1fb5c7337 [clang-tidy] Changes suffixes to uppercase
Found with hicpp-uppercase-literal-suffix

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
daniel
f1559e1d56 Use grouping() from locale for specifier 'n' 2019-11-05 07:22:12 +00:00
Victor Zverovich
ffd05e65ed basic_parse_context -> basic_format_parse_context per standard and document 2019-11-05 07:13:58 +00:00
Attila Tajti
0889856d61 Fix UTF-8 truncation 2019-11-03 11:53:15 +00:00
Victor Zverovich
d6eede9e08 Remove redundant ctor 2019-11-01 12:09:04 -07:00
Victor Zverovich
213e09644f Workaround X11 madness (#1388) 2019-11-01 08:47:11 -07:00
Victor Zverovich
3487f1b9cd Always inline grisu_gen_digits and disable grisu2 by default 2019-10-30 16:52:00 -07:00
Victor Zverovich
8e700619b7 Simplify format_handler 2019-10-30 07:02:38 -07:00
Victor Zverovich
58c6f8c7f5 Make unsigned-integer-overflow sanitizer happy (#1377) 2019-10-28 14:41:09 -07:00
Victor Zverovich
40414b3446 Don't emit trailing zeros in exponential notation (#1376) 2019-10-28 12:31:00 -07:00
Victor Zverovich
b7a157401e Simplify grisu_writer 2019-10-23 13:52:09 -07:00
Victor Zverovich
ce4d87acd4 Remove obsolete comment and clang-format 2019-10-23 11:15:43 -07:00
Ivan Shynkarenka
21acc2af43 Fix more Visual Studio 2019 pedantic warnings (#1371)
* format-inl.h(444,1): warning C4804: '>>': unsafe use of type 'bool' in operation
format.h(2808,1): warning C4127: conditional expression is constant

* More fixes for VS2019 pedantic warnings

* Fix "conditional expression is constant" VS2019 warning in more specific way

* Use const_check to silence constexpr warning
2019-10-22 17:13:03 -07:00
Victor Zverovich
d39ebf3ff2 Optimize counting 2019-10-21 06:57:42 -07:00
Victor Zverovich
6498bc6d31 Simplify grisu_writer 2019-10-20 19:29:24 -07:00
Victor Zverovich
a967dcbe20 Improve handling of signs 2019-10-20 19:05:38 -07:00
Victor Zverovich
8498bc97dd Initialize all the things 2019-10-20 17:53:18 -07:00
Victor Zverovich
36d1390e67 Implement round half to even 2019-10-18 07:21:12 -07:00
Orivej Desh
599e0aef45 Support single precision floats in grisu formatting
Fixes #1336
2019-10-18 07:08:41 -07:00
Victor Zverovich
1cbc5fa6cb Handle negative exponent and rename value/pow10 to numerator/denominator 2019-10-13 12:50:48 -07:00
Victor Zverovich
0e94b931a2 Fix a linkage error introduced by #1360 (#1362) 2019-10-13 08:23:47 -07:00
Orivej Desh
3a15ea3ea5 Rename write_double to write_fp
It handles all floating point types, not just doubles.
2019-10-12 11:41:24 -07:00
Orivej Desh
b87ac4d840 Distinguish float from double 2019-10-12 11:41:24 -07:00
Deniz Evrenci
96f91428c6 Add defaulted copy and move operations to format_error and system_error (#1347)
* Avoid weak vtables by providing a private virtual member function

* Add warning Wweak-vtables to clang when FMT_PEDANTIC is on

* Add defaulted copy and move operations to format_error and system_error

Compiler generated copy operations are deprecated and move operations
are not generated altogether.

* Add warning Wdeprecated to clang when FMT_PEDANTIC is on
2019-10-11 10:44:20 -07:00
Victor Zverovich
758446c80d Fix a warning (#1319) and simplify code 2019-09-19 16:00:40 -07:00
Victor Zverovich
c85ae23c73 Add max_value 2019-09-08 09:21:30 -07:00
Victor Zverovich
56b5c192a0 Add a bigint stub and reenable grisu 2019-09-07 13:50:22 -07:00
Victor Zverovich
3d9f3c163b Integrate new format string compilation 2019-09-07 07:01:51 -07:00
gabime
df4dcf2ece Fixed vs 2015 warning about unused variable when grisu is off 2019-09-06 11:29:56 -07:00
Victor Zverovich
f7a4b4ab91 Make numeric alignment optional 2019-09-06 09:43:53 -07:00
Victor Zverovich
611cf0b3c6 Format octal 0 as 0 2019-09-06 07:03:47 -07:00
Victor Zverovich
1882b9687b Reduce the numer of ifdefs with an empty (u)int128_t fallback 2019-09-05 18:03:47 -07:00
Deniz Evrenci
6de0454b42 Add support for built-in __int128 when available 2019-09-04 07:05:08 -07:00