The standard library of the D programming language
Find a file
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
.circleci ci: circleci: remove unused variable 2020-10-19 00:04:21 +01:00
changelog Merge pull request #8015 from berni44/add_integer_efga 2021-05-07 14:59:25 +08:00
etc/c Mark etc.c.odbc as deprecated 2021-01-28 13:30:32 +01:00
std Fix issue 21926 - Allow leadings zeros in std.conv.octal 2021-05-20 01:48:15 +02:00
test Add sumtype to Phobos (#7702) 2021-03-05 12:41:34 +01:00
.cirrus.yml CirrusCI: Use HOST_DMD instead of HOST_DC 2020-12-09 22:21:49 +01:00
.codecov.yml Use informational:true for CodeCov 2018-02-04 17:23:57 +01:00
.dscanner.ini std.format: Refactor formatReflectTest 2021-04-22 03:21:31 +02:00
.editorconfig Fix line endings in .editorconfig 2018-09-16 12:19:04 -07:00
.gitignore Add initial dub.sdl with stdx-allocator and stdx-checkedint 2018-06-22 16:56:20 +02:00
azure-pipelines.yml Sync Azure CI script with druntime's 2020-10-14 10:53:02 +09:00
CODEOWNERS Add sumtype to Phobos (#7702) 2021-03-05 12:41:34 +01:00
CONTRIBUTING.md update issue link to issues.dlang.org 2016-05-17 09:40:29 +03:00
dub.sdl Expose a copy of std.conv with the DUB package of stdx.allocator 2018-06-26 06:17:36 +02:00
index.d Add sumtype to Phobos (#7702) 2021-03-05 12:41:34 +01:00
Jenkinsfile use ci repo as shared jenkins library 2017-10-06 16:04:07 +02:00
LICENSE_1_0.txt
posix.mak std.math: Move floating point operations into operations submodule. 2021-04-17 21:52:27 +02:00
project.ddoc add PROJECT=phobos ddoc macro 2014-01-10 19:16:53 +01:00
README.md Remove no longer available issue stats and add a Buildkite badge 2019-01-04 18:02:28 +01:00
unittest.d Remove deprecated symbols from std.digest.digest 2020-04-09 11:35:23 +02:00
win32.mak std.math: Move floating point operations into operations submodule. 2021-04-17 21:52:27 +02:00
win64.mak std.math: Move floating point operations into operations submodule. 2021-04-17 21:52:27 +02:00

D Logo Phobos Standard Library

GitHub tag Bugzilla Issues CircleCi Buildkite Code coverage license

Phobos is the standard library that comes with the D Programming Language Compiler.

Download

Phobos is packaged together with the compiler. You should download the whole precompiled package.

To build everything yourself, there is a description in the wiki.

Phobos is distributed under Boost Software Licence. See the licence file.

I Want to Contribute

Great! See the CONTRIBUTING.md file.