diff --git a/etc/c/curl.d b/etc/c/curl.d index 5d772f16b07..7c8fc36342a 100644 --- a/etc/c/curl.d +++ b/etc/c/curl.d @@ -115,12 +115,12 @@ alias CURL = void; alias curl_socket_t = socket_t; /// jdrewsen - Would like to get socket error constant from std.socket by it is private atm. -version(Windows) +version (Windows) { import core.sys.windows.windows, core.sys.windows.winsock2; enum CURL_SOCKET_BAD = SOCKET_ERROR; } -version(Posix) enum CURL_SOCKET_BAD = -1; +version (Posix) enum CURL_SOCKET_BAD = -1; /// extern (C) struct curl_httppost diff --git a/etc/c/odbc/sqltypes.d b/etc/c/odbc/sqltypes.d index 4c7e7ecad5d..4f3ce8aeb66 100644 --- a/etc/c/odbc/sqltypes.d +++ b/etc/c/odbc/sqltypes.d @@ -175,11 +175,11 @@ alias GUID = SQLGUID; alias BOOKMARK = uint; alias SQLWCHAR = ushort; -version( UNICODE ) +version (UNICODE) { alias SQLTCHAR = SQLWCHAR; } else { alias SQLTCHAR = SQLCHAR; -} // end version( UNICODE ) +} // end version (UNICODE) diff --git a/posix.mak b/posix.mak index d1ed5e7167a..7ea8904b6bf 100644 --- a/posix.mak +++ b/posix.mak @@ -562,7 +562,10 @@ style_lint: dscanner $(LIB) grep -nr '[[:blank:]]$$' etc std ; test $$? -eq 1 @echo "Enforce whitespace before opening parenthesis" - grep -nrE "(for|foreach|foreach_reverse|if|while|switch|catch)\(" $$(find etc std -name '*.d') ; test $$? -eq 1 + grep -nrE "\<(for|foreach|foreach_reverse|if|while|switch|catch|version)\(" $$(find etc std -name '*.d') ; test $$? -eq 1 + + @echo "Enforce no whitespace after opening parenthesis" + grep -nrE "\<(version) \( " $$(find etc std -name '*.d') ; test $$? -eq 1 @echo "Enforce whitespace between colon(:) for import statements (doesn't catch everything)" grep -nr 'import [^/,=]*:.*;' $$(find etc std -name '*.d') | grep -vE "import ([^ ]+) :\s"; test $$? -eq 1 diff --git a/std/algorithm/internal.d b/std/algorithm/internal.d index 41624d57147..666584f820a 100644 --- a/std/algorithm/internal.d +++ b/std/algorithm/internal.d @@ -14,7 +14,7 @@ package template algoFormat() } // Internal random array generators -version(unittest) +version (unittest) { package enum size_t maxArraySize = 50; package enum size_t minArraySize = maxArraySize - 1; diff --git a/std/algorithm/iteration.d b/std/algorithm/iteration.d index a51a4089513..cedc999ad8c 100644 --- a/std/algorithm/iteration.d +++ b/std/algorithm/iteration.d @@ -365,18 +365,18 @@ private struct _Cache(R, bool bidir) E front() @property { - version(assert) if (empty) throw new RangeError(); + version (assert) if (empty) throw new RangeError(); return caches[0]; } static if (bidir) E back() @property { - version(assert) if (empty) throw new RangeError(); + version (assert) if (empty) throw new RangeError(); return caches[1]; } void popFront() { - version(assert) if (empty) throw new RangeError(); + version (assert) if (empty) throw new RangeError(); source.popFront(); if (!source.empty) caches[0] = source.front; @@ -385,7 +385,7 @@ private struct _Cache(R, bool bidir) } static if (bidir) void popBack() { - version(assert) if (empty) throw new RangeError(); + version (assert) if (empty) throw new RangeError(); source.popBack(); if (!source.empty) caches[1] = source.back; @@ -2137,7 +2137,7 @@ if (isInputRange!Range) ])); } -version(none) // this example requires support for non-equivalence relations +version (none) // this example requires support for non-equivalence relations @safe unittest { // Grouping by maximum adjacent difference: @@ -2278,7 +2278,7 @@ version(none) // this example requires support for non-equivalence relations } // Issue 13595 -version(none) // This requires support for non-equivalence relations +version (none) // This requires support for non-equivalence relations @system unittest { import std.algorithm.comparison : equal; @@ -4849,7 +4849,7 @@ private struct SplitterResult(alias isTerminator, Range) @property auto front() { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -4866,7 +4866,7 @@ private struct SplitterResult(alias isTerminator, Range) void popFront() { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -5043,14 +5043,14 @@ if (isSomeChar!C) @property C[] front() pure @safe { - version(assert) if (empty) throw new RangeError(); + version (assert) if (empty) throw new RangeError(); return _s[0 .. _frontLength]; } void popFront() pure @safe { import std.string : stripLeft; - version(assert) if (empty) throw new RangeError(); + version (assert) if (empty) throw new RangeError(); _s = _s[_frontLength .. $].stripLeft(); getFirst(); } diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index 1a4ca5f6d21..f748b85293c 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -638,7 +638,7 @@ if (isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && hasAssig for (;;) { // Loop invariant - version(unittest) + version (unittest) { // this used to import std.algorithm.all, but we want to save // imports when unittests are enabled if possible. @@ -3964,7 +3964,7 @@ if (isRandomAccessRange!Range && hasLength!Range && else static if (k == 5) { // Credit: Teppo Niinimäki - version(unittest) scope(success) + version (unittest) scope(success) { assert(!lt(r[c], r[a])); assert(!lt(r[c], r[b])); diff --git a/std/array.d b/std/array.d index b2ddd0a3cf3..a88d66f05e4 100644 --- a/std/array.d +++ b/std/array.d @@ -219,7 +219,7 @@ if (isPointer!Range && isIterable!(PointerTarget!Range) && !isNarrowString!Range assert(a.length == 5); } -version(unittest) +version (unittest) private extern(C) void _d_delarray_t(void[] *p, TypeInfo_Struct ti); @system unittest @@ -456,7 +456,7 @@ if (isInputRange!Range) assert(b == ["foo":"bar", "baz":"quux"]); } -// @@@11053@@@ - Cannot be version(unittest) - recursive instantiation error +// @@@11053@@@ - Cannot be version (unittest) - recursive instantiation error @safe unittest { import std.typecons; @@ -4295,7 +4295,7 @@ nothrow pure @safe unittest staticArray!(long, 2.iota).checkStaticArray!long([0, 1]); } -version(unittest) private void checkStaticArray(T, T1, T2)(T1 a, T2 b) nothrow @safe pure @nogc +version (unittest) private void checkStaticArray(T, T1, T2)(T1 a, T2 b) nothrow @safe pure @nogc { static assert(is(T1 == T[T1.length])); assert(a == b); diff --git a/std/ascii.d b/std/ascii.d index 8622785b1d7..9b0f547caa1 100644 --- a/std/ascii.d +++ b/std/ascii.d @@ -103,9 +103,9 @@ enum LetterCase : bool } /// Newline sequence for this system. -version(Windows) +version (Windows) immutable newline = "\r\n"; -else version(Posix) +else version (Posix) immutable newline = "\n"; else static assert(0, "Unsupported OS"); diff --git a/std/base64.d b/std/base64.d index 9b83bdb95db..46b70f1731a 100644 --- a/std/base64.d +++ b/std/base64.d @@ -1908,7 +1908,7 @@ class Base64Exception : Exception // @@@9543@@@ These tests were disabled because they actually relied on the input range having length. // The implementation (currently) doesn't support encoding/decoding from a length-less source. - version(none) + version (none) { // with InputRange // InputRange to ubyte[] or char[] auto encoded = Base64.encode(map!(to!(ubyte))(["20", "251", "156", "3", "217", "126"])); diff --git a/std/bitmanip.d b/std/bitmanip.d index d94a910feff..9c42886db9f 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -2873,7 +2873,7 @@ if (isIntegral!T || isSomeChar!T || isBoolean!T) { EndianSwapper!T es = void; - version(LittleEndian) + version (LittleEndian) es.value = swapEndian(val); else es.value = val; @@ -2884,7 +2884,7 @@ if (isIntegral!T || isSomeChar!T || isBoolean!T) private auto nativeToBigEndianImpl(T)(T val) @safe pure nothrow @nogc if (isFloatOrDouble!T) { - version(LittleEndian) + version (LittleEndian) return floatEndianImpl!(T, true)(val); else return floatEndianImpl!(T, false)(val); @@ -2998,7 +2998,7 @@ if ((isIntegral!T || isSomeChar!T || isBoolean!T) && EndianSwapper!T es = void; es.array = val; - version(LittleEndian) + version (LittleEndian) immutable retval = swapEndian(es.value); else immutable retval = es.value; @@ -3009,7 +3009,7 @@ if ((isIntegral!T || isSomeChar!T || isBoolean!T) && private T bigEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc if (isFloatOrDouble!T && n == T.sizeof) { - version(LittleEndian) + version (LittleEndian) return cast(T) floatEndianImpl!(n, true)(val); else return cast(T) floatEndianImpl!(n, false)(val); @@ -3048,7 +3048,7 @@ if (isIntegral!T || isSomeChar!T || isBoolean!T) { EndianSwapper!T es = void; - version(BigEndian) + version (BigEndian) es.value = swapEndian(val); else es.value = val; @@ -3059,7 +3059,7 @@ if (isIntegral!T || isSomeChar!T || isBoolean!T) private auto nativeToLittleEndianImpl(T)(T val) @safe pure nothrow @nogc if (isFloatOrDouble!T) { - version(BigEndian) + version (BigEndian) return floatEndianImpl!(T, true)(val); else return floatEndianImpl!(T, false)(val); @@ -3146,7 +3146,7 @@ if ((isIntegral!T || isSomeChar!T || isBoolean!T) && EndianSwapper!T es = void; es.array = val; - version(BigEndian) + version (BigEndian) immutable retval = swapEndian(es.value); else immutable retval = es.value; @@ -3158,7 +3158,7 @@ private T littleEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow if (((isFloatOrDouble!T) && n == T.sizeof)) { - version(BigEndian) + version (BigEndian) return floatEndianImpl!(n, true)(val); else return floatEndianImpl!(n, false)(val); diff --git a/std/compiler.d b/std/compiler.d index e67cf43a4b0..2f983c58fe0 100644 --- a/std/compiler.d +++ b/std/compiler.d @@ -32,12 +32,12 @@ immutable } /// Which vendor produced this compiler. - version(StdDdoc) Vendor vendor; - else version(DigitalMars) Vendor vendor = Vendor.digitalMars; - else version(GNU) Vendor vendor = Vendor.gnu; - else version(LDC) Vendor vendor = Vendor.llvm; - else version(D_NET) Vendor vendor = Vendor.dotNET; - else version(SDC) Vendor vendor = Vendor.sdc; + version (StdDdoc) Vendor vendor; + else version (DigitalMars) Vendor vendor = Vendor.digitalMars; + else version (GNU) Vendor vendor = Vendor.gnu; + else version (LDC) Vendor vendor = Vendor.llvm; + else version (D_NET) Vendor vendor = Vendor.dotNET; + else version (SDC) Vendor vendor = Vendor.sdc; else Vendor vendor = Vendor.unknown; diff --git a/std/concurrency.d b/std/concurrency.d index 24b03e3969e..a329f0f9ed3 100644 --- a/std/concurrency.d +++ b/std/concurrency.d @@ -710,7 +710,7 @@ do } // Make sure receive() works with free functions as well. -version(unittest) +version (unittest) { private void receiveFunction(int x) {} } diff --git a/std/container/rbtree.d b/std/container/rbtree.d index 5b2a8c0ab49..ce17d5d88a3 100644 --- a/std/container/rbtree.d +++ b/std/container/rbtree.d @@ -61,7 +61,7 @@ import std.functional : binaryFun; public import std.container.util; -version(unittest) debug = RBDoChecks; +version (unittest) debug = RBDoChecks; //debug = RBDoChecks; @@ -745,7 +745,7 @@ if (is(typeof(binaryFun!less(T.init, T.init)))) alias _less = binaryFun!less; - version(unittest) + version (unittest) { static if (is(typeof(less) == string)) { diff --git a/std/conv.d b/std/conv.d index 0c9e4c4c780..b7337aee271 100644 --- a/std/conv.d +++ b/std/conv.d @@ -1666,7 +1666,7 @@ if (!isImplicitlyConvertible!(S, T) && isAssociativeArray!S && assert(a.to!(const(int)[int]).byPair.equal(a.byPair)); } -version(unittest) +version (unittest) private void testIntegralToFloating(Integral, Floating)() { Integral a = 42; @@ -1675,7 +1675,7 @@ private void testIntegralToFloating(Integral, Floating)() assert(a == to!Integral(b)); } -version(unittest) +version (unittest) private void testFloatingToIntegral(Floating, Integral)() { bool convFails(Source, Target, E)(Source src) @@ -3086,7 +3086,7 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum // min and max real r = to!real(to!string(real.min_normal)); - version(NetBSD) + version (NetBSD) { // NetBSD notice // to!string returns 3.3621e-4932L. It is less than real.min_normal and it is subnormal value @@ -4689,7 +4689,7 @@ if (!is(T == class)) assert(u1.a == "hello"); } -version(unittest) private struct __conv_EmplaceTest +version (unittest) private struct __conv_EmplaceTest { int i = 3; this(int i) @@ -4710,7 +4710,7 @@ version(unittest) private struct __conv_EmplaceTest void opAssign(); } -version(unittest) private class __conv_EmplaceTestClass +version (unittest) private class __conv_EmplaceTestClass { int i = 3; this(int i) @nogc @safe pure nothrow @@ -5131,7 +5131,7 @@ version(unittest) private class __conv_EmplaceTestClass } } -version(unittest) +version (unittest) { //Ambiguity private struct __std_conv_S diff --git a/std/datetime/date.d b/std/datetime/date.d index 7bb866c199e..2dc206c6f61 100644 --- a/std/datetime/date.d +++ b/std/datetime/date.d @@ -47,7 +47,7 @@ import std.traits : isSomeString, Unqual; import std.typecons : Flag; import std.range.primitives : isOutputRange; -version(unittest) import std.exception : assertThrown; +version (unittest) import std.exception : assertThrown; @safe unittest { @@ -10416,7 +10416,7 @@ if (isSomeString!T) } -version(unittest) +version (unittest) { private: // All of these helper arrays are sorted in ascending order. diff --git a/std/datetime/interval.d b/std/datetime/interval.d index 41d7eb89d8f..bf88e78743f 100644 --- a/std/datetime/interval.d +++ b/std/datetime/interval.d @@ -41,7 +41,7 @@ import std.range.primitives : isOutputRange; import std.traits : isIntegral, Unqual; import std.typecons : Flag; -version(unittest) import std.exception : assertThrown; +version (unittest) import std.exception : assertThrown; /++ diff --git a/std/datetime/systime.d b/std/datetime/systime.d index 906faa044b8..aed5c0461e4 100644 --- a/std/datetime/systime.d +++ b/std/datetime/systime.d @@ -78,19 +78,19 @@ import std.format : format; import std.range.primitives; import std.traits : isIntegral, isSigned, isSomeString, Unqual, isNarrowString; -version(Windows) +version (Windows) { import core.stdc.time : time_t; import core.sys.windows.windows; import core.sys.windows.winsock2; } -else version(Posix) +else version (Posix) { import core.sys.posix.signal : timespec; import core.sys.posix.sys.types : time_t; } -version(unittest) +version (unittest) { import core.exception : AssertError; import std.exception : assertThrown; @@ -140,7 +140,7 @@ public: // In particular, dmc does not use unix time. If we can guarantee that // the MS runtime uses unix time, then we may be able run this test // then, but for now, we're just not going to run this test on Windows. - version(Posix) + version (Posix) { static import core.stdc.time; static import std.math; @@ -188,7 +188,7 @@ public: static assert(0, format("ClockType.%s is not supported by Clock.currTime or Clock.currStdTime", clockType)); } - version(Windows) + version (Windows) { FILETIME fileTime; GetSystemTimeAsFileTime(&fileTime); @@ -205,12 +205,12 @@ public: else return result; } - else version(Posix) + else version (Posix) { static import core.stdc.time; enum hnsecsToUnixEpoch = unixTimeToStdTime(0); - version(OSX) + version (OSX) { static if (clockType == ClockType.second) return unixTimeToStdTime(core.stdc.time.time(null)); @@ -225,7 +225,7 @@ public: hnsecsToUnixEpoch; } } - else version(linux) + else version (linux) { static if (clockType == ClockType.second) return unixTimeToStdTime(core.stdc.time.time(null)); @@ -245,7 +245,7 @@ public: hnsecsToUnixEpoch; } } - else version(FreeBSD) + else version (FreeBSD) { import core.sys.freebsd.time : clock_gettime, CLOCK_REALTIME, CLOCK_REALTIME_FAST, CLOCK_REALTIME_PRECISE, CLOCK_SECOND; @@ -261,7 +261,7 @@ public: ts.tv_nsec / 100 + hnsecsToUnixEpoch; } - else version(NetBSD) + else version (NetBSD) { static if (clockType == ClockType.second) return unixTimeToStdTime(core.stdc.time.time(null)); @@ -276,7 +276,7 @@ public: hnsecsToUnixEpoch; } } - else version(DragonFlyBSD) + else version (DragonFlyBSD) { import core.sys.dragonflybsd.time : clock_gettime, CLOCK_REALTIME, CLOCK_REALTIME_FAST, CLOCK_REALTIME_PRECISE, CLOCK_SECOND; @@ -292,7 +292,7 @@ public: ts.tv_nsec / 100 + hnsecsToUnixEpoch; } - else version(Solaris) + else version (Solaris) { static if (clockType == ClockType.second) return unixTimeToStdTime(core.stdc.time.time(null)); @@ -402,7 +402,7 @@ private: struct SysTime { import core.stdc.time : tm; - version(Posix) import core.sys.posix.sys.time : timeval; + version (Posix) import core.sys.posix.sys.time : timeval; import std.typecons : Rebindable; public: @@ -2474,7 +2474,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { private struct timespec {} /++ @@ -2484,7 +2484,7 @@ public: +/ timespec toTimeSpec() @safe const pure nothrow scope; } - else version(Posix) + else version (Posix) { timespec toTimeSpec() @safe const pure nothrow scope { @@ -2548,7 +2548,7 @@ public: timeInfo.tm_yday = dateTime.dayOfYear - 1; timeInfo.tm_isdst = _timezone.dstInEffect(_stdTime); - version(Posix) + version (Posix) { import std.utf : toUTFz; timeInfo.tm_gmtoff = cast(int) convert!("hnsecs", "seconds")(adjTime - _stdTime); @@ -2564,7 +2564,7 @@ public: import std.conv : to; import core.time; - version(Posix) + version (Posix) { import std.datetime.timezone : clearTZEnvVar, setTZEnvVar; setTZEnvVar("America/Los_Angeles"); @@ -2583,12 +2583,12 @@ public: assert(timeInfo.tm_wday == 4); assert(timeInfo.tm_yday == 0); - version(Posix) + version (Posix) assert(timeInfo.tm_isdst == 0); - else version(Windows) + else version (Windows) assert(timeInfo.tm_isdst == 0 || timeInfo.tm_isdst == 1); - version(Posix) + version (Posix) { assert(timeInfo.tm_gmtoff == -8 * 60 * 60); assert(to!string(timeInfo.tm_zone) == "PST"); @@ -2607,12 +2607,12 @@ public: assert(timeInfo.tm_wday == 0); assert(timeInfo.tm_yday == 184); - version(Posix) + version (Posix) assert(timeInfo.tm_isdst == 1); - else version(Windows) + else version (Windows) assert(timeInfo.tm_isdst == 0 || timeInfo.tm_isdst == 1); - version(Posix) + version (Posix) { assert(timeInfo.tm_gmtoff == -7 * 60 * 60); assert(to!string(timeInfo.tm_zone) == "PDT"); @@ -2635,7 +2635,7 @@ public: assert(timeInfo.tm_yday == 0); assert(timeInfo.tm_isdst == 0); - version(Posix) + version (Posix) { assert(timeInfo.tm_gmtoff == 0); assert(to!string(timeInfo.tm_zone) == "SysTime.init's timezone"); @@ -6669,12 +6669,12 @@ public: assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)) - SysTime(DateTime(1, 1, 1, 0, 0, 0)) == dur!"hnsecs"(-1)); - version(Posix) + version (Posix) { import std.datetime.timezone : PosixTimeZone; immutable tz = PosixTimeZone.getTimeZone("America/Los_Angeles"); } - else version(Windows) + else version (Windows) { import std.datetime.timezone : WindowsTimeZone; immutable tz = WindowsTimeZone.getTimeZone("Pacific Standard Time"); @@ -9735,9 +9735,9 @@ if (is(T == int) || is(T == long)) } -version(StdDdoc) +version (StdDdoc) { - version(Windows) + version (Windows) {} else { @@ -9852,7 +9852,7 @@ version(StdDdoc) +/ FILETIME SysTimeToFILETIME(scope SysTime sysTime) @safe; } -else version(Windows) +else version (Windows) { SysTime SYSTEMTIMEToSysTime(const scope SYSTEMTIME* st, immutable TimeZone tz = LocalTime()) @safe { @@ -10417,7 +10417,7 @@ afterMon: stripAndCheckLen(value[3 .. value.length], "1200:00A".length); assertThrown!DateTimeException(parseRFC822DateTime(badStr)); } -version(unittest) private void testParse822(alias cr)(string str, SysTime expected, size_t line = __LINE__) +version (unittest) private void testParse822(alias cr)(string str, SysTime expected, size_t line = __LINE__) { import std.format : format; auto value = cr(str); @@ -10426,7 +10426,7 @@ version(unittest) private void testParse822(alias cr)(string str, SysTime expect throw new AssertError(format("wrong result. expected [%s], actual[%s]", expected, result), __FILE__, line); } -version(unittest) private void testBadParse822(alias cr)(string str, size_t line = __LINE__) +version (unittest) private void testBadParse822(alias cr)(string str, size_t line = __LINE__) { try parseRFC822DateTime(cr(str)); @@ -11363,7 +11363,7 @@ if (isIntegral!T && isSigned!T) // The constraints on R were already covered by } -version(unittest) +version (unittest) { private: // Variables to help in testing. @@ -11646,13 +11646,13 @@ private: immutable lt = LocalTime().utcToTZ(0); currLocalDiffFromUTC = dur!"hnsecs"(lt); - version(Posix) + version (Posix) { import std.datetime.timezone : PosixTimeZone; immutable otherTZ = lt < 0 ? PosixTimeZone.getTimeZone("Australia/Sydney") : PosixTimeZone.getTimeZone("America/Denver"); } - else version(Windows) + else version (Windows) { import std.datetime.timezone : WindowsTimeZone; immutable otherTZ = lt < 0 ? WindowsTimeZone.getTimeZone("AUS Eastern Standard Time") diff --git a/std/datetime/timezone.d b/std/datetime/timezone.d index fce854283f2..cd5eb5e0707 100644 --- a/std/datetime/timezone.d +++ b/std/datetime/timezone.d @@ -34,7 +34,7 @@ import std.datetime.systime;// : Clock, stdTimeToUnixTime, SysTime; import std.range.primitives;// : back, front, empty, popFront; import std.traits : isIntegral, isSomeString, Unqual; -version(Windows) +version (Windows) { import core.stdc.time : time_t; import core.sys.windows.windows; @@ -47,13 +47,13 @@ version(Windows) // for updating the translations. // version = UpdateWindowsTZTranslations; } -else version(Posix) +else version (Posix) { import core.sys.posix.signal : timespec; import core.sys.posix.sys.types : time_t; } -version(unittest) import std.exception : assertThrown; +version (unittest) import std.exception : assertThrown; /++ @@ -198,10 +198,10 @@ public: import std.stdio : writefln; import std.typecons : tuple; - version(Posix) alias getTimeZone = PosixTimeZone.getTimeZone; - else version(Windows) alias getTimeZone = WindowsTimeZone.getTimeZone; + version (Posix) alias getTimeZone = PosixTimeZone.getTimeZone; + else version (Windows) alias getTimeZone = WindowsTimeZone.getTimeZone; - version(Posix) scope(exit) clearTZEnvVar(); + version (Posix) scope(exit) clearTZEnvVar(); static immutable(TimeZone) testTZ(string tzName, string stdName, @@ -212,12 +212,12 @@ public: { scope(failure) writefln("Failed time zone: %s", tzName); - version(Posix) + version (Posix) { immutable tz = PosixTimeZone.getTimeZone(tzName); assert(tz.name == tzName); } - else version(Windows) + else version (Windows) { immutable tz = WindowsTimeZone.getTimeZone(tzName); assert(tz.name == stdName); @@ -246,7 +246,7 @@ public: assert(cast(DateTime) dst == dstDate); assert(std == stdUTC); - version(Posix) + version (Posix) { setTZEnvVar(tzName); @@ -321,14 +321,14 @@ public: /+Australia/Adelaide+/ tuple(DateTime(2012, 10, 7), DateTime(2012, 4, 1), 2, 3)]; import std.datetime.date : DateTimeException; - version(Posix) - { - version(FreeBSD) enum utcZone = "Etc/UTC"; - else version(NetBSD) enum utcZone = "UTC"; - else version(DragonFlyBSD) enum utcZone = "UTC"; - else version(linux) enum utcZone = "UTC"; - else version(OSX) enum utcZone = "UTC"; - else version(Solaris) enum utcZone = "UTC"; + version (Posix) + { + version (FreeBSD) enum utcZone = "Etc/UTC"; + else version (NetBSD) enum utcZone = "UTC"; + else version (DragonFlyBSD) enum utcZone = "UTC"; + else version (linux) enum utcZone = "UTC"; + else version (OSX) enum utcZone = "UTC"; + else version (Solaris) enum utcZone = "UTC"; else static assert(0, "The location of the UTC timezone file on this Posix platform must be set."); auto tzs = [testTZ("America/Los_Angeles", "PST", "PDT", dur!"hours"(-8), dur!"hours"(1)), @@ -346,7 +346,7 @@ public: testTZ(utcZone, "UTC", "UTC", dur!"hours"(0), dur!"hours"(0)); assertThrown!DateTimeException(PosixTimeZone.getTimeZone("hello_world")); } - else version(Windows) + else version (Windows) { auto tzs = [testTZ("Pacific Standard Time", "Pacific Standard Time", "Pacific Daylight Time", dur!"hours"(-8), dur!"hours"(1)), @@ -539,7 +539,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ In principle, this is the name of the local time zone. However, @@ -573,7 +573,7 @@ public: +/ @property override string stdName() @trusted const nothrow { - version(Posix) + version (Posix) { import core.stdc.time : tzname; import std.conv : to; @@ -582,7 +582,7 @@ public: catch (Exception e) assert(0, "to!string(tzname[0]) failed."); } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -617,12 +617,12 @@ public: @safe unittest { - version(FreeBSD) + version (FreeBSD) { // A bug on FreeBSD 9+ makes it so that this test fails. // https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=168862 } - else version(NetBSD) + else version (NetBSD) { // The same bug on NetBSD 7+ } @@ -630,7 +630,7 @@ public: { assert(LocalTime().stdName !is null); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -658,7 +658,7 @@ public: +/ @property override string dstName() @trusted const nothrow { - version(Posix) + version (Posix) { import core.stdc.time : tzname; import std.conv : to; @@ -667,7 +667,7 @@ public: catch (Exception e) assert(0, "to!string(tzname[1]) failed."); } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -703,21 +703,21 @@ public: @safe unittest { // tzname, called from dstName, isn't set by default for Musl. - version(CRuntime_Musl) + version (CRuntime_Musl) assert(LocalTime().dstName is null); else assert(LocalTime().dstName !is null); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); - version(FreeBSD) + version (FreeBSD) { // A bug on FreeBSD 9+ makes it so that this test fails. // https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=168862 } - else version(NetBSD) + else version (NetBSD) { // The same bug on NetBSD 7+ } @@ -741,7 +741,7 @@ public: +/ @property override bool hasDST() @trusted const nothrow { - version(Posix) + version (Posix) { static if (is(typeof(daylight))) return cast(bool)(daylight); @@ -762,7 +762,7 @@ public: assert(0, "Clock.currTime() threw."); } } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -775,7 +775,7 @@ public: { LocalTime().hasDST; - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -806,7 +806,7 @@ public: time_t unixTime = stdTimeToUnixTime(stdTime); - version(Posix) + version (Posix) { import core.sys.posix.time : localtime_r; @@ -815,7 +815,7 @@ public: return cast(bool)(timeInfo.tm_isdst); } - else version(Windows) + else version (Windows) { import core.stdc.time : localtime; @@ -856,9 +856,9 @@ public: +/ override long utcToTZ(long stdTime) @trusted const nothrow { - version(Solaris) + version (Solaris) return stdTime + convert!("seconds", "hnsecs")(tm_gmtoff(stdTime)); - else version(Posix) + else version (Posix) { import core.stdc.time : tm; import core.sys.posix.time : localtime_r; @@ -868,7 +868,7 @@ public: return stdTime + convert!("seconds", "hnsecs")(timeInfo.tm_gmtoff); } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -897,7 +897,7 @@ public: +/ override long tzToUTC(long adjTime) @trusted const nothrow { - version(Posix) + version (Posix) { import core.stdc.time : tm; import core.sys.posix.time : localtime_r; @@ -923,7 +923,7 @@ public: return adjTime - convert!("seconds", "hnsecs")(timeInfo.tm_gmtoff); } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -944,7 +944,7 @@ public: assert(LocalTime().tzToUTC(LocalTime().utcToTZ(0)) == 0); assert(LocalTime().utcToTZ(LocalTime().tzToUTC(0)) == 0); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -1101,7 +1101,7 @@ private: // The Solaris version of struct tm has no tm_gmtoff field, so do it here - version(Solaris) + version (Solaris) { long tm_gmtoff(long stdTime) @trusted const nothrow { @@ -1175,7 +1175,7 @@ public: { assert(UTC().utcToTZ(0) == 0); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -1208,7 +1208,7 @@ public: { assert(UTC().tzToUTC(0) == 0); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -1997,7 +1997,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ The default directory where the TZ Database files are stored. It's @@ -2009,24 +2009,24 @@ public: +/ enum defaultTZDatabaseDir = ""; } - else version(TZDatabaseDir) + else version (TZDatabaseDir) { import std.string : strip; enum defaultTZDatabaseDir = strip(import("TZDatabaseDirFile")); } - else version(Android) + else version (Android) { enum defaultTZDatabaseDir = "/system/usr/share/zoneinfo/"; } - else version(Solaris) + else version (Solaris) { enum defaultTZDatabaseDir = "/usr/share/lib/zoneinfo/"; } - else version(Posix) + else version (Posix) { enum defaultTZDatabaseDir = "/usr/share/zoneinfo/"; } - else version(Windows) + else version (Windows) { enum defaultTZDatabaseDir = ""; } @@ -2073,7 +2073,7 @@ public: enforce(tzDatabaseDir.exists(), new DateTimeException(format("Directory %s does not exist.", tzDatabaseDir))); enforce(tzDatabaseDir.isDir, new DateTimeException(format("%s is not a directory.", tzDatabaseDir))); - version(Android) + version (Android) { auto tzfileOffset = name in tzdataIndex(tzDatabaseDir); enforce(tzfileOffset, new DateTimeException(format("The time zone %s is not listed.", name))); @@ -2087,7 +2087,7 @@ public: enforce(file.isFile, new DateTimeException(format("%s is not a file.", file))); auto tzFile = File(file); - version(Android) tzFile.seek(*tzfileOffset); + version (Android) tzFile.seek(*tzfileOffset); immutable gmtZone = name.representation().canFind("GMT"); import std.datetime.date : DateTimeException; @@ -2273,7 +2273,7 @@ public: cast(void) tzFile.readln(); - version(Android) + version (Android) { // Android uses a single file for all timezone data, so the file // doesn't end here. @@ -2383,7 +2383,7 @@ public: /// @safe unittest { - version(Posix) + version (Posix) { auto tz = PosixTimeZone.getTimeZone("America/Los_Angeles"); @@ -2416,9 +2416,9 @@ public: import std.exception : enforce; import std.format : format; - version(Posix) + version (Posix) subName = strip(subName); - else version(Windows) + else version (Windows) { import std.array : replace; import std.path : dirSeparator; @@ -2431,7 +2431,7 @@ public: auto timezones = appender!(string[])(); - version(Android) + version (Android) { import std.algorithm.iteration : filter; import std.algorithm.mutation : copy; @@ -2464,7 +2464,7 @@ public: return timezones.data; } - version(Posix) @system unittest + version (Posix) @system unittest { import std.exception : assertNotThrown; import std.stdio : writefln; @@ -2489,7 +2489,7 @@ public: assertNotThrown!DateTimeException(testPTZSuccess(tzName)); // No timezone directories on Android, just a single tzdata file - version(Android) + version (Android) {} else { @@ -2728,7 +2728,7 @@ private: // tzdata, along with an index to jump to each timezone's offset. In older // versions of Android, the index was stored in a separate file, zoneinfo.idx, // whereas now it's stored at the beginning of tzdata. - version(Android) + version (Android) { // Keep track of whether there's a separate index, zoneinfo.idx. Only // check this after calling tzdataIndex, as it's initialized there. @@ -2809,7 +2809,7 @@ private: } -version(StdDdoc) +version (StdDdoc) { /++ $(BLUE This class is Windows-Only.) @@ -2923,7 +2923,7 @@ version(StdDdoc) private: - version(Windows) + version (Windows) {} else alias TIME_ZONE_INFORMATION = void*; @@ -2939,7 +2939,7 @@ version(StdDdoc) } } -else version(Windows) +else version (Windows) { final class WindowsTimeZone : TimeZone { @@ -3262,7 +3262,7 @@ else version(Windows) } -version(StdDdoc) +version (StdDdoc) { /++ $(BLUE This function is Posix-Only.) @@ -3283,7 +3283,7 @@ version(StdDdoc) +/ void clearTZEnvVar() @safe nothrow; } -else version(Posix) +else version (Posix) { void setTZEnvVar(string tzDatabaseName) @trusted nothrow { @@ -3292,7 +3292,7 @@ else version(Posix) import std.internal.cstring : tempCString; import std.path : asNormalizedPath, chainPath; - version(Android) + version (Android) auto value = asNormalizedPath(tzDatabaseName); else auto value = asNormalizedPath(chainPath(PosixTimeZone.defaultTZDatabaseDir, tzDatabaseName)); diff --git a/std/digest/hmac.d b/std/digest/hmac.d index 0102ca4fc2c..d1d8bd69c62 100644 --- a/std/digest/hmac.d +++ b/std/digest/hmac.d @@ -321,7 +321,7 @@ unittest import std.digest.sha : SHA1, SHA256; // Note, can't be UFCS because we don't want to import inside - // version(unittest). + // version (unittest). import std.digest : toHexString, LetterCase; alias hex = toHexString!(LetterCase.lower); diff --git a/std/digest/md.d b/std/digest/md.d index c95727e0e0c..6f06ceba24b 100644 --- a/std/digest/md.d +++ b/std/digest/md.d @@ -188,7 +188,7 @@ struct MD5 uint[16] x = void; - version(BigEndian) + version (BigEndian) { import std.bitmanip : littleEndianToNative; diff --git a/std/digest/murmurhash.d b/std/digest/murmurhash.d index 1ed9bd67369..b5b5bc74f98 100644 --- a/std/digest/murmurhash.d +++ b/std/digest/murmurhash.d @@ -685,7 +685,7 @@ the 'put' method. assert(hashed == [181, 151, 88, 252]); } -version(unittest) +version (unittest) { private auto hash(H, Element = H.Element)(string data) { diff --git a/std/digest/package.d b/std/digest/package.d index 871dafe3be9..9e03f074101 100644 --- a/std/digest/package.d +++ b/std/digest/package.d @@ -186,10 +186,10 @@ import std.traits; } } -version(StdDdoc) +version (StdDdoc) version = ExampleDigest; -version(ExampleDigest) +version (ExampleDigest) { /** * This documents the general structure of a Digest in the template API. @@ -960,7 +960,7 @@ if (isDigest!T) : Digest return buf; } - version(StdDdoc) + version (StdDdoc) { /** * Works like `finish` but does not reset the internal state, so it's possible diff --git a/std/digest/ripemd.d b/std/digest/ripemd.d index 14b8c1a437b..e5bfa670f08 100644 --- a/std/digest/ripemd.d +++ b/std/digest/ripemd.d @@ -233,7 +233,7 @@ struct RIPEMD160 uint[16] x = void; - version(BigEndian) + version (BigEndian) { import std.bitmanip : littleEndianToNative; diff --git a/std/digest/sha.d b/std/digest/sha.d index 3732364124e..110504c7171 100644 --- a/std/digest/sha.d +++ b/std/digest/sha.d @@ -101,21 +101,21 @@ module std.digest.sha; hash1 = sha1.finish(); } -version(Win64) +version (Win64) { // wrong calling convention } -else version(D_InlineAsm_X86) +else version (D_InlineAsm_X86) { version (D_PIC) {} // Bugzilla 9378 else private version = USE_SSSE3; } -else version(D_InlineAsm_X86_64) +else version (D_InlineAsm_X86_64) { private version = USE_SSSE3; } -version(LittleEndian) import core.bitop : bswap; +version (LittleEndian) import core.bitop : bswap; public import std.digest; @@ -125,7 +125,7 @@ public import std.digest; */ private ubyte[8] nativeToBigEndian(ulong val) @trusted pure nothrow @nogc { - version(LittleEndian) + version (LittleEndian) immutable ulong res = (cast(ulong) bswap(cast(uint) val)) << 32 | bswap(cast(uint) (val >> 32)); else immutable ulong res = val; @@ -134,7 +134,7 @@ private ubyte[8] nativeToBigEndian(ulong val) @trusted pure nothrow @nogc private ubyte[4] nativeToBigEndian(uint val) @trusted pure nothrow @nogc { - version(LittleEndian) + version (LittleEndian) immutable uint res = bswap(val); else immutable uint res = val; @@ -143,7 +143,7 @@ private ubyte[4] nativeToBigEndian(uint val) @trusted pure nothrow @nogc private ulong bigEndianToNative(ubyte[8] val) @trusted pure nothrow @nogc { - version(LittleEndian) + version (LittleEndian) { import std.bitmanip : bigEndianToNative; return bigEndianToNative!ulong(val); @@ -154,7 +154,7 @@ private ulong bigEndianToNative(ubyte[8] val) @trusted pure nothrow @nogc private uint bigEndianToNative(ubyte[4] val) @trusted pure nothrow @nogc { - version(LittleEndian) + version (LittleEndian) return bswap(*cast(uint*) &val); else return *cast(uint*) &val; @@ -203,7 +203,7 @@ struct SHA(uint hashBlockSize, uint digestSize) static if (digestSize == 160) /* SHA-1 */ { - version(USE_SSSE3) + version (USE_SSSE3) { import core.cpuid : ssse3; import std.internal.digest.sha_SSSE3 : sse3_constants=constants, transformSSSE3; @@ -1188,7 +1188,7 @@ auto sha512_256Of(T...)(T data) string a = "Mary has ", b = "a little lamb"; int[] c = [ 1, 2, 3, 4, 5 ]; auto d = toHexString(sha1Of(a, b, c)); - version(LittleEndian) + version (LittleEndian) assert(d[] == "CDBB611D00AC2387B642D3D7BDF4C3B342237110", d); else assert(d[] == "A0F1196C7A379C09390476D9CA4AA11B71FD11C8", d); diff --git a/std/encoding.d b/std/encoding.d index 3e3e15420c1..570c2e47a90 100644 --- a/std/encoding.d +++ b/std/encoding.d @@ -3504,8 +3504,8 @@ class EncodingSchemeUtf16Native : EncodingScheme const { - version(LittleEndian) { enum string NAME = "UTF-16LE"; } - version(BigEndian) { enum string NAME = "UTF-16BE"; } + version (LittleEndian) { enum string NAME = "UTF-16LE"; } + version (BigEndian) { enum string NAME = "UTF-16BE"; } override string[] names() @safe pure nothrow { @@ -3567,12 +3567,12 @@ class EncodingSchemeUtf16Native : EncodingScheme } @system unittest { - version(LittleEndian) + version (LittleEndian) { auto efrom = EncodingScheme.create("utf-16le"); ubyte[6] sample = [154,1, 155,1, 156,1]; } - version(BigEndian) + version (BigEndian) { auto efrom = EncodingScheme.create("utf-16be"); ubyte[6] sample = [1,154, 1,155, 1,156]; @@ -3600,8 +3600,8 @@ class EncodingSchemeUtf32Native : EncodingScheme const { - version(LittleEndian) { enum string NAME = "UTF-32LE"; } - version(BigEndian) { enum string NAME = "UTF-32BE"; } + version (LittleEndian) { enum string NAME = "UTF-32LE"; } + version (BigEndian) { enum string NAME = "UTF-32BE"; } override string[] names() @safe pure nothrow { @@ -3663,12 +3663,12 @@ class EncodingSchemeUtf32Native : EncodingScheme } @system unittest { - version(LittleEndian) + version (LittleEndian) { auto efrom = EncodingScheme.create("utf-32le"); ubyte[12] sample = [154,1,0,0, 155,1,0,0, 156,1,0,0]; } - version(BigEndian) + version (BigEndian) { auto efrom = EncodingScheme.create("utf-32be"); ubyte[12] sample = [0,0,1,154, 0,0,1,155, 0,0,1,156]; @@ -3766,7 +3766,7 @@ if (isForwardRange!Range && is(Unqual!(ElementType!Range) == ubyte)) auto ts = dchar(0x0000FEFF) ~ "Hello World"d; auto entry = getBOM(cast(ubyte[]) ts); - version(BigEndian) + version (BigEndian) { assert(entry.schema == BOM.utf32be, format("%s", entry.schema)); } diff --git a/std/exception.d b/std/exception.d index 324a9934827..6c2e799c711 100644 --- a/std/exception.d +++ b/std/exception.d @@ -554,7 +554,7 @@ private void bailOut(E : Throwable = Exception)(string file, size_t line, scope enum expect = (BodySafe || !EncloseSafe) && (!EnclosePure || BodyPure); - version(none) + version (none) pragma(msg, "safe = ", EncloseSafe?1:0, "/", BodySafe?1:0, ", ", "pure = ", EnclosePure?1:0, "/", BodyPure?1:0, ", ", "expect = ", expect?"OK":"NG", ", ", @@ -1309,7 +1309,7 @@ bool mayPointTo(S, T)(auto ref const shared S source, ref const shared T target) } -version(unittest) +version (unittest) { // 17084 : the bug doesn't happen if these declarations are // in the unittest block (static or not). @@ -1850,7 +1850,7 @@ expression. static assert(!__traits(compiles, (new Object()).ifThrown(e=>1))); } -version(unittest) package +version (unittest) package void assertCTFEable(alias dg)() { static assert({ cast(void) dg(); return true; }()); diff --git a/std/experimental/allocator/building_blocks/allocator_list.d b/std/experimental/allocator/building_blocks/allocator_list.d index b6fe9d00ce7..af9be3e305b 100644 --- a/std/experimental/allocator/building_blocks/allocator_list.d +++ b/std/experimental/allocator/building_blocks/allocator_list.d @@ -616,7 +616,7 @@ template AllocatorList(alias factoryFunction, } /// -version(Posix) @system unittest +version (Posix) @system unittest { import std.algorithm.comparison : max; import std.experimental.allocator.building_blocks.free_list : ContiguousFreeList; diff --git a/std/experimental/allocator/building_blocks/ascending_page_allocator.d b/std/experimental/allocator/building_blocks/ascending_page_allocator.d index 25d47b86ca7..af2fc370ea7 100644 --- a/std/experimental/allocator/building_blocks/ascending_page_allocator.d +++ b/std/experimental/allocator/building_blocks/ascending_page_allocator.d @@ -11,7 +11,7 @@ private mixin template AscendingPageAllocatorImpl(bool isShared) bool deallocate(void[] buf) nothrow @nogc { size_t goodSize = goodAllocSize(buf.length); - version(Posix) + version (Posix) { import core.sys.posix.sys.mman : mmap, MAP_FAILED, MAP_PRIVATE, MAP_ANON, MAP_FIXED, PROT_NONE, munmap; @@ -20,7 +20,7 @@ private mixin template AscendingPageAllocatorImpl(bool isShared) if (ptr == MAP_FAILED) return false; } - else version(Windows) + else version (Windows) { import core.sys.windows.windows : VirtualFree, MEM_RELEASE, MEM_DECOMMIT; @@ -50,14 +50,14 @@ private mixin template AscendingPageAllocatorImpl(bool isShared) bool deallocateAll() nothrow @nogc { - version(Posix) + version (Posix) { import core.sys.posix.sys.mman : munmap; auto ret = munmap(cast(void*) data, numPages * pageSize); if (ret != 0) assert(0, "Failed to unmap memory, munmap failure"); } - else version(Windows) + else version (Windows) { import core.sys.windows.windows : VirtualFree, MEM_RELEASE; auto ret = VirtualFree(cast(void*) data, 0, MEM_RELEASE); @@ -85,7 +85,7 @@ private mixin template AscendingPageAllocatorImpl(bool isShared) lock = SpinLock(SpinLock.Contention.brief); } - version(Posix) + version (Posix) { import core.sys.posix.sys.mman : mmap, MAP_ANON, PROT_NONE, MAP_PRIVATE, MAP_FAILED; @@ -98,7 +98,7 @@ private mixin template AscendingPageAllocatorImpl(bool isShared) if (data == MAP_FAILED) assert(0, "Failed to mmap memory"); } - else version(Windows) + else version (Windows) { import core.sys.windows.windows : VirtualAlloc, PAGE_NOACCESS, MEM_RESERVE, GetSystemInfo, SYSTEM_INFO; @@ -139,14 +139,14 @@ private mixin template AscendingPageAllocatorImpl(bool isShared) // Sets the protection of a memory range to read/write private bool extendMemoryProtection(void* start, size_t size) nothrow @nogc { - version(Posix) + version (Posix) { import core.sys.posix.sys.mman : mprotect, PROT_WRITE, PROT_READ; auto ret = mprotect(start, size, PROT_WRITE | PROT_READ); return ret == 0; } - else version(Windows) + else version (Windows) { import core.sys.windows.windows : VirtualAlloc, MEM_COMMIT, PAGE_READWRITE; @@ -660,7 +660,7 @@ public: tg.joinAll(); } -version(unittest) +version (unittest) { private static void testrw(void[] b) @nogc nothrow { @@ -674,13 +674,13 @@ version(unittest) private static size_t getPageSize() @nogc nothrow { size_t pageSize; - version(Posix) + version (Posix) { import core.sys.posix.unistd : sysconf, _SC_PAGESIZE; pageSize = cast(size_t) sysconf(_SC_PAGESIZE); } - else version(Windows) + else version (Windows) { import core.sys.windows.windows : GetSystemInfo, SYSTEM_INFO; diff --git a/std/experimental/allocator/building_blocks/bitmapped_block.d b/std/experimental/allocator/building_blocks/bitmapped_block.d index 33da3480488..22e7a8646bd 100644 --- a/std/experimental/allocator/building_blocks/bitmapped_block.d +++ b/std/experimental/allocator/building_blocks/bitmapped_block.d @@ -1208,7 +1208,7 @@ Params: struct BitmappedBlock(size_t theBlockSize, uint theAlignment = platformAlignment, ParentAllocator = NullAllocator, Flag!"multiblock" f = Yes.multiblock) { - version(StdDdoc) + version (StdDdoc) { /** Constructs a block allocator given a hunk of memory, or a desired capacity @@ -1489,7 +1489,7 @@ Params: shared struct SharedBitmappedBlock(size_t theBlockSize, uint theAlignment = platformAlignment, ParentAllocator = NullAllocator, Flag!"multiblock" f = Yes.multiblock) { - version(StdDdoc) + version (StdDdoc) { /** Constructs a block allocator given a hunk of memory, or a desired capacity @@ -1640,7 +1640,7 @@ shared struct SharedBitmappedBlock(size_t theBlockSize, uint theAlignment = plat } else { - version(unittest) + version (unittest) @system unittest { import std.algorithm.comparison : max; diff --git a/std/experimental/allocator/building_blocks/kernighan_ritchie.d b/std/experimental/allocator/building_blocks/kernighan_ritchie.d index ef6a7b12a87..f335b6a6500 100644 --- a/std/experimental/allocator/building_blocks/kernighan_ritchie.d +++ b/std/experimental/allocator/building_blocks/kernighan_ritchie.d @@ -494,7 +494,7 @@ struct KRRegion(ParentAllocator = NullAllocator) return true; } - version(assert) foreach (test; byNodePtr) + version (assert) foreach (test; byNodePtr) { assert(test != n); } diff --git a/std/experimental/allocator/building_blocks/region.d b/std/experimental/allocator/building_blocks/region.d index 7c1d4a35c5f..5713bae9592 100644 --- a/std/experimental/allocator/building_blocks/region.d +++ b/std/experimental/allocator/building_blocks/region.d @@ -707,7 +707,7 @@ struct InSituRegion(size_t size, size_t minAlign = platformAlignment) assert((() nothrow @nogc => r2.deallocateAll())()); } -version(CRuntime_Musl) +version (CRuntime_Musl) { // sbrk and brk are disabled in Musl: // https://git.musl-libc.org/cgit/musl/commit/?id=7a995fe706e519a4f55399776ef0df9596101f93 @@ -729,8 +729,8 @@ that uncontrolled calls to `brk` and `sbrk` may affect the workings of $(D SbrkRegion) adversely. */ -version(CRuntime_Musl) {} else -version(Posix) struct SbrkRegion(uint minAlign = platformAlignment) +version (CRuntime_Musl) {} else +version (Posix) struct SbrkRegion(uint minAlign = platformAlignment) { import core.sys.posix.pthread : pthread_mutex_init, pthread_mutex_destroy, pthread_mutex_t, pthread_mutex_lock, pthread_mutex_unlock, @@ -910,8 +910,8 @@ version(Posix) struct SbrkRegion(uint minAlign = platformAlignment) } } -version(CRuntime_Musl) {} else -version(Posix) @system nothrow @nogc unittest +version (CRuntime_Musl) {} else +version (Posix) @system nothrow @nogc unittest { // Let's test the assumption that sbrk(n) returns the old address const p1 = sbrk(0); @@ -923,8 +923,8 @@ version(Posix) @system nothrow @nogc unittest sbrk(-4096); } -version(CRuntime_Musl) {} else -version(Posix) @system nothrow @nogc unittest +version (CRuntime_Musl) {} else +version (Posix) @system nothrow @nogc unittest { import std.typecons : Ternary; import std.algorithm.comparison : min; @@ -947,7 +947,7 @@ version(Posix) @system nothrow @nogc unittest assert((() nothrow @safe @nogc => alloc.owns(a))() == Ternary.yes); assert((() nothrow @safe @nogc => alloc.owns(b))() == Ternary.yes); // reducing the brk does not work on OSX - version(OSX) {} else + version (OSX) {} else { assert((() nothrow @nogc => alloc.deallocate(b))()); // Check that expand and deallocate work well diff --git a/std/experimental/allocator/common.d b/std/experimental/allocator/common.d index 78a66ef06bb..5057ae81528 100644 --- a/std/experimental/allocator/common.d +++ b/std/experimental/allocator/common.d @@ -482,7 +482,7 @@ Forwards each of the methods in `funs` (if defined) to `member`. return result; } -version(unittest) +version (unittest) { package void testAllocator(alias make)() diff --git a/std/experimental/allocator/mallocator.d b/std/experimental/allocator/mallocator.d index 4ab61958d16..2b015ca811c 100644 --- a/std/experimental/allocator/mallocator.d +++ b/std/experimental/allocator/mallocator.d @@ -120,7 +120,7 @@ version (Windows) { // DMD Win 32 bit, DigitalMars C standard library misses the _aligned_xxx // functions family (snn.lib) - version(CRuntime_DigitalMars) + version (CRuntime_DigitalMars) { // Helper to cast the infos written before the aligned pointer // this header keeps track of the size (required to realloc) and of @@ -233,7 +233,7 @@ struct AlignedMallocator $(HTTP msdn.microsoft.com/en-us/library/8z34s9c6(v=vs.80).aspx, `__aligned_malloc`) on Windows. */ - version(Posix) + version (Posix) @trusted @nogc nothrow void[] alignedAllocate(size_t bytes, uint a) shared { @@ -243,8 +243,8 @@ struct AlignedMallocator void* result; auto code = posix_memalign(&result, a, bytes); -version(OSX) -version(LDC_AddressSanitizer) +version (OSX) +version (LDC_AddressSanitizer) { // The return value with AddressSanitizer may be -1 instead of ENOMEM // or EINVAL. See https://bugs.llvm.org/show_bug.cgi?id=36510 @@ -265,7 +265,7 @@ version(LDC_AddressSanitizer) else return result[0 .. bytes]; } - else version(Windows) + else version (Windows) @trusted @nogc nothrow void[] alignedAllocate(size_t bytes, uint a) shared { @@ -371,7 +371,7 @@ version(LDC_AddressSanitizer) //... } -version(Posix) +version (Posix) @nogc @system nothrow unittest { // 16398 : test the "pseudo" alignedReallocate for Posix @@ -398,7 +398,7 @@ version(Posix) AlignedMallocator.instance.deallocate(c); } -version(CRuntime_DigitalMars) +version (CRuntime_DigitalMars) @nogc @system nothrow unittest { void* m; diff --git a/std/experimental/allocator/mmap_allocator.d b/std/experimental/allocator/mmap_allocator.d index bf40b07a89a..2b124fe97f6 100644 --- a/std/experimental/allocator/mmap_allocator.d +++ b/std/experimental/allocator/mmap_allocator.d @@ -25,7 +25,7 @@ struct MmapAllocator */ enum size_t alignment = 4096; - version(Posix) + version (Posix) { /// Allocator API. pure nothrow @nogc @safe @@ -56,20 +56,20 @@ struct MmapAllocator // Anonymous mmap might be zero-filled on all Posix systems but // not all commit to this in the documentation. - version(linux) + version (linux) // http://man7.org/linux/man-pages/man2/mmap.2.html package alias allocateZeroed = allocate; - else version(NetBSD) + else version (NetBSD) // http://netbsd.gw.com/cgi-bin/man-cgi?mmap+2+NetBSD-current package alias allocateZeroed = allocate; - else version(Solaris) + else version (Solaris) // https://docs.oracle.com/cd/E88353_01/html/E37841/mmap-2.html package alias allocateZeroed = allocate; - else version(AIX) + else version (AIX) // https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.basetrf1/mmap.htm package alias allocateZeroed = allocate; } - else version(Windows) + else version (Windows) { import core.sys.windows.windows : MEM_COMMIT, PAGE_READWRITE, MEM_RELEASE; @@ -105,7 +105,7 @@ struct MmapAllocator // pure wrappers around `mmap` and `munmap` because they are used here locally // solely to perform allocation and deallocation which in this case is `pure` -version(Posix) +version (Posix) extern (C) private pure @system @nogc nothrow { import core.sys.posix.sys.types : off_t; @@ -116,7 +116,7 @@ extern (C) private pure @system @nogc nothrow // Pure wrappers around VirtualAlloc/VirtualFree for use here only. Their use is sound // because when we call them we ensure that last-error is not visibly changed. -version(Windows) +version (Windows) extern (Windows) private pure @system @nogc nothrow { import core.sys.windows.basetsd : SIZE_T; diff --git a/std/experimental/allocator/package.d b/std/experimental/allocator/package.d index 92ef92c844e..2d2674a8d75 100644 --- a/std/experimental/allocator/package.d +++ b/std/experimental/allocator/package.d @@ -2068,7 +2068,7 @@ if (isInputRange!R && !isInfinite!R) assert(arr2.map!`a.val`.equal(iota(32, 204, 2))); } -version(unittest) +version (unittest) { private struct ForcedInputRange { @@ -2377,7 +2377,7 @@ if (is(T == class) || is(T == interface)) if (!p) return; static if (is(T == interface)) { - version(Windows) + version (Windows) { import core.sys.windows.unknwn : IUnknown; static assert(!is(T: IUnknown), "COM interfaces can't be destroyed in " diff --git a/std/experimental/checkedint.d b/std/experimental/checkedint.d index 8aef9391872..86396cb1ac0 100644 --- a/std/experimental/checkedint.d +++ b/std/experimental/checkedint.d @@ -2709,7 +2709,7 @@ if (isIntegral!T && T.sizeof >= 4) testPow!ulong(3, 41); } -version(unittest) private struct CountOverflows +version (unittest) private struct CountOverflows { uint calls; auto onOverflow(string op, Lhs)(Lhs lhs) @@ -2734,7 +2734,7 @@ version(unittest) private struct CountOverflows } } -version(unittest) private struct CountOpBinary +version (unittest) private struct CountOpBinary { uint calls; auto hookOpBinary(string op, Lhs, Rhs)(Lhs lhs, Rhs rhs) diff --git a/std/experimental/logger/core.d b/std/experimental/logger/core.d index 4d50b165007..eff547888af 100644 --- a/std/experimental/logger/core.d +++ b/std/experimental/logger/core.d @@ -1846,7 +1846,7 @@ package class TestLogger : Logger } } -version(unittest) private void testFuncNames(Logger logger) @safe +version (unittest) private void testFuncNames(Logger logger) @safe { string s = "I'm here"; logger.log(s); diff --git a/std/experimental/typecons.d b/std/experimental/typecons.d index d642557ad2b..d55e4ec9fe0 100644 --- a/std/experimental/typecons.d +++ b/std/experimental/typecons.d @@ -184,7 +184,7 @@ if (Targets.length >= 1 && allSatisfy!(isInterface, Targets)) { import std.meta : ApplyLeft, staticMap; - version(StdDdoc) + version (StdDdoc) { /** * Wrap src in an anonymous class implementing $(D_PARAM Targets). @@ -406,7 +406,7 @@ private string unwrapExceptionText(Source, Target)() return Target.stringof~ " not wrapped into "~ Source.stringof; } -version(StdDdoc) +version (StdDdoc) { /** * Extract object previously wrapped by $(LREF wrap). diff --git a/std/file.d b/std/file.d index 88fcb0723ab..55a85a6b9c4 100644 --- a/std/file.d +++ b/std/file.d @@ -134,7 +134,7 @@ else return _deleteme; } -version(unittest) private struct TestAliasedString +version (unittest) private struct TestAliasedString { string get() @safe @nogc pure nothrow { return _s; } alias get this; @@ -142,12 +142,12 @@ version(unittest) private struct TestAliasedString string _s; } -version(Android) +version (Android) { package enum system_directory = "/system/etc"; package enum system_file = "/system/etc/hosts"; } -else version(Posix) +else version (Posix) { package enum system_directory = "/usr/include"; package enum system_file = "/usr/include/assert.h"; @@ -202,14 +202,14 @@ class FileException : Exception line = The _line where the error occurred. Defaults to `__LINE__`. +/ - version(Windows) this(scope const(char)[] name, + version (Windows) this(scope const(char)[] name, uint errno = .GetLastError(), string file = __FILE__, size_t line = __LINE__) @safe { this(name, sysErrorString(errno), file, line, errno); } - else version(Posix) this(scope const(char)[] name, + else version (Posix) this(scope const(char)[] name, uint errno = .errno, string file = __FILE__, size_t line = __LINE__) @trusted @@ -534,14 +534,14 @@ if (isSomeString!S && (isInputRange!R && !isInfinite!R && isSomeChar!(ElementTyp case utf8: throw new UTFException("UTF-16 requested. BOM is for UTF-8"); case utf16be: { - version(BigEndian) + version (BigEndian) break; else throw new UTFException("BOM is for UTF-16 LE on Big Endian machine"); } case utf16le: { - version(BigEndian) + version (BigEndian) throw new UTFException("BOM is for UTF-16 BE on Little Endian machine"); else break; @@ -560,14 +560,14 @@ if (isSomeString!S && (isInputRange!R && !isInfinite!R && isSomeChar!(ElementTyp case utf16le: throw new UTFException("UTF-8 requested. BOM is for UTF-16"); case utf32be: { - version(BigEndian) + version (BigEndian) break; else throw new UTFException("BOM is for UTF-32 LE on Big Endian machine"); } case utf32le: { - version(BigEndian) + version (BigEndian) throw new UTFException("BOM is for UTF-32 BE on Little Endian machine"); else break; @@ -689,7 +689,7 @@ if (isSomeString!S && (isInputRange!R && !isInfinite!R && isSomeChar!(ElementTyp assertThrown!UTFException(readText!wstring(none8)); assert(readText!wstring(none16) == "京都市"w); assertThrown!UTFException(readText!wstring(utf8)); - version(BigEndian) + version (BigEndian) { assert(readText!wstring(utf16be) == "\uFEFF京都市"w); assertThrown!UTFException(readText!wstring(utf16le)); @@ -706,7 +706,7 @@ if (isSomeString!S && (isInputRange!R && !isInfinite!R && isSomeChar!(ElementTyp assertThrown!UTFException(readText!dstring(utf8)); assertThrown!UTFException(readText!dstring(utf16be)); assertThrown!UTFException(readText!dstring(utf16le)); - version(BigEndian) + version (BigEndian) { assert(readText!dstring(utf32be) == "\U0000FEFF京都市"d); assertThrown!UTFException(readText!dstring(utf32le)); @@ -819,7 +819,7 @@ if (isConvertibleToString!R) // Posix implementation helper for write and append -version(Posix) private void writeImpl(scope const(char)[] name, scope const(FSChar)* namez, +version (Posix) private void writeImpl(scope const(char)[] name, scope const(FSChar)* namez, scope const(void)[] buffer, bool append) @trusted { import std.conv : octal; @@ -850,7 +850,7 @@ version(Posix) private void writeImpl(scope const(char)[] name, scope const(FSCh // Windows implementation helper for write and append -version(Windows) private void writeImpl(scope const(char)[] name, scope const(FSChar)* namez, +version (Windows) private void writeImpl(scope const(char)[] name, scope const(FSChar)* namez, scope const(void)[] buffer, bool append) @trusted { HANDLE h; @@ -957,7 +957,7 @@ if (isConvertibleToString!RF || isConvertibleToString!RT) private void renameImpl(scope const(char)[] f, scope const(char)[] t, scope const(FSChar)* fromz, scope const(FSChar)* toz) @trusted { - version(Windows) + version (Windows) { import std.exception : enforce; @@ -978,7 +978,7 @@ private void renameImpl(scope const(char)[] f, scope const(char)[] t, text("Attempting to rename file ", f, " to ", t))); } } - else version(Posix) + else version (Posix) { static import core.stdc.stdio; @@ -1046,11 +1046,11 @@ if (isConvertibleToString!R) private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @trusted { - version(Windows) + version (Windows) { cenforce(DeleteFileW(namez), name, namez); } - else version(Posix) + else version (Posix) { static import core.stdc.stdio; @@ -1065,7 +1065,7 @@ private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @t } } -version(Windows) private WIN32_FILE_ATTRIBUTE_DATA getFileAttributesWin(R)(R name) +version (Windows) private WIN32_FILE_ATTRIBUTE_DATA getFileAttributesWin(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) { auto namez = name.tempCString!FSChar(); @@ -1099,7 +1099,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) return fad; } -version(Windows) private ulong makeUlong(DWORD dwLow, DWORD dwHigh) @safe pure nothrow @nogc +version (Windows) private ulong makeUlong(DWORD dwLow, DWORD dwHigh) @safe pure nothrow @nogc { ULARGE_INTEGER li; li.LowPart = dwLow; @@ -1121,12 +1121,12 @@ ulong getSize(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) { with (getFileAttributesWin(name)) return makeUlong(nFileSizeLow, nFileSizeHigh); } - else version(Posix) + else version (Posix) { auto namez = name.tempCString(); @@ -1183,7 +1183,7 @@ if (isConvertibleToString!R) } // Reads a time field from a stat_t with full precision. -version(Posix) +version (Posix) private SysTime statTimeToStdTime(char which)(ref const stat_t statbuf) { auto unixTime = mixin(`statbuf.st_` ~ which ~ `time`); @@ -1221,7 +1221,7 @@ void getTimes(R)(R name, if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) { import std.datetime.systime : FILETIMEToSysTime; @@ -1231,7 +1231,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && modificationTime = FILETIMEToSysTime(&ftLastWriteTime); } } - else version(Posix) + else version (Posix) { auto namez = name.tempCString(); @@ -1314,7 +1314,7 @@ if (isConvertibleToString!R) assert(abs(diffm) <= leeway); } - version(fullFileTests) + version (fullFileTests) { import core.thread; enum sleepTime = dur!"seconds"(2); @@ -1344,7 +1344,7 @@ if (isConvertibleToString!R) } -version(StdDdoc) +version (StdDdoc) { /++ $(BLUE This function is Windows-Only.) @@ -1370,7 +1370,7 @@ version(StdDdoc) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R); } -else version(Windows) +else version (Windows) { void getTimesWin(R)(R name, out SysTime fileCreationTime, @@ -1399,7 +1399,7 @@ else version(Windows) } } -version(Windows) @system unittest +version (Windows) @system unittest { import std.stdio : writefln; auto currTime = Clock.currTime(); @@ -1431,7 +1431,7 @@ version(Windows) @system unittest assert(abs(diffm) <= leeway); } - version(fullFileTests) + version (fullFileTests) { import core.thread; Thread.sleep(dur!"seconds"(2)); @@ -1487,7 +1487,7 @@ void setTimes(R)(R name, if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) { import std.datetime.systime : SysTimeToFILETIME; @@ -1535,7 +1535,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && cenforce(trustedSetFileTime(h, null, ta, tm), names, namez); } - else version(Posix) + else version (Posix) { auto namez = name.tempCString!FSChar(); static if (is(typeof(&utimensat))) @@ -1656,7 +1656,7 @@ SysTime timeLastModified(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) { SysTime dummy; SysTime ftm; @@ -1665,7 +1665,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && return ftm; } - else version(Posix) + else version (Posix) { auto namez = name.tempCString!FSChar(); static auto trustedStat(const(FSChar)* namez, ref stat_t buf) @trusted @@ -1744,7 +1744,7 @@ else SysTime timeLastModified(R)(R name, SysTime returnIfMissing) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) { - version(Windows) + version (Windows) { if (!exists(name)) return returnIfMissing; @@ -1756,7 +1756,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) return ftm; } - else version(Posix) + else version (Posix) { auto namez = name.tempCString!FSChar(); static auto trustedStat(const(FSChar)* namez, ref stat_t buf) @trusted @@ -1788,7 +1788,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) assert(target.timeLastModified(SysTime.min) >= source.timeLastModified); } -version(StdDdoc) +version (StdDdoc) { /++ $(BLUE This function is Posix-Only.) @@ -1815,7 +1815,7 @@ version(StdDdoc) +/ SysTime timeStatusChanged()(auto ref stat_t statbuf) pure nothrow {assert(false);} } -else version(Posix) +else version (Posix) { SysTime timeLastModified()(auto ref stat_t statbuf) pure nothrow { @@ -1925,13 +1925,13 @@ if (isConvertibleToString!R) private bool existsImpl(const(FSChar)* namez) @trusted nothrow @nogc { - version(Windows) + version (Windows) { // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ // fileio/base/getfileattributes.asp return GetFileAttributesW(namez) != 0xFFFFFFFF; } - else version(Posix) + else version (Posix) { /* The reason why we use stat (and not access) here is @@ -2001,7 +2001,7 @@ uint getAttributes(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) { auto namez = name.tempCString!FSChar(); static auto trustedGetFileAttributesW(const(FSChar)* namez) @trusted @@ -2018,7 +2018,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && return result; } - else version(Posix) + else version (Posix) { auto namez = name.tempCString!FSChar(); static auto trustedStat(const(FSChar)* namez, ref stat_t buf) @trusted @@ -2106,11 +2106,11 @@ uint getLinkAttributes(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) { return getAttributes(name); } - else version(Posix) + else version (Posix) { auto namez = name.tempCString!FSChar(); static auto trustedLstat(const(FSChar)* namez, ref stat_t buf) @trusted @@ -2146,7 +2146,7 @@ if (isConvertibleToString!R) assertThrown!FileException(source.getLinkAttributes); // symlinking isn't available on Windows - version(Posix) + version (Posix) { scope(exit) source.remove, target.remove; @@ -2259,7 +2259,7 @@ if (isConvertibleToString!R) import std.conv : octal; auto f = deleteme ~ "file"; - version(Posix) + version (Posix) { scope(exit) f.remove; @@ -2285,7 +2285,7 @@ if (isConvertibleToString!R) import std.conv : octal; auto dir = deleteme ~ "dir"; - version(Posix) + version (Posix) { scope(exit) dir.rmdir; @@ -2320,11 +2320,11 @@ if (isConvertibleToString!R) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) { return (getAttributes(name) & FILE_ATTRIBUTE_DIRECTORY) != 0; } - else version(Posix) + else version (Posix) { return (getAttributes(name) & S_IFMT) == S_IFDIR; } @@ -2364,7 +2364,7 @@ if (isConvertibleToString!R) @safe unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) assert("C:\\Program Files\\".isDir); @@ -2372,7 +2372,7 @@ if (isConvertibleToString!R) if ("C:\\Windows\\system.ini".exists) assert(!"C:\\Windows\\system.ini".isDir); } - else version(Posix) + else version (Posix) { if (system_directory.exists) assert(system_directory.isDir); @@ -2384,9 +2384,9 @@ if (isConvertibleToString!R) @system unittest { - version(Windows) + version (Windows) enum dir = "C:\\Program Files\\"; - else version(Posix) + else version (Posix) enum dir = system_directory; if (dir.exists) @@ -2408,11 +2408,11 @@ if (isConvertibleToString!R) +/ bool attrIsDir(uint attributes) @safe pure nothrow @nogc { - version(Windows) + version (Windows) { return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } - else version(Posix) + else version (Posix) { return (attributes & S_IFMT) == S_IFDIR; } @@ -2441,7 +2441,7 @@ bool attrIsDir(uint attributes) @safe pure nothrow @nogc @safe unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) { @@ -2455,7 +2455,7 @@ bool attrIsDir(uint attributes) @safe pure nothrow @nogc assert(!attrIsDir(getLinkAttributes("C:\\Windows\\system.ini"))); } } - else version(Posix) + else version (Posix) { if (system_directory.exists) { @@ -2500,9 +2500,9 @@ bool attrIsDir(uint attributes) @safe pure nothrow @nogc if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) return !name.isDir; - else version(Posix) + else version (Posix) return (getAttributes(name) & S_IFMT) == S_IFREG; } @@ -2545,7 +2545,7 @@ if (isConvertibleToString!R) @safe unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) assert(!"C:\\Program Files\\".isFile); @@ -2553,7 +2553,7 @@ if (isConvertibleToString!R) if ("C:\\Windows\\system.ini".exists) assert("C:\\Windows\\system.ini".isFile); } - else version(Posix) + else version (Posix) { if (system_directory.exists) assert(!system_directory.isFile); @@ -2592,11 +2592,11 @@ assert(attrIsFile(getLinkAttributes("/etc/fonts/fonts.conf"))); +/ bool attrIsFile(uint attributes) @safe pure nothrow @nogc { - version(Windows) + version (Windows) { return (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0; } - else version(Posix) + else version (Posix) { return (attributes & S_IFMT) == S_IFREG; } @@ -2625,7 +2625,7 @@ bool attrIsFile(uint attributes) @safe pure nothrow @nogc @safe unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) { @@ -2639,7 +2639,7 @@ bool attrIsFile(uint attributes) @safe pure nothrow @nogc assert(attrIsFile(getLinkAttributes("C:\\Windows\\system.ini"))); } } - else version(Posix) + else version (Posix) { if (system_directory.exists) { @@ -2675,9 +2675,9 @@ bool attrIsFile(uint attributes) @safe pure nothrow @nogc if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) return (getAttributes(name) & FILE_ATTRIBUTE_REPARSE_POINT) != 0; - else version(Posix) + else version (Posix) return (getLinkAttributes(name) & S_IFMT) == S_IFLNK; } @@ -2705,7 +2705,7 @@ if (isConvertibleToString!R) assertThrown!FileException(source.isSymlink); // symlinking isn't available on Windows - version(Posix) + version (Posix) { scope(exit) source.remove, target.remove; @@ -2719,7 +2719,7 @@ if (isConvertibleToString!R) @system unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) assert(!"C:\\Program Files\\".isSymlink); @@ -2744,7 +2744,7 @@ if (isConvertibleToString!R) assert(getAttributes(fakeSymFile) == getLinkAttributes(fakeSymFile)); } } - else version(Posix) + else version (Posix) { if (system_directory.exists) { @@ -2813,9 +2813,9 @@ assert(getLinkAttributes("/tmp/alink").isSymlink); +/ bool attrIsSymlink(uint attributes) @safe pure nothrow @nogc { - version(Windows) + version (Windows) return (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; - else version(Posix) + else version (Posix) return (attributes & S_IFMT) == S_IFLNK; } @@ -2831,7 +2831,7 @@ bool attrIsSymlink(uint attributes) @safe pure nothrow @nogc assertThrown!FileException(source.getLinkAttributes.attrIsSymlink); // symlinking isn't available on Windows - version(Posix) + version (Posix) { scope(exit) source.remove, target.remove; @@ -2859,14 +2859,14 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && // Place outside of @trusted block auto pathz = pathname.tempCString!FSChar(); - version(Windows) + version (Windows) { static auto trustedChdir(const(FSChar)* pathz) @trusted { return SetCurrentDirectoryW(pathz); } } - else version(Posix) + else version (Posix) { static auto trustedChdir(const(FSChar)* pathz) @trusted { @@ -2928,7 +2928,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && // Place outside of @trusted block const pathz = pathname.tempCString!FSChar(); - version(Windows) + version (Windows) { static auto trustedCreateDirectoryW(const(FSChar)* pathz) @trusted { @@ -2940,7 +2940,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && string pathStr = null; wenforce(trustedCreateDirectoryW(pathz), pathStr, pathz); } - else version(Posix) + else version (Posix) { import std.conv : octal; @@ -2996,13 +2996,13 @@ private bool ensureDirExists()(scope const(char)[] pathname) import std.exception : enforce; const pathz = pathname.tempCString!FSChar(); - version(Windows) + version (Windows) { if (() @trusted { return CreateDirectoryW(pathz, null); }()) return true; cenforce(GetLastError() == ERROR_ALREADY_EXISTS, pathname.idup); } - else version(Posix) + else version (Posix) { import std.conv : octal; @@ -3093,7 +3093,7 @@ void mkdirRecurse(scope const(char)[] pathname) @safe mkdirRecurse(path); // should not throw } - version(Windows) + version (Windows) { assertThrown!FileException(mkdirRecurse(`1:\foobar`)); } @@ -3132,14 +3132,14 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && // Place outside of @trusted block auto pathz = pathname.tempCString!FSChar(); - version(Windows) + version (Windows) { static auto trustedRmdir(const(FSChar)* pathz) @trusted { return RemoveDirectoryW(pathz); } } - else version(Posix) + else version (Posix) { static auto trustedRmdir(const(FSChar)* pathz) @trusted { @@ -3192,12 +3192,12 @@ if (isConvertibleToString!R) $(LREF FileException) on error (which includes if the _symlink already exists). +/ -version(StdDdoc) void symlink(RO, RL)(RO original, RL link) +version (StdDdoc) void symlink(RO, RL)(RO original, RL link) if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || isConvertibleToString!RO) && (isInputRange!RL && !isInfinite!RL && isSomeChar!(ElementEncodingType!RL) || isConvertibleToString!RL)); -else version(Posix) void symlink(RO, RL)(RO original, RL link) +else version (Posix) void symlink(RO, RL)(RO original, RL link) if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || isConvertibleToString!RO) && (isInputRange!RL && !isInfinite!RL && isSomeChar!(ElementEncodingType!RL) || @@ -3220,7 +3220,7 @@ if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || } } -version(Posix) @safe unittest +version (Posix) @safe unittest { if (system_directory.exists) { @@ -3263,7 +3263,7 @@ version(Posix) @safe unittest } } -version(Posix) @safe unittest +version (Posix) @safe unittest { static assert(__traits(compiles, symlink(TestAliasedString(null), TestAliasedString(null)))); @@ -3281,10 +3281,10 @@ version(Posix) @safe unittest Throws: $(LREF FileException) on error. +/ -version(StdDdoc) string readLink(R)(R link) +version (StdDdoc) string readLink(R)(R link) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isConvertibleToString!R); -else version(Posix) string readLink(R)(R link) +else version (Posix) string readLink(R)(R link) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isConvertibleToString!R) { @@ -3334,7 +3334,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || } } -version(Posix) @safe unittest +version (Posix) @safe unittest { import std.exception : assertThrown; import std.string; @@ -3354,12 +3354,12 @@ version(Posix) @safe unittest assertThrown!FileException(readLink("/doesnotexist")); } -version(Posix) @safe unittest +version (Posix) @safe unittest { static assert(__traits(compiles, readLink(TestAliasedString("foo")))); } -version(Posix) @system unittest // input range of dchars +version (Posix) @system unittest // input range of dchars { mkdirRecurse(deleteme); scope(exit) if (deleteme.exists) rmdirRecurse(deleteme); @@ -3380,7 +3380,7 @@ version(Posix) @system unittest // input range of dchars * Get the current working directory. * Throws: $(LREF FileException) on error. */ -version(Windows) string getcwd() @trusted +version (Windows) string getcwd() @trusted { import std.conv : to; import std.experimental.checkedint : checked; @@ -3391,7 +3391,7 @@ version(Windows) string getcwd() @trusted 3. the buffer (lpBuffer) is not large enough: the required size of the buffer, in characters, including the null-terminating character. */ - version(unittest) + version (unittest) enum BUF_SIZE = 10; // trigger reallocation code else enum BUF_SIZE = 4096; // enough for most common case @@ -3555,7 +3555,7 @@ else version (NetBSD) assert(path.isFile); } -version(StdDdoc) +version (StdDdoc) { /++ Info on a file, similar to what you'd get from stat on a Posix system. @@ -3715,7 +3715,7 @@ assert(!de2.isFile); +/ @property uint linkAttributes(); - version(Windows) + version (Windows) alias stat_t = void*; /++ @@ -3726,7 +3726,7 @@ assert(!de2.isFile); @property stat_t statBuf(); } } -else version(Windows) +else version (Windows) { struct DirEntry { @@ -3835,7 +3835,7 @@ else version(Windows) uint _attributes; /// The file attributes from WIN32_FIND_DATAW. } } -else version(Posix) +else version (Posix) { struct DirEntry { @@ -4044,7 +4044,7 @@ else version(Posix) @system unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) { @@ -4068,7 +4068,7 @@ else version(Posix) assert(!de.isSymlink); } } - else version(Posix) + else version (Posix) { import std.exception : assertThrown; @@ -4131,7 +4131,7 @@ version (StdDdoc) /// Defaults to `Yes.preserveAttributes` on Windows, and the opposite on all other platforms. PreserveAttributes preserveAttributesDefault; } -else version(Windows) +else version (Windows) { enum preserveAttributesDefault = Yes.preserveAttributes; } @@ -4213,7 +4213,7 @@ private void copyImpl(scope const(char)[] f, scope const(char)[] t, scope const(FSChar)* fromz, scope const(FSChar)* toz, PreserveAttributes preserve) @trusted { - version(Windows) + version (Windows) { assert(preserve == Yes.preserveAttributes); immutable result = CopyFileW(fromz, toz, false); @@ -4228,7 +4228,7 @@ private void copyImpl(scope const(char)[] f, scope const(char)[] t, throw new FileException(t); } } - else version(Posix) + else version (Posix) { static import core.stdc.stdio; import std.conv : to, octal; @@ -4313,7 +4313,7 @@ private void copyImpl(scope const(char)[] f, scope const(char)[] t, assert(readText(t2.byChar) == "2"); } -@safe version(Posix) @safe unittest //issue 11434 +@safe version (Posix) @safe unittest //issue 11434 { import std.conv : octal; auto t1 = deleteme, t2 = deleteme~"2"; @@ -4405,7 +4405,7 @@ void rmdirRecurse(DirEntry de) assert(!deleteme.exists); } -version(Windows) @system unittest +version (Windows) @system unittest { import std.exception : enforce; auto d = deleteme ~ r".dir\a\b\c\d\e\f\g"; @@ -4414,7 +4414,7 @@ version(Windows) @system unittest enforce(!exists(deleteme ~ ".dir")); } -version(Posix) @system unittest +version (Posix) @system unittest { import std.exception : enforce, collectException; import std.process : executeShell; @@ -4431,7 +4431,7 @@ version(Posix) @system unittest d = deleteme~"/a/b/c/d/e/f/g"; mkdirRecurse(d); - version(Android) string link_cmd = "ln -s "; + version (Android) string link_cmd = "ln -s "; else string link_cmd = "ln -sf "; executeShell(link_cmd~deleteme~"/a/b/c "~deleteme~"/link"); rmdirRecurse(deleteme); @@ -4550,7 +4550,7 @@ private struct DirIteratorImpl return de; } - version(Windows) + version (Windows) { WIN32_FIND_DATAW _findinfo; struct DirHandle @@ -4623,7 +4623,7 @@ private struct DirIteratorImpl return _followSymlink ? _cur.isDir : _cur.isDir && !_cur.isSymlink; } } - else version(Posix) + else version (Posix) { struct DirHandle { @@ -4894,7 +4894,7 @@ auto dirEntries(string path, SpanMode mode, bool followSymlink = true) import std.process : thisProcessID; import std.range.primitives : walkLength; - version(Android) + version (Android) string testdir = deleteme; // This has to be an absolute path when // called from a shared library on Android, // ie an apk @@ -5026,12 +5026,12 @@ auto dirEntries(string path, string pattern, SpanMode mode, assert(!attrIsSymlink(de.attributes)); assert(attrIsSymlink(de.linkAttributes) == flags.link); - version(Windows) + version (Windows) { assert(de.timeCreated > past); assert(de.timeCreated < future); } - else version(Posix) + else version (Posix) { assert(de.timeStatusChanged > past); assert(de.timeStatusChanged < future); @@ -5185,7 +5185,7 @@ string tempDir() @trusted static string cache; if (cache is null) { - version(Windows) + version (Windows) { import std.conv : to; // http://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx @@ -5193,7 +5193,7 @@ string tempDir() @trusted DWORD len = GetTempPathW(buf.length, buf.ptr); if (len) cache = buf[0 .. len].to!string; } - else version(Posix) + else version (Posix) { import std.process : environment; // This function looks through the list of alternative directories diff --git a/std/format.d b/std/format.d index 6ebc0a78bbe..074c7a3cc86 100644 --- a/std/format.d +++ b/std/format.d @@ -1079,7 +1079,7 @@ if (is(Unqual!Char == Char)) */ ubyte indexEnd; - version(StdDdoc) + version (StdDdoc) { /** The format specifier contained a `'-'` (`printf` @@ -2559,7 +2559,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) if (s.length > 0) { - version(none) + version (none) { return formatValueImpl(w, s, f); } @@ -2753,7 +2753,7 @@ if (is(Unqual!T : creal) && !is(T == enum) && !hasToString!(T, Char)) put(w, 'i'); } -version(TestComplex) +version (TestComplex) deprecated @safe /*pure*/ unittest // formatting floating point values is now impure { @@ -2772,7 +2772,7 @@ deprecated } } -version(TestComplex) +version (TestComplex) deprecated @system unittest { @@ -2804,7 +2804,7 @@ if (is(Unqual!T : ireal) && !is(T == enum) && !hasToString!(T, Char)) put(w, 'i'); } -version(TestComplex) +version (TestComplex) deprecated @safe /*pure*/ unittest // formatting floating point values is now impure { @@ -2817,7 +2817,7 @@ deprecated } } -version(TestComplex) +version (TestComplex) deprecated @system unittest { @@ -4001,7 +4001,7 @@ if (is(T == class) && !is(T == enum)) // outside the unittest block, otherwise the FQN of the // class contains the line number of the unittest -version(unittest) +version (unittest) { private class C {} } @@ -4581,7 +4581,7 @@ private T getNth(string kind, alias Condition, T, A...)(uint index, A args) /* ======================== Unit Tests ====================================== */ -version(unittest) +version (unittest) private void formatTest(T)(T val, string expected, size_t ln = __LINE__, string fn = __FILE__) { import core.exception : AssertError; @@ -4595,7 +4595,7 @@ private void formatTest(T)(T val, string expected, size_t ln = __LINE__, string text("expected = `", expected, "`, result = `", w.data, "`"), fn, ln); } -version(unittest) +version (unittest) private void formatTest(T)(string fmt, T val, string expected, size_t ln = __LINE__, string fn = __FILE__) @safe { import core.exception : AssertError; @@ -4608,7 +4608,7 @@ private void formatTest(T)(string fmt, T val, string expected, size_t ln = __LIN text("expected = `", expected, "`, result = `", w.data, "`"), fn, ln); } -version(unittest) +version (unittest) private void formatTest(T)(T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__) { import core.exception : AssertError; @@ -4626,7 +4626,7 @@ private void formatTest(T)(T val, string[] expected, size_t ln = __LINE__, strin text("expected one of `", expected, "`, result = `", w.data, "`"), fn, ln); } -version(unittest) +version (unittest) private void formatTest(T)(string fmt, T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__) @safe { import core.exception : AssertError; @@ -5108,7 +5108,7 @@ here: assert(a == "hello" && b == 124 && c == 34.5); } -version(unittest) +version (unittest) private void formatReflectTest(T)(ref T val, string fmt, string formatted, string fn = __FILE__, size_t ln = __LINE__) { import core.exception : AssertError; @@ -5150,7 +5150,7 @@ private void formatReflectTest(T)(ref T val, string fmt, string formatted, strin input, fn, ln); } -version(unittest) +version (unittest) private void formatReflectTest(T)(ref T val, string fmt, string[] formatted, string fn = __FILE__, size_t ln = __LINE__) { import core.exception : AssertError; @@ -5899,7 +5899,7 @@ private bool needToSwapEndianess(Char)(const ref FormatSpec!Char f) assert(s == "1193135 2947526575"); } -version(TestComplex) +version (TestComplex) deprecated @system unittest { diff --git a/std/internal/cstring.d b/std/internal/cstring.d index e0944bb3d32..491dc3b8c28 100644 --- a/std/internal/cstring.d +++ b/std/internal/cstring.d @@ -18,7 +18,7 @@ module std.internal.cstring; /// @safe unittest { - version(Posix) + version (Posix) { import core.stdc.stdlib : free; import core.sys.posix.stdlib : setenv; @@ -28,7 +28,7 @@ module std.internal.cstring; { enforce(setenv(name.tempCString(), value.tempCString(), 1) != -1); } } - version(Windows) + version (Windows) { import core.sys.windows.windows : SetEnvironmentVariableW; import std.exception : enforce; @@ -174,7 +174,7 @@ pure nothrow @nogc @safe unittest assert(ptr is null); } -version(Windows) +version (Windows) alias tempCStringW = tempCString!(wchar, const(char)[]); private struct TempCStringBuffer(To = char) @@ -214,7 +214,7 @@ private: To* _ptr; size_t _length; // length of the string - version(unittest) + version (unittest) // the 'small string optimization' { // smaller size to trigger reallocations. Padding is to account for diff --git a/std/internal/digest/sha_SSSE3.d b/std/internal/digest/sha_SSSE3.d index 9637c736016..2e4f18d3d51 100644 --- a/std/internal/digest/sha_SSSE3.d +++ b/std/internal/digest/sha_SSSE3.d @@ -15,7 +15,7 @@ */ module std.internal.digest.sha_SSSE3; -version(D_InlineAsm_X86) +version (D_InlineAsm_X86) { version (D_PIC) {} // Bugzilla 9378 else @@ -24,7 +24,7 @@ version(D_InlineAsm_X86) private version = _32Bit; } } -else version(D_InlineAsm_X86_64) +else version (D_InlineAsm_X86_64) { private version = USE_SSSE3; private version = _64Bit; @@ -65,7 +65,7 @@ else version(D_InlineAsm_X86_64) * computed values. */ -version(USE_SSSE3) +version (USE_SSSE3) { /* * The general idea is to use the XMM registers as a sliding window over @@ -91,7 +91,7 @@ version(USE_SSSE3) private immutable string E = "EDX"; /* */ - version(_32Bit) + version (_32Bit) { private immutable string SP = "ESP"; private immutable string BUFFER_PTR = "EAX"; @@ -103,7 +103,7 @@ version(USE_SSSE3) // Round constant (only used in round 0-15) private immutable string X_CONSTANT = "XMM7"; } - version(_64Bit) + version (_64Bit) { private immutable string SP = "RSP"; private immutable string BUFFER_PTR = "R9"; @@ -196,11 +196,11 @@ version(USE_SSSE3) */ private nothrow pure string[] swt3264(string[] insn32, string[] insn64) { - version(_32Bit) + version (_32Bit) { return insn32; } - version(_64Bit) + version (_64Bit) { return insn64; } @@ -318,7 +318,7 @@ version(USE_SSSE3) ["movdqa "~X_SHUFFLECTL~","~bswap_shufb_ctl(), "movdqa "~X_CONSTANT~","~constant(i)]); } - version(_64Bit) + version (_64Bit) { if (i%20 == 0) { @@ -339,11 +339,11 @@ version(USE_SSSE3) int regno = regno(i); string W = "XMM" ~ to_string(regno); - version(_32Bit) + version (_32Bit) { string W_TMP = "XMM" ~ to_string(regno+2); } - version(_64Bit) + version (_64Bit) { string W_TMP = "XMM" ~ to_string(regno+8); } @@ -392,7 +392,7 @@ version(USE_SSSE3) string W_minus_8 = "XMM" ~ to_string((regno-2)&7); string W_minus_12 = "XMM" ~ to_string((regno-3)&7); string W_minus_16 = "XMM" ~ to_string((regno-4)&7); - version(_32Bit) + version (_32Bit) { string W_TMP = "XMM" ~ to_string((regno+1)&7); string W_TMP2 = "XMM" ~ to_string((regno+2)&7); @@ -447,14 +447,14 @@ version(USE_SSSE3) string W_minus_4 = "XMM" ~ to_string((regno-1)&7); string W_minus_8 = "XMM" ~ to_string((regno-2)&7); string W_minus_16 = "XMM" ~ to_string((regno-4)&7); - version(_32Bit) + version (_32Bit) { string W_minus_28 = "[ESP + WI_PTR + "~ to_string((regno-7)&7)~"*16]"; string W_minus_32 = "[ESP + WI_PTR + "~ to_string((regno-8)&7)~"*16]"; string W_TMP = "XMM" ~ to_string((regno+1)&7); string W_TMP2 = "XMM" ~ to_string((regno+2)&7); } - version(_64Bit) + version (_64Bit) { string W_minus_28 = "XMM" ~ to_string((regno-7)&7); string W_minus_32 = "XMM" ~ to_string((regno-8)&7); @@ -534,11 +534,11 @@ version(USE_SSSE3) } // Offset into stack (see below) - version(_32Bit) + version (_32Bit) { private enum { STATE_OFS = 4, WI_PLUS_KI_PTR = 8, WI_PTR = 72 } } - version(_64Bit) + version (_64Bit) { private enum { WI_PLUS_KI_PTR = 0 } } @@ -546,7 +546,7 @@ version(USE_SSSE3) /** The prologue sequence. */ private nothrow pure string[] prologue() { - version(_32Bit) + version (_32Bit) { /* * Parameters: @@ -594,7 +594,7 @@ version(USE_SSSE3) "push EBP", ]; } - version(_64Bit) + version (_64Bit) { /* * Parameters: @@ -634,7 +634,7 @@ version(USE_SSSE3) */ private nothrow pure string[] epilogue() { - version(_32Bit) + version (_32Bit) { return ["pop ESP", "pop EBX", @@ -644,7 +644,7 @@ version(USE_SSSE3) "ret 4", ]; } - version(_64Bit) + version (_64Bit) { return ["add RSP,4*16+8", "pop RBX", @@ -718,7 +718,7 @@ version(USE_SSSE3) mixin(wrap(round(74, B, C, D, E, A))); mixin(wrap(round(76, E, A, B, C, D))); mixin(wrap(round(78, C, D, E, A, B))); - version(_32Bit) + version (_32Bit) { // Load pointer to state mixin(wrap(["mov "~STATE_PTR~",[ESP + STATE_OFS]"])); diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index d97fd110683..86931b0549b 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -33,7 +33,7 @@ Idioms: */ module std.internal.math.biguintcore; -version(D_InlineAsm_X86) +version (D_InlineAsm_X86) { static import std.internal.math.biguintx86; } @@ -56,14 +56,14 @@ private: // dipatchers to the right low-level primitives. Added to allow BigInt CTFE for // 32 bit systems (issue 14767) although it's used by the other architectures too. // See comments below in case it has to be refactored. -version(X86) +version (X86) uint multibyteAddSub(char op)(uint[] dest, const(uint)[] src1, const (uint)[] src2, uint carry) { // must be checked before, otherwise D_InlineAsm_X86 is true. if (__ctfe) return std.internal.math.biguintnoasm.multibyteAddSub!op(dest, src1, src2, carry); // Runtime. - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) return std.internal.math.biguintx86.multibyteAddSub!op(dest, src1, src2, carry); // Runtime if no asm available. else @@ -72,120 +72,120 @@ uint multibyteAddSub(char op)(uint[] dest, const(uint)[] src1, const (uint)[] sr // Any other architecture else alias multibyteAddSub = std.internal.math.biguintnoasm.multibyteAddSub; -version(X86) +version (X86) uint multibyteIncrementAssign(char op)(uint[] dest, uint carry) { if (__ctfe) return std.internal.math.biguintnoasm.multibyteIncrementAssign!op(dest, carry); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) return std.internal.math.biguintx86.multibyteIncrementAssign!op(dest, carry); else return std.internal.math.biguintnoasm.multibyteIncrementAssign!op(dest, carry); } else alias multibyteIncrementAssign = std.internal.math.biguintnoasm.multibyteIncrementAssign; -version(X86) +version (X86) uint multibyteShl()(uint[] dest, const(uint)[] src, uint numbits) { if (__ctfe) return std.internal.math.biguintnoasm.multibyteShl(dest, src, numbits); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) return std.internal.math.biguintx86.multibyteShl(dest, src, numbits); else return std.internal.math.biguintnoasm.multibyteShl(dest, src, numbits); } else alias multibyteShl = std.internal.math.biguintnoasm.multibyteShl; -version(X86) +version (X86) void multibyteShr()(uint[] dest, const(uint)[] src, uint numbits) { if (__ctfe) std.internal.math.biguintnoasm.multibyteShr(dest, src, numbits); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) std.internal.math.biguintx86.multibyteShr(dest, src, numbits); else std.internal.math.biguintnoasm.multibyteShr(dest, src, numbits); } else alias multibyteShr = std.internal.math.biguintnoasm.multibyteShr; -version(X86) +version (X86) uint multibyteMul()(uint[] dest, const(uint)[] src, uint multiplier, uint carry) { if (__ctfe) return std.internal.math.biguintnoasm.multibyteMul(dest, src, multiplier, carry); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) return std.internal.math.biguintx86.multibyteMul(dest, src, multiplier, carry); else return std.internal.math.biguintnoasm.multibyteMul(dest, src, multiplier, carry); } else alias multibyteMul = std.internal.math.biguintnoasm.multibyteMul; -version(X86) +version (X86) uint multibyteMulAdd(char op)(uint[] dest, const(uint)[] src, uint multiplier, uint carry) { if (__ctfe) return std.internal.math.biguintnoasm.multibyteMulAdd!op(dest, src, multiplier, carry); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) return std.internal.math.biguintx86.multibyteMulAdd!op(dest, src, multiplier, carry); else return std.internal.math.biguintnoasm.multibyteMulAdd!op(dest, src, multiplier, carry); } else alias multibyteMulAdd = std.internal.math.biguintnoasm.multibyteMulAdd; -version(X86) +version (X86) void multibyteMultiplyAccumulate()(uint[] dest, const(uint)[] left, const(uint)[] right) { if (__ctfe) std.internal.math.biguintnoasm.multibyteMultiplyAccumulate(dest, left, right); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) std.internal.math.biguintx86.multibyteMultiplyAccumulate(dest, left, right); else std.internal.math.biguintnoasm.multibyteMultiplyAccumulate(dest, left, right); } else alias multibyteMultiplyAccumulate = std.internal.math.biguintnoasm.multibyteMultiplyAccumulate; -version(X86) +version (X86) uint multibyteDivAssign()(uint[] dest, uint divisor, uint overflow) { if (__ctfe) return std.internal.math.biguintnoasm.multibyteDivAssign(dest, divisor, overflow); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) return std.internal.math.biguintx86.multibyteDivAssign(dest, divisor, overflow); else return std.internal.math.biguintnoasm.multibyteDivAssign(dest, divisor, overflow); } else alias multibyteDivAssign = std.internal.math.biguintnoasm.multibyteDivAssign; -version(X86) +version (X86) void multibyteAddDiagonalSquares()(uint[] dest, const(uint)[] src) { if (__ctfe) std.internal.math.biguintnoasm.multibyteAddDiagonalSquares(dest, src); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) std.internal.math.biguintx86.multibyteAddDiagonalSquares(dest, src); else std.internal.math.biguintnoasm.multibyteAddDiagonalSquares(dest, src); } else alias multibyteAddDiagonalSquares = std.internal.math.biguintnoasm.multibyteAddDiagonalSquares; -version(X86) +version (X86) void multibyteTriangleAccumulate()(uint[] dest, const(uint)[] x) { if (__ctfe) std.internal.math.biguintnoasm.multibyteTriangleAccumulate(dest, x); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) std.internal.math.biguintx86.multibyteTriangleAccumulate(dest, x); else std.internal.math.biguintnoasm.multibyteTriangleAccumulate(dest, x); } else alias multibyteTriangleAccumulate = std.internal.math.biguintnoasm.multibyteTriangleAccumulate; -version(X86) +version (X86) void multibyteSquare()(BigDigit[] result, const(BigDigit)[] x) { if (__ctfe) std.internal.math.biguintnoasm.multibyteSquare(result, x); - else version(D_InlineAsm_X86) + else version (D_InlineAsm_X86) std.internal.math.biguintx86.multibyteSquare(result, x); else std.internal.math.biguintnoasm.multibyteSquare(result, x); @@ -1337,7 +1337,7 @@ int highestPowerBelowUlongMax(uint x) pure nothrow @safe return 2; } -version(unittest) +version (unittest) { private int slowHighestPowerBelowUintMax(uint x) pure nothrow @safe @@ -2393,7 +2393,7 @@ void schoolbookDivMod(BigDigit [] quotient, BigDigit [] u, in BigDigit [] v) else { uint ulo = u[j + v.length - 2]; - version(D_InlineAsm_X86) + version (D_InlineAsm_X86) { // Note: On DMD, this is only ~10% faster than the non-asm code. uint *p = &u[j + v.length - 1]; @@ -2419,7 +2419,7 @@ div3by2done: ; } } else - { // version(InlineAsm) + { // version (InlineAsm) ulong uu = (cast(ulong)(u[j + v.length]) << 32) | u[j + v.length - 1]; immutable bigqhat = uu / vhi; ulong rhat = uu - bigqhat * vhi; @@ -2432,7 +2432,7 @@ again: if (!(rhat & 0xFFFF_FFFF_0000_0000L)) goto again; } - } // version(InlineAsm) + } // version (InlineAsm) } // Multiply and subtract. uint carry = multibyteMulAdd!('-')(u[j .. j + v.length], v, qhat, 0); diff --git a/std/internal/math/biguintnoasm.d b/std/internal/math/biguintnoasm.d index ff06808d8f6..aea1d50c2d6 100644 --- a/std/internal/math/biguintnoasm.d +++ b/std/internal/math/biguintnoasm.d @@ -6,7 +6,7 @@ * intended for internal use only. * This module is intended only to assist development of high-speed routines * on currently unsupported processors. - * The X86 asm version is about 30 times faster than the D version(DMD). + * The X86 asm version is about 30 times faster than the D version (DMD). */ /* Copyright Don Clugston 2008 - 2010. diff --git a/std/internal/math/biguintx86.d b/std/internal/math/biguintx86.d index 0b1eb2568f7..a2f4c2411fc 100644 --- a/std/internal/math/biguintx86.d +++ b/std/internal/math/biguintx86.d @@ -60,7 +60,7 @@ nothrow: (b) compiler bugs prevent the use of .ptr when a frame pointer is used. */ -version(D_InlineAsm_X86) +version (D_InlineAsm_X86) { private: @@ -573,7 +573,7 @@ uint multibyteMul(uint[] dest, const uint[] src, uint multiplier, uint carry) enum { LASTPARAM = 4*4 } // 4* pushes + return address. // We'll use p2 (load unit) instead of the overworked p0 or p1 (ALU units) // when initializing variables to zero. - version(D_PIC) + version (D_PIC) { enum { zero = 0 } } @@ -658,7 +658,7 @@ string asmMulAdd_innerloop(string OP, string M_ADDRESS) pure { // The first member of 'dest' which will be modified is [EDI+4*EBX]. // EAX must already contain the first member of 'src', [ESI+4*EBX]. - version(D_PIC) { bool using_PIC = true; } else { bool using_PIC = false; } + version (D_PIC) { bool using_PIC = true; } else { bool using_PIC = false; } return " // Entry point for even length add EBX, 1; @@ -746,7 +746,7 @@ uint multibyteMulAdd(char op)(uint [] dest, const uint [] src, uint // ESI = src enum string OP = (op=='+')? "add" : "sub"; - version(D_PIC) + version (D_PIC) { enum { zero = 0 } } @@ -830,7 +830,7 @@ void multibyteMultiplyAccumulate(uint [] dest, const uint[] left, // ESI = end of left. never changes // [ESP] = M = right[i] = multiplier for this pass through the loop. // right.length is changed into dest.ptr+dest.length - version(D_PIC) + version (D_PIC) { enum { zero = 0 } } @@ -1114,7 +1114,7 @@ void multibyteTriangleAccumulateAsm(uint[] dest, const uint[] src) pure // ESI = end of src. never changes // [ESP] = M = src[i] = multiplier for this pass through the loop. // dest.length is changed into dest.ptr+dest.length - version(D_PIC) + version (D_PIC) { enum { zero = 0 } } @@ -1276,7 +1276,7 @@ void multibyteSquare(BigDigit[] result, const BigDigit [] x) pure multibyteAddDiagonalSquares(result, x); } -version(BignumPerformanceTest) +version (BignumPerformanceTest) { import core.stdc.stdio; int clock() { asm { push EBX; xor EAX, EAX; cpuid; pop EBX; rdtsc; } } @@ -1350,4 +1350,4 @@ static this() } } -} // version(D_InlineAsm_X86) +} // version (D_InlineAsm_X86) diff --git a/std/internal/windows/advapi32.d b/std/internal/windows/advapi32.d index 85281bfc65d..9cdad540fbc 100644 --- a/std/internal/windows/advapi32.d +++ b/std/internal/windows/advapi32.d @@ -10,7 +10,7 @@ */ module std.internal.windows.advapi32; -version(Windows): +version (Windows): import core.sys.windows.windows; diff --git a/std/math.d b/std/math.d index 4f6e9d4e239..77e48569ac3 100644 --- a/std/math.d +++ b/std/math.d @@ -132,12 +132,12 @@ static import core.stdc.math; static import core.stdc.fenv; import std.traits; // CommonType, isFloatingPoint, isIntegral, isSigned, isUnsigned, Largest, Unqual -version(LDC) +version (LDC) { import ldc.intrinsics; } -version(DigitalMars) +version (DigitalMars) { version = INLINE_YL2X; // x87 has opcodes for these } @@ -151,11 +151,11 @@ version (MIPS64) version = MIPS_Any; version (AArch64) version = ARM_Any; version (ARM) version = ARM_Any; -version(D_InlineAsm_X86) +version (D_InlineAsm_X86) { version = InlineAsm_X86_Any; } -else version(D_InlineAsm_X86_64) +else version (D_InlineAsm_X86_64) { version = InlineAsm_X86_Any; } @@ -173,7 +173,7 @@ else version (X86) private alias haveSSE = core.cpuid.sse; } -version(unittest) private +version (unittest) private { static if (real.sizeof > double.sizeof) enum uint useDigits = 16; @@ -210,7 +210,7 @@ version(unittest) private int ix; int iy; - version(CRuntime_Microsoft) + version (CRuntime_Microsoft) alias real_t = double; else alias real_t = real; @@ -231,7 +231,7 @@ version(unittest) private package: // The following IEEE 'real' formats are currently supported. -version(LittleEndian) +version (LittleEndian) { static assert(real.mant_dig == 53 || real.mant_dig == 64 || real.mant_dig == 113, @@ -276,7 +276,7 @@ template floatTraits(T) enum uint EXPMASK_INT = 0x7F80_0000; enum uint MANTISSAMASK_INT = 0x007F_FFFF; enum realFormat = RealFormat.ieeeSingle; - version(LittleEndian) + version (LittleEndian) { enum EXPPOS_SHORT = 1; enum SIGNPOS_BYTE = 3; @@ -298,7 +298,7 @@ template floatTraits(T) enum uint EXPMASK_INT = 0x7FF0_0000; enum uint MANTISSAMASK_INT = 0x000F_FFFF; // for the MSB only enum realFormat = RealFormat.ieeeDouble; - version(LittleEndian) + version (LittleEndian) { enum EXPPOS_SHORT = 3; enum SIGNPOS_BYTE = 7; @@ -316,7 +316,7 @@ template floatTraits(T) enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeExtended53; - version(LittleEndian) + version (LittleEndian) { enum EXPPOS_SHORT = 4; enum SIGNPOS_BYTE = 9; @@ -337,7 +337,7 @@ template floatTraits(T) enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeExtended; - version(LittleEndian) + version (LittleEndian) { enum EXPPOS_SHORT = 4; enum SIGNPOS_BYTE = 9; @@ -355,7 +355,7 @@ template floatTraits(T) enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeQuadruple; - version(LittleEndian) + version (LittleEndian) { enum EXPPOS_SHORT = 7; enum SIGNPOS_BYTE = 15; @@ -380,7 +380,7 @@ template floatTraits(T) enum DOUBLEPAIR_LSB = 1; // The exponent/sign byte is for most significant part. - version(LittleEndian) + version (LittleEndian) { enum EXPPOS_SHORT = 3; enum SIGNPOS_BYTE = 7; @@ -396,7 +396,7 @@ template floatTraits(T) } // These apply to all floating-point types -version(LittleEndian) +version (LittleEndian) { enum MANTISSA_LSB = 0; enum MANTISSA_MSB = 1; @@ -601,7 +601,7 @@ if ((is(Unqual!Num == short) || is(Unqual!Num == byte)) || assert(abs(2321312L) == 2321312L); } -version(TestComplex) +version (TestComplex) deprecated @safe pure nothrow @nogc unittest { @@ -631,7 +631,7 @@ deprecated }} } -version(TestComplex) +version (TestComplex) deprecated @safe pure nothrow @nogc unittest { @@ -886,7 +886,7 @@ deprecated */ real tan(real x) @trusted pure nothrow @nogc // TODO: @safe { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { if (!__ctfe) return tanAsm(x); @@ -908,10 +908,10 @@ float tan(float x) @safe pure nothrow @nogc { return __ctfe ? cast(float) tan(ca assert(tan(PI / 3).approxEqual(sqrt(3.0))); } -version(InlineAsm_X86_Any) +version (InlineAsm_X86_Any) private real tanAsm(real x) @trusted pure nothrow @nogc { - version(D_InlineAsm_X86) + version (D_InlineAsm_X86) { asm pure nothrow @nogc { @@ -948,7 +948,7 @@ Clear1: asm pure nothrow @nogc{ Lret: {} } - else version(D_InlineAsm_X86_64) + else version (D_InlineAsm_X86_64) { version (Win64) { @@ -1287,7 +1287,7 @@ float asin(float x) @safe pure nothrow @nogc { return asin(cast(real) x); } */ real atan(real x) @safe pure nothrow @nogc { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { if (!__ctfe) return atan2Asm(x, 1.0L); @@ -1537,7 +1537,7 @@ private T atanImpl(T)(T x) @safe pure nothrow @nogc */ real atan2(real y, real x) @trusted pure nothrow @nogc // TODO: @safe { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { if (!__ctfe) return atan2Asm(y, x); @@ -1563,7 +1563,7 @@ float atan2(float y, float x) @safe pure nothrow @nogc assert(atan2(1.0, sqrt(3.0)).approxEqual(PI / 6)); } -version(InlineAsm_X86_Any) +version (InlineAsm_X86_Any) private real atan2Asm(real y, real x) @trusted pure nothrow @nogc { version (Win64) @@ -2045,7 +2045,7 @@ extern (C) real rndtonl(real x); /// deprecated @system unittest { - version(CRuntime_DigitalMars) + version (CRuntime_DigitalMars) { assert(rndtonl(1.0) is -real.nan); assert(rndtonl(1.2) is -real.nan); @@ -2152,7 +2152,7 @@ auto sqrt(creal z) @nogc @safe pure nothrow */ real exp(real x) @trusted pure nothrow @nogc // TODO: @safe { - version(D_InlineAsm_X86) + version (D_InlineAsm_X86) { // e^^x = 2^^(LOG2E*x) // (This is valid because the overflow & underflow limits for exp @@ -2160,7 +2160,7 @@ real exp(real x) @trusted pure nothrow @nogc // TODO: @safe if (!__ctfe) return exp2Asm(LOG2E*x); } - else version(D_InlineAsm_X86_64) + else version (D_InlineAsm_X86_64) { // e^^x = 2^^(LOG2E*x) // (This is valid because the overflow & underflow limits for exp @@ -2465,7 +2465,7 @@ private T expImpl(T)(T x) @safe pure nothrow @nogc */ real expm1(real x) @trusted pure nothrow @nogc // TODO: @safe { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { if (!__ctfe) return expm1Asm(x); @@ -2494,10 +2494,10 @@ float expm1(float x) @safe pure nothrow @nogc assert(expm1(2.0).feqrel(6.3890) > 16); } -version(InlineAsm_X86_Any) +version (InlineAsm_X86_Any) private real expm1Asm(real x) @trusted pure nothrow @nogc { - version(D_InlineAsm_X86) + version (D_InlineAsm_X86) { enum PARAMSIZE = (real.sizeof+3)&(0xFFFF_FFFC); // always a multiple of 4 asm pure nothrow @nogc @@ -2569,7 +2569,7 @@ L_largenegative: ret PARAMSIZE; } } - else version(D_InlineAsm_X86_64) + else version (D_InlineAsm_X86_64) { asm pure nothrow @nogc { @@ -2814,7 +2814,7 @@ private T expm1Impl(T)(T x) @safe pure nothrow @nogc */ real exp2(real x) @nogc @trusted pure nothrow // TODO: @safe { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { if (!__ctfe) return exp2Asm(x); @@ -2838,7 +2838,7 @@ float exp2(float x) @nogc @safe pure nothrow { return __ctfe ? cast(float) exp2( @safe unittest { - version(CRuntime_Microsoft) {} else // aexp2/exp2f/exp2l not implemented + version (CRuntime_Microsoft) {} else // aexp2/exp2f/exp2l not implemented { assert( core.stdc.math.exp2f(0.0f) == 1 ); assert( core.stdc.math.exp2 (0.0) == 1 ); @@ -2846,10 +2846,10 @@ float exp2(float x) @nogc @safe pure nothrow { return __ctfe ? cast(float) exp2( } } -version(InlineAsm_X86_Any) +version (InlineAsm_X86_Any) private real exp2Asm(real x) @nogc @trusted pure nothrow { - version(D_InlineAsm_X86) + version (D_InlineAsm_X86) { enum PARAMSIZE = (real.sizeof+3)&(0xFFFF_FFFC); // always a multiple of 4 @@ -2935,7 +2935,7 @@ L_was_nan: ret PARAMSIZE; } } - else version(D_InlineAsm_X86_64) + else version (D_InlineAsm_X86_64) { asm pure nothrow @nogc { @@ -3211,7 +3211,7 @@ private T exp2Impl(T)(T x) @nogc @safe pure nothrow deprecated("Use std.complex.expi") creal expi(real y) @trusted pure nothrow @nogc { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { version (Win64) { @@ -4226,7 +4226,7 @@ real log10(real x) @safe pure nothrow @nogc */ real log1p(real x) @safe pure nothrow @nogc { - version(INLINE_YL2X) + version (INLINE_YL2X) { // On x87, yl2xp1 is valid if and only if -0.5 <= lg(x) <= 0.5, // ie if -0.29 <= x <= 0.414 @@ -4486,7 +4486,7 @@ real modf(real x, ref real i) @trusted nothrow @nogc */ real scalbn(real x, int n) @trusted nothrow @nogc { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { // scalbnl is not supported on DMD-Windows, so use asm pure nothrow @nogc. version (Win64) @@ -4724,7 +4724,7 @@ real ceil(real x) @trusted pure nothrow @nogc ret ; } } - else version(CRuntime_Microsoft) + else version (CRuntime_Microsoft) { short cw; asm pure nothrow @nogc @@ -4852,7 +4852,7 @@ real floor(real x) @trusted pure nothrow @nogc ret ; } } - else version(CRuntime_Microsoft) + else version (CRuntime_Microsoft) { short cw; asm pure nothrow @nogc @@ -5127,7 +5127,7 @@ float rint(float x) @safe pure nothrow @nogc { return rint(cast(real) x); } */ long lrint(real x) @trusted pure nothrow @nogc { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { version (Win64) { @@ -5355,7 +5355,7 @@ auto round(real x) @trusted nothrow @nogc } // assure purity on Posix -version(Posix) +version (Posix) { @safe pure nothrow @nogc unittest { @@ -5382,7 +5382,7 @@ long lround(real x) @trusted nothrow @nogc /// @safe nothrow @nogc unittest { - version(Posix) + version (Posix) { assert(lround(0.49) == 0); assert(lround(0.5) == 1); @@ -5416,7 +5416,7 @@ real trunc(real x) @trusted nothrow @nogc pure ret ; } } - else version(CRuntime_Microsoft) + else version (CRuntime_Microsoft) { short cw; asm pure nothrow @nogc @@ -5492,7 +5492,7 @@ real remquo(real x, real y, out int n) @trusted nothrow @nogc /// ditto /// @safe @nogc nothrow unittest { - version(Posix) + version (Posix) { assert(remainder(5.1, 3.0).feqrel(-0.9) > 16); assert(remainder(-5.1, 3.0).feqrel(0.9) > 16); @@ -5506,7 +5506,7 @@ real remquo(real x, real y, out int n) @trusted nothrow @nogc /// ditto /// @safe @nogc nothrow unittest { - version(Posix) + version (Posix) { int n; @@ -5568,7 +5568,7 @@ private: private: static uint getIeeeFlags() @trusted pure { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { ushort sw; asm pure nothrow @nogc { fstsw sw; } @@ -5601,7 +5601,7 @@ private: static void resetIeeeFlags() @trusted { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { asm nothrow @nogc { @@ -5738,19 +5738,19 @@ public: }} } -version(X86_Any) +version (X86_Any) { version = IeeeFlagsSupport; } -else version(PPC_Any) +else version (PPC_Any) { version = IeeeFlagsSupport; } -else version(MIPS_Any) +else version (MIPS_Any) { version = IeeeFlagsSupport; } -else version(ARM_Any) +else version (ARM_Any) { version = IeeeFlagsSupport; } @@ -5841,7 +5841,7 @@ nothrow @nogc: alias RoundingMode = uint; /// - version(StdDdoc) + version (StdDdoc) { enum : RoundingMode { @@ -5898,7 +5898,7 @@ nothrow @nogc: alias ExceptionMask = uint; /// - version(StdDdoc) + version (StdDdoc) { enum : ExceptionMask { @@ -5918,7 +5918,7 @@ nothrow @nogc: allExceptions, /// ditto } } - else version(ARM_Any) + else version (ARM_Any) { enum : ExceptionMask { @@ -5934,7 +5934,7 @@ nothrow @nogc: | inexactException | subnormalException, } } - else version(PPC_Any) + else version (PPC_Any) { enum : ExceptionMask { @@ -5949,7 +5949,7 @@ nothrow @nogc: | inexactException, } } - else version(MIPS_Any) + else version (MIPS_Any) { enum : ExceptionMask { @@ -6031,13 +6031,13 @@ public: /// Returns: true if the current FPU supports exception trapping @property static bool hasExceptionTraps() @safe pure { - version(X86_Any) + version (X86_Any) return true; - else version(PPC_Any) + else version (PPC_Any) return true; - else version(MIPS_Any) + else version (MIPS_Any) return true; - else version(ARM_Any) + else version (ARM_Any) { // The hasExceptionTraps_impl function is basically pure, // as it restores all global state @@ -6054,7 +6054,7 @@ public: { assert(hasExceptionTraps); initialize(); - version(X86_Any) + version (X86_Any) setControlState(getControlState() & ~(exceptions & allExceptions)); else setControlState(getControlState() | (exceptions & allExceptions)); @@ -6065,7 +6065,7 @@ public: { assert(hasExceptionTraps); initialize(); - version(X86_Any) + version (X86_Any) setControlState(getControlState() | (exceptions & allExceptions)); else setControlState(getControlState() & ~(exceptions & allExceptions)); @@ -6075,7 +6075,7 @@ public: @property static ExceptionMask enabledExceptions() @trusted pure { assert(hasExceptionTraps); - version(X86_Any) + version (X86_Any) return (getControlState() & allExceptions) ^ allExceptions; else return (getControlState() & allExceptions); @@ -6094,15 +6094,15 @@ private: bool initialized = false; - version(ARM_Any) + version (ARM_Any) { alias ControlState = uint; } - else version(PPC_Any) + else version (PPC_Any) { alias ControlState = uint; } - else version(MIPS_Any) + else version (MIPS_Any) { alias ControlState = uint; } @@ -6202,7 +6202,7 @@ private: /// @safe unittest { - version(D_HardFloat) + version (D_HardFloat) { FloatingPointControl fpctrl; @@ -6217,7 +6217,7 @@ private: } } -version(D_HardFloat) @safe unittest +version (D_HardFloat) @safe unittest { void ensureDefaults() { @@ -6254,7 +6254,7 @@ version(D_HardFloat) @safe unittest ensureDefaults(); } -version(D_HardFloat) @safe unittest // rounding +version (D_HardFloat) @safe unittest // rounding { import std.meta : AliasSeq; @@ -6885,7 +6885,7 @@ real NaN(ulong payload) @trusted pure nothrow @nogc { v <<= 1; // there's no implicit bit - version(LittleEndian) + version (LittleEndian) { *cast(ulong*)(6+cast(ubyte*)(&x)) = v; } @@ -6945,7 +6945,7 @@ ulong getNaNPayload(real x) @trusted pure nothrow @nogc } else static if (F.realFormat == RealFormat.ieeeQuadruple) { - version(LittleEndian) + version (LittleEndian) { ulong m = *cast(ulong*)(6+cast(ubyte*)(&x)); } @@ -7493,11 +7493,11 @@ if (isFloatingPoint!(F) && isIntegral!(G)) assert(pow(x, neg1) == 1 / x); - version(X86_64) + version (X86_64) { pragma(msg, "test disabled on x86_64, see bug 5628"); } - else version(ARM) + else version (ARM) { pragma(msg, "test disabled on ARM, see bug 5628"); } @@ -7814,7 +7814,7 @@ if (isFloatingPoint!(F) && isFloatingPoint!(G)) } x = -x; } - version(INLINE_YL2X) + version (INLINE_YL2X) { // If x > 0, x ^^ y == 2 ^^ ( y * log2(x) ) // TODO: This is not accurate in practice. A fast and accurate @@ -7863,7 +7863,7 @@ if (isFloatingPoint!(F) && isFloatingPoint!(G)) @safe pure nothrow @nogc unittest { // Test all the special values. These unittests can be run on Windows - // by temporarily changing the version(linux) to version(all). + // by temporarily changing the version (linux) to version (all). immutable float zero = 0; immutable real one = 1; immutable double two = 2; @@ -7890,8 +7890,8 @@ if (isFloatingPoint!(F) && isFloatingPoint!(G)) assert(isIdentical(pow(rninf, -2.0), +0.0)); // @@@BUG@@@ somewhere - version(OSX) {} else assert(isNaN(pow(one, dinf))); - version(OSX) {} else assert(isNaN(pow(-one, dinf))); + version (OSX) {} else assert(isNaN(pow(one, dinf))); + version (OSX) {} else assert(isNaN(pow(-one, dinf))); assert(isNaN(pow(-0.2, PI))); // boundary cases. Note that epsilon == 2^^-n for some n, // so 1/epsilon == 2^^n is always even. @@ -8959,7 +8959,7 @@ if (isFloatingPoint!T) var.bytes[F.SIGNPOS_BYTE] |= 0x80; } - version(LittleEndian) + version (LittleEndian) { if (vars[0].bits.rem < vars[1].bits.rem) return -1; diff --git a/std/meta.d b/std/meta.d index 13abc488be6..1bcacbb7b49 100644 --- a/std/meta.d +++ b/std/meta.d @@ -954,7 +954,7 @@ template Filter(alias pred, TList...) // Used in template predicate unit tests below. -private version(unittest) +private version (unittest) { template testAlways(T...) { diff --git a/std/mmfile.d b/std/mmfile.d index 538de32d2f9..0ea2e579127 100644 --- a/std/mmfile.d +++ b/std/mmfile.d @@ -74,7 +74,7 @@ class MmFile this(filename, Mode.read, 0, null); } - version(linux) this(File file, Mode mode = Mode.read, ulong size = 0, + version (linux) this(File file, Mode mode = Mode.read, ulong size = 0, void* address = null, size_t window = 0) { // Save a copy of the File to make sure the fd stays open. @@ -82,7 +82,7 @@ class MmFile this(file.fileno, mode, size, address, window); } - version(linux) private this(int fildes, Mode mode, ulong size, + version (linux) private this(int fildes, Mode mode, ulong size, void* address, size_t window) { int oflag; @@ -334,7 +334,7 @@ class MmFile else { fd = -1; - version(CRuntime_Glibc) import core.sys.linux.sys.mman : MAP_ANON; + version (CRuntime_Glibc) import core.sys.linux.sys.mman : MAP_ANON; flags |= MAP_ANON; } this.size = size; @@ -500,7 +500,7 @@ class MmFile private void unmap() { debug (MMFILE) printf("MmFile.unmap()\n"); - version(Windows) + version (Windows) { wenforce(!data.ptr || UnmapViewOfFile(data.ptr) != FALSE, "UnmapViewOfFile"); } @@ -519,7 +519,7 @@ class MmFile void* p; if (start+len > size) len = cast(size_t)(size-start); - version(Windows) + version (Windows) { uint hi = cast(uint)(start >> 32); p = MapViewOfFileEx(hFileMap, dwDesiredAccess, hi, cast(uint) start, len, address); @@ -636,7 +636,7 @@ private: const size_t K = 1024; size_t win = 64*K; // assume the page size is 64K - version(Windows) + version (Windows) { /+ these aren't defined in core.sys.windows.windows so let's use default SYSTEM_INFO sysinfo; @@ -674,7 +674,7 @@ private: auto test = new MmFile(null, MmFile.Mode.readWriteNew, 1024*1024, null); } -version(linux) +version (linux) @system unittest // Issue 14868 { import std.file : deleteme; diff --git a/std/net/curl.d b/std/net/curl.d index ee480fc003c..81e44df614e 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -167,14 +167,14 @@ import std.typecons : Flag, Yes, No, Tuple; // Curl tests for FreeBSD 32-bit are temporarily disabled. // https://github.com/braddr/d-tester/issues/70 // https://issues.dlang.org/show_bug.cgi?id=18519 -version(unittest) -version(FreeBSD) -version(X86) +version (unittest) +version (FreeBSD) +version (X86) version = DisableCurlTests; -version(DisableCurlTests) {} else: +version (DisableCurlTests) {} else: -version(unittest) +version (unittest) { import std.socket : Socket; @@ -332,7 +332,7 @@ version(unittest) private enum httpContinue = "HTTP/1.1 100 Continue\r\n\r\n"; } -version(StdDdoc) import std.stdio; +version (StdDdoc) import std.stdio; // Default data timeout for Protocols private enum _defaultDataTimeout = dur!"minutes"(2); diff --git a/std/numeric.d b/std/numeric.d index 19a105b2d27..40f80440ed5 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -680,7 +680,7 @@ on very many factors. template FPTemporary(F) if (isFloatingPoint!F) { - version(X86) + version (X86) alias FPTemporary = real; else alias FPTemporary = Unqual!F; @@ -2613,7 +2613,7 @@ if (isIntegral!T) { return gcd!(Unqual!T)(a, b); } - else version(DigitalMars) + else version (DigitalMars) { static if (T.min < 0) { diff --git a/std/parallelism.d b/std/parallelism.d index 8613310333b..b0a41cb3473 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -86,19 +86,19 @@ import std.meta; import std.range.primitives; import std.traits; -version(OSX) +version (OSX) { version = useSysctlbyname; } -else version(FreeBSD) +else version (FreeBSD) { version = useSysctlbyname; } -else version(DragonFlyBSD) +else version (DragonFlyBSD) { version = useSysctlbyname; } -else version(NetBSD) +else version (NetBSD) { version = useSysctlbyname; } @@ -681,7 +681,7 @@ struct Task(alias fun, Args...) if (job !is null) { - version(verboseUnittest) + version (verboseUnittest) { stderr.writeln("Doing workForce work."); } @@ -702,7 +702,7 @@ struct Task(alias fun, Args...) } else { - version(verboseUnittest) + version (verboseUnittest) { stderr.writeln("Yield from workForce."); } @@ -945,7 +945,7 @@ if (is(typeof(fun(args))) && isSafeTask!F) return ret; } -version(useSysctlbyname) +version (useSysctlbyname) private extern(C) int sysctlbyname( const char *, void *, size_t *, void *, size_t ) @nogc nothrow; @@ -959,7 +959,7 @@ alias totalCPUs = uint totalCPUsImpl() @nogc nothrow @trusted { - version(Windows) + version (Windows) { // BUGS: Only works on Windows 2000 and above. import core.sys.windows.windows : SYSTEM_INFO, GetSystemInfo; @@ -968,31 +968,31 @@ uint totalCPUsImpl() @nogc nothrow @trusted GetSystemInfo(&si); return max(1, cast(uint) si.dwNumberOfProcessors); } - else version(linux) + else version (linux) { import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf; return cast(uint) sysconf(_SC_NPROCESSORS_ONLN); } - else version(Solaris) + else version (Solaris) { import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf; return cast(uint) sysconf(_SC_NPROCESSORS_ONLN); } - else version(useSysctlbyname) + else version (useSysctlbyname) { - version(OSX) + version (OSX) { auto nameStr = "machdep.cpu.core_count\0".ptr; } - else version(FreeBSD) + else version (FreeBSD) { auto nameStr = "hw.ncpu\0".ptr; } - else version(DragonFlyBSD) + else version (DragonFlyBSD) { auto nameStr = "hw.ncpu\0".ptr; } - else version(NetBSD) + else version (NetBSD) { auto nameStr = "hw.ncpu\0".ptr; } @@ -4120,7 +4120,7 @@ private struct RoundRobinBuffer(C1, C2) } } -version(unittest) +version (unittest) { // This was the only way I could get nested maps to work. private __gshared TaskPool poolInstance; @@ -4539,7 +4539,7 @@ version(unittest) // These are more like stress tests than real unit tests. They print out // tons of stuff and should not be run every time make unittest is run. -version(parallelismStressTest) +version (parallelismStressTest) { @safe unittest { diff --git a/std/path.d b/std/path.d index f76441efd64..b9b28f7ca8a 100644 --- a/std/path.d +++ b/std/path.d @@ -102,7 +102,7 @@ static import std.meta; import std.range.primitives; import std.traits; -version(unittest) +version (unittest) { private: struct TestAliasedString @@ -122,8 +122,8 @@ private: /** String used to separate directory names in a path. Under POSIX this is a slash, under Windows a backslash. */ -version(Posix) enum string dirSeparator = "/"; -else version(Windows) enum string dirSeparator = "\\"; +version (Posix) enum string dirSeparator = "/"; +else version (Windows) enum string dirSeparator = "\\"; else static assert(0, "unsupported platform"); @@ -132,8 +132,8 @@ else static assert(0, "unsupported platform"); /** Path separator string. A colon under POSIX, a semicolon under Windows. */ -version(Posix) enum string pathSeparator = ":"; -else version(Windows) enum string pathSeparator = ";"; +version (Posix) enum string pathSeparator = ":"; +else version (Windows) enum string pathSeparator = ";"; else static assert(0, "unsupported platform"); @@ -147,14 +147,14 @@ else static assert(0, "unsupported platform"); bool isDirSeparator(dchar c) @safe pure nothrow @nogc { if (c == '/') return true; - version(Windows) if (c == '\\') return true; + version (Windows) if (c == '\\') return true; return false; } /// @safe pure nothrow @nogc unittest { - version(Windows) + version (Windows) { assert( '/'.isDirSeparator); assert( '\\'.isDirSeparator); @@ -175,17 +175,17 @@ bool isDirSeparator(dchar c) @safe pure nothrow @nogc */ private bool isDriveSeparator(dchar c) @safe pure nothrow @nogc { - version(Windows) return c == ':'; + version (Windows) return c == ':'; else return false; } /* Combines the isDirSeparator and isDriveSeparator tests. */ -version(Windows) private bool isSeparator(dchar c) @safe pure nothrow @nogc +version (Windows) private bool isSeparator(dchar c) @safe pure nothrow @nogc { return isDirSeparator(c) || isDriveSeparator(c); } -version(Posix) private alias isSeparator = isDirSeparator; +version (Posix) private alias isSeparator = isDirSeparator; /* Helper function that determines the position of the last @@ -355,7 +355,7 @@ enum CaseSensitive : bool assert(baseName!(CaseSensitive.no)("dir/file.EXT", ".ext") == "file"); assert(baseName!(CaseSensitive.yes)("dir/file.EXT", ".ext") != "file"); - version(Posix) + version (Posix) assert(relativePath!(CaseSensitive.no)("/FOO/bar", "/foo/baz") == "../bar"); else assert(relativePath!(CaseSensitive.no)(`c:\FOO\bar`, `c:\foo\baz`) == `..\bar`); @@ -849,9 +849,9 @@ if (isSomeChar!C) { assert(testAliasedString!driveName("d:/file")); - version(Posix) + version (Posix) immutable result = ""; - else version(Windows) + else version (Windows) immutable result = "d:"; enum S : string { a = "d:/file" } @@ -931,9 +931,9 @@ if (isSomeChar!C) { assert(testAliasedString!stripDrive("d:/dir/file")); - version(Posix) + version (Posix) immutable result = "d:/dir/file"; - else version(Windows) + else version (Windows) immutable result = "/dir/file"; enum S : string { a = "d:/dir/file" } @@ -945,7 +945,7 @@ if (isSomeChar!C) @safe unittest { - version(Windows) + version (Windows) { assert(stripDrive(`d:\dir\file`) == `\dir\file`); assert(stripDrive(`\\server\share\dir\file`) == `\dir\file`); @@ -956,7 +956,7 @@ if (isSomeChar!C) foreach (i, c; `\dir\file`) assert(s[i] == c); } - version(Posix) + version (Posix) { assert(stripDrive(`d:\dir\file`) == `d:\dir\file`); @@ -969,7 +969,7 @@ if (isSomeChar!C) private auto _stripDrive(R)(R path) { - version(Windows) + version (Windows) { if (hasDrive!(BaseOf!R)(path)) return path[2 .. path.length]; else if (isUNC!(BaseOf!R)(path)) return path[uncRootLength!(BaseOf!R)(path) .. path.length]; @@ -1015,7 +1015,7 @@ if (isRandomAccessRange!R && hasLength!R && isSomeChar!(ElementType!R) || assert(extSeparatorPos("dir/.foo"d) == -1); assert(extSeparatorPos("dir/.foo.ext".dup) == 8); - version(Windows) + version (Windows) { assert(extSeparatorPos("dir\\file") == -1); assert(extSeparatorPos("dir\\file.ext") == 8); @@ -3939,7 +3939,7 @@ if (isConvertibleToString!Range) */ string expandTilde(string inputPath) @safe nothrow { - version(Posix) + version (Posix) { import core.exception : onOutOfMemoryError; import core.stdc.errno : errno, ERANGE; @@ -3999,7 +3999,7 @@ string expandTilde(string inputPath) @safe nothrow { // bionic doesn't really support this, as getpwnam_r // isn't provided and getpwnam is basically just a stub - version(CRuntime_Bionic) + version (CRuntime_Bionic) { return path; } @@ -4085,7 +4085,7 @@ string expandTilde(string inputPath) @safe nothrow else return expandFromDatabase(inputPath); } - else version(Windows) + else version (Windows) { // Put here real windows implementation. return inputPath; @@ -4152,7 +4152,7 @@ string expandTilde(string inputPath) @safe nothrow } } -version(unittest) +version (unittest) { private: /* Define a mock RandomAccessRange to use for unittesting. diff --git a/std/process.d b/std/process.d index 6adeb33a13b..03eb3ffeeb0 100644 --- a/std/process.d +++ b/std/process.d @@ -334,7 +334,7 @@ Pid spawnProcess(scope const(char)[] program, return spawnProcess((&program)[0 .. 1], env, config, workDir); } -version(Posix) private enum InternalError : ubyte +version (Posix) private enum InternalError : ubyte { noerror, exec, @@ -1146,7 +1146,7 @@ version (Posix) @system unittest assertThrown!ProcessException(spawnProcess("./rgiuhrifuheiohnmnvqweoijwf", null, Config.detached)); // can't execute malformed file with executable permissions - version(Posix) + version (Posix) { import std.path : buildPath; import std.file : remove, write, setAttributes; @@ -1189,7 +1189,7 @@ version (Posix) @system unittest assertThrown!ProcessException(spawnProcess([prog.path], null, Config.detached, directory)); // can't run in directory if user does not have search permission on this directory - version(Posix) + version (Posix) { if (core.sys.posix.unistd.getuid() != 0) { @@ -1335,7 +1335,7 @@ Pid spawnShell(scope const(char)[] command, auto env = ["foo" : "bar"]; assert(wait(spawnShell(cmd~redir, env)) == 0); auto f = File(tmpFile, "a"); - version(CRuntime_Microsoft) f.seek(0, SEEK_END); // MSVCRT probably seeks to the end when writing, not before + version (CRuntime_Microsoft) f.seek(0, SEEK_END); // MSVCRT probably seeks to the end when writing, not before assert(wait(spawnShell(cmd, std.stdio.stdin, f, std.stdio.stderr, env)) == 0); f.close(); auto output = std.file.readText(tmpFile); @@ -1879,7 +1879,7 @@ void kill(Pid pid, int codeOrSignal) */ Thread.sleep(1.seconds); assert(!pid.owned); - version(Windows) assert(pid.osHandle == INVALID_HANDLE_VALUE); + version (Windows) assert(pid.osHandle == INVALID_HANDLE_VALUE); assertThrown!ProcessException(wait(pid)); assertThrown!ProcessException(kill(pid)); } @@ -2734,7 +2734,7 @@ version (Windows) private immutable string shellSwitch = "/C"; // file. On Windows the file name gets a .cmd extension, while on // POSIX its executable permission bit is set. The file is // automatically deleted when the object goes out of scope. -version(unittest) +version (unittest) private struct TestScript { this(string code) @system @@ -2777,7 +2777,7 @@ private struct TestScript string path; } -version(unittest) +version (unittest) private string uniqueTempPath() @safe { import std.file : tempDir; @@ -3076,7 +3076,7 @@ if (is(typeof(allocator(size_t.init)[0] = char.init))) return buf; } -version(Windows) version(unittest) +version (Windows) version (unittest) { private: import core.stdc.stddef; @@ -3195,7 +3195,7 @@ string escapeShellFileName(scope const(char)[] fileName) @trusted pure nothrow // Loop generating strings with random characters //version = unittest_burnin; -version(unittest_burnin) +version (unittest_burnin) @system unittest { // There are no readily-available commands on all platforms suitable @@ -3763,7 +3763,7 @@ version (Posix) { import core.sys.posix.stdlib; } -version(unittest) +version (unittest) { import std.conv, std.file, std.random; } @@ -3798,7 +3798,7 @@ private void toAStringz(in string[] a, const(char)**az) // Incorporating idea (for spawnvp() on Posix) from Dave Fladebo enum { _P_WAIT, _P_NOWAIT, _P_OVERLAY } -version(Windows) extern(C) int spawnvp(int, scope const(char) *, scope const(char*)*); +version (Windows) extern(C) int spawnvp(int, scope const(char) *, scope const(char*)*); alias P_WAIT = _P_WAIT; alias P_NOWAIT = _P_NOWAIT; @@ -3875,7 +3875,7 @@ version (StdDdoc) /// ditto int execvpe(in string pathname, in string[] argv, in string[] envp); } -else version(Posix) +else version (Posix) { int execv(in string pathname, in string[] argv) { @@ -3901,7 +3901,7 @@ extern(C) int execv(scope const(char) *, scope const(char *)*); int execve(scope const(char)*, scope const(char*)*, scope const(char*)*); int execvp(scope const(char)*, scope const(char*)*); - version(Windows) int execvpe(scope const(char)*, scope const(char*)*, scope const(char*)*); + version (Windows) int execvpe(scope const(char)*, scope const(char*)*, scope const(char*)*); } private int execv_(in string pathname, in string[] argv) @@ -3939,7 +3939,7 @@ private int execvp_(in string pathname, in string[] argv) private int execvpe_(in string pathname, in string[] argv, in string[] envp) { -version(Posix) +version (Posix) { import std.array : split; import std.conv : to; @@ -3974,7 +3974,7 @@ version(Posix) return iRet; } } -else version(Windows) +else version (Windows) { auto argv_ = cast(const(char)**)core.stdc.stdlib.malloc((char*).sizeof * (1 + argv.length)); scope(exit) core.stdc.stdlib.free(argv_); @@ -3992,7 +3992,7 @@ else } // version } -version(StdDdoc) +version (StdDdoc) { /**************************************** * Start up the browser and set it to viewing the page at url. diff --git a/std/random.d b/std/random.d index cbc9ad72d17..1cfa83373e9 100644 --- a/std/random.d +++ b/std/random.d @@ -153,15 +153,15 @@ import std.traits; assert(10.iota.randomSample(3, rnd2).equal([7, 8, 9])); // Cover all elements in an array in random order - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert(10.iota.randomCover(rnd2).equal([7, 4, 2, 0, 1, 6, 8, 3, 9, 5])); // Shuffle an array - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert([0, 1, 2, 4, 5].randomShuffle(rnd2).equal([2, 0, 4, 5, 1])); } -version(unittest) +version (unittest) { static import std.meta; package alias PseudoRngTypes = std.meta.AliasSeq!(MinstdRand0, MinstdRand, Mt19937, Xorshift32, Xorshift64, @@ -698,7 +698,7 @@ alias MinstdRand = LinearCongruentialEngine!(uint, 48_271, 0, 2_147_483_647); auto rnd2 = rnd1.save; assert(rnd1 == rnd2); // Enable next test when RNGs are reference types - version(none) { assert(rnd1 !is rnd2); } + version (none) { assert(rnd1 !is rnd2); } for (auto i = 0; i < 100; i++, rnd1.popFront, rnd2.popFront) assert(rnd1.front() == rnd2.front()); }} @@ -1153,7 +1153,7 @@ alias Mt19937_64 = MersenneTwisterEngine!(ulong, 64, 312, 156, 31, auto gen2 = gen1.save; assert(gen1 == gen2); // Danger, Will Robinson -- no opEquals for MT // Enable next test when RNGs are reference types - version(none) { assert(gen1 !is gen2); } + version (none) { assert(gen1 !is gen2); } for (auto i = 0; i < 100; i++, gen1.popFront, gen2.popFront) assert(gen1.front() == gen2.front()); }} @@ -1468,7 +1468,7 @@ alias Xorshift = Xorshift128; /// ditto auto rnd2 = rnd1.save; assert(rnd1 == rnd2); // Enable next test when RNGs are reference types - version(none) { assert(rnd1 !is rnd2); } + version (none) { assert(rnd1 !is rnd2); } for (auto i = 0; i < 100; i++, rnd1.popFront, rnd2.popFront) assert(rnd1.front() == rnd2.front()); } @@ -2119,7 +2119,7 @@ if (!is(T == enum) && (isIntegral!T || isSomeChar!T)) assert(rnd.uniform!ulong == 4838462006927449017); enum Fruit { apple, mango, pear } - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert(rnd.uniform!Fruit == Fruit.mango); } @@ -2366,7 +2366,7 @@ auto ref choice(Range)(auto ref Range range) auto rnd = MinstdRand0(42); auto elem = [1, 2, 3, 4, 5].choice(rnd); - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert(elem == 3); } @@ -2448,7 +2448,7 @@ if (isRandomAccessRange!Range) auto rnd = MinstdRand0(42); auto arr = [1, 2, 3, 4, 5].randomShuffle(rnd); - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert(arr == [3, 5, 2, 4, 1]); } @@ -2536,15 +2536,15 @@ if (isRandomAccessRange!Range) auto arr = [1, 2, 3, 4, 5, 6]; arr = arr.dup.partialShuffle(1, rnd); - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert(arr == [2, 1, 3, 4, 5, 6]); // 1<->2 arr = arr.dup.partialShuffle(2, rnd); - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert(arr == [1, 4, 3, 2, 5, 6]); // 1<->2, 2<->4 arr = arr.dup.partialShuffle(3, rnd); - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert(arr == [5, 4, 6, 2, 1, 3]); // 1<->5, 2<->4, 3<->6 } @@ -2948,7 +2948,7 @@ if (isRandomAccessRange!Range) import std.range : iota; auto rnd = MinstdRand0(42); - version(X86_64) // Issue 15147 + version (X86_64) // Issue 15147 assert(10.iota.randomCover(rnd).equal([7, 4, 2, 0, 1, 6, 8, 3, 9, 5])); } diff --git a/std/range/interfaces.d b/std/range/interfaces.d index de8f97d87a4..1bed5d3383f 100644 --- a/std/range/interfaces.d +++ b/std/range/interfaces.d @@ -187,7 +187,7 @@ interface RandomAccessFinite(E) : BidirectionalRange!(E) { // Can't support slicing until issues with requiring slicing for all // finite random access ranges are fully resolved. - version(none) + version (none) { /// RandomAccessFinite!E opSlice(size_t, size_t); @@ -442,7 +442,7 @@ if (isInputRange!(Unqual!R)) // Can't support slicing until all the issues with // requiring slicing support for finite random access // ranges are resolved. - version(none) + version (none) { typeof(this) opSlice(size_t lower, size_t upper) { return new typeof(this)(_range[lower .. upper]); diff --git a/std/range/package.d b/std/range/package.d index 3d9ba844068..b308d03af51 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -9474,7 +9474,7 @@ private struct OnlyResult(T, size_t arity) private size_t backIndex = 0; // @@@BUG@@@ 10643 - version(none) + version (none) { import std.traits : hasElaborateAssign; static if (hasElaborateAssign!T) @@ -10119,7 +10119,7 @@ pure @safe unittest }} } -version(none) // @@@BUG@@@ 10939 +version (none) // @@@BUG@@@ 10939 { // Re-enable (or remove) if 10939 is resolved. /+pure+/ @safe unittest // Impure because of std.conv.to @@ -11079,7 +11079,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ +/ @property auto front() {assert(0);} @@ -11107,7 +11107,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { @property bool empty(); /// @property bool empty() const; ///Ditto @@ -11135,7 +11135,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if `isForwardRange!R` is `true`. @@ -11205,7 +11205,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if `isBidirectionalRange!R` is `true`. @@ -11242,7 +11242,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if `isRandomAccesRange!R` is `true`. @@ -11298,7 +11298,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if `hasLength!R` is `true`. @@ -11327,7 +11327,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if `hasSlicing!R` is `true`. diff --git a/std/range/primitives.d b/std/range/primitives.d index e1e0c89e11c..12f2e60870d 100644 --- a/std/range/primitives.d +++ b/std/range/primitives.d @@ -1566,7 +1566,7 @@ template hasLength(R) static assert(!hasLength!(A)); static assert(hasLength!(B)); } - else version(X86_64) + else version (X86_64) { static assert(hasLength!(A)); static assert(!hasLength!(B)); diff --git a/std/regex/internal/parser.d b/std/regex/internal/parser.d index 85d0f0e579d..a4706b997f0 100644 --- a/std/regex/internal/parser.d +++ b/std/regex/internal/parser.d @@ -42,7 +42,7 @@ auto makeRegex(S, CG)(Parser!(S, CG) p) } //@@@BUG@@@ (not reduced) //somehow just using validate _collides_ with std.utf.validate (!) - version(assert) re.validateRe(); + version (assert) re.validateRe(); } return re; } diff --git a/std/regex/internal/tests.d b/std/regex/internal/tests.d index 5af78d32f06..8a0fec16a1b 100644 --- a/std/regex/internal/tests.d +++ b/std/regex/internal/tests.d @@ -405,23 +405,23 @@ debug(std_regex_test) import std.stdio; void ct_tests() { import std.algorithm.comparison : equal; - version(std_regex_ct1) + version (std_regex_ct1) { pragma(msg, "Testing 1st part of ctRegex"); enum Tests = iota(0, 155); } - else version(std_regex_ct2) + else version (std_regex_ct2) { pragma(msg, "Testing 2nd part of ctRegex"); enum Tests = iota(155, 174); } //FIXME: #174-178 contains CTFE parser bug - else version(std_regex_ct3) + else version (std_regex_ct3) { pragma(msg, "Testing 3rd part of ctRegex"); enum Tests = iota(178, 220); } - else version(std_regex_ct4) + else version (std_regex_ct4) { pragma(msg, "Testing 4th part of ctRegex"); enum Tests = iota(220, tv.length); diff --git a/std/regex/internal/tests2.d b/std/regex/internal/tests2.d index 258dbad3a9d..1bba66e90b3 100644 --- a/std/regex/internal/tests2.d +++ b/std/regex/internal/tests2.d @@ -539,7 +539,7 @@ import std.uni : Escapables; // characters that need escaping } // bugzilla 13532 -version(none) // TODO: revist once we have proper benchmark framework +version (none) // TODO: revist once we have proper benchmark framework @safe unittest { import std.datetime.stopwatch : StopWatch, AutoStart; diff --git a/std/signals.d b/std/signals.d index 8a9a843fb57..09a73ef9343 100644 --- a/std/signals.d +++ b/std/signals.d @@ -651,7 +651,7 @@ void linkin() { } a.emit(); // should not raise segfault since &o.watch2 is no longer connected } -version(none) // Disabled because of dmd @@@BUG5028@@@ +version (none) // Disabled because of dmd @@@BUG5028@@@ @system unittest { class A diff --git a/std/socket.d b/std/socket.d index 5339547404f..d5a40c770df 100644 --- a/std/socket.d +++ b/std/socket.d @@ -55,7 +55,7 @@ import std.internal.cstring; @safe: -version(Windows) +version (Windows) { pragma (lib, "ws2_32.lib"); pragma (lib, "wsock32.lib"); @@ -74,9 +74,9 @@ version(Windows) return WSAGetLastError(); } } -else version(Posix) +else version (Posix) { - version(linux) + version (linux) { enum : int { @@ -120,7 +120,7 @@ else static assert(0); // No socket support yet. } -version(unittest) +version (unittest) { // Print a message on exception instead of failing the unittest. private void softUnittest(void delegate() @safe test, int line = __LINE__) @trusted @@ -153,7 +153,7 @@ version (CRuntime_UClibc) version = GNU_STRERROR; */ string formatSocketError(int err) @trusted { - version(Posix) + version (Posix) { char[80] buf; const(char)* cs; @@ -179,7 +179,7 @@ string formatSocketError(int err) @trusted return cs[0 .. len].idup; } else - version(Windows) + version (Windows) { return sysErrorString(err); } @@ -263,9 +263,9 @@ class SocketFeatureException: SocketException */ bool wouldHaveBlocked() nothrow @nogc { - version(Windows) + version (Windows) return _lasterr() == WSAEWOULDBLOCK; - else version(Posix) + else version (Posix) return _lasterr() == EAGAIN; else static assert(0); @@ -281,7 +281,7 @@ private immutable shared static this() @system { - version(Windows) + version (Windows) { WSADATA wd; @@ -305,7 +305,7 @@ shared static this() @system GetProcAddress(ws2Lib, "freeaddrinfo"); } } - else version(Posix) + else version (Posix) { getnameinfoPointer = &getnameinfo; getaddrinfoPointer = &getaddrinfo; @@ -316,7 +316,7 @@ shared static this() @system shared static ~this() @system nothrow @nogc { - version(Windows) + version (Windows) { WSACleanup(); } @@ -447,7 +447,7 @@ class Protocol // Skip this test on Android because getprotobyname/number are // unimplemented in bionic. -version(CRuntime_Bionic) {} else +version (CRuntime_Bionic) {} else @safe unittest { // import std.stdio : writefln; @@ -691,7 +691,7 @@ class InternetHost return true; } - version(Windows) + version (Windows) alias getHost = getHostNoSync; else { @@ -833,7 +833,7 @@ enum AddressInfoFlags: int */ private string formatGaiError(int err) @trusted { - version(Windows) + version (Windows) { return sysErrorString(err); } @@ -1281,7 +1281,7 @@ abstract class Address { if (ret == EAI_NONAME) return null; - version(Windows) + version (Windows) if (ret == WSANO_DATA) return null; } @@ -1880,7 +1880,7 @@ public: } -version(StdDdoc) +version (StdDdoc) { static if (!is(sockaddr_un)) { @@ -2415,7 +2415,7 @@ public: { softUnittest({ enum PAIRS = 768; - version(Posix) + version (Posix) () @trusted { enum LIMIT = 2048; @@ -2585,7 +2585,7 @@ private: socket_t sock; AddressFamily _family; - version(Windows) + version (Windows) bool _blocking = false; /// Property to get or set whether the socket is blocking or nonblocking. // The WinSock timeouts seem to be effectively skewed by a constant @@ -2597,7 +2597,7 @@ private: @safe unittest { - version(SlowTests) + version (SlowTests) softUnittest({ import std.datetime.stopwatch; import std.typecons; @@ -2717,11 +2717,11 @@ public: */ @property bool blocking() @trusted const nothrow @nogc { - version(Windows) + version (Windows) { return _blocking; } - else version(Posix) + else version (Posix) { return !(fcntl(handle, F_GETFL, 0) & O_NONBLOCK); } @@ -2730,14 +2730,14 @@ public: /// ditto @property void blocking(bool byes) @trusted { - version(Windows) + version (Windows) { uint num = !byes; if (_SOCKET_ERROR == ioctlsocket(sock, FIONBIO, &num)) goto err; _blocking = byes; } - else version(Posix) + else version (Posix) { int x = fcntl(sock, F_GETFL, 0); if (-1 == x) @@ -2791,12 +2791,12 @@ public: if (!blocking) { - version(Windows) + version (Windows) { if (WSAEWOULDBLOCK == err) return; } - else version(Posix) + else version (Posix) { if (EINPROGRESS == err) return; @@ -2854,7 +2854,7 @@ public: assert(newSocket.sock == socket_t.init); newSocket.setSock(newsock); - version(Windows) + version (Windows) newSocket._blocking = _blocking; //inherits blocking mode newSocket._family = _family; //same family } @@ -2876,11 +2876,11 @@ public: private static void _close(socket_t sock) @system nothrow @nogc { - version(Windows) + version (Windows) { .closesocket(sock); } - else version(Posix) + else version (Posix) { .close(sock); } @@ -2963,7 +2963,7 @@ public: { flags = cast(SocketFlags)(flags | MSG_NOSIGNAL); } - version( Windows ) + version (Windows) auto sent = .send(sock, buf.ptr, capToInt(buf.length), cast(int) flags); else auto sent = .send(sock, buf.ptr, buf.length, cast(int) flags); @@ -2989,7 +2989,7 @@ public: { flags = cast(SocketFlags)(flags | MSG_NOSIGNAL); } - version( Windows ) + version (Windows) return .sendto( sock, buf.ptr, capToInt(buf.length), cast(int) flags, to.name, to.nameLen @@ -3013,7 +3013,7 @@ public: { flags = cast(SocketFlags)(flags | MSG_NOSIGNAL); } - version(Windows) + version (Windows) return .sendto(sock, buf.ptr, capToInt(buf.length), cast(int) flags, null, 0); else return .sendto(sock, buf.ptr, buf.length, cast(int) flags, null, 0); @@ -3036,7 +3036,7 @@ public: */ ptrdiff_t receive(void[] buf, SocketFlags flags) @trusted { - version(Windows) // Does not use size_t + version (Windows) // Does not use size_t { return buf.length ? .recv(sock, buf.ptr, capToInt(buf.length), cast(int) flags) @@ -3070,7 +3070,7 @@ public: if (from is null || from.addressFamily != _family) from = createAddress(); socklen_t nameLen = from.nameLen; - version(Windows) + version (Windows) { auto read = .recvfrom(sock, buf.ptr, capToInt(buf.length), cast(int) flags, from.name, &nameLen); from.setNameLen(nameLen); @@ -3102,7 +3102,7 @@ public: { if (!buf.length) //return 0 and don't think the connection closed return 0; - version(Windows) + version (Windows) { auto read = .recvfrom(sock, buf.ptr, capToInt(buf.length), cast(int) flags, null, null); // if (!read) //connection closed @@ -3294,7 +3294,7 @@ public: */ void setKeepAlive(int time, int interval) @trusted { - version(Windows) + version (Windows) { tcp_keepalive options; options.onoff = 1; @@ -3376,7 +3376,7 @@ public: fd_set* fr, fw, fe; int n = 0; - version(Windows) + version (Windows) { // Windows has a problem with empty fd_set`s that aren't null. fr = checkRead && checkRead.count ? checkRead.toFd_set() : null; @@ -3430,12 +3430,12 @@ public: int result = .select(n, fr, fw, fe, &timeout.ctimeval); - version(Windows) + version (Windows) { if (_SOCKET_ERROR == result && WSAGetLastError() == WSAEINTR) return -1; } - else version(Posix) + else version (Posix) { if (_SOCKET_ERROR == result && errno == EINTR) return -1; @@ -3585,7 +3585,7 @@ class UdpSocket: Socket */ Socket[2] socketPair() @trusted { - version(Posix) + version (Posix) { int[2] socks; if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1) @@ -3601,7 +3601,7 @@ Socket[2] socketPair() @trusted return [toSocket(0), toSocket(1)]; } - else version(Windows) + else version (Windows) { // We do not have socketpair() on Windows, just manually create a // pair of sockets connected over some localhost port. diff --git a/std/stdio.d b/std/stdio.d index 8578a67fba1..bce8ed99cbd 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -99,7 +99,7 @@ else version (Posix) else static assert(0); -version(Windows) +version (Windows) { // core.stdc.stdio.fopen expects file names to be // encoded in CP_ACP on Windows instead of UTF-8. @@ -250,7 +250,7 @@ else static assert(0, "unsupported C I/O system"); } -version(HAS_GETDELIM) extern(C) nothrow @nogc +version (HAS_GETDELIM) extern(C) nothrow @nogc { ptrdiff_t getdelim(char**, size_t*, int, FILE*); // getline() always comes together with getdelim() @@ -675,7 +675,7 @@ opengroup.org/onlinepubs/007908799/xsh/_popen.html, _popen). Throws: `ErrnoException` in case of error. */ - version(Posix) void popen(string command, scope const(char)[] stdioOpenmode = "r") @safe + version (Posix) void popen(string command, scope const(char)[] stdioOpenmode = "r") @safe { resetFile(command, stdioOpenmode ,true); } @@ -731,7 +731,7 @@ Throws: `ErrnoException` in case of error. // Declare a dummy HANDLE to allow generating documentation // for Windows-only methods. - version(StdDdoc) { version(Windows) {} else alias HANDLE = int; } + version (StdDdoc) { version (Windows) {} else alias HANDLE = int; } /** First calls `detach` (throwing on failure), and then attempts to @@ -740,10 +740,10 @@ be compatible with the access attributes of the handle. Windows only. Throws: `ErrnoException` in case of error. */ - version(StdDdoc) + version (StdDdoc) void windowsHandleOpen(HANDLE handle, scope const(char)[] stdioOpenmode); - version(Windows) + version (Windows) void windowsHandleOpen(HANDLE handle, scope const(char)[] stdioOpenmode) { import core.stdc.stdint : intptr_t; @@ -982,12 +982,12 @@ Throws: `Exception` if `buffer` is empty. if (!buffer.length) throw new Exception("rawRead must take a non-empty buffer"); - version(Windows) + version (Windows) { immutable fd = ._fileno(_p.handle); immutable mode = ._setmode(fd, _O_BINARY); scope(exit) ._setmode(fd, mode); - version(DIGITAL_MARS_STDIO) + version (DIGITAL_MARS_STDIO) { import core.atomic : atomicOp; @@ -1037,13 +1037,13 @@ Throws: `ErrnoException` if the file is not opened or if the call to `fwrite` fa import std.conv : text; import std.exception : errnoEnforce; - version(Windows) + version (Windows) { flush(); // before changing translation mode immutable fd = ._fileno(_p.handle); immutable mode = ._setmode(fd, _O_BINARY); scope(exit) ._setmode(fd, mode); - version(DIGITAL_MARS_STDIO) + version (DIGITAL_MARS_STDIO) { import core.atomic : atomicOp; @@ -1232,7 +1232,7 @@ Throws: `Exception` if the file is not opened. } - version(Windows) + version (Windows) { import core.sys.windows.windows : ULARGE_INTEGER, OVERLAPPED, BOOL; @@ -1261,7 +1261,7 @@ Throws: `Exception` if the file is not opened. throw new Exception(str ~ ": " ~ sysErrorString(GetLastError())); } } - version(Posix) + version (Posix) { private int lockImpl(int operation, short l_type, ulong start, ulong length) @@ -1310,7 +1310,7 @@ $(UL "Could not set lock for file `"~_name~"'"); } else - version(Windows) + version (Windows) { import core.sys.windows.windows : LockFileEx, LOCKFILE_EXCLUSIVE_LOCK; immutable type = lockType == LockType.readWrite ? @@ -1348,7 +1348,7 @@ specified file segment was already locked. return true; } else - version(Windows) + version (Windows) { import core.sys.windows.windows : GetLastError, LockFileEx, LOCKFILE_EXCLUSIVE_LOCK, ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, LOCKFILE_FAIL_IMMEDIATELY; @@ -1382,7 +1382,7 @@ Removes the lock over the specified file segment. "Could not remove lock for file `"~_name~"'"); } else - version(Windows) + version (Windows) { import core.sys.windows.windows : UnlockFileEx; wenforce(lockImpl!UnlockFileEx(start, length), @@ -1392,7 +1392,7 @@ Removes the lock over the specified file segment. static assert(false); } - version(Windows) + version (Windows) @system unittest { static import std.file; @@ -1411,7 +1411,7 @@ Removes the lock over the specified file segment. g.unlock(); } - version(Posix) + version (Posix) @system unittest { static import std.file; @@ -2054,10 +2054,10 @@ Returns the file number corresponding to this object. /** Returns the underlying operating system `HANDLE` (Windows only). */ - version(StdDdoc) + version (StdDdoc) @property HANDLE windowsHandle(); - version(Windows) + version (Windows) @property HANDLE windowsHandle() { version (DIGITAL_MARS_STDIO) @@ -2491,7 +2491,7 @@ $(REF readText, std,file) import std.algorithm.comparison : equal; import std.range : drop, take; - version(Win64) + version (Win64) { static import std.file; @@ -2500,7 +2500,7 @@ $(REF readText, std,file) auto file = File(deleteme, "w+"); scope(success) std.file.remove(deleteme); } - else version(CRuntime_Bionic) + else version (CRuntime_Bionic) { static import std.file; @@ -2641,7 +2641,7 @@ $(REF readText, std,file) @property nothrow ubyte[] front() { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -2653,7 +2653,7 @@ $(REF readText, std,file) /// Ditto void popFront() { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -3493,7 +3493,7 @@ void main() assert(e && e.msg == "Attempting to write to closed File"); } -version(StdStressTest) +version (StdStressTest) { // issue 15768 @system unittest @@ -3588,7 +3588,7 @@ struct LockingTextReader { if (!_hasChar) { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -4223,11 +4223,11 @@ if ((isInputRange!R1 && isSomeChar!(ElementEncodingType!R1) || isSomeString!R1) static _fopenImpl(const(FSChar)* namez, const(FSChar)* modez) @trusted nothrow @nogc { - version(Windows) + version (Windows) { return _wfopen(namez, modez); } - else version(Posix) + else version (Posix) { /* * The new opengroup large file support API is transparently @@ -5408,7 +5408,7 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orie Bugs: Only works on Linux */ -version(linux) +version (linux) { File openNetwork(string host, ushort port) { @@ -5451,7 +5451,7 @@ version(linux) } } -version(unittest) private string testFilename(string file = __FILE__, size_t line = __LINE__) @safe +version (unittest) private string testFilename(string file = __FILE__, size_t line = __LINE__) @safe { import std.conv : text; import std.file : deleteme; diff --git a/std/string.d b/std/string.d index 8269f935c09..1d29e263899 100644 --- a/std/string.d +++ b/std/string.d @@ -143,7 +143,7 @@ Source: $(PHOBOSSRC std/string.d) */ module std.string; -version(unittest) +version (unittest) { private: struct TestAliasedString @@ -6420,7 +6420,7 @@ if (isSomeString!S || assert(!isNumeric("+")); } -version(TestComplex) +version (TestComplex) deprecated @safe unittest { diff --git a/std/system.d b/std/system.d index 97f9eed88f2..366057200d5 100644 --- a/std/system.d +++ b/std/system.d @@ -19,8 +19,8 @@ immutable Note: This is for cases where you need a value representing the OS at runtime. If you're doing something which should compile differently - on different OSes, then please use `version(Windows)`, - `version(linux)`, etc. + on different OSes, then please use `version (Windows)`, + `version (linux)`, etc. See_Also: $(DDSUBLINK spec/version,PredefinedVersions, Predefined Versions) @@ -40,15 +40,15 @@ immutable } /// The OS that the program was compiled for. - version(Win32) OS os = OS.win32; - else version(Win64) OS os = OS.win64; - else version(Android) OS os = OS.android; - else version(linux) OS os = OS.linux; - else version(OSX) OS os = OS.osx; - else version(FreeBSD) OS os = OS.freeBSD; - else version(NetBSD) OS os = OS.netBSD; - else version(DragonFlyBSD) OS os = OS.dragonFlyBSD; - else version(Posix) OS os = OS.otherPosix; + version (Win32) OS os = OS.win32; + else version (Win64) OS os = OS.win64; + else version (Android) OS os = OS.android; + else version (linux) OS os = OS.linux; + else version (OSX) OS os = OS.osx; + else version (FreeBSD) OS os = OS.freeBSD; + else version (NetBSD) OS os = OS.netBSD; + else version (DragonFlyBSD) OS os = OS.dragonFlyBSD; + else version (Posix) OS os = OS.otherPosix; else static assert(0, "Unknown OS."); /++ @@ -58,8 +58,8 @@ immutable This is intended for cases where you need to deal with endianness at runtime. If you're doing something which should compile differently depending on whether you're compiling on a big endian or little - endian machine, then please use `version(BigEndian)` and - `version(LittleEndian)`. + endian machine, then please use `version (BigEndian)` and + `version (LittleEndian)`. See_Also: $(DDSUBLINK spec/version,PredefinedVersions, Predefined Versions) @@ -71,7 +71,7 @@ immutable } /// The endianness that the program was compiled for. - version(LittleEndian) Endian endian = Endian.littleEndian; + version (LittleEndian) Endian endian = Endian.littleEndian; else Endian endian = Endian.bigEndian; } diff --git a/std/traits.d b/std/traits.d index a31fb64fc13..253d3f70495 100644 --- a/std/traits.d +++ b/std/traits.d @@ -468,7 +468,7 @@ template QualifierOf(T) alias Qual7 = QualifierOf!( immutable int); static assert(is(Qual7!long == immutable long)); } -version(unittest) +version (unittest) { alias TypeQualifierList = AliasSeq!(MutableOf, ConstOf, SharedOf, SharedConstOf, ImmutableOf); @@ -651,7 +651,7 @@ if (T.length == 1) static assert(fullyQualifiedName!fullyQualifiedName == "std.traits.fullyQualifiedName"); } -version(unittest) +version (unittest) { // Used for both fqnType and fqnSym unittests private struct QualifiedNameTests @@ -2436,7 +2436,7 @@ if (is(T == function)) } } -version(unittest) +version (unittest) { private: // Some function types to test. @@ -6454,7 +6454,7 @@ enum bool isEqualityComparable(T) = ifTestable!(T, unaryFun!"a == a"); assert(b1 != b3); } -version(TestComplex) +version (TestComplex) deprecated @safe unittest { @@ -7886,7 +7886,7 @@ if (sth.length == 1) static assert(TL == AliasSeq!("i", "xi", "yi")); } -version(unittest) private void freeFunc(string); +version (unittest) private void freeFunc(string); @safe unittest { diff --git a/std/typecons.d b/std/typecons.d index 0686a21bb72..0c5ed3ad01c 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -137,7 +137,7 @@ else public: // Deferred in case we get some language support for checking uniqueness. - version(None) + version (None) /** Allows safe construction of `Unique`. It creates the resource and guarantees unique ownership of it (unless `T` publishes aliases of @@ -4833,7 +4833,7 @@ private static: alias Implementation = AutoImplement!(Issue17177, how, templateNot!isFinalFunction); } -version(unittest) +version (unittest) { // Issue 10647 // Add prefix "issue10647_" as a workaround for issue 1238 @@ -5844,7 +5844,7 @@ private template TypeMod(T) enum TypeMod = cast(TypeModifier)(mod1 | mod2); } -version(unittest) +version (unittest) { private template UnittestFuncInfo(alias f) { @@ -6311,7 +6311,7 @@ Assignment operators } //version to have a single properly ddoc'ed function (w/ correct sig) - version(StdDdoc) + version (StdDdoc) { /** Returns a reference to the payload. If (autoInit == @@ -7161,7 +7161,7 @@ mixin template Proxy(alias a) } // excludes struct S; it's 'mixin Proxy!foo' doesn't compile with -dip1000 -version(DIP1000) {} else +version (DIP1000) {} else @system unittest { // bug14213, using function for the payload @@ -7739,14 +7739,14 @@ if (is(T == class)) // Here the temporary scoped A is immediately destroyed. // This means the reference is then invalid. - version(Bug) + version (Bug) { // Wrong, should use `auto` A invalid = scoped!A(); } // Restrictions - version(Bug) + version (Bug) { import std.algorithm.mutation : move; auto invalid = a1.move; // illegal, scoped objects can't be moved @@ -7838,7 +7838,7 @@ if (alignment > 0 && !((alignment - 1) & alignment)) alignmentTest(); - version(DigitalMars) + version (DigitalMars) { void test(size_t size) { diff --git a/std/uni.d b/std/uni.d index 82742cbc0dc..e661d8eec16 100644 --- a/std/uni.d +++ b/std/uni.d @@ -715,7 +715,7 @@ debug(std_uni) import std.stdio; // writefln, writeln private: -version(unittest) +version (unittest) { private: struct TestAliasedString @@ -758,9 +758,9 @@ void copyForward(T,U)(T[] src, U[] dest) } // TODO: update to reflect all major CPUs supporting unaligned reads -version(X86) +version (X86) enum hasUnalignedReads = true; -else version(X86_64) +else version (X86_64) enum hasUnalignedReads = true; else enum hasUnalignedReads = false; // better be safe then sorry @@ -3135,7 +3135,7 @@ pure @system unittest @system private uint safeRead24(scope const ubyte* ptr, size_t idx) pure nothrow @nogc { idx *= 3; - version(LittleEndian) + version (LittleEndian) return ptr[idx] + (cast(uint) ptr[idx+1]<<8) + (cast(uint) ptr[idx+2]<<16); else @@ -3147,7 +3147,7 @@ pure @system unittest @system private void safeWrite24(scope ubyte* ptr, uint val, size_t idx) pure nothrow @nogc { idx *= 3; - version(LittleEndian) + version (LittleEndian) { ptr[idx] = val & 0xFF; ptr[idx+1] = (val >> 8) & 0xFF; @@ -3165,7 +3165,7 @@ pure @system unittest @system private uint unalignedRead24(scope const ubyte* ptr, size_t idx) pure nothrow @nogc { uint* src = cast(uint*)(ptr+3*idx); - version(LittleEndian) + version (LittleEndian) return *src & 0xFF_FFFF; else return *src >> 8; @@ -3175,7 +3175,7 @@ pure @system unittest @system private void unalignedWrite24(scope ubyte* ptr, uint val, size_t idx) pure nothrow @nogc { uint* dest = cast(uint*)(cast(ubyte*) ptr + 3*idx); - version(LittleEndian) + version (LittleEndian) *dest = val | (*dest & 0xFF00_0000); else *dest = (val << 8) | (*dest & 0xFF); @@ -3497,7 +3497,7 @@ pure @safe unittest// Uint24 tests }} } -version(unittest) +version (unittest) { private alias AllSets = AliasSeq!(InversionList!GcPolicy, InversionList!ReallocPolicy); } @@ -3751,7 +3751,7 @@ pure @safe unittest// iteration & opIndex ), text(a.byInterval)); // same @@@BUG as in issue 8949 ? - version(bug8949) + version (bug8949) { import std.range : retro; assert(equal(retro(a.byInterval), @@ -3976,7 +3976,7 @@ private: { // get index to it, reuse ptr space for the next block next_lvl_index = force!NextIdx(j/pageSize); - version(none) + version (none) { import std.stdio : writefln, writeln; writefln("LEVEL(%s) page mapped idx: %s: 0..%s ---> [%s..%s]" @@ -4000,7 +4000,7 @@ private: state[level].idx_zeros = next_lvl_index; } // allocate next page - version(none) + version (none) { import std.stdio : writefln; writefln("LEVEL(%s) page allocated: %s" @@ -5633,7 +5633,7 @@ template Sequence(size_t start, size_t end) import std.range : iota; static trieStats(TRIE)(TRIE t) { - version(std_uni_stats) + version (std_uni_stats) { import std.stdio : writefln, writeln; writeln("---TRIE FOOTPRINT STATS---"); @@ -5643,7 +5643,7 @@ template Sequence(size_t start, size_t end) , i, t.bytes!i, t.pages!i); } writefln("TOTAL: %s bytes", t.bytes); - version(none) + version (none) { writeln("INDEX (excluding value level):"); static foreach (i; 0 .. t.table.dim-1) @@ -5931,7 +5931,7 @@ static assert(isInputRange!DecompressedIntervals); static assert(isForwardRange!DecompressedIntervals); //============================================================================ -version(std_uni_bootstrap){} +version (std_uni_bootstrap){} else { @@ -7229,7 +7229,7 @@ if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) } // For testing non-forward-range input ranges -version(unittest) +version (unittest) private static struct InputRangeString { private string s; @@ -8856,7 +8856,7 @@ private bool notAllowedIn(NormalizationForm norm)(dchar ch) } -version(std_uni_bootstrap) +version (std_uni_bootstrap) { // old version used for bootstrapping of gen_uni.d that generates // up to date optimal versions of all of isXXX functions @@ -10608,4 +10608,4 @@ private: } -}// version(!std_uni_bootstrap) +}// version (!std_uni_bootstrap) diff --git a/std/utf.d b/std/utf.d index ed93763393a..c6b809ca334 100644 --- a/std/utf.d +++ b/std/utf.d @@ -1839,7 +1839,7 @@ unittest } -version(unittest) private void testDecode(R)(R range, +version (unittest) private void testDecode(R)(R range, size_t index, dchar expectedChar, size_t expectedIndex, @@ -1868,7 +1868,7 @@ version(unittest) private void testDecode(R)(R range, } } -version(unittest) private void testDecodeFront(R)(ref R range, +version (unittest) private void testDecodeFront(R)(ref R range, dchar expectedChar, size_t expectedNumCodeUnits, size_t line = __LINE__) @@ -1893,7 +1893,7 @@ version(unittest) private void testDecodeFront(R)(ref R range, } } -version(unittest) private void testDecodeBack(R)(ref R range, +version (unittest) private void testDecodeBack(R)(ref R range, dchar expectedChar, size_t expectedNumCodeUnits, size_t line = __LINE__) @@ -1924,7 +1924,7 @@ version(unittest) private void testDecodeBack(R)(ref R range, } } -version(unittest) private void testAllDecode(R)(R range, +version (unittest) private void testAllDecode(R)(R range, dchar expectedChar, size_t expectedIndex, size_t line = __LINE__) @@ -1938,7 +1938,7 @@ version(unittest) private void testAllDecode(R)(R range, testDecodeFront(range, expectedChar, expectedIndex, line); } -version(unittest) private void testBadDecode(R)(R range, size_t index, size_t line = __LINE__) +version (unittest) private void testBadDecode(R)(R range, size_t index, size_t line = __LINE__) { import core.exception : AssertError; import std.string : format; @@ -1964,7 +1964,7 @@ version(unittest) private void testBadDecode(R)(R range, size_t index, size_t li assertThrown!UTFException(decodeFront(range, index), null, __FILE__, line); } -version(unittest) private void testBadDecodeBack(R)(R range, size_t line = __LINE__) +version (unittest) private void testBadDecodeBack(R)(R range, size_t line = __LINE__) { // This condition is to allow unit testing all `decode` functions together static if (!isBidirectionalRange!R) @@ -3366,7 +3366,7 @@ if (isSomeChar!C) // Ranges of code units for testing. -version(unittest) +version (unittest) { private: struct InputCU(C) @@ -4122,7 +4122,7 @@ pure @safe nothrow @nogc unittest foreach (c; s[].byDchar()) { } } -version(unittest) +version (unittest) private int impureVariable; @system unittest diff --git a/std/variant.d b/std/variant.d index 08d916fcafa..08c10787cfd 100644 --- a/std/variant.d +++ b/std/variant.d @@ -712,7 +712,7 @@ public: } /// - version(unittest) + version (unittest) @system unittest { Variant a; @@ -745,7 +745,7 @@ public: } /// - version(unittest) + version (unittest) @system unittest { Variant a = 5; @@ -1083,7 +1083,7 @@ public: } /// - version(unittest) + version (unittest) @system unittest { Variant a = new int[10]; @@ -1924,7 +1924,7 @@ static class VariantException : Exception } } -version(TestComplex) +version (TestComplex) deprecated @system unittest { diff --git a/std/windows/registry.d b/std/windows/registry.d index e1973b0593a..b18b8f10dd8 100644 --- a/std/windows/registry.d +++ b/std/windows/registry.d @@ -81,7 +81,7 @@ class Win32Exception : WindowsException @property int error() { return super.code; } } -version(unittest) import std.string : startsWith, endsWith; +version (unittest) import std.string : startsWith, endsWith; @safe unittest { @@ -560,14 +560,14 @@ do break; case REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN: - version(LittleEndian) + version (LittleEndian) value = to!string(u.dw); else value = to!string(bswap(u.dw)); break; case REG_VALUE_TYPE.REG_DWORD_BIG_ENDIAN: - version(LittleEndian) + version (LittleEndian) value = to!string(bswap(u.dw)); else value = to!string(u.dw); @@ -646,14 +646,14 @@ do switch (type) { case REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN: - version(LittleEndian) + version (LittleEndian) static assert(REG_VALUE_TYPE.REG_DWORD == REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN); else value = bswap(value); break; case REG_VALUE_TYPE.REG_DWORD_BIG_ENDIAN: - version(LittleEndian) + version (LittleEndian) value = bswap(value); else static assert(REG_VALUE_TYPE.REG_DWORD == REG_VALUE_TYPE.REG_DWORD_BIG_ENDIAN); diff --git a/std/windows/syserror.d b/std/windows/syserror.d index 5c725ec8ee8..331b2aad552 100644 --- a/std/windows/syserror.d +++ b/std/windows/syserror.d @@ -177,7 +177,7 @@ T wenforce(T)(T condition, const(char)[] name, const(wchar)* namez, string file throw new WindowsException(GetLastError(), names, file, line); } -version(Windows) +version (Windows) @system unittest { import std.algorithm.searching : startsWith, endsWith; diff --git a/std/zip.d b/std/zip.d index 3018443da02..7945461542f 100644 --- a/std/zip.d +++ b/std/zip.d @@ -973,8 +973,8 @@ the quick brown fox jumps over the lazy dog\r // Non-Android Posix-only, because we can't rely on the unzip command being // available on Android or Windows -version(Android) {} else -version(Posix) @system unittest +version (Android) {} else +version (Posix) @system unittest { import std.datetime, std.file, std.format, std.path, std.process, std.stdio;