* preallocate oom error
fixes issue 23196.
unfortunately, while i believe it should be possible to make this function `@nogc nothrow` [since we are throwing an error, which cannot be recovered from], i wasn't able to figure out how to get enforce to realise it. advice would be greatly appreciated on this front.
* undo wording change
* Update stdio.d
use onOutOfMemoryError instead of custom implementation
* nogc nothrow
* style fix
* remove unneeded variable
* remove unused import
This ensures that the actual error message won't be suppressed when the
lookup error code => message fails. The exception will also be more
informative because `WindowsException` is explicitly intended for
Windows API errors.
combines the very common constraint
`isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)`
and adds a bunch of documentation with examples for users to understand
it better. This should lower the neccessary needed technical insight to
read basic docs, especially std.path and std.file docs.
when the code is `!isOpen` it now means:
- in exception documentation it's now always saying "not opened" (or similar, it's clear the file is in error state in that case)
- in general documentation it now always says "closed or not yet opened" (to avoid mistaking it with eof)
- in runtime error messages it always says "unopened"
Fixes#22222.
`exit(0)` call from libc does an exit sequence before exit and therefore
doesn't exit immediately. This causes problems on custom unittest runners. To
circunvent this problem we should call `_exit()` syscall to exit immediately.
In this context this is just fine to do and can prevent any future frustration
when debugging.
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
The publicly available `extern(C)` binding for `getdelim` in `std.stdio`
has been deprecated. Any code that still needs it can import the symbol
from `core.sys.posix.stdio` in druntime instead.
The publicly available `extern(C)` binding for `getline` in `std.stdio` has
been deprecated. Any code that still needs it can import the symbol from
`core.sys.posix.stdio` in druntime instead.
Instead of using buf.length = 0, use buf = buf[0..0] slice technique to clean
the array and reuse, if possible, the buffer to reduce GC allocations.
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
This moves the std.process import inside the unittest. The import is not used elsewhere, and so is unnecessary for non-unittest builds. This greatly speeds up importing std.stdio. (In a simple testcase, more than 90% of the import time of std.stdio was spent on std.process)
I've tried to keep whitespace changes to a minimum, while keeping the code readable.