Commit graph

647 commits

Author SHA1 Message Date
vali0901
1d16213980 Fix Issue 13893 - rawRead must take a non-empty buffer 2022-07-23 18:09:32 +03:00
vali0901
85b47bc401 Fix Issue 13893 - rawRead must take a non-empty buffer 2022-07-23 16:50:33 +03:00
Su
a4a18d21c4
preallocate oom error (#8480)
* 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
2022-06-22 06:33:10 +01:00
Martin Nowak
0e3efabacc Merge remote-tracking branch 'upstream/stable' into merge_stable 2022-04-01 10:23:49 +02:00
Dennis Korpel
ba92563a0d Fix issue 22939 - bad error message: Error: no property msg for type string 2022-03-29 18:51:30 +00:00
MoonlightSentinel
304160f5af
Issue 13541 - Use wenforce instead of enforce + sysErrorString
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.
2022-03-28 01:01:19 +02:00
WebFreak001
dac59a4bde add isSomeFiniteCharInputRange as simplification
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.
2022-01-15 18:38:52 +01:00
Jan Jurzitza
a5c3c24b71 std.stdio: clarify "not opened" documentation
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"
2022-01-10 12:47:47 +00:00
dkorpel
cd7389266e Add explicit return to inout functions 2021-11-16 23:22:33 +00:00
Nathan Sashihara
2ba87d2ff7 Delete the bodies of a number of private wrapper functions in std.stdio and std.file 2021-10-28 06:10:01 -04:00
Luís Ferreira
6fa9189df9 std.stdio: change exit(0) to _exit(0) to prevent segfault
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>
2021-08-19 04:23:46 +00:00
Nathan Sashihara
1bdcf1f512 isSomeChar!(Unqual!T) -> isSomeChar!T
Removing the redundant `Unqual` does not change the result.
2021-07-24 09:26:46 +00:00
Max Haughton
3415c253a0 Fix Issue 21495 - File.readf documentation does not state what what is returned. 2021-07-20 02:07:01 +01:00
Martin Nowak
7a461990da Merge remote-tracking branch 'upstream/stable' into merge_stable 2021-06-04 13:02:58 +02:00
Martin Kinkelin
e150b1e052 std.stdio: Restore compilability of unittests for iOS 2021-06-03 18:23:40 +00: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
5a18d8cea1 Annotate std/stdio.d to please dlang/dmd#12520 2021-05-17 20:43:46 +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
berni44
6584744946 Fix Issue 21730 - null ptr dereferenced in ChunksImpl.opApply (SIGSEGV) 2021-05-01 20:34:47 +02:00
berni44
5511155ccc Fix Issue 21728 - rawRead calls fread with NULL if invoked on closed readEnd of Pipe (segfault) 2021-05-01 16:17:04 +02:00
berni44
3b501e1ddc Fix Issue 21729 - rawRead derefences null pointer if invoked on closed File (segfault) 2021-05-01 16:16:45 +02:00
Iain Buclaw
f0b8f77789 std.stdio: Deprecate aliases that should be internal to implementation 2021-04-24 10:33:49 +02:00
Iain Buclaw
b3ed876649 std.stdio: Remove 'under-the-hood' C I/O functions that are now declared in druntime 2021-04-21 22:28:49 +02:00
Nick Treleaven
15cc376607
std.stdio docs: Group symbol links in a table (#7904)
std.stdio docs: Group symbol links in a table
merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
2021-03-31 13:38:08 +02:00
berni44
6f2a0934a7 Adapt imports of std.format to new structure of std.format. 2021-03-19 13:22:00 +01:00
aG0aep6G
3debd58cb4 fix issue 21592 - two stack traces if high surrogate is printed 2021-03-03 13:46:29 +01:00
Hiroki Noda
11ec2bff64 Fix Issue 21627 - macOS: std.stdio.File.sync does not guarantee to be written to disk 2021-03-01 15:31:32 +01:00
Iain Buclaw
c6c8b12852 Implement missing OpenBSD ports in phobos 2021-02-01 18:46:54 +01:00
Martin Kinkelin
30fb34dab4 std.stdio: Adapt LockingBinaryWriter to emplace() in druntime 2021-01-18 14:20:31 +01:00
Nathan Sashihara
c16bb67bb5 Fix Issue 21523 - Microsoft Windows std.stdio.File.lock(), tryLock(), unlock(): do not allocate memory for error messages when they are not needed 2021-01-04 04:55:24 +01:00
aG0aep6G
31df240930 fix issue 21493 - Documentation broken hyperlink std.stdio 2020-12-20 13:24:16 +01:00
Iain Buclaw
2c06601417 std.stdio: Fix typo in getdelim deprecation message 2020-12-02 13:23:52 +01:00
Iain Buclaw
2db474be28 std.stdio: Deprecate extern(C) getdelim
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.
2020-12-02 06:19:53 +01:00
Iain Buclaw
11f075500e std.stdio: Replace version(HAS_GETDELIM) with __traits(compiles, getdelim) 2020-12-01 15:38:45 +01:00
Iain Buclaw
9c7974a3db std.stdio: Merge readlnImpl implementations into one function 2020-12-01 13:50:27 +01:00
Iain Buclaw
a2c407b42c std.stdio: Deprecate extern(C) getline
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.
2020-12-01 11:59:05 +01:00
Luís Ferreira
3ea61977ec stdio: optimize readln algorithm for non-char type
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>
2020-10-28 15:09:58 +01:00
Johan Engelen
dfd45c0ac1 std.stdio: move std.process import inside unittest
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.
2020-10-23 16:58:25 +02:00
Rainer Schuetze
e74cd7f553 Keep a copy of the return value of setlocale(), it can become invalid 2020-10-13 11:28:16 +02:00
aG0aep6G
e7e75cf234 add the original test case of issue 18789
... to ensure that it doesn't throw any exceptions like it used to.
2020-09-21 21:19:06 +02:00
aG0aep6G
4b416afe16 ditch the ccs flag; set locale instead 2020-09-21 21:07:29 +02:00
aG0aep6G
b394e321be refactor: merge tests 2020-09-21 21:05:47 +02:00
aG0aep6G
41f78fc1e1 fix conversion from wchar to wchar_t in LockingTextWriter.put
This fixes issue 18789.
2020-09-21 21:05:44 +02:00
aG0aep6G
ece1672ae8 fix conversion from char to wchar_t in LockingTextWriter.put 2020-09-21 21:05:30 +02:00
aG0aep6G
3754e92341 fix issue 18801 - std.stdio.File doesn't work with MSVCRT's UTF-8 mode 2020-09-17 11:42:33 +02:00
canopyofstars
90c62c6c4e
Fix issue 7033: File.rawWrite is slow on Windows (#7590)
Fix issue 7033: File.rawWrite is slow on Windows
merged-on-behalf-of: Steven Schveighoffer <schveiguy@users.noreply.github.com>
2020-08-15 12:07:38 +02:00
Andrei Alexandrescu
42138c021c
Replace Unqual-based idiom with immutable-based idiom (#7576)
Replace Unqual-based idiom with immutable-based idiom
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
2020-08-04 04:32:14 +02:00