Commit Graph

1102 Commits

Author SHA1 Message Date
Victor Zverovich
e5422db4b2 Fix handling of uintptr_t 2019-06-12 08:16:41 -07:00
stryku
9427f15bef Fixed issue with formatting to an array of chars 2019-06-11 18:09:18 -07:00
Victor Zverovich
87fbc6f756 get_type -> mapped_type_constant 2019-06-11 07:23:39 -07:00
Victor Zverovich
a291f07e1a Clean up argument mapping 2019-06-09 22:27:40 -07:00
Victor Zverovich
4faadff0a0 Add preliminary user-defined type support 2019-06-08 09:04:46 -07:00
Victor Zverovich
cb4c59495e Deprecate convert_to_int 2019-06-07 13:38:08 -07:00
Victor Zverovich
40779749ac is_formattable -> has_formatter 2019-06-07 06:51:21 -07:00
Victor Zverovich
b3cf8613b1 Make formatter specializations override implicit conversions 2019-06-07 06:25:46 -07:00
Victor Zverovich
3fdba04924 Reduce the number of nontrivial formatter instantiations 2019-06-06 22:02:53 -07:00
Victor Zverovich
d2ee5f2407 Merge tests 2019-06-04 21:31:23 -07:00
Victor Zverovich
eddb84cfc0 Fix formatting of exotic characters 2019-06-03 17:08:00 -07:00
Victor Zverovich
d54e64b3c8 Make buffer_context an alias template 2019-06-02 18:28:49 -07:00
Victor Zverovich
ec6651087d Remove old is_constructible workarounds and replace typedefs with using 2019-06-02 16:46:45 -07:00
Victor Zverovich
af2c73772c Implement parsing of string_views 2019-06-02 11:11:28 -07:00
Victor Zverovich
9df0e2d1f1 Implement string parsing 2019-06-02 07:39:38 -07:00
Victor Zverovich
78daa50ffc Fix handling of chrono durations with minimal signed rep 2019-06-01 09:36:37 -07:00
Victor Zverovich
87e4ea2906 Fix a warning 2019-06-01 08:24:36 -07:00
Victor Zverovich
49f78a427b Demacrify 2019-05-30 21:30:29 -07:00
Victor Zverovich
8302c2f33b fmt::internal::declval -> std::declval 2019-05-30 09:46:10 -07:00
Victor Zverovich
d07cc2026b FMT_EXPLICIT -> explicit, FMT_NULL -> nullptr 2019-05-30 07:42:36 -07:00
Victor Zverovich
30bce6c14c Fix a few chrono formatting corner cases (#1178) 2019-05-29 18:02:26 -07:00
Victor Zverovich
afc571aedc Document join and relax its compiler requirements 2019-05-29 11:21:05 -07:00
Victor Zverovich
bb254d146b Disable std-format-test by default 2019-05-27 20:02:08 -07:00
Victor Zverovich
01c631af95 Implement unsigned and long long parsing 2019-05-19 07:34:54 -07:00
Victor Zverovich
4fcd4a4bd0 Reuse parse_format_string in scan 2019-05-18 14:18:06 -07:00
Victor Zverovich
91bb3aaf06 fmtlib.net -> fmt.dev 2019-05-17 15:42:00 -07:00
Victor Zverovich
ef6282fc45 Fix gcc 4.4 build 2019-05-15 22:37:00 -07:00
Victor Zverovich
67179dbc23 Remove deprecated format_decimal 2019-05-15 10:34:38 -07:00
Victor Zverovich
a5ffa735db Fix gcc 4.4 build 2019-05-15 10:20:51 -07:00
Victor Zverovich
5ee0804631 Experiment with scan API 2019-05-15 10:02:40 -07:00
Victor Zverovich
25b72fc4cd Move <format> to tests not to confuse users 2019-05-15 09:08:42 -07:00
denchat
f4dfd6e30f Suppress all clang-target-msvc test warning in CMake and other misc fixes (#1151)
* Fix conditional `char8_t` from `format.h` and fix `-Wunused-result` of [[no_discard]] begin() when in c++17

* Suppress `-Winconsistent-dllimport` when in clang-target-msvc

* Suppress warning _CRT_SECURE_NO_WARNINGS in MSVC and -Wdeprecated-declarations

Suppress warning _CRT_SECURE_NO_WARNINGS in MSVC and -Wdeprecated-declarations of POSIX functions in Clang target MSVC.
Those functions are used by gtest.

* Remove FMT_FUNC, mark FMT_API to export
2019-05-11 11:48:27 -07:00
Victor Zverovich
de5da50910 Fix formatting of extreme durations (#1154) 2019-05-11 08:42:02 -07:00
Victor Zverovich
ea2976e6d5 Move internal::uintptr_t test to format-impl-test (#1152) 2019-05-11 06:58:22 -07:00
Alex Alabuzhev
77d6036cd5 Fix unexpected trailing decimal point (#1153) 2019-05-11 06:34:47 -07:00
Victor Zverovich
e9bab6d028 Improve handling of large durations 2019-05-08 12:40:33 -07:00
denchat
3fd134be03 Move test_count_digits to format-impl-test and disable gtest warnings (#1147)
* This translation unit includes `gtest.h` in which using something like `strncpy`

Suppress MSVC warnings from `gtest.h` included.

Warning sample:
fmt-master\test\gtest\gtest.h(2873,10): warning: 'strncpy' is deprecated: This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]

* Moving `test_count_digits` to format-impl-test then count_digits<4>(internal::uintptr_t) shall not be exported

* retaining _CRT_SECURE_NO_WARNINGS always defined should be no harms.
2019-05-07 12:09:11 -07:00
Victor Zverovich
ca978b3d21 Fix handling of nan durations 2019-05-05 08:53:23 -07:00
Victor Zverovich
c1d430e61a Improve handling of negative durations 2019-05-04 17:52:20 -07:00
Victor Zverovich
38a85502ed Use the same rep type for seconds to prevent overflow 2019-05-04 09:22:09 -07:00
Paul Dreik
b3cc9c0567 Merge remote-tracking branch 'upstream/master' into invalidcolons
# Conflicts:
#	test/chrono-test.cc
2019-04-28 21:35:21 +02:00
Paul Dreik
2e3352fd05 provoke assertion
fmt/include/fmt/core.h:246:
typename std::make_unsigned<_Tp>::type fmt::v5::internal::to_unsigned(Int)
[with Int = long int;
 typename std::make_unsigned<_Tp>::type = long unsigned int]:
Assertion `(value >= 0) && "negative value"' failed.
2019-04-28 21:34:09 +02:00
Victor Zverovich
4c721e3a2f Fix chrono formatting with invalid argument id (#1132) 2019-04-28 07:08:41 -07:00
Victor Zverovich
8d8ea21c69 Partially implement Grisu3 2019-04-27 12:17:21 -07:00
Victor Zverovich
40a7975640 Remove trailing zeros 2019-04-27 07:42:27 -07:00
Victor Zverovich
cb46397dfb Fix typo 2019-04-27 07:13:35 -07:00
Victor Zverovich
134904c886 Re-enabled constexpr tests 2019-04-26 17:07:37 -07:00
Victor Zverovich
bd516e3429 Convert negative precision to zero in printf (#1127)
and remove redundant check in grisu2_prettify.
2019-04-21 07:44:04 -07:00
Victor Zverovich
5efb24dd2b Add specialization test 2019-04-19 17:15:46 -07:00
Victor Zverovich
946498cfbc Fix handling of zero precision 2019-04-19 15:10:12 -07:00
HE, Tao
6b20863918 fmt::ptr: support unique_ptr and shared_ptr. 2019-04-18 10:12:11 -07:00
Victor Zverovich
d306585a3f Don't inject internal names into std (#1120) 2019-04-17 13:25:31 -07:00
Victor Zverovich
dc94010fa5 Remove char_traits (#1117) 2019-04-16 17:08:24 -07:00
Victor Zverovich
397e8dd9d5 clang-format 2019-04-15 11:39:19 -07:00
ToolsDevler
2b415b7af7 Restructure printf_arg_formatter to make it customizable 2019-04-15 11:10:31 -07:00
Victor Zverovich
5d755d0a4e Fix handling of volatile char (#1115) 2019-04-14 12:34:56 -07:00
Victor Zverovich
41fbaeb3b1 Add <format> test 2019-04-13 11:37:52 -07:00
Victor Zverovich
8bc0adb9ba Get rid of obsolete cmake stuff 2019-04-13 11:37:52 -07:00
Bruce Mitchener
aeb5ad3ce1 Enable [[noreturn]] some. 2019-04-08 07:53:59 -07:00
Victor Zverovich
2808395481 basic_buffer -> buffer
This reduces symbol sizes and gets rid of shadowing warnings.
2019-04-07 20:32:28 -07:00
Victor Zverovich
07d5a86a7c Fix warnings 2019-04-06 22:10:10 -07:00
Victor Zverovich
f10a7e2e46 Test exotic pointer formatting 2019-04-06 09:04:44 -07:00
Victor Zverovich
bd8177177a Add support for platforms without uintptr_t 2019-04-06 08:11:03 -07:00
Victor Zverovich
018d8b57f6 Remove broken snprintf 2019-03-30 20:27:52 -07:00
Victor Zverovich
da0ea4161a Make compile-time checks work with fallback formatter (#1088) 2019-03-21 19:26:53 -07:00
mwinterb
7ad3015f5b Added missing typename to FMT_STRING. (#1089)
* Added missing typename to FMT_STRING.

This is so that FMT_STRING can be used in a template.
2019-03-20 20:37:00 -07:00
Victor Zverovich
294fd7df96 Remove isinf workaround 2019-03-17 14:49:19 -07:00
Victor Zverovich
76d326a2a2 Enable grisu for general format 2019-03-17 09:48:50 -07:00
Victor Zverovich
97619e27a2 More fixed precision tests 2019-03-15 10:20:20 -07:00
Victor Zverovich
dd6cc0e6ac Merge time-test into chrono-test 2019-03-14 18:10:56 -07:00
Victor Zverovich
a939c75956 Merge fmt/time.h into fmt/chrono.h 2019-03-14 18:07:42 -07:00
Victor Zverovich
a82b3680dc More tests and fixed precision fixes 2019-03-13 19:47:07 -07:00
Victor Zverovich
e28429ee73 Prevent overflow with zero precision 2019-03-13 10:46:25 -07:00
Victor Zverovich
1632f72cbe Test get_round_direction 2019-03-10 11:14:50 -07:00
Victor Zverovich
8129b9bc46 Test that the library can be compiled witout locales 2019-03-10 07:57:29 -07:00
Victor Zverovich
835087dd04 Add color-test 2019-03-10 07:57:29 -07:00
Victor Zverovich
8407f4cb24 Round close to zero fixed precision 2019-03-09 15:18:34 -08:00
Victor Zverovich
49d244c065 Don't emit more than precision digits (#1072) 2019-03-09 13:53:23 -08:00
Michael Winterberg
d8434baa03 Declare the size of RESET_COLOR.
This is so that the format with a text_tyle will compile even if
header-only mode isn't enabled. Addresses #1063.
2019-03-06 09:41:45 -10:00
Victor Zverovich
2e526a664a Fix handling of output iterator in ranges 2019-03-06 08:10:46 -08:00
gawain
79b79f329e Add support for '%' type to output floating point values as a
percentage.

This helps with compatibility with Python's format strings.
2019-03-05 17:36:20 -08:00
Alexander Bolz
287eaab3b2 Increment output iterator in basic_writer::write for character types (#1056) 2019-02-26 12:16:34 -10:00
Victor Zverovich
a97757736b Use grisu for fixed precision 2019-02-23 15:50:50 -10:00
Victor Zverovich
8af651be39 Implement fixed precision 2019-02-22 10:47:27 -10:00
Victor Zverovich
ed138d794a test: assert-test: fix typo in else-branch of EXPECT_DEBUG_DEATH_IF_SUPPORTED
Patch by Ievgen Liubymkin (jackyf).
2019-02-18 14:02:02 -10:00
Victor Zverovich
442fa1bd46 Decouple format and parse contexts 2019-02-09 20:39:37 -08:00
Victor Zverovich
744e66bb08 Deprecate format_context::parse_context() 2019-02-09 16:15:20 -08:00
Daniela Engert
01f34d0b0b Fix library deprecation warning
Since C++17, using template specialization 'std::allocator<void>' in any shape or form (even just mentioning it) is deprecated! A simple workaround is replacing 'void' by another (preferably empty) type, e.g. 'fmt::monostate'.

Found by Clang 9 in Visual Studio.
2019-02-07 12:20:46 -08:00
morinmorin
9a0a24f90b Test is_streamable with overloaded comma operators 2019-02-06 15:44:59 -08:00
Victor Zverovich
5a314a5288 Eliminate extra copy on floating-point formatting 2019-02-06 10:17:50 -08:00
Elias Kosunen
22de5a755f Fix warnings from Travis 2019-02-03 15:25:09 -08:00
Victor Zverovich
355eb6d29a Enable grisu for shortest roundtrip (default) formatting 2019-02-03 10:38:28 -08:00
Victor Zverovich
b8d34e0db3 Fix rounding 2019-02-02 09:19:46 -08:00
Elias Kosunen
7fbbfed8c6 Fix warnings caused by usage of deprecated functionality 2019-02-02 05:48:39 -08:00
Elias Kosunen
c3268f4e50 Remove use cases of deprecated functionality 2019-02-02 05:48:39 -08:00
Victor Zverovich
5289dd600b Test formatting of special numbers 2019-01-30 06:56:46 -08:00
Daniela Engert
0700612249 Implement 'chrono' formatting specifiers '%Q' and '%q'
Howard Hinnant's 'date' library recently gained these two new formatting specifiers. This implementation in {fmt} includes support for 'std::chrono::duration' specializations with floating-point representation types and user-definable precision.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-27 11:10:08 -08:00
Victor Zverovich
06c005b7b0 Clarify that compile-time checks don't support named arguments 2019-01-27 10:10:13 -08:00
Victor Zverovich
4f6fda558c Add a grisu test stub 2019-01-27 10:10:13 -08:00
Daniela Engert
9f70b034e1 Implement precision for floating-point durations.
The formatting syntax follows p1361r0, augmented by a precision field as proposed in #1004.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-23 07:17:00 -08:00
Victor Zverovich
5f1ceebc7f Make formatter<T> override ostream<< for templates (#952) 2019-01-21 09:42:55 -08:00
Victor Zverovich
83f052930a Add code from p0645 2019-01-20 15:12:01 -08:00
Victor Zverovich
fdd8e333c1 Fix compilation with locales disabled (#1011) 2019-01-19 07:16:05 -08:00
Daniela Engert
b0cde860ae Implement 'snprintf(OutputIt it, size_t n, const S &format, const Args & ... args)' (#917)
Mostly equivalent to 'sprintf(const S &format, const Args & ... args)' but generates at most 'n' characters through output iterator 'it'. The output type is the same as with 'format_to_n'.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-13 13:08:01 -05:00
Daniela Engert
e05dfb0887 Fix compile errors due to name-hiding and an unused function argument.
These problems are pointed out by clang-tidy and fail compilation on msvc at /W4 /WX.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-13 12:18:05 -05:00
Victor Zverovich
58b6f8db48 Format the code using clang-format 2019-01-13 06:58:20 -08:00
stryku
9a777b9e1c Implemented fmt::prepare()
Implementation of fmt::prepare() function and features around it.
2019-01-12 10:53:31 -08:00
Victor Zverovich
dc8f8ce4c0 Fix handling of dynamic width in chrono formatter
Thanks to Howard Hinnant.
2019-01-09 15:23:21 -08:00
Michael Winterberg
39623a7400 Replaced usage of gtest's internal scoped_ptr with unique_ptr.
scoped_ptr was removed in with gtest google/googletest@e857f9cdd9.
2019-01-02 19:05:51 -05:00
Denis Blank
ae1de3a8d3 Add support for using text_style in format and vformat directly (#993)
* Closes #993
2019-01-01 09:26:54 -05:00
Sign Bit
0bbdca5b8b Fix conversion warnings (#989)
* Fix sign conversion warnings

* Ignore unused local typedefs

* Remove cast reported as useless on GCC

* Remove warning on unused variable

* Enable conversion warning checking for pedantic build

* Fix sign-conversion warnings in headers
2018-12-20 06:24:19 -08:00
Victor Zverovich
77a7244804 Implement fill/align/width for strftime-like formatting 2018-12-19 07:03:02 -08:00
Victor Zverovich
3e01376e08 Implement fill/align/width parsing in chrono formatter 2018-12-16 09:08:11 -08:00
Victor Zverovich
8668639ae2 Get rid of null_terminating_iterator in format 2018-12-15 06:17:25 -08:00
Nicolas
93fd473b8f Add support for builtin terminal colors. (#974) 2018-12-15 06:16:00 -08:00
Victor Zverovich
b180b39152 Fix default formatting 2018-12-12 06:39:47 -08:00
Nicolas
24594c747e Disable printing the reset escape code when no style modifiers where applied. (#973) 2018-12-09 15:57:20 -08:00
Victor Zverovich
b0f2224719 Implement default chrono formatting 2018-12-09 15:56:15 -08:00
Nicolas
749276072f Add file stream support for stylized text printing. (#967) 2018-12-09 09:28:48 -08:00
Victor Zverovich
f54f3d0fb7 Move chrono-specific code to a separate header 2018-12-09 06:45:20 -08:00
Victor Zverovich
bf1f1c73e3 Fix time test 2018-12-07 08:19:13 -08:00
Victor Zverovich
acfa95d4a8 Workaround a bug in MSVC's strftime (#965) 2018-12-07 07:07:21 -08:00
Victor Zverovich
628f830583 More chrono formatting 2018-12-07 06:36:08 -08:00
Victor Zverovich
aa3b5aba41 Implement locale-specific minute formatting 2018-12-06 16:12:10 -08:00
Victor Zverovich
639de21757 Workaround more MSVC bugs 2018-12-06 12:16:04 -08:00
Victor Zverovich
bd1104046b Workaround a bug in MSVC 2018-12-06 08:16:01 -08:00
Nicolas
81b5c4a5fd Add experimental emphasis support (#961) 2018-12-06 07:56:01 -08:00
Victor Zverovich
b31680990e Fix a warning 2018-12-05 09:49:39 -08:00
Victor Zverovich
68214bd904 More time formatting 2018-11-30 20:12:01 -08:00
Victor Zverovich
322b2594e0 Implement more time specifiers 2018-11-30 09:25:18 -08:00
Victor Zverovich
f5fe849238 Specialize formatter for chrono durations 2018-11-28 11:39:21 -08:00
tnovotny
e37d6a9840 add make_printf_args and make_wprintf_args functions (#934)
* add make_printf_args and make_wprintf_args to printf.h
add minimal test for make_printf_args and make_wprintf_args to printf-test.cc

renamed the old printf_context template to basic_printf_context_t. the original wish was to rename it basic_printf_context, but that clashed with the name of the inner typedef. this style matches the format_context_t struct.
2018-11-22 13:57:07 -08:00
Victor Zverovich
982ee5c699 parse_context -> format_parse_context 2018-11-21 07:10:22 -08:00
Victor Zverovich
00a8cc8325 Fix formatting 2018-11-20 07:43:40 -08:00
Andreas Schönle
bd6121596f Disable fmt-impl-test in windows + shared lib. 2018-11-20 07:01:21 -08:00
Victor Zverovich
19e008876b More locale support 2018-11-14 16:25:49 -08:00
Victor Zverovich
f2ee988105 Improve locale support 2018-11-14 12:07:39 -08:00
Victor Zverovich
1385050e26 More formatter tests 2018-11-08 16:26:55 -08:00
Victor Zverovich
03c1b110a5 Fix gcc 4.4 build 2018-11-08 12:41:55 -08:00
Victor Zverovich
cc805c6162 Test enabled formatters 2018-11-08 10:59:10 -08:00
Victor Zverovich
e01579231d Disallow leading zeros in arg-id 2018-11-08 08:48:56 -08:00
Victor Zverovich
a23d592472 Fix check_format_string (#925) 2018-11-03 16:51:15 -07:00
Daniela Engert
5ee1a4bc8a check for property 'mutable iterator' and SFINAE on it 2018-10-28 08:57:43 -07:00
XZiar
2dea780fbd change type naming and fix sfinae bug 2018-10-28 06:00:55 -07:00
XZiar
b98e8301d5 add non-char support for compile-time format check 2018-10-28 06:00:55 -07:00
Victor Zverovich
ccd3e8bbf3 Make is_constructible public (#918) 2018-10-27 17:10:19 -07:00
Daniela Engert
ec384302db additional test for print with background color
checks for clashes with other function overloads in fmt with templated parameters on the first or second position in the parameter list
2018-10-25 16:54:54 -07:00
Victor Zverovich
0a96c032b9 Parameterize v*printf on string type (#920) 2018-10-25 13:52:08 -07:00
Victor Zverovich
61e6d2e38c Fix core version of vformat_to 2018-10-25 06:21:41 -07:00
Daniela Engert
1e3dcbba81 fix: 'format_to_n' compiles 'std::back_inserter' arguments
std::back_insert_iterators model the OutputIterator concept but differ considerably in their traits and behavior. In particular the former made compilation to fail when format_to_n is given a back_inserter as first argument. The emulation of an OutputIterator is not perfect due to the behavioural differences of back_insert_iterators (e.g. assignment always implies increment) but good enough to be used within fmt's machinery.
2018-10-24 16:45:18 -07:00