Value '3' can be a valid value on Linux (`SEEK_DATA`, since 3.18).
The support depends on the kernel version and the libc used.
Hence, make the check common to all platform / runtime.
The code compiled and ran, but behaved differently.
The silent breakage was due to the implicit conversion of char to
dchar. Forbidding such conversions would prevent the silent breakage.
C fclose is allowed to fail, and some libc implementations do cause it
to fail.
For example, reading on a file opened only for writing, or (in Wine's
MSVCRT implementation) writing on a file opened only for reading sets
an error flag, which then causes fclose to return EOF to signal an
error.
However, all descriptions of the function specify that "whether or not
the call succeeds, the stream shall be disassociated from the file"
and "after the call to fclose(), any use of stream results in
undefined behavior" (POSIX) or similar.
Currently, if File.close throws and is called again (e.g. in a
destructor), it will retry the fclose call. This is undefined behavior
as described above, and may potentially affect an unrelated file.
It also makes it overly difficult to "get rid" of a File instance
associated with a FILE with its error flag set - all attempts at
destroying it will fail and only be eventually retried.
[refactor] posix.mak: Enforce whitespace before opening parenthesis for version …
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
fopen and popen wrap C functions that exist in druntime, and it's not
uncommon for folks to end up accidentally trying to use the private
functions in std.stdio instead of the ones from druntime - which then
tends to result in questions on D.Learn. There's no reason that either
of these private functions needs to be named the same as the C function
that it wraps. It just causes confusion when folks accidentally try to
use them instead of the C functions.
So, this changes them to _fopen and _popen so that there will be no such
conflict, and the error messages when folks try to call the C functions
but do so incorrectly will not mention std.stdio's internals.