Commit graph

15460 commits

Author SHA1 Message Date
Witold Baryluk
a8d4b00f98 Fix issue 21926 - Allow leadings zeros in std.conv.octal
First of all, the DDoc currently says that:

"Leading zero is allowed, but not required."

The current implementation doesn't respect that.

D lexer allows leading zero(s) also.

And when considering octal from string, there is no possibility
of confusion, as the comments in the code claim. Disallowing
leading zeros for octal conversion from string, does not help
with anything actually.

So lets allow leading zeros.

Allowing leading zeros, does help when implementing various
APIs (i.e. glibc, Linux kernel), where a lot of octal constant,
are defined with multiple leading zeros, for readability and
alignment, in C headers. Having to manually or automatically
special case these when porting such API definitions, is
counter-productive.

Example from a Linux kernel (`include/uapi/linux/stat.h`):

```c
#define S_IFMT  00170000
#define S_IFSOCK 0140000
#define S_IFLNK	 0120000
#define S_IFREG  0100000
#define S_IFBLK  0060000
#define S_IFDIR  0040000
#define S_IFCHR  0020000
#define S_IFIFO  0010000
#define S_ISUID  0004000
#define S_ISGID  0002000
#define S_ISVTX  0001000
```

With this patch, now it is trivial and easier to convert these to D:

```d
...
enum S_ISVTX = octal!"0001000";
```

while being close to original. That helps with readability,
and long term maintenance.

