Commit graph

525 commits

Author SHA1 Message Date
Walter Bright
3061c451d2 [dmd-cxx] printf format fixes 2021-04-02 13:53:32 +08:00
Iain Buclaw
dd2edb247f Synchronize dmd-cxx with gdc-stable 2019-01-05 14:10:15 +01:00
Jack Applegame
d2a3d8ae71 Remove unnecessary auto refs and fix style. 2017-07-23 16:02:18 +03:00
Jack Applegame
6995c19d61 Change "ref" to "auto ref" 2017-07-23 15:27:05 +03:00
Jack Applegame
7d1b0891bb formattedWrite should take output range by reference
At the moment formattedWrite takes output range by value. It prevents to pass non-copyable ranges.
2017-07-23 15:18:59 +03:00
The Dlang Bot
436b67825c Merge pull request #5440 from Geod24/format-extended
Simplify and improve format positional argument output (+bonus test)
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2017-07-02 21:21:15 +02:00
Vladimir Panteleev
d0b9555a06
Revert "Sort selective imports"
This reverts commit 998ad51fd7.
2017-06-13 17:51:52 +00:00
Sebastian Wilzbach
998ad51fd7 Sort selective imports 2017-06-12 08:12:09 +02:00
Sebastian Wilzbach
61717ecc7d Sort imports 2017-06-12 07:54:38 +02:00
Geod24
fe55345a74 Simplify and improve format positional argument output
The previous code was needlessly complicated, storing arguments' as `void*` in an array,
and having a matching array of delegates to cast them.
It was not ctfe-able which required an extra code path, and tricks such as an artificial call to the `formatValue` function to ensure correct inference of `@safe`ty.

The new code do away with those limitations by simply using a switch of which branches are CT-generated.
This simple technique makes the code faster, as less instructions are generated, inlining is possible, and a switch with not so many cases will usually result in a jump table being generated.
2017-06-05 03:04:26 +02:00
Geod24
3d2d786110 std.format: Add a test for range of argument formatting
This feature was totally untested and is not documented either.
The only way I could find about it was while reading a comment in the code.
2017-06-02 00:14:04 +02:00
Martin Nowak
c46fe4bc2c Merge remote-tracking branch 'upstream/stable' into merge_stable 2017-06-01 05:53:15 +02:00
Martin
13ca4ddac7 Relax a few unittests for double-precision reals
A loss-less roundtrip (to string <=> parse) apparently isn't guaranteed
when using double-precision reals.
2017-05-24 23:51:54 +02:00
Nick Treleaven
3a367d3f4e Test positional width/precision 2017-05-08 12:39:23 +01:00
Nick Treleaven
4c86b69672 Show argument kind in getNth exception messages
Show argument number for type mismatches, but not for missing arguments.
Also remove unnecessary to!int calls.
2017-05-05 08:31:14 +01:00
Nick Treleaven
88e26cbda6 Improve format separator docs 2017-05-03 16:08:34 +01:00
Nick Treleaven
88fc139610 Show type for missing width/precision/separatorChar
Also add tests for incorrect arguments with separatorChar.
2017-05-03 15:46:55 +01:00
Nick Treleaven
6dd51ec8f1 Throw exception when positional format spec exceeds args.length
Before this threw "Orphan format arguments: args[3..2]" (and that is
due to be removed).
2017-05-01 10:04:55 +01:00
Nick Treleaven
cc8eff102f Add tests 2017-04-26 13:21:13 +01:00
Nick Treleaven
9ef964bf53 Refactor getNth with switch
Switch is faster & reduces template bloat vs. recursion.
Also fixes over-specific missing argument message (not just for int).
2017-04-25 12:46:18 +01:00
Nick Treleaven
a1f4df7e9b Refactor formatNth without mixin 2017-04-25 12:45:01 +01:00
Robert burner Schadek
7ddc85db37 format with comma formatspec to add separator into numbers 2017-04-19 09:05:14 +02:00
The Dlang Bot
df82dea9ca Merge pull request #4949 from andralex/onRangeError
Replace use of onRangeError
merged-on-behalf-of: H. S. Teoh <quickfur@users.noreply.github.com>
2017-04-06 20:32:16 +02:00
H. S. Teoh
9e4aa3249d Remove now-redundant import of onRangeError. 2017-04-06 10:36:41 -07:00
The Dlang Bot
9595c9c278 Merge pull request #5314 from ntrel/format-ex
std.format: Improve FormatException messages
merged-on-behalf-of: Jack Stouffer <jack@jackstouffer.com>
2017-04-03 19:16:58 +02:00
The Dlang Bot
95b2b139e9 Merge pull request #5296 from ntrel/ct-stdio-format
Issue 13568: Add CT-checked format string overloads to std.stdio
merged-on-behalf-of: H. S. Teoh <quickfur@users.noreply.github.com>
2017-04-01 13:04:20 +02:00
Nick Treleaven
d1e6cf0340 Add tests for incompatible format spec
Note: Remaining formatValue overloads may defer to these value types,
e.g. pointer -> int, bool -> int, char -> int.
2017-03-31 10:43:32 +01:00
Nick Treleaven
d1471d95e0 Use collectExceptionMsg, fix coverage for missing width/precision 2017-03-31 09:43:37 +01:00
Nick Treleaven
b09ad9aeea Fix Issue 17288 - formattedWrite with width/precision and no value
Previously an RangeError at runtime or assert(0) at CT would fire from
formatNth with message e.g. "n = 1".
2017-03-30 17:45:03 +01:00
Nick Treleaven
d20056974a Document compile-time checking for format strings 2017-03-21 12:22:09 +00:00
Nick Treleaven
9ba4bd1958 std.format: Improve FormatException messages 2017-03-20 16:27:15 +00:00
The Dlang Bot
4a1733e7e2 Merge pull request #5288 from ntrel/ct-format
Issue 13568: Add CT-checked format string overloads to std.format
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
2017-03-19 01:06:35 +01:00
Nick Treleaven
c6a7e3ede4 Tweaks
Add constraints.
Fix test for ctfpMessage equality.
2017-03-18 10:33:06 +00:00
Nick Treleaven
f55d6b0547 Add CT-checked format string overloads to std.format
* Add overloads for formattedWrite, formattedRead, format, sformat.

