Skip to content

Commit 9cb5f6d

Browse files
authored
Merge pull request #8802 from WalterBright/CRuntimeStdio
std.stdio: remove redundant version declarations
2 parents 6fd66c5 + 258c98a commit 9cb5f6d

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

std/stdio.d

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,12 @@ alias KeepTerminator = Flag!"keepTerminator";
122122

123123
version (CRuntime_Microsoft)
124124
{
125-
version = MICROSOFT_STDIO;
126125
}
127126
else version (CRuntime_DigitalMars)
128127
{
129-
// Specific to the way Digital Mars C does stdio
130-
version = DIGITAL_MARS_STDIO;
131128
}
132129
else version (CRuntime_Glibc)
133130
{
134-
// Specific to the way Gnu C does stdio
135-
version = GCC_IO;
136131
}
137132
else version (CRuntime_Bionic)
138133
{
@@ -220,7 +215,7 @@ version (Posix)
220215
static import core.sys.posix.stdio; // getdelim, flockfile
221216
}
222217

223-
version (DIGITAL_MARS_STDIO)
218+
version (CRuntime_DigitalMars)
224219
{
225220
private alias _FPUTC = _fputc_nlock;
226221
private alias _FPUTWC = _fputwc_nlock;
@@ -229,7 +224,7 @@ version (DIGITAL_MARS_STDIO)
229224
private alias _FLOCK = __fp_lock;
230225
private alias _FUNLOCK = __fp_unlock;
231226

232-
// Alias for MICROSOFT_STDIO compatibility.
227+
// Alias for CRuntime_Microsoft compatibility.
233228
// @@@DEPRECATED_2.107@@@
234229
// Rename this back to _setmode once the deprecation phase has ended.
235230
private alias __setmode = setmode;
@@ -267,7 +262,7 @@ version (DIGITAL_MARS_STDIO)
267262
~ "std.stdio and will be removed afer 2.107")
268263
fileno_t _fileno(FILE* f) { return f._file; }
269264
}
270-
else version (MICROSOFT_STDIO)
265+
else version (CRuntime_Microsoft)
271266
{
272267
private alias _FPUTC = _fputc_nolock;
273268
private alias _FPUTWC = _fputwc_nolock;
@@ -277,7 +272,7 @@ else version (MICROSOFT_STDIO)
277272
private alias _FUNLOCK = _unlock_file;
278273

279274
// @@@DEPRECATED_2.107@@@
280-
// Remove this once the deprecation phase for DIGITAL_MARS_STDIO has ended.
275+
// Remove this once the deprecation phase for CRuntime_DigitalMars has ended.
281276
private alias __setmode = _setmode;
282277

283278
// @@@DEPRECATED_2.107@@@
@@ -305,7 +300,7 @@ else version (MICROSOFT_STDIO)
305300
~ "std.stdio and will be removed afer 2.107")
306301
alias FUNLOCK = _unlock_file;
307302
}
308-
else version (GCC_IO)
303+
else version (CRuntime_Glibc)
309304
{
310305
private alias _FPUTC = fputc_unlocked;
311306
private alias _FPUTWC = fputwc_unlocked;
@@ -419,7 +414,7 @@ private extern (C) @nogc nothrow
419414
{
420415
pragma(mangle, _FPUTC.mangleof) int trustedFPUTC(int ch, _iobuf* h) @trusted;
421416

422-
version (DIGITAL_MARS_STDIO)
417+
version (CRuntime_DigitalMars)
423418
pragma(mangle, _FPUTWC.mangleof) int trustedFPUTWC(int ch, _iobuf* h) @trusted;
424419
else
425420
pragma(mangle, _FPUTWC.mangleof) int trustedFPUTWC(wchar_t ch, _iobuf* h) @trusted;
@@ -598,7 +593,7 @@ Throws: `ErrnoException` if the file could not be opened.
598593
name);
599594

600595
// MSVCRT workaround (https://issues.dlang.org/show_bug.cgi?id=14422)
601-
version (MICROSOFT_STDIO)
596+
version (CRuntime_Microsoft)
602597
{
603598
setAppendWin(stdioOpenmode);
604599
}
@@ -726,7 +721,7 @@ Throws: `ErrnoException` in case of error.
726721
}
727722
_p = cast(Impl*) enforce(malloc(Impl.sizeof), "Out of memory");
728723
initImpl(handle, name, 1, isPopened);
729-
version (MICROSOFT_STDIO)
724+
version (CRuntime_Microsoft)
730725
{
731726
setAppendWin(stdioOpenmode);
732727
}
@@ -761,7 +756,7 @@ Throws: `ErrnoException` in case of error.
761756
}
762757
}
763758