In fact the run-time version provided by `parse!(int)(string, 8)`
also supports leading zeros already. So this makes `octal`
more consistent `parse`.
2021-05-20 01:48:15 +02:00
Razvan Nitu
5131694f1c
Merge pull request #8088 from nordlow/fix-pure-scope-json
Annotate std/json.d to please dlang/dmd#12520
2021-05-19 14:38:26 +08:00
Razvan Nitu
6ae4991ca1
Merge pull request #8104 from WalterBright/bigint-ret
bigint.d: add return annotations for opOpAssign()
2021-05-19 14:29:33 +08:00
nordlow
dc54832b5c Annotate std/path.d to please dlang/dmd#12520, absolutePath excluded 2021-05-19 04:06:24 +02:00
Walter Bright
22ca8abece bigint.d: add return annotations for opOpAssign() 2021-05-18 09:43:40 -07:00
Walter Bright
f0e8bcf369
Merge pull request #8081 from nordlow/fix-pure-scope-bigint
Annotate std/bigint.d and std/internal/math/biguintcore.d to please d…
2021-05-18 09:40:09 -07:00
nordlow
a44f71813f Annotate std/bigint.d and std/internal/math/biguintcore.d to please dlang/dmd#12520 #8076 2021-05-18 13:14:08 +02:00
nordlow
62d9ffb42c Annotate std/range/package.d to please dlang/dmd#12520 2021-05-18 11:31:41 +02:00
nordlow
450e79cd6a Annotate std/json.d to please dlang/dmd#12520 2021-05-18 11:02:18 +02:00
The Dlang Bot
862c39241d
Merge pull request #8092 from dlang/revert-8055-issue_9489
Revert "Fix Issue 9489 - writeln of struct with disabled copy ctor"
merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
2021-05-18 08:49:41 +02:00
Iain Buclaw
7ff6bb705d Revert "Annotate std/path.d to please dlang/dmd#12520"
This reverts commit 384b4be243.
2021-05-18 06:48:54 +02:00
avaj
8b31d022f0 std.traits: Fix unittest for isNumeric 2021-05-18 05:13:18 +02:00
nordlow
f1bcb5270f Annotate std/bitmanip to please dlang/dmd#12520 2021-05-18 04:48:36 +02:00
nordlow
4449049c18 Annotate std/base64.d to please dlang/dmd#12520 #8076 2021-05-18 03:28:07 +02:00
nordlow
4ba167b15b Annotate std/container/dlist.d to please dlang/dmd#12520 2021-05-18 01:58:16 +02:00
nordlow
b4ce8436d7 Annotate bitmapped_block.d to please dlang/dmd#12520 2021-05-18 01:13:52 +02:00
nordlow
1a72c4f83e Annotate std/net/isemail.d to please dlang/dmd#12520 2021-05-18 00:29:19 +02:00
The Dlang Bot
a01c94531e
Merge pull request #8079 from nordlow/fix-pure-scope-searching
Annotate std/algorithm/searching.d to please dlang/dmd#12520
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2021-05-17 23:44:59 +02:00
Iain Buclaw
c16220295f fix Issue 21920 - [REG master] Error: auto can only be used as part of auto ref for template function parameters 2021-05-17 23:03:37 +02:00
Iain Buclaw
116d33b635 Revert "Fix Issue 9489 - writeln of struct with disabled copy ctor"
This reverts commit 838da632cb.
2021-05-17 23:03:37 +02:00
nordlow
93ea473f53 Annotate std/internal/digest/sha_SSSE3.d to please dlang/dmd#12520 2021-05-17 23:00:24 +02:00
nordlow
6ce97eb9ff Annotate std/socket.d to please dlang/dmd#12520 2021-05-17 21:50:31 +02:00
nordlow
5a18d8cea1 Annotate std/stdio.d to please dlang/dmd#12520 2021-05-17 20:43:46 +02:00
nordlow
086ad984dd Annotate std/string.d to please dlang/dmd#12520 2021-05-17 19:37:00 +02:00
nordlow
88a4ebbc1f Annotate std/uni/package.d to please dlang/dmd#12520 2021-05-17 18:30:15 +02:00
nordlow
0db0187885 Annotate std/utf.d to please dlang/dmd#12520 2021-05-17 17:15:35 +02:00
nordlow
778495cd9a Annotate std/xml.d to please dlang/dmd#12520 2021-05-17 14:09:09 +02:00
nordlow
db6a3ac21c Annotate std/process.d to please dlang/dmd#12520 2021-05-17 19:00:50 +08:00
nordlow
384b4be243 Annotate std/path.d to please dlang/dmd#12520 2021-05-17 19:00:35 +08:00
nordlow
5d31a68082 Break line to please maximum line length enforced by style checker 2021-05-17 12:04:06 +02:00
nordlow
f8bc7a1181 Annotate allocator/common.d to please dlang/dmd#12520 2021-05-17 05:21:35 +02:00
nordlow
6bef53dd1a Annotate std/algorithm/searching.d to please dlang/dmd#12520 #8076 2021-05-17 00:02:04 +02:00
Max Haughton
bc0a16273e Fix Issue 21125 - Typo in std.range.refRange documentation for opIndex 2021-05-16 21:14:25 +02:00
Iain Buclaw
859a367ffa Cleanup temp files in std.process and std.experimental.checkedint
Co-Authored-By: Bernd Edlinger <bernd.edlinger@hotmail.de>
2021-05-14 15:03:34 +02:00
Razvan Nitu
d154c239c4
Merge pull request #8050 from berni44/rounding_e
std.format: Use rounding tool to round %e on floats.
2021-05-14 14:38:42 +08:00
Razvan Nitu
dba3cbc88c
Merge pull request #8059 from berni44/rounding_a
std.format: Use rounding tool to round %a on floats.
2021-05-13 14:35:19 +08:00
Vladimir Panteleev
28b9d08fa2 Fix Issue 21916 - Error message is obfuscated when using wrong format specifier at compile-time 2021-05-13 02:22:27 +02:00
The Dlang Bot
b5b4dc176c
Merge pull request #8069 from MartinNowak/merge_stable
merge stable
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2021-05-12 12:06:44 +02:00
berni44
838da632cb Fix Issue 9489 - writeln of struct with disabled copy ctor 2021-05-12 09:41:58 +02:00
Martin Nowak
0f71d7494f Merge remote-tracking branch 'upstream/master' into stable 2021-05-12 08:29:15 +02:00
Boris Carvajal
5dd42968e3 Rename the initial value of some enums from init to _init 2021-05-12 10:56:46 +08:00
berni44
3b4dc67878 Make unittests in std.format @safe 2021-05-11 16:13:09 +02:00
Iain Buclaw
f3567fbb69 std.complex: Add missing imports in unittests for non-DigitalMars targets 2021-05-11 14:30:35 +02:00
Iain Buclaw
79bf8c3c32 std.math.algebraic: Convert hypot to a template 2021-05-11 12:22:13 +02:00
Andrei Alexandrescu
5c931c89fa Replace the use of format() during compilation in std.traits with concatenations 2021-05-11 09:40:56 +02:00
Iain Buclaw
52699fc020 std.math: Adjust whitespace of a few unittests 2021-05-11 09:14:14 +02:00
Iain Buclaw
543a3d0cd6 std.math.algebraic: Support more float types in hypot 2021-05-11 02:59:57 +02:00
Witold Baryluk
46b7b3b02a Fix missing space in exception text in std.conv.to
For example:

Evaluating `to!(int[])("")`
Leads to `ConvException` with message:

`Can't parse string: unexpected end of input when expecting"["`

but should be

`Can't parse string: unexpected end of input when expecting "["`
2021-05-11 02:00:12 +02:00
Andrei Alexandrescu
4655240bbe Make staticIsSorted use static foreach instead of recursion 2021-05-10 19:20:37 +02:00
berni44
36221cf4cc Revert "Fix Issue 21456 - std.format does not accept enum member with string base type as template parameter"
This reverts commit 974a88a967.
2021-05-10 18:30:05 +02:00