* Throw FormatError when formatValue is called with floating points.

The latter allows `snprintf` to be avoided in CTFE when checking format
strings so floating point arguments can be checked.
2017-03-17 17:28:35 +00:00
H. S. Teoh
848c3a658b Fix missing '|' in std.format grammar. 2017-03-16 17:39:03 -07:00
Jack Applegame
dddf4fd64a Adding const to all ref FormatSpec parameters. 2017-03-10 18:46:53 +03:00
Sebastian Wilzbach
090d5164e8 Fix links from $(LREF $(D ...)) -> $(LREF ...)
sed -E 's/[$]\(D [$]\(LREF (.*)\)\)/$(LREF \1)/' -i **/*.d
2017-03-05 08:11:29 +01:00
Sebastian Wilzbach
3817d6f37d Check public functions for public examples (#4998)
Check public functions for public examples
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2017-03-01 15:49:15 +01:00
Jack Stouffer
8475b593c3 Merge pull request #5009 from wilzbach/fix-16281
Fix issue 16281 - std.format.formattedRead should use ref instead of requiring pointers
2017-02-27 14:20:34 -05:00
The Dlang Bot
0fef09a311 Merge pull request #5191 from JackStouffer/format3
Simply the docs of std.format.unformatValue
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2017-02-26 22:05:42 +01:00
Jack Stouffer
a081721327 Merge pull request #5190 from JackStouffer/format2
Add Throws info to the docs of std.format.formattedRead
2017-02-25 22:29:16 -05:00
Jack Stouffer
c1e9f21cbf Simply the docs of std.format.unformatValue 2017-02-24 13:28:19 -05:00
Jack Stouffer
3741955334 Add throws info to the docs of std.format.formattedRead 2017-02-24 13:16:40 -05:00
Jack Stouffer
fa8b82c1bc Improve the enfore code and the docs for std.format.sformat 2017-02-24 13:09:53 -05:00
Sebastian Wilzbach
fc1eb2f0ce Fix issue 16281 - std.format.formattedRead should use ref instead of requiring pointers 2017-02-22 06:16:39 +01:00
Sebastian Wilzbach
425ab667a3 Automatically set the range style from a..b -> a .. b
Commands:

sed -E "s/([[:alnum:]])[.][.]([[:alnum:]])/\1 .. \2/g" -i **/*.d
sed -E "s/([[:alnum:]])[.][.] ([[:alnum:]])/\1 .. \2/g" -i **/*.d
sed -E "s/([[:alnum:]]) [.][.]([[:alnum:]])/\1 .. \2/g" -i **/*.d
2017-02-22 05:37:31 +01:00
Sebastian Wilzbach
805c720595 Unify Phobos by ensuring there's always a space after cast(...)
Command:

sed -E 's/([^"])cast\(([^)]*?)\)([[:alnum:]])/\1cast(\2) \3/g' -i **/*.d
2017-02-21 16:40:20 +01:00
Sebastian Wilzbach
87dec58a41 DStyle: Constraints on declarations should have the same indentation level 2017-02-17 07:36:23 +01:00
Jack Stouffer
316b4501b7 Expand the examples for std.format.unformatValue to show all uses cases 2017-02-15 15:14:41 -05:00
Sebastian Wilzbach
eb2bf6fd6b Merge pull request #5130 from JackStouffer/format-docs
Consolidated and added examples to the std.format.unformatValue docs
2017-02-15 19:52:00 +01:00