764-
version (MICROSOFT_STDIO)
759+
version (CRuntime_Microsoft)
765760
{
766761
private void setAppendWin(scope const(char)[] stdioOpenmode) @safe
767762
{
@@ -894,7 +889,7 @@ Params:
894889
auto modez = stdioOpenmode.tempCString();
895890
detach();
896891

897-
version (DIGITAL_MARS_STDIO)
892+
version (CRuntime_DigitalMars)
898893
{
899894
// This is a re-implementation of DMC's fdopen, but without the
900895
// mucking with the file descriptor. POSIX standard requires the
@@ -948,7 +943,7 @@ Throws: `ErrnoException` in case of error.
948943
import std.format : format;
949944

950945
// Create file descriptors from the handles
951-
version (DIGITAL_MARS_STDIO)
946+
version (CRuntime_DigitalMars)
952947
auto fd = _handleToFD(handle, FHND_DEVICE);
953948
else // MSVCRT
954949
{
@@ -1193,7 +1188,7 @@ Throws: `ErrnoException` if the file is not opened or the call to `fread` fails.
11931188
immutable fileno_t fd = .fileno(_p.handle);
11941189
immutable mode = .__setmode(fd, _O_BINARY);
11951190
scope(exit) .__setmode(fd, mode);
1196-
version (DIGITAL_MARS_STDIO)
1191+
version (CRuntime_DigitalMars)
11971192
{
11981193
import core.atomic : atomicOp;
11991194

@@ -1291,7 +1286,7 @@ Throws: `ErrnoException` if the file is not opened or if the call to `fwrite` fa
12911286
.__setmode(fd, _O_BINARY);
12921287
}
12931288

1294-
version (DIGITAL_MARS_STDIO)
1289+
version (CRuntime_DigitalMars)
12951290
{
12961291
import core.atomic : atomicOp;
12971292

@@ -2354,7 +2349,7 @@ Returns the underlying operating system `HANDLE` (Windows only).
23542349
version (Windows)
23552350
@property HANDLE windowsHandle()
23562351
{
2357-
version (DIGITAL_MARS_STDIO)
2352+
version (CRuntime_DigitalMars)
23582353
return _fdToHandle(fileno);
23592354
else
23602355
return cast(HANDLE)_get_osfhandle(fileno);
@@ -3150,7 +3145,7 @@ is empty, throws an `Exception`. In case of an I/O error throws
31503145
file_ = f;
31513146
FILE* fps = f._p.handle;
31523147

3153-
version (MICROSOFT_STDIO)
3148+
version (CRuntime_Microsoft)
31543149
{
31553150
// Microsoft doesn't implement fwide. Instead, there's the
31563151
// concept of ANSI/UNICODE mode. fputc doesn't work in UNICODE
@@ -3391,7 +3386,7 @@ is empty, throws an `Exception`. In case of an I/O error throws
33913386
{
33923387
fileno_t fd;
33933388
int oldMode;
3394-
version (DIGITAL_MARS_STDIO)
3389+
version (CRuntime_DigitalMars)
33953390
ubyte oldInfo;
33963391
}
33973392

@@ -3413,7 +3408,7 @@ is empty, throws an `Exception`. In case of an I/O error throws
34133408
.fflush(fps); // before changing translation mode
34143409
fd = .fileno(fps);
34153410
oldMode = .__setmode(fd, _O_BINARY);
3416-
version (DIGITAL_MARS_STDIO)
3411+
version (CRuntime_DigitalMars)
34173412
{
34183413
import core.atomic : atomicOp;
34193414

@@ -3434,7 +3429,7 @@ is empty, throws an `Exception`. In case of an I/O error throws
34343429
version (Windows)
34353430
{
34363431
.fflush(fps); // before restoring translation mode
3437-
version (DIGITAL_MARS_STDIO)
3432+
version (CRuntime_DigitalMars)
34383433
{
34393434
// https://issues.dlang.org/show_bug.cgi?id=4243
34403435
__fhnd_info[fd] = oldInfo;
@@ -3892,7 +3887,7 @@ void main()
38923887
return setlocale(LC_CTYPE, loc.ptr).fromStringz.endsWith(loc);
38933888
});
38943889
scope(exit) () @trusted { setlocale(LC_CTYPE, oldCt); } ();
3895-
version (DIGITAL_MARS_STDIO) // DM can't handle Unicode above U+07FF.
3890+
version (CRuntime_DigitalMars) // DM can't handle Unicode above U+07FF.
38963891
{
38973892
alias strs = AliasSeq!("\u07FE", "\u07FF"w);
38983893
}
@@ -3902,7 +3897,7 @@ void main()
39023897
}
39033898
{
39043899
auto f = File(deleteme, "w");
3905-
version (MICROSOFT_STDIO)
3900+
version (CRuntime_Microsoft)
39063901
{
39073902
() @trusted { __setmode(fileno(f.getFP()), _O_U8TEXT); } ();
39083903
}
@@ -5542,7 +5537,7 @@ private struct LockedFile
55425537
// Private implementation of readln
55435538
private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orientation orientation) @safe
55445539
{
5545-
version (DIGITAL_MARS_STDIO)
5540+
version (CRuntime_DigitalMars)
55465541
return () @trusted {
55475542
auto lf = LockedFile(fps);
55485543
ReadlnAppender app;
@@ -5655,7 +5650,7 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orie
56555650
buf = app.data;
56565651
return buf.length;
56575652
}();
5658-
else version (MICROSOFT_STDIO)
5653+
else version (CRuntime_Microsoft)
56595654
{
56605655
auto lf = LockedFile(fps);
56615656

0 commit comments

Comments
 (0)