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..89ad3512d6b 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 bd309627136..d6e9ebe303b 100644 --- a/posix.mak +++ b/posix.mak @@ -542,7 +542,7 @@ 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 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 dfc478bcde3..480fa0cc8a8 100644 --- a/std/algorithm/internal.d +++ b/std/algorithm/internal.d @@ -14,7 +14,7 @@ package template algoFormat() } // Internal random array generators -version(StdUnittest) +version (StdUnittest) { 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 cdc4554b8af..a641819617c 100644 --- a/std/algorithm/iteration.d +++ b/std/algorithm/iteration.d @@ -362,18 +362,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; @@ -382,7 +382,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; @@ -1955,7 +1955,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: @@ -2096,7 +2096,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; @@ -4319,7 +4319,7 @@ private struct SplitterResult(alias isTerminator, Range) @property auto front() { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -4336,7 +4336,7 @@ private struct SplitterResult(alias isTerminator, Range) void popFront() { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -4513,14 +4513,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 5b8516e5f16..2942b41d855 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -637,7 +637,7 @@ if (isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range) for (;;) { // Loop invariant - version(StdUnittest) + version (StdUnittest) { import std.algorithm.searching : all; assert(r[0 .. lo].all!(x => !lt(p, x))); @@ -3439,7 +3439,7 @@ done: a.length / 2 + 1); } -version(StdUnittest) +version (StdUnittest) private T[] randomArray(Flag!"exactSize" flag = No.exactSize, T = int)( size_t maxSize = 1000, T minValue = 0, T maxValue = 255) @@ -3957,7 +3957,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 04b1f70c4b3..d3699662d03 100644 --- a/std/array.d +++ b/std/array.d @@ -427,7 +427,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; @@ -550,7 +550,7 @@ private template blockAttribute(T) enum blockAttribute = GC.BlkAttr.NO_SCAN; } } -version(StdUnittest) +version (StdUnittest) { import core.memory : UGC = GC; static assert(!(blockAttribute!void & UGC.BlkAttr.NO_SCAN)); @@ -569,7 +569,7 @@ private template nDimensions(T) } } -version(StdUnittest) +version (StdUnittest) { static assert(nDimensions!(uint[]) == 1); static assert(nDimensions!(float[][]) == 2); diff --git a/std/ascii.d b/std/ascii.d index f929e5797a8..564dfc52261 100644 --- a/std/ascii.d +++ b/std/ascii.d @@ -59,7 +59,7 @@ $(TR $(TD Enums) $(TD +/ module std.ascii; -version(StdUnittest) +version (StdUnittest) { // FIXME: When dmd bug #314 is fixed, make these selective. import std.meta; // : AliasSeq; @@ -111,9 +111,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 ab352bce24a..5401926b6ac 100644 --- a/std/base64.d +++ b/std/base64.d @@ -1914,7 +1914,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 12a1150d7b7..22ac788f8a0 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -58,7 +58,7 @@ import std.range.primitives; public import std.system : Endian; import std.traits; -version(StdUnittest) +version (StdUnittest) { import std.stdio; } @@ -2523,7 +2523,7 @@ if (isIntegral!T || isSomeChar!T || isBoolean!T) { EndianSwapper!T es = void; - version(LittleEndian) + version (LittleEndian) es.value = swapEndian(val); else es.value = val; @@ -2534,7 +2534,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); @@ -2647,7 +2647,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; @@ -2658,7 +2658,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); @@ -2697,7 +2697,7 @@ if (isIntegral!T || isSomeChar!T || isBoolean!T) { EndianSwapper!T es = void; - version(BigEndian) + version (BigEndian) es.value = swapEndian(val); else es.value = val; @@ -2708,7 +2708,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); @@ -2794,7 +2794,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; @@ -2806,7 +2806,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/c/stdlib.d b/std/c/stdlib.d index e05da65a1c1..70ff423e2a8 100644 --- a/std/c/stdlib.d +++ b/std/c/stdlib.d @@ -13,4 +13,4 @@ deprecated("Import core.stdc.stdlib or core.sys.posix.stdlib instead") module std.c.stdlib; public import core.stdc.stdlib; -version(Posix) public import core.sys.posix.stdlib : setenv, unsetenv; +version (Posix) public import core.sys.posix.stdlib : setenv, unsetenv; diff --git a/std/compiler.d b/std/compiler.d index 6ceabcefb45..6b7d07460b9 100644 --- a/std/compiler.d +++ b/std/compiler.d @@ -32,13 +32,13 @@ 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; - else Vendor vendor = Vendor.unknown; + 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 66a6e39d04c..a8ad92ed572 100644 --- a/std/concurrency.d +++ b/std/concurrency.d @@ -707,7 +707,7 @@ do } // Make sure receive() works with free functions as well. -version(StdUnittest) +version (StdUnittest) { private void receiveFunction(int x) {} } @@ -2427,7 +2427,7 @@ private } } -version(StdUnittest) +version (StdUnittest) { import std.stdio; import std.typecons : tuple, Tuple; diff --git a/std/container/rbtree.d b/std/container/rbtree.d index f6711525c54..66b1c0e64ad 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(StdUnittest) debug = RBDoChecks; +version (StdUnittest) debug = RBDoChecks; //debug = RBDoChecks; @@ -745,7 +745,7 @@ if (is(typeof(binaryFun!less(T.init, T.init)))) alias _less = binaryFun!less; - version(StdUnittest) + version (StdUnittest) { static if (is(typeof(less) == string)) { diff --git a/std/conv.d b/std/conv.d index 40f8b597fd5..4d3a69a19f2 100644 --- a/std/conv.d +++ b/std/conv.d @@ -3307,7 +3307,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 @@ -4882,7 +4882,7 @@ if (!is(T == class)) assert(u1.a == "hello"); } -version(StdUnittest) private struct __conv_EmplaceTest +version (StdUnittest) private struct __conv_EmplaceTest { int i = 3; this(int i) @@ -4903,7 +4903,7 @@ version(StdUnittest) private struct __conv_EmplaceTest void opAssign(); } -version(StdUnittest) private class __conv_EmplaceTestClass +version (StdUnittest) private class __conv_EmplaceTestClass { int i = 3; this(int i) @nogc @safe pure nothrow @@ -5323,7 +5323,7 @@ version(StdUnittest) private class __conv_EmplaceTestClass assert(s.i == 2); } } -version(StdUnittest) +version (StdUnittest) { //Ambiguity struct __std_conv_S diff --git a/std/datetime/date.d b/std/datetime/date.d index e34ed972f03..afc77e99335 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(StdUnittest) import std.exception : assertThrown; +version (StdUnittest) import std.exception : assertThrown; @safe unittest { @@ -10305,7 +10305,7 @@ if (isSomeString!T) } -version(StdUnittest) +version (StdUnittest) { // All of these helper arrays are sorted in ascending order. auto testYearsBC = [-1999, -1200, -600, -4, -1, 0]; diff --git a/std/datetime/interval.d b/std/datetime/interval.d index 06d3f5f6cef..e27028ec795 100644 --- a/std/datetime/interval.d +++ b/std/datetime/interval.d @@ -40,7 +40,7 @@ import std.exception : enforce; import std.traits : isIntegral, Unqual; import std.typecons : Flag; -version(StdUnittest) import std.exception : assertThrown; +version (StdUnittest) import std.exception : assertThrown; /++ diff --git a/std/datetime/systime.d b/std/datetime/systime.d index a399a2f487c..d45a3c433d1 100644 --- a/std/datetime/systime.d +++ b/std/datetime/systime.d @@ -43,19 +43,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(StdUnittest) +version (StdUnittest) { import core.exception : AssertError; import std.exception : assertThrown; @@ -106,7 +106,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; @@ -155,7 +155,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); @@ -172,12 +172,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)); @@ -192,7 +192,7 @@ public: hnsecsToUnixEpoch; } } - else version(linux) + else version (linux) { static if (clockType == ClockType.second) return unixTimeToStdTime(core.stdc.time.time(null)); @@ -212,7 +212,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; @@ -228,7 +228,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)); @@ -243,7 +243,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; @@ -259,7 +259,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)); @@ -363,7 +363,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: @@ -2230,7 +2230,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { private struct timespec {} /++ @@ -2240,7 +2240,7 @@ public: +/ timespec toTimeSpec() @safe const pure nothrow; } - else version(Posix) + else version (Posix) { timespec toTimeSpec() @safe const pure nothrow { @@ -2299,7 +2299,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); @@ -2315,7 +2315,7 @@ public: import std.conv : to; import core.time; - version(Posix) + version (Posix) { import std.datetime.timezone : clearTZEnvVar, setTZEnvVar; setTZEnvVar("America/Los_Angeles"); @@ -2334,12 +2334,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"); @@ -2358,12 +2358,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"); @@ -6324,12 +6324,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"); @@ -9109,9 +9109,9 @@ if (is(T == int) || is(T == long)) } -version(StdDdoc) +version (StdDdoc) { - version(Windows) + version (Windows) {} else { @@ -9226,7 +9226,7 @@ version(StdDdoc) +/ FILETIME SysTimeToFILETIME(SysTime sysTime) @safe; } -else version(Windows) +else version (Windows) { SysTime SYSTEMTIMEToSysTime(const SYSTEMTIME* st, immutable TimeZone tz = LocalTime()) @safe { @@ -9749,7 +9749,7 @@ afterMon: stripAndCheckLen(value[3 .. value.length], "1200:00A".length); assertThrown!DateTimeException(parseRFC822DateTime(badStr)); } -version(StdUnittest) void testParse822(alias cr)(string str, SysTime expected, size_t line = __LINE__) +version (StdUnittest) void testParse822(alias cr)(string str, SysTime expected, size_t line = __LINE__) { import std.format : format; auto value = cr(str); @@ -9758,7 +9758,7 @@ version(StdUnittest) void testParse822(alias cr)(string str, SysTime expected, s throw new AssertError(format("wrong result. expected [%s], actual[%s]", expected, result), __FILE__, line); } -version(StdUnittest) void testBadParse822(alias cr)(string str, size_t line = __LINE__) +version (StdUnittest) void testBadParse822(alias cr)(string str, size_t line = __LINE__) { try parseRFC822DateTime(cr(str)); @@ -10686,7 +10686,7 @@ if (isIntegral!T && isSigned!T) // The constraints on R were already covered by } -version(StdUnittest) +version (StdUnittest) { // Variables to help in testing. Duration currLocalDiffFromUTC; @@ -10969,13 +10969,13 @@ version(StdUnittest) 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 12348f64986..7b2ad28bdd3 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(StdUnittest) import std.exception : assertThrown; +version (StdUnittest) import std.exception : assertThrown; /++ @@ -166,9 +166,9 @@ public: deprecated("Use PosixTimeZone.getTimeZone or WindowsTimeZone.getTimeZone instead") static immutable(TimeZone) getTimeZone(string name) @safe { - version(Posix) + version (Posix) return PosixTimeZone.getTimeZone(name); - else version(Windows) + else version (Windows) { import std.datetime.date : DateTimeException; import std.format : format; @@ -227,10 +227,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, @@ -241,12 +241,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); @@ -275,7 +275,7 @@ public: assert(cast(DateTime) dst == dstDate); assert(std == stdUTC); - version(Posix) + version (Posix) { setTZEnvVar(tzName); @@ -347,14 +347,14 @@ public: /+Australia/Adelaide+/ tuple(DateTime(2012, 10, 7), DateTime(2012, 4, 1), 2, 3)]; import std.datetime.date : DateTimeException; - version(Posix) + 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 (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)), @@ -372,7 +372,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)), @@ -520,9 +520,9 @@ public: deprecated("Use PosixTimeZone.getInstalledTZNames or WindowsTimeZone.getInstalledTZNames instead") static string[] getInstalledTZNames(string subName = "") @safe { - version(Posix) + version (Posix) return PosixTimeZone.getInstalledTZNames(subName); - else version(Windows) + else version (Windows) { import std.algorithm.searching : startsWith; import std.algorithm.sorting : sort; @@ -613,7 +613,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ The name of the time zone per the TZ Database. This is the name used @@ -649,7 +649,7 @@ public: +/ @property override string stdName() @trusted const nothrow { - version(Posix) + version (Posix) { import core.stdc.time : tzname; import std.conv : to; @@ -658,7 +658,7 @@ public: catch (Exception e) assert(0, "to!string(tzname[0]) failed."); } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -693,12 +693,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+ } @@ -706,7 +706,7 @@ public: { assert(LocalTime().stdName !is null); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -734,7 +734,7 @@ public: +/ @property override string dstName() @trusted const nothrow { - version(Posix) + version (Posix) { import core.stdc.time : tzname; import std.conv : to; @@ -743,7 +743,7 @@ public: catch (Exception e) assert(0, "to!string(tzname[1]) failed."); } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -780,16 +780,16 @@ public: { 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+ } @@ -813,7 +813,7 @@ public: +/ @property override bool hasDST() @trusted const nothrow { - version(Posix) + version (Posix) { static if (is(typeof(daylight))) return cast(bool)(daylight); @@ -834,7 +834,7 @@ public: assert(0, "Clock.currTime() threw."); } } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -847,7 +847,7 @@ public: { LocalTime().hasDST; - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -877,13 +877,13 @@ public: import core.stdc.time : localtime, tm; time_t unixTime = stdTimeToUnixTime(stdTime); - version(Posix) + version (Posix) { tm* timeInfo = localtime(&unixTime); return cast(bool)(timeInfo.tm_isdst); } - else version(Windows) + else version (Windows) { // Apparently Windows isn't smart enough to deal with negative time_t. if (unixTime >= 0) @@ -922,9 +922,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 : localtime, tm; time_t unixTime = stdTimeToUnixTime(stdTime); @@ -932,7 +932,7 @@ public: return stdTime + convert!("seconds", "hnsecs")(timeInfo.tm_gmtoff); } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -961,7 +961,7 @@ public: +/ override long tzToUTC(long adjTime) @trusted const nothrow { - version(Posix) + version (Posix) { import core.stdc.time : localtime, tm; time_t unixTime = stdTimeToUnixTime(adjTime); @@ -985,7 +985,7 @@ public: return adjTime - convert!("seconds", "hnsecs")(timeInfo.tm_gmtoff); } - else version(Windows) + else version (Windows) { TIME_ZONE_INFORMATION tzInfo; GetTimeZoneInformation(&tzInfo); @@ -1006,7 +1006,7 @@ public: assert(LocalTime().tzToUTC(LocalTime().utcToTZ(0)) == 0); assert(LocalTime().utcToTZ(LocalTime().tzToUTC(0)) == 0); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -1163,7 +1163,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 { @@ -1236,7 +1236,7 @@ public: { assert(UTC().utcToTZ(0) == 0); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -1269,7 +1269,7 @@ public: { assert(UTC().tzToUTC(0) == 0); - version(Posix) + version (Posix) { scope(exit) clearTZEnvVar(); @@ -2029,7 +2029,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ The default directory where the TZ Database files are stored. It's @@ -2041,24 +2041,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 = ""; } @@ -2105,7 +2105,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))); @@ -2119,7 +2119,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; @@ -2305,7 +2305,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. @@ -2415,7 +2415,7 @@ public: /// @safe unittest { - version(Posix) + version (Posix) { auto tz = PosixTimeZone.getTimeZone("America/Los_Angeles"); @@ -2448,9 +2448,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; @@ -2463,7 +2463,7 @@ public: auto timezones = appender!(string[])(); - version(Android) + version (Android) { import std.algorithm.iteration : filter; import std.algorithm.mutation : copy; @@ -2495,7 +2495,7 @@ public: return timezones.data; } - version(Posix) @system unittest + version (Posix) @system unittest { import std.exception : assertNotThrown; import std.stdio : writefln; @@ -2520,7 +2520,7 @@ public: assertNotThrown!DateTimeException(testPTZSuccess(tzName)); // No timezone directories on Android, just a single tzdata file - version(Android) + version (Android) {} else { @@ -2759,7 +2759,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. @@ -2840,7 +2840,7 @@ private: } -version(StdDdoc) +version (StdDdoc) { /++ $(BLUE This class is Windows-Only.) @@ -2957,7 +2957,7 @@ version(StdDdoc) private: - version(Windows) + version (Windows) {} else alias TIME_ZONE_INFORMATION = void*; @@ -2973,7 +2973,7 @@ version(StdDdoc) } } -else version(Windows) +else version (Windows) { final class WindowsTimeZone : TimeZone { @@ -3296,7 +3296,7 @@ else version(Windows) } -version(StdDdoc) +version (StdDdoc) { /++ $(BLUE This function is Posix-Only.) @@ -3317,7 +3317,7 @@ version(StdDdoc) +/ void clearTZEnvVar() @safe nothrow; } -else version(Posix) +else version (Posix) { void setTZEnvVar(string tzDatabaseName) @trusted nothrow { @@ -3326,7 +3326,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)); @@ -4007,7 +4007,7 @@ string tzDatabaseNameToWindowsTZName(string tzName) @safe pure nothrow @nogc } } -version(Windows) version(UpdateWindowsTZTranslations) deprecated @system unittest +version (Windows) version (UpdateWindowsTZTranslations) deprecated @system unittest { import std.stdio : stderr; @@ -4169,7 +4169,7 @@ string windowsTZNameToTZDatabaseName(string tzName) @safe pure nothrow @nogc } } -version(Windows) version(UpdateWindowsTZTranslations) deprecated @system unittest +version (Windows) version (UpdateWindowsTZTranslations) deprecated @system unittest { import std.stdio : stderr; diff --git a/std/digest/crc.d b/std/digest/crc.d index c873aa296d4..1accaec731a 100644 --- a/std/digest/crc.d +++ b/std/digest/crc.d @@ -60,7 +60,7 @@ module std.digest.crc; public import std.digest; -version(StdUnittest) import std.exception; +version (StdUnittest) import std.exception; /// diff --git a/std/digest/hmac.d b/std/digest/hmac.d index 2a195caf69b..749ebde8a01 100644 --- a/std/digest/hmac.d +++ b/std/digest/hmac.d @@ -287,7 +287,7 @@ if (isDigest!H) } } -version(StdUnittest) +version (StdUnittest) { import std.digest : toHexString, LetterCase; alias hex = toHexString!(LetterCase.lower); diff --git a/std/digest/md.d b/std/digest/md.d index 5c7c599dd3d..30899e56657 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 859b1c22e08..f9c5cbe1a61 100644 --- a/std/digest/murmurhash.d +++ b/std/digest/murmurhash.d @@ -658,7 +658,7 @@ L_end: } } -version(StdUnittest) +version (StdUnittest) { import std.string : representation; diff --git a/std/digest/package.d b/std/digest/package.d index 3f3bc15f1ac..7798868d9cb 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. @@ -950,7 +950,7 @@ if (isDigest!T) : Digest return buf; } - version(StdDdoc) + version (StdDdoc) { /** * Works like $(D 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 f4b554d574e..0768c0408d6 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 354aa3d7cff..c4bdf64d9fb 100644 --- a/std/digest/sha.d +++ b/std/digest/sha.d @@ -101,24 +101,24 @@ 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; -version(StdUnittest) +version (StdUnittest) { import std.exception; } @@ -132,7 +132,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; @@ -141,7 +141,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; @@ -150,7 +150,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); @@ -161,7 +161,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; @@ -210,7 +210,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; @@ -1192,7 +1192,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 dd263c75da5..c7bec33b81c 100644 --- a/std/encoding.d +++ b/std/encoding.d @@ -3455,8 +3455,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 { @@ -3518,12 +3518,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]; @@ -3551,8 +3551,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 { @@ -3614,12 +3614,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]; @@ -3634,7 +3634,7 @@ class EncodingSchemeUtf32Native : EncodingScheme // Helper functions -version(StdUnittest) +version (StdUnittest) { void transcodeReverse(Src,Dst)(immutable(Src)[] s, out immutable(Dst)[] r) { @@ -3822,7 +3822,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 ccbb01d09d2..85e747207bb 100644 --- a/std/exception.d +++ b/std/exception.d @@ -514,7 +514,7 @@ private void bailOut(E : Throwable = Exception)(string file, size_t line, in cha 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", ", ", @@ -1771,7 +1771,7 @@ CommonType!(T1, T2) ifThrown(T1, T2)(lazy scope T1 expression, scope T2 delegate static assert(!__traits(compiles, (new Object()).ifThrown(e=>1))); } -version(StdUnittest) package +version (StdUnittest) package @property 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 57a7a266c2d..65750c9d17a 100644 --- a/std/experimental/allocator/building_blocks/allocator_list.d +++ b/std/experimental/allocator/building_blocks/allocator_list.d @@ -7,7 +7,7 @@ module std.experimental.allocator.building_blocks.allocator_list; import std.experimental.allocator.building_blocks.null_allocator; import std.experimental.allocator.common; import std.experimental.allocator.gc_allocator; -version(StdUnittest) import std.stdio; +version (StdUnittest) import std.stdio; // Turn this on for debugging // debug = allocator_list; @@ -549,7 +549,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 9b9766d4b43..04dd22603f2 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; @@ -657,7 +657,7 @@ else } } -version(StdUnittest) +version (StdUnittest) { static void testrw(void[] b) @nogc nothrow { @@ -671,13 +671,13 @@ version(StdUnittest) 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 0b1937139ef..2da80c4b7ab 100644 --- a/std/experimental/allocator/building_blocks/bitmapped_block.d +++ b/std/experimental/allocator/building_blocks/bitmapped_block.d @@ -53,7 +53,7 @@ struct BitmappedBlock(size_t theBlockSize, uint theAlignment = platformAlignment import std.typecons : Ternary; import std.typecons : tuple, Tuple; - version(StdUnittest) + version (StdUnittest) @system unittest { import std.algorithm.comparison : max; diff --git a/std/experimental/allocator/building_blocks/fallback_allocator.d b/std/experimental/allocator/building_blocks/fallback_allocator.d index e30c3136d5e..e1ad2fee8be 100644 --- a/std/experimental/allocator/building_blocks/fallback_allocator.d +++ b/std/experimental/allocator/building_blocks/fallback_allocator.d @@ -29,7 +29,7 @@ struct FallbackAllocator(Primary, Fallback) // Need both allocators to be stateless // This is to avoid using default initialized stateful allocators - version(StdUnittest) + version (StdUnittest) static if (!stateSize!Primary && !stateSize!Fallback) @system unittest { diff --git a/std/experimental/allocator/building_blocks/free_list.d b/std/experimental/allocator/building_blocks/free_list.d index 7ae87b980ff..dfcc71c45ce 100644 --- a/std/experimental/allocator/building_blocks/free_list.d +++ b/std/experimental/allocator/building_blocks/free_list.d @@ -120,7 +120,7 @@ struct FreeList(ParentAllocator, _max = high; } - version(StdUnittest) + version (StdUnittest) @system unittest { import std.experimental.allocator.common : chooseAtRuntime; diff --git a/std/experimental/allocator/building_blocks/free_tree.d b/std/experimental/allocator/building_blocks/free_tree.d index 128981f719b..0768768393a 100644 --- a/std/experimental/allocator/building_blocks/free_tree.d +++ b/std/experimental/allocator/building_blocks/free_tree.d @@ -335,7 +335,7 @@ struct FreeTree(ParentAllocator) return true; } - version(StdUnittest) + version (StdUnittest) @system unittest // test a few simple configurations { import std.experimental.allocator.gc_allocator; @@ -357,7 +357,7 @@ struct FreeTree(ParentAllocator) assert(a.formatSizes == "(_)", a.formatSizes); } - version(StdUnittest) + version (StdUnittest) @system unittest // build a complex free tree { import std.experimental.allocator.gc_allocator, std.range; diff --git a/std/experimental/allocator/building_blocks/kernighan_ritchie.d b/std/experimental/allocator/building_blocks/kernighan_ritchie.d index d380d7d227a..560eb30dc07 100644 --- a/std/experimental/allocator/building_blocks/kernighan_ritchie.d +++ b/std/experimental/allocator/building_blocks/kernighan_ritchie.d @@ -6,7 +6,7 @@ module std.experimental.allocator.building_blocks.kernighan_ritchie; import std.experimental.allocator.building_blocks.null_allocator; //debug = KRRegion; -version(StdUnittest) import std.conv : text; +version (StdUnittest) import std.conv : text; debug(KRRegion) import std.stdio; // KRRegion @@ -486,7 +486,7 @@ struct KRRegion(ParentAllocator = NullAllocator) return true; } - version(assert) foreach (test; byNodePtr) + version (assert) foreach (test; byNodePtr) { assert(test != n); } @@ -554,7 +554,7 @@ struct KRRegion(ParentAllocator = NullAllocator) } /// - version(StdUnittest) + version (StdUnittest) @system unittest { import std.experimental.allocator.gc_allocator : GCAllocator; diff --git a/std/experimental/allocator/building_blocks/region.d b/std/experimental/allocator/building_blocks/region.d index 82e550e3cbc..19d50ae1c0e 100644 --- a/std/experimental/allocator/building_blocks/region.d +++ b/std/experimental/allocator/building_blocks/region.d @@ -646,7 +646,7 @@ that uncontrolled calls to $(D brk) and $(D sbrk) may affect the workings of $(D SbrkRegion) adversely. */ -version(Posix) struct SbrkRegion(uint minAlign = platformAlignment) +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, @@ -830,7 +830,7 @@ version(Posix) struct SbrkRegion(uint minAlign = platformAlignment) } } -version(Posix) @system unittest +version (Posix) @system unittest { // Let's test the assumption that sbrk(n) returns the old address const p1 = sbrk(0); @@ -842,7 +842,7 @@ version(Posix) @system unittest sbrk(-4096); } -version(Posix) @system unittest +version (Posix) @system unittest { import std.typecons : Ternary; import std.algorithm.comparison : min; @@ -865,7 +865,7 @@ version(Posix) @system 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/building_blocks/scoped_allocator.d b/std/experimental/allocator/building_blocks/scoped_allocator.d index 8955049c489..4727b999cf9 100644 --- a/std/experimental/allocator/building_blocks/scoped_allocator.d +++ b/std/experimental/allocator/building_blocks/scoped_allocator.d @@ -23,7 +23,7 @@ struct ScopedAllocator(ParentAllocator) static if (!stateSize!ParentAllocator) { // This test is available only for stateless allocators - version(StdUnittest) + version (StdUnittest) @system unittest { testAllocator!(() => ScopedAllocator()); diff --git a/std/experimental/allocator/common.d b/std/experimental/allocator/common.d index 570ba269727..5186d5126e7 100644 --- a/std/experimental/allocator/common.d +++ b/std/experimental/allocator/common.d @@ -479,7 +479,7 @@ Forwards each of the methods in `funs` (if defined) to `member`. return result; } -version(StdUnittest) +version (StdUnittest) { import std.experimental.allocator : RCIAllocator, RCISharedAllocator; diff --git a/std/experimental/allocator/mallocator.d b/std/experimental/allocator/mallocator.d index 6bc9d3f77f8..bf6f099a5af 100644 --- a/std/experimental/allocator/mallocator.d +++ b/std/experimental/allocator/mallocator.d @@ -12,7 +12,7 @@ import std.experimental.allocator.common; */ struct Mallocator { - version(StdUnittest) + version (StdUnittest) @system unittest { testAllocator!(() => Mallocator.instance); } /** @@ -112,7 +112,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 @@ -225,7 +225,7 @@ struct AlignedMallocator $(HTTP msdn.microsoft.com/en-us/library/8z34s9c6(v=vs.80).aspx, $(D __aligned_malloc)) on Windows. */ - version(Posix) + version (Posix) @trusted @nogc nothrow void[] alignedAllocate(size_t bytes, uint a) shared { @@ -248,7 +248,7 @@ struct AlignedMallocator else return result[0 .. bytes]; } - else version(Windows) + else version (Windows) @trusted @nogc nothrow void[] alignedAllocate(size_t bytes, uint a) shared { @@ -354,11 +354,11 @@ struct AlignedMallocator //... } -version(StdUnittest) version(CRuntime_DigitalMars) +version (StdUnittest) version (CRuntime_DigitalMars) @nogc nothrow size_t addr(ref void* ptr) { return cast(size_t) ptr; } -version(Posix) +version (Posix) @nogc @system nothrow unittest { // 16398 : test the "pseudo" alignedReallocate for Posix @@ -385,7 +385,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 530ee41591f..e8d77176fbc 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. void[] allocate(size_t bytes) shared @@ -48,7 +48,7 @@ struct MmapAllocator return true; } } - else version(Windows) + else version (Windows) { import core.sys.windows.windows : VirtualAlloc, VirtualFree, MEM_COMMIT, PAGE_READWRITE, MEM_RELEASE; diff --git a/std/experimental/allocator/package.d b/std/experimental/allocator/package.d index 2c80a637384..7e0d8af3430 100644 --- a/std/experimental/allocator/package.d +++ b/std/experimental/allocator/package.d @@ -1930,7 +1930,7 @@ if (isInputRange!R && !isInfinite!R) assert(arr2.map!`a.val`.equal(iota(32, 204, 2))); } -version(StdUnittest) +version (StdUnittest) { private struct ForcedInputRange { @@ -2239,7 +2239,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 c07566ee6d3..33cb183fb6a 100644 --- a/std/experimental/checkedint.d +++ b/std/experimental/checkedint.d @@ -2620,7 +2620,7 @@ if (isIntegral!T && T.sizeof >= 4) testPow!ulong(3, 41); } -version(StdUnittest) private struct CountOverflows +version (StdUnittest) private struct CountOverflows { uint calls; auto onOverflow(string op, Lhs)(Lhs lhs) @@ -2645,7 +2645,7 @@ version(StdUnittest) private struct CountOverflows } } -version(StdUnittest) private struct CountOpBinary +version (StdUnittest) 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 3a8fbf352e5..57461cd6c69 100644 --- a/std/experimental/logger/core.d +++ b/std/experimental/logger/core.d @@ -1846,7 +1846,7 @@ package class TestLogger : Logger } } -version(StdUnittest) private void testFuncNames(Logger logger) @safe +version (StdUnittest) 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 fe79a881551..9025dde875e 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 f1cd1c1a84e..f513d8b80a8 100644 --- a/std/file.d +++ b/std/file.d @@ -132,7 +132,7 @@ else return _deleteme; } -version(StdUnittest) private struct TestAliasedString +version (StdUnittest) private struct TestAliasedString { string get() @safe @nogc pure nothrow { return _s; } alias get this; @@ -140,12 +140,12 @@ version(StdUnittest) 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"; @@ -195,18 +195,18 @@ class FileException : Exception line = The _line where the error occurred. Defaults to $(D __LINE__). +/ - version(Windows) this(in char[] name, - uint errno = .GetLastError(), - string file = __FILE__, - size_t line = __LINE__) @safe + version (Windows) this(in char[] name, + uint errno = .GetLastError(), + string file = __FILE__, + size_t line = __LINE__) @safe { this(name, sysErrorString(errno), file, line); this.errno = errno; } - else version(Posix) this(in char[] name, - uint errno = .errno, - string file = __FILE__, - size_t line = __LINE__) @trusted + else version (Posix) this(in char[] name, + uint errno = .errno, + string file = __FILE__, + size_t line = __LINE__) @trusted { import std.exception : errnoString; this(name, errnoString(errno), file, line); @@ -615,8 +615,8 @@ if (isConvertibleToString!R) // Posix implementation helper for write and append -version(Posix) private void writeImpl(const(char)[] name, const(FSChar)* namez, - in void[] buffer, bool append) @trusted +version (Posix) private void writeImpl(const(char)[] name, const(FSChar)* namez, + in void[] buffer, bool append) @trusted { import std.conv : octal; @@ -646,8 +646,8 @@ version(Posix) private void writeImpl(const(char)[] name, const(FSChar)* namez, // Windows implementation helper for write and append -version(Windows) private void writeImpl(const(char)[] name, const(FSChar)* namez, - in void[] buffer, bool append) @trusted +version (Windows) private void writeImpl(const(char)[] name, const(FSChar)* namez, + in void[] buffer, bool append) @trusted { HANDLE h; if (append) @@ -737,7 +737,7 @@ if (isConvertibleToString!RF || isConvertibleToString!RT) private void renameImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, const(FSChar)* toz) @trusted { - version(Windows) + version (Windows) { import std.exception : enforce; @@ -758,7 +758,7 @@ private void renameImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, text("Attempting to rename file ", f, " to ", t))); } } - else version(Posix) + else version (Posix) { static import core.stdc.stdio; @@ -813,11 +813,11 @@ if (isConvertibleToString!R) private void removeImpl(const(char)[] name, const(FSChar)* namez) @trusted { - version(Windows) + version (Windows) { cenforce(DeleteFileW(namez), name, namez); } - else version(Posix) + else version (Posix) { static import core.stdc.stdio; @@ -832,7 +832,7 @@ private void removeImpl(const(char)[] name, const(FSChar)* namez) @trusted } } -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(); @@ -865,7 +865,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; @@ -885,12 +885,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(); @@ -934,7 +934,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 stat_t statbuf) { auto unixTime = mixin(`statbuf.st_` ~ which ~ `time`); @@ -972,7 +972,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; @@ -982,7 +982,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && modificationTime = FILETIMEToSysTime(&ftLastWriteTime); } } - else version(Posix) + else version (Posix) { auto namez = name.tempCString(); @@ -1043,7 +1043,7 @@ if (isConvertibleToString!R) assert(abs(diffm) <= leeway); } - version(fullFileTests) + version (fullFileTests) { import core.thread; enum sleepTime = dur!"seconds"(2); @@ -1073,7 +1073,7 @@ if (isConvertibleToString!R) } -version(StdDdoc) +version (StdDdoc) { /++ $(BLUE This function is Windows-Only.) @@ -1099,7 +1099,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, @@ -1128,7 +1128,7 @@ else version(Windows) } } -version(Windows) @system unittest +version (Windows) @system unittest { import std.stdio : writefln; auto currTime = Clock.currTime(); @@ -1160,7 +1160,7 @@ version(Windows) @system unittest assert(abs(diffm) <= leeway); } - version(fullFileTests) + version (fullFileTests) { import core.thread; Thread.sleep(dur!"seconds"(2)); @@ -1216,7 +1216,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; @@ -1264,7 +1264,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))) @@ -1362,7 +1362,7 @@ SysTime timeLastModified(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { - version(Windows) + version (Windows) { SysTime dummy; SysTime ftm; @@ -1371,7 +1371,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 @@ -1435,7 +1435,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; @@ -1447,7 +1447,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 @@ -1535,13 +1535,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 @@ -1609,7 +1609,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 @@ -1626,7 +1626,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 @@ -1680,11 +1680,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 @@ -1790,11 +1790,11 @@ assert("/usr/share/include".isDir); 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; } @@ -1814,7 +1814,7 @@ if (isConvertibleToString!R) @safe unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) assert("C:\\Program Files\\".isDir); @@ -1822,7 +1822,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); @@ -1834,9 +1834,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) @@ -1864,11 +1864,11 @@ assert(!attrIsDir(getLinkAttributes("/etc/fonts/fonts.conf"))); +/ 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; } @@ -1876,7 +1876,7 @@ bool attrIsDir(uint attributes) @safe pure nothrow @nogc @safe unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) { @@ -1890,7 +1890,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) { @@ -1941,9 +1941,9 @@ assert(!"/usr/share/include".isFile); 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; } @@ -1967,7 +1967,7 @@ if (isConvertibleToString!R) @safe unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) assert(!"C:\\Program Files\\".isFile); @@ -1975,7 +1975,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); @@ -2014,11 +2014,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; } @@ -2026,7 +2026,7 @@ bool attrIsFile(uint attributes) @safe pure nothrow @nogc @safe unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) { @@ -2040,7 +2040,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) { @@ -2076,9 +2076,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; } @@ -2096,7 +2096,7 @@ if (isConvertibleToString!R) @system unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) assert(!"C:\\Program Files\\".isSymlink); @@ -2121,7 +2121,7 @@ if (isConvertibleToString!R) assert(getAttributes(fakeSymFile) == getLinkAttributes(fakeSymFile)); } } - else version(Posix) + else version (Posix) { if (system_directory.exists) { @@ -2190,9 +2190,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; } @@ -2208,14 +2208,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 { @@ -2254,7 +2254,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 { @@ -2266,7 +2266,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; @@ -2303,13 +2303,13 @@ private bool ensureDirExists()(in 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; @@ -2368,7 +2368,7 @@ void mkdirRecurse(in char[] pathname) @safe mkdirRecurse(path); // should not throw } - version(Windows) + version (Windows) { assertThrown!FileException(mkdirRecurse(`1:\foobar`)); } @@ -2407,14 +2407,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 { @@ -2456,12 +2456,12 @@ if (isConvertibleToString!R) $(D 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) || @@ -2484,7 +2484,7 @@ if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || } } -version(Posix) @safe unittest +version (Posix) @safe unittest { if (system_directory.exists) { @@ -2527,7 +2527,7 @@ version(Posix) @safe unittest } } -version(Posix) @safe unittest +version (Posix) @safe unittest { static assert(__traits(compiles, symlink(TestAliasedString(null), TestAliasedString(null)))); @@ -2545,10 +2545,10 @@ version(Posix) @safe unittest Throws: $(D 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) { @@ -2598,7 +2598,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || } } -version(Posix) @safe unittest +version (Posix) @safe unittest { import std.exception : assertThrown; import std.string; @@ -2618,12 +2618,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); @@ -2644,7 +2644,7 @@ version(Posix) @system unittest // input range of dchars * Get the current working directory. * Throws: $(D FileException) on error. */ -version(Windows) string getcwd() +version (Windows) string getcwd() { import std.conv : to; import std.experimental.checkedint : checked; @@ -2655,7 +2655,7 @@ version(Windows) string getcwd() 3. the buffer (lpBuffer) is not large enough: the required size of the buffer, in characters, including the null-terminating character. */ - version(StdUnittest) + version (StdUnittest) enum BUF_SIZE = 10; // trigger reallocation code else enum BUF_SIZE = 4096; // enough for most common case @@ -2814,7 +2814,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. @@ -2966,7 +2966,7 @@ assert(!de2.isFile); +/ @property uint linkAttributes(); - version(Windows) + version (Windows) alias stat_t = void*; /++ @@ -2977,7 +2977,7 @@ assert(!de2.isFile); @property stat_t statBuf(); } } -else version(Windows) +else version (Windows) { struct DirEntry { @@ -3086,7 +3086,7 @@ else version(Windows) uint _attributes; /// The file attributes from WIN32_FIND_DATAW. } } -else version(Posix) +else version (Posix) { struct DirEntry { @@ -3295,7 +3295,7 @@ else version(Posix) @system unittest { - version(Windows) + version (Windows) { if ("C:\\Program Files\\".exists) { @@ -3319,7 +3319,7 @@ else version(Posix) assert(!de.isSymlink); } } - else version(Posix) + else version (Posix) { import std.exception : assertThrown; @@ -3382,7 +3382,7 @@ version (StdDdoc) /// Defaults to $(D Yes.preserveAttributes) on Windows, and the opposite on all other platforms. PreserveAttributes preserveAttributesDefault; } -else version(Windows) +else version (Windows) { enum preserveAttributesDefault = Yes.preserveAttributes; } @@ -3442,7 +3442,7 @@ if (isConvertibleToString!RF || isConvertibleToString!RT) private void copyImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, const(FSChar)* toz, PreserveAttributes preserve) @trusted { - version(Windows) + version (Windows) { assert(preserve == Yes.preserveAttributes); immutable result = CopyFileW(fromz, toz, false); @@ -3457,7 +3457,7 @@ private void copyImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, co throw new FileException(t); } } - else version(Posix) + else version (Posix) { static import core.stdc.stdio; import std.conv : to, octal; @@ -3542,7 +3542,7 @@ private void copyImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, co 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"; @@ -3622,7 +3622,7 @@ void rmdirRecurse(DirEntry de) rmdirRecurse(de); } -version(Windows) @system unittest +version (Windows) @system unittest { import std.exception : enforce; auto d = deleteme ~ r".dir\a\b\c\d\e\f\g"; @@ -3631,7 +3631,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; @@ -3648,7 +3648,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); @@ -3739,7 +3739,7 @@ private struct DirIteratorImpl return de; } - version(Windows) + version (Windows) { WIN32_FIND_DATAW _findinfo; struct DirHandle @@ -3812,7 +3812,7 @@ private struct DirIteratorImpl return _followSymlink ? _cur.isDir : _cur.isDir && !_cur.isSymlink; } } - else version(Posix) + else version (Posix) { struct DirHandle { @@ -4078,7 +4078,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 @@ -4210,12 +4210,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); @@ -4354,7 +4354,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 @@ -4362,7 +4362,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 2cfba740fc9..d1870862053 100644 --- a/std/format.d +++ b/std/format.d @@ -1064,7 +1064,7 @@ if (is(Unqual!Char == Char)) */ ubyte indexEnd; - version(StdDdoc) + version (StdDdoc) { /** The format specifier contained a $(D '-') ($(D printf) @@ -2477,7 +2477,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) if (s.length > 0) { - version(none) + version (none) { return formatValueImpl(w, s, f); } @@ -2656,7 +2656,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 { @@ -2675,7 +2675,7 @@ deprecated } } -version(TestComplex) +version (TestComplex) deprecated @system unittest { @@ -2707,7 +2707,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 { @@ -2720,7 +2720,7 @@ deprecated } } -version(TestComplex) +version (TestComplex) deprecated @system unittest { @@ -4344,7 +4344,7 @@ private T getNth(string kind, alias Condition, T, A...)(uint index, A args) /* ======================== Unit Tests ====================================== */ -version(StdUnittest) +version (StdUnittest) void formatTest(T)(T val, string expected, size_t ln = __LINE__, string fn = __FILE__) { import core.exception : AssertError; @@ -4358,7 +4358,7 @@ void formatTest(T)(T val, string expected, size_t ln = __LINE__, string fn = __F text("expected = `", expected, "`, result = `", w.data, "`"), fn, ln); } -version(StdUnittest) +version (StdUnittest) void formatTest(T)(string fmt, T val, string expected, size_t ln = __LINE__, string fn = __FILE__) @safe { import core.exception : AssertError; @@ -4371,7 +4371,7 @@ void formatTest(T)(string fmt, T val, string expected, size_t ln = __LINE__, str text("expected = `", expected, "`, result = `", w.data, "`"), fn, ln); } -version(StdUnittest) +version (StdUnittest) void formatTest(T)(T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__) { import core.exception : AssertError; @@ -4389,7 +4389,7 @@ void formatTest(T)(T val, string[] expected, size_t ln = __LINE__, string fn = _ text("expected one of `", expected, "`, result = `", w.data, "`"), fn, ln); } -version(StdUnittest) +version (StdUnittest) void formatTest(T)(string fmt, T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__) @safe { import core.exception : AssertError; @@ -4871,7 +4871,7 @@ here: assert(a == "hello" && b == 124 && c == 34.5); } -version(StdUnittest) +version (StdUnittest) void formatReflectTest(T)(ref T val, string fmt, string formatted, string fn = __FILE__, size_t ln = __LINE__) { import core.exception : AssertError; @@ -4913,7 +4913,7 @@ void formatReflectTest(T)(ref T val, string fmt, string formatted, string fn = _ input, fn, ln); } -version(StdUnittest) +version (StdUnittest) void formatReflectTest(T)(ref T val, string fmt, string[] formatted, string fn = __FILE__, size_t ln = __LINE__) { import core.exception : AssertError; @@ -5658,7 +5658,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 c8c35088bcd..da24c030ef3 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; @@ -41,7 +41,7 @@ module std.internal.cstring; import std.range; import std.traits; -version(unittest) +version (unittest) @property inout(C)[] asArray(C)(inout C* cstr) pure nothrow @nogc @trusted if (isSomeChar!C) in { assert(cstr); } @@ -177,7 +177,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) @@ -217,7 +217,7 @@ private: To* _ptr; size_t _length; // length of the string - version(StdUnittest) + version (StdUnittest) // 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 547b208bddf..4060f34a063 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 e633dc30e66..ce87a98e4db 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) { int slowHighestPowerBelowUintMax(uint x) pure nothrow @safe @@ -2387,7 +2387,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]; @@ -2413,7 +2413,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; @@ -2426,7 +2426,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 2f49340c8c5..bd03d2e6fe9 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 386c0a9b1d4..9ed67629df0 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 7203cda186e..47f9145c601 100644 --- a/std/math.d +++ b/std/math.d @@ -136,12 +136,12 @@ static import core.stdc.fenv; import std.range.primitives : isInputRange, ElementType; 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 } @@ -153,11 +153,11 @@ version (PPC64) version = PPC_Any; version (MIPS) version = MIPS_Any; version (MIPS64) version = MIPS_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; } @@ -175,7 +175,7 @@ else version (X86) private alias haveSSE = core.cpuid.sse; } -version(StdUnittest) +version (StdUnittest) { import core.stdc.stdio; // : sprintf; @@ -212,7 +212,7 @@ version(StdUnittest) int ix; int iy; - version(CRuntime_Microsoft) + version (CRuntime_Microsoft) alias real_t = double; else alias real_t = real; @@ -229,7 +229,7 @@ version(StdUnittest) 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; @@ -373,7 +373,7 @@ template floatTraits(T) enum ushort EXPSHIFT = 4; enum realFormat = RealFormat.ibmExtended; // the exponent byte is not unique - version(LittleEndian) + version (LittleEndian) { enum EXPPOS_SHORT = 7; // [3] is also an exp short enum SIGNPOS_BYTE = 15; @@ -389,7 +389,7 @@ template floatTraits(T) } // These apply to all floating-point types -version(LittleEndian) +version (LittleEndian) { enum MANTISSA_LSB = 0; enum MANTISSA_MSB = 1; @@ -836,7 +836,7 @@ deprecated real tan(real x) @trusted pure nothrow @nogc { - version(D_InlineAsm_X86) + version (D_InlineAsm_X86) { asm pure nothrow @nogc { @@ -873,7 +873,7 @@ Clear1: asm pure nothrow @nogc{ Lret: {} } - else version(D_InlineAsm_X86_64) + else version (D_InlineAsm_X86_64) { version (Win64) { @@ -1149,7 +1149,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) { return atan2(x, 1.0L); } @@ -1276,7 +1276,7 @@ float atan(float x) @safe pure nothrow @nogc { return atan(cast(real) x); } */ real atan2(real y, real x) @trusted pure nothrow @nogc { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { version (Win64) { @@ -1738,14 +1738,14 @@ auto sqrt(creal z) @nogc @safe pure nothrow */ real exp(real x) @trusted pure nothrow @nogc { - version(D_InlineAsm_X86) + version (D_InlineAsm_X86) { // e^^x = 2^^(LOG2E*x) // (This is valid because the overflow & underflow limits for exp // and exp2 are so similar). return exp2(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 @@ -1899,7 +1899,7 @@ float exp(float x) @safe pure nothrow @nogc { return exp(cast(real) x); } */ real expm1(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 @@ -1971,7 +1971,7 @@ L_largenegative: ret PARAMSIZE; } } - else version(D_InlineAsm_X86_64) + else version (D_InlineAsm_X86_64) { asm pure nothrow @nogc { @@ -2168,7 +2168,7 @@ L_largenegative: pragma(inline, true) real exp2(real x) @nogc @trusted pure nothrow { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { if (!__ctfe) return exp2Asm(x); @@ -2181,10 +2181,10 @@ real exp2(real x) @nogc @trusted pure nothrow } } -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 @@ -2270,7 +2270,7 @@ L_was_nan: ret PARAMSIZE; } } - else version(D_InlineAsm_X86_64) + else version (D_InlineAsm_X86_64) { asm pure nothrow @nogc { @@ -2462,7 +2462,7 @@ private real exp2Impl(real x) @nogc @trusted pure nothrow @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 ); @@ -2600,7 +2600,7 @@ private real exp2Impl(real x) @nogc @trusted 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) { @@ -3588,7 +3588,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 @@ -3805,7 +3805,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) @@ -4019,7 +4019,7 @@ real ceil(real x) @trusted pure nothrow @nogc ret ; } } - else version(CRuntime_Microsoft) + else version (CRuntime_Microsoft) { short cw; asm pure nothrow @nogc @@ -4147,7 +4147,7 @@ real floor(real x) @trusted pure nothrow @nogc ret ; } } - else version(CRuntime_Microsoft) + else version (CRuntime_Microsoft) { short cw; asm pure nothrow @nogc @@ -4380,7 +4380,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) { @@ -4611,7 +4611,7 @@ long lround(real x) @trusted nothrow @nogc assert(0, "lround not implemented"); } -version(Posix) +version (Posix) { @safe nothrow @nogc unittest { @@ -4647,7 +4647,7 @@ real trunc(real x) @trusted nothrow @nogc ret ; } } - else version(CRuntime_Microsoft) + else version (CRuntime_Microsoft) { short cw; asm pure nothrow @nogc @@ -4760,7 +4760,7 @@ private: private: static uint getIeeeFlags() { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { ushort sw; asm pure nothrow @nogc { fstsw sw; } @@ -4792,7 +4792,7 @@ private: } static void resetIeeeFlags() @nogc { - version(InlineAsm_X86_Any) + version (InlineAsm_X86_Any) { asm pure nothrow @nogc { @@ -4883,7 +4883,7 @@ public: assert(ieeeFlags == f); } -version(D_HardFloat) @system unittest +version (D_HardFloat) @system unittest { import std.meta : AliasSeq; @@ -4929,23 +4929,23 @@ version(D_HardFloat) @system unittest }} } -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(AArch64) +else version (AArch64) { version = IeeeFlagsSupport; } -else version(ARM) +else version (ARM) { version = IeeeFlagsSupport; } @@ -5012,7 +5012,7 @@ struct FloatingPointControl { alias RoundingMode = uint; /// - version(StdDdoc) + version (StdDdoc) { enum : RoundingMode { @@ -5069,7 +5069,7 @@ struct FloatingPointControl alias ExceptionMask = uint; /// - version(StdDdoc) + version (StdDdoc) { enum : ExceptionMask { @@ -5089,7 +5089,7 @@ struct FloatingPointControl allExceptions, /// ditto } } - else version(AArch64) + else version (AArch64) { enum : ExceptionMask { @@ -5104,7 +5104,7 @@ struct FloatingPointControl | inexactException, } } - else version(ARM) + else version (ARM) { enum : ExceptionMask { @@ -5120,7 +5120,7 @@ struct FloatingPointControl | inexactException | subnormalException, } } - else version(PPC_Any) + else version (PPC_Any) { enum : ExceptionMask { @@ -5135,7 +5135,7 @@ struct FloatingPointControl | inexactException, } } - else version(MIPS_Any) + else version (MIPS_Any) { enum : ExceptionMask { @@ -5173,13 +5173,13 @@ public: /// Returns: true if the current FPU supports exception trapping @property static bool hasExceptionTraps() @safe nothrow @nogc { - 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(AArch64) + else version (AArch64) { auto oldState = getControlState(); // If exceptions are not supported, we set the bit but read it back as zero @@ -5189,7 +5189,7 @@ public: setControlState(oldState); return result; } - else version(ARM) + else version (ARM) { auto oldState = getControlState(); // If exceptions are not supported, we set the bit but read it back as zero @@ -5208,7 +5208,7 @@ public: { assert(hasExceptionTraps); initialize(); - version(X86_Any) + version (X86_Any) setControlState(getControlState() & ~(exceptions & allExceptions)); else setControlState(getControlState() | (exceptions & allExceptions)); @@ -5219,7 +5219,7 @@ public: { assert(hasExceptionTraps); initialize(); - version(X86_Any) + version (X86_Any) setControlState(getControlState() | (exceptions & allExceptions)); else setControlState(getControlState() & ~(exceptions & allExceptions)); @@ -5229,7 +5229,7 @@ public: @property static ExceptionMask enabledExceptions() @nogc { assert(hasExceptionTraps); - version(X86_Any) + version (X86_Any) return (getControlState() & allExceptions) ^ allExceptions; else return (getControlState() & allExceptions); @@ -5248,19 +5248,19 @@ private: bool initialized = false; - version(AArch64) + version (AArch64) { alias ControlState = uint; } - else version(ARM) + else version (ARM) { 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; } @@ -5364,7 +5364,7 @@ private: } ensureDefaults(); - version(D_HardFloat) + version (D_HardFloat) { { FloatingPointControl ctrl; @@ -5389,7 +5389,7 @@ private: ensureDefaults(); } -version(D_HardFloat) @system unittest // rounding +version (D_HardFloat) @system unittest // rounding { import std.meta : AliasSeq; @@ -6008,7 +6008,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; } @@ -6060,7 +6060,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)); } @@ -6532,11 +6532,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"); } @@ -6844,7 +6844,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 @@ -6870,7 +6870,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; @@ -6897,8 +6897,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. @@ -7938,7 +7938,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 6d6fbe2d820..598bd091aff 100644 --- a/std/meta.d +++ b/std/meta.d @@ -950,7 +950,7 @@ template Filter(alias pred, TList...) // Used in template predicate unit tests below. -private version(StdUnittest) +private version (StdUnittest) { template testAlways(T...) { diff --git a/std/mmfile.d b/std/mmfile.d index c11234c7bf7..e1f578481ca 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; @@ -495,7 +495,7 @@ class MmFile private void unmap() { debug (MMFILE) printf("MmFile.unmap()\n"); - version(Windows) + version (Windows) { wenforce(!data.ptr || UnmapViewOfFile(data.ptr) != FALSE, "UnmapViewOfFile"); } @@ -514,7 +514,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); @@ -631,7 +631,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; @@ -669,7 +669,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 2cca4197499..15f24f0853f 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -164,7 +164,7 @@ import std.encoding : EncodingScheme; import std.traits : isSomeChar; import std.typecons : Flag, Yes, No, Tuple; -version(StdUnittest) +version (StdUnittest) { import std.socket : Socket; @@ -310,7 +310,7 @@ version(StdUnittest) 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 enum _defaultDataTimeout = dur!"minutes"(2); diff --git a/std/numeric.d b/std/numeric.d index 6b1cf68df0b..379ab1d2fed 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -26,7 +26,7 @@ import std.range.primitives; import std.traits; import std.typecons; -version(StdUnittest) +version (StdUnittest) { import std.stdio; } @@ -684,7 +684,7 @@ on very many factors. template FPTemporary(F) if (isFloatingPoint!F) { - version(X86) + version (X86) alias FPTemporary = real; else alias FPTemporary = Unqual!F; @@ -2616,7 +2616,7 @@ T gcd(T)(T a, T b) { 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 3b8b8ab0c9d..ce6fc28aadf 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; } @@ -4103,7 +4103,7 @@ private struct RoundRobinBuffer(C1, C2) } } -version(StdUnittest) +version (StdUnittest) { // This was the only way I could get nested maps to work. __gshared TaskPool poolInstance; @@ -4523,7 +4523,7 @@ version(StdUnittest) // 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 { @@ -4770,7 +4770,7 @@ version(parallelismStressTest) } } -version(StdUnittest) +version (StdUnittest) { struct __S_12733 { diff --git a/std/path.d b/std/path.d index 715fdf9dfaa..7150ba698dc 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(StdUnittest) +version (StdUnittest) { 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,7 +147,7 @@ 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; } @@ -160,17 +160,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 @@ -842,9 +842,9 @@ private auto _driveName(R)(R path) { 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" } @@ -898,7 +898,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]; @@ -920,9 +920,9 @@ private auto _stripDrive(R)(R path) { 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" } @@ -934,7 +934,7 @@ private auto _stripDrive(R)(R path) @safe unittest { - version(Windows) + version (Windows) { assert(stripDrive(`d:\dir\file`) == `\dir\file`); assert(stripDrive(`\\server\share\dir\file`) == `\dir\file`); @@ -945,7 +945,7 @@ private auto _stripDrive(R)(R path) foreach (i, c; `\dir\file`) assert(s[i] == c); } - version(Posix) + version (Posix) { assert(stripDrive(`d:\dir\file`) == `d:\dir\file`); @@ -994,7 +994,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); @@ -3916,7 +3916,7 @@ if (isConvertibleToString!Range) */ string expandTilde(string inputPath) nothrow { - version(Posix) + version (Posix) { import core.exception : onOutOfMemoryError; import core.stdc.errno : errno, ERANGE; @@ -3976,7 +3976,7 @@ string expandTilde(string inputPath) 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; } @@ -4062,7 +4062,7 @@ string expandTilde(string inputPath) nothrow else return expandFromDatabase(inputPath); } - else version(Windows) + else version (Windows) { // Put here real windows implementation. return inputPath; @@ -4114,7 +4114,7 @@ string expandTilde(string inputPath) nothrow } } -version(StdUnittest) +version (StdUnittest) { /* Define a mock RandomAccessRange to use for unittesting. */ @@ -4145,7 +4145,7 @@ version(StdUnittest) static assert( isRandomAccessRange!(MockRange!(const(char))) ); } -version(StdUnittest) +version (StdUnittest) { /* Define a mock BidirectionalRange to use for unittesting. */ diff --git a/std/process.d b/std/process.d index 2b10a889da0..19b74753c77 100644 --- a/std/process.d +++ b/std/process.d @@ -334,7 +334,7 @@ Pid spawnProcess(in 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(in 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(StdUnittest) +version (StdUnittest) private struct TestScript { this(string code) @system @@ -2777,7 +2777,7 @@ private struct TestScript string path; } -version(StdUnittest) +version (StdUnittest) 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(StdUnittest) +version (Windows) version (StdUnittest) { import core.stdc.stddef; import core.stdc.wchar_ : wcslen; @@ -3194,7 +3194,7 @@ string escapeShellFileName(in 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 @@ -3762,7 +3762,7 @@ version (Posix) { import core.sys.posix.stdlib; } -version(StdUnittest) +version (StdUnittest) { import std.conv, std.file, std.random; } @@ -3797,7 +3797,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, in char *, in char **); +version (Windows) extern(C) int spawnvp(int, in char *, in char **); alias P_WAIT = _P_WAIT; alias P_NOWAIT = _P_NOWAIT; @@ -3874,7 +3874,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) { @@ -3900,7 +3900,7 @@ extern(C) int execv(in char *, in char **); int execve(in char *, in char **, in char **); int execvp(in char *, in char **); - version(Windows) int execvpe(in char *, in char **, in char **); + version (Windows) int execvpe(in char *, in char **, in char **); } private int execv_(in string pathname, in string[] argv) @@ -3938,7 +3938,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; @@ -3973,7 +3973,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_); @@ -3991,7 +3991,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 0b1c05d10e2..87a5822f45b 100644 --- a/std/random.d +++ b/std/random.d @@ -75,7 +75,7 @@ import std.traits; static assert(is(typeof(u) == uint)); } -version(StdUnittest) +version (StdUnittest) { static import std.meta; package alias PseudoRngTypes = std.meta.AliasSeq!(MinstdRand0, MinstdRand, Mt19937, Xorshift32, Xorshift64, @@ -532,7 +532,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); } assert(rnd1.take(100).array() == rnd2.take(100).array()); }} } @@ -969,7 +969,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); } assert(gen1.take(100).array() == gen2.take(100).array()); }} } @@ -1270,7 +1270,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); } assert(rnd1.take(100).array() == rnd2.take(100).array()); } } diff --git a/std/range/interfaces.d b/std/range/interfaces.d index b3a24408ea6..3ee3923c0dd 100644 --- a/std/range/interfaces.d +++ b/std/range/interfaces.d @@ -186,7 +186,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); @@ -441,7 +441,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 1c683a76685..2489119c645 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -8910,7 +8910,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) @@ -9555,7 +9555,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 @@ -10474,7 +10474,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ +/ @property auto front() {assert(0);} @@ -10502,7 +10502,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { @property bool empty(); /// @property bool empty() const; ///Ditto @@ -10530,7 +10530,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if $(D isForwardRange!R) is $(D true). @@ -10600,7 +10600,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if $(D isBidirectionalRange!R) is $(D true). @@ -10637,7 +10637,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if $(D isRandomAccesRange!R) is $(D true). @@ -10693,7 +10693,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if $(D hasLength!R) is $(D true). @@ -10722,7 +10722,7 @@ public: } - version(StdDdoc) + version (StdDdoc) { /++ Only defined if $(D hasSlicing!R) is $(D true). diff --git a/std/range/primitives.d b/std/range/primitives.d index b670ec7effb..6b02a3ea48e 100644 --- a/std/range/primitives.d +++ b/std/range/primitives.d @@ -1471,7 +1471,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)); @@ -2121,7 +2121,7 @@ if (!isNarrowString!(T[]) && !is(T[] == void[])) assert(a == [ 2, 3 ]); } -version(StdUnittest) +version (StdUnittest) { static assert(!is(typeof({ int[4] a; popFront(a); }))); static assert(!is(typeof({ immutable int[] a; popFront(a); }))); @@ -2242,7 +2242,7 @@ if (!isNarrowString!(T[]) && !is(T[] == void[])) assert(a == [ 1, 2 ]); } -version(StdUnittest) +version (StdUnittest) { static assert(!is(typeof({ immutable int[] a; popBack(a); }))); static assert(!is(typeof({ int[4] a; popBack(a); }))); diff --git a/std/regex/internal/parser.d b/std/regex/internal/parser.d index a4caae38bcd..ce29c8de9d9 100644 --- a/std/regex/internal/parser.d +++ b/std/regex/internal/parser.d @@ -41,7 +41,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 3153ebd0a4f..0a4892821ca 100644 --- a/std/regex/internal/tests.d +++ b/std/regex/internal/tests.d @@ -403,23 +403,23 @@ import std.uni : Escapables; // characters that need escaping 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 61d2d88fbe9..d19b72af82d 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 33f4eff44aa..18d0e816882 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 6a5e5ff2ba8..2eff315b694 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(StdUnittest) +version (StdUnittest) { static assert(is(uint32_t == uint)); static assert(is(uint16_t == ushort)); @@ -155,7 +155,7 @@ class SocketException: Exception */ string formatSocketError(int err) @trusted { - version(Posix) + version (Posix) { char[80] buf; const(char)* cs; @@ -223,7 +223,7 @@ string formatSocketError(int err) @trusted return cs[0 .. len].idup; } else - version(Windows) + version (Windows) { return sysErrorString(err); } @@ -307,9 +307,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); @@ -325,7 +325,7 @@ private immutable shared static this() @system { - version(Windows) + version (Windows) { WSADATA wd; @@ -349,7 +349,7 @@ shared static this() @system GetProcAddress(ws2Lib, "freeaddrinfo"); } } - else version(Posix) + else version (Posix) { getnameinfoPointer = &getnameinfo; getaddrinfoPointer = &getaddrinfo; @@ -360,7 +360,7 @@ shared static this() @system shared static ~this() @system nothrow @nogc { - version(Windows) + version (Windows) { WSACleanup(); } @@ -491,7 +491,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 { softUnittest({ @@ -733,7 +733,7 @@ class InternetHost return true; } - version(Windows) + version (Windows) alias getHost = getHostNoSync; else { @@ -875,7 +875,7 @@ enum AddressInfoFlags: int */ private string formatGaiError(int err) @trusted { - version(Windows) + version (Windows) { return sysErrorString(err); } @@ -1323,7 +1323,7 @@ abstract class Address { if (ret == EAI_NONAME) return null; - version(Windows) + version (Windows) if (ret == WSANO_DATA) return null; } @@ -1922,7 +1922,7 @@ public: } -version(StdDdoc) +version (StdDdoc) { static if (!is(sockaddr_un)) { @@ -2457,7 +2457,7 @@ public: { softUnittest({ enum PAIRS = 768; - version(Posix) + version (Posix) () @trusted { enum LIMIT = 2048; @@ -2619,7 +2619,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 @@ -2631,7 +2631,7 @@ private: @safe unittest { - version(SlowTests) + version (SlowTests) softUnittest({ import std.datetime.stopwatch; import std.typecons; @@ -2751,11 +2751,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); } @@ -2764,14 +2764,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) @@ -2825,12 +2825,12 @@ public: if (!blocking) { - version(Windows) + version (Windows) { if (WSAEWOULDBLOCK == err) return; } - else version(Posix) + else version (Posix) { if (EINPROGRESS == err) return; @@ -2888,7 +2888,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 } @@ -2910,11 +2910,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); } @@ -2999,7 +2999,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); @@ -3025,7 +3025,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 @@ -3049,7 +3049,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); @@ -3072,7 +3072,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) @@ -3106,7 +3106,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); @@ -3138,7 +3138,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 @@ -3330,7 +3330,7 @@ public: */ void setKeepAlive(int time, int interval) @trusted { - version(Windows) + version (Windows) { tcp_keepalive options; options.onoff = 1; @@ -3412,7 +3412,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; @@ -3466,12 +3466,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; @@ -3621,7 +3621,7 @@ class UdpSocket: Socket */ Socket[2] socketPair() @trusted { - version(Posix) + version (Posix) { int[2] socks; if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1) @@ -3637,7 +3637,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 16d34f0e940..6e8b615fa45 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -93,7 +93,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. @@ -244,7 +244,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() @@ -676,7 +676,7 @@ opengroup.org/onlinepubs/007908799/xsh/_popen.html, _popen). Throws: $(D ErrnoException) in case of error. */ - version(Posix) void popen(string command, in char[] stdioOpenmode = "r") @safe + version (Posix) void popen(string command, in char[] stdioOpenmode = "r") @safe { resetFile(command, stdioOpenmode ,true); } @@ -733,7 +733,7 @@ Throws: $(D 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 $(D detach) (throwing on failure), and then attempts to @@ -742,10 +742,10 @@ be compatible with the access attributes of the handle. Windows only. Throws: $(D ErrnoException) in case of error. */ - version(StdDdoc) + version (StdDdoc) void windowsHandleOpen(HANDLE handle, in char[] stdioOpenmode); - version(Windows) + version (Windows) void windowsHandleOpen(HANDLE handle, in char[] stdioOpenmode) { import core.stdc.stdint : intptr_t; @@ -984,12 +984,12 @@ $(D rawRead) always reads in binary mode on Windows. 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; @@ -1039,13 +1039,13 @@ Throws: $(D ErrnoException) if the file is not opened or if the call to $(D fwri 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; @@ -1234,7 +1234,7 @@ Throws: $(D Exception) if the file is not opened. } - version(Windows) + version (Windows) { import core.sys.windows.windows : ULARGE_INTEGER, OVERLAPPED, BOOL; @@ -1263,7 +1263,7 @@ Throws: $(D 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) @@ -1312,7 +1312,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 ? @@ -1350,7 +1350,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; @@ -1384,7 +1384,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), @@ -1394,7 +1394,7 @@ Removes the lock over the specified file segment. static assert(false); } - version(Windows) + version (Windows) @system unittest { static import std.file; @@ -1413,7 +1413,7 @@ Removes the lock over the specified file segment. g.unlock(); } - version(Posix) + version (Posix) @system unittest { static import std.file; @@ -2056,10 +2056,10 @@ Returns the file number corresponding to this object. /** Returns the underlying operating system $(D HANDLE) (Windows only). */ - version(StdDdoc) + version (StdDdoc) @property HANDLE windowsHandle(); - version(Windows) + version (Windows) @property HANDLE windowsHandle() { version (DIGITAL_MARS_STDIO) @@ -2492,7 +2492,7 @@ $(REF readText, std,file) import std.algorithm.comparison : equal; import std.range : drop, take; - version(Win64) + version (Win64) { static import std.file; @@ -2501,7 +2501,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; @@ -2642,7 +2642,7 @@ $(REF readText, std,file) @property nothrow ubyte[] front() { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -2654,7 +2654,7 @@ $(REF readText, std,file) /// Ditto void popFront() { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -3489,7 +3489,7 @@ struct LockingTextReader { if (!_hasChar) { - version(assert) + version (assert) { import core.exception : RangeError; if (empty) @@ -4127,11 +4127,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 @@ -5230,7 +5230,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) { @@ -5273,7 +5273,7 @@ version(linux) } } -version(StdUnittest) string testFilename(string file = __FILE__, size_t line = __LINE__) @safe +version (StdUnittest) 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 b41b97214ef..9e954b95132 100644 --- a/std/string.d +++ b/std/string.d @@ -143,7 +143,7 @@ Source: $(PHOBOSSRC std/_string.d) */ module std.string; -version(StdUnittest) +version (StdUnittest) { private: struct TestAliasedString @@ -6400,7 +6400,7 @@ if (isSomeString!S || assert(!isNumeric("+")); } -version(TestComplex) +version (TestComplex) deprecated unittest { diff --git a/std/system.d b/std/system.d index 2320ff09b20..e0b3dee8dae 100644 --- a/std/system.d +++ b/std/system.d @@ -18,8 +18,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 $(D version(Windows)), - $(D version(linux)), etc. + on different OSes, then please use $(D version (Windows)), + $(D version (linux)), etc. See_Also: $(DDSUBLINK spec/version,PredefinedVersions, Predefined Versions) @@ -39,15 +39,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."); /++ @@ -57,8 +57,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 $(D version(BigEndian)) and - $(D version(LittleEndian)). + endian machine, then please use $(D version (BigEndian)) and + $(D version (LittleEndian)). See_Also: $(DDSUBLINK spec/version,PredefinedVersions, Predefined Versions) @@ -70,7 +70,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 c98d5eabf8f..3c041c53200 100644 --- a/std/traits.d +++ b/std/traits.d @@ -334,7 +334,7 @@ template QualifierOf(T) alias Qual7 = QualifierOf!( immutable int); static assert(is(Qual7!long == immutable long)); } -version(StdUnittest) +version (StdUnittest) { alias TypeQualifierList = AliasSeq!(MutableOf, ConstOf, SharedOf, SharedConstOf, ImmutableOf); @@ -393,7 +393,7 @@ template packageName(alias T) static assert(packageName!(X12287!int.i) == "std"); } -version (none) version(unittest) //Please uncomment me when changing packageName to test global imports +version (none) version (unittest) //Please uncomment me when changing packageName to test global imports { import core.sync.barrier; // global import static assert(packageName!core == "core"); @@ -448,7 +448,7 @@ template moduleName(alias T) static assert(moduleName!(X12287!int.i) == "std.traits"); } -version (none) version(unittest) //Please uncomment me when changing moduleName to test global imports +version (none) version (unittest) //Please uncomment me when changing moduleName to test global imports { import core.sync.barrier; // global import static assert(!__traits(compiles, moduleName!(core.sync))); @@ -482,7 +482,7 @@ template fullyQualifiedName(T...) static assert(fullyQualifiedName!fullyQualifiedName == "std.traits.fullyQualifiedName"); } -version(StdUnittest) +version (StdUnittest) { // Used for both fqnType and fqnSym unittests private struct QualifiedNameTests @@ -2238,7 +2238,7 @@ template SetFunctionAttributes(T, string linkage, uint attrs) } } -version(StdUnittest) +version (StdUnittest) { // Some function types to test. int sc(scope int, ref int, out int, lazy int, int); @@ -6138,7 +6138,7 @@ enum bool isEqualityComparable(T) = ifTestable!(T, unaryFun!"a == a"); assert(b1 != b3); } -version(TestComplex) +version (TestComplex) deprecated @safe unittest { @@ -7498,7 +7498,7 @@ template mangledName(sth...) static assert(TL == AliasSeq!("i", "xi", "yi")); } -version(StdUnittest) void freeFunc(string); +version (StdUnittest) void freeFunc(string); @safe unittest { diff --git a/std/typecons.d b/std/typecons.d index 3e5d5dbb083..b363faa914b 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -136,7 +136,7 @@ else public: // Deferred in case we get some language support for checking uniqueness. - version(None) + version (None) /** Allows safe construction of $(D Unique). It creates the resource and guarantees unique ownership of it (unless $(D T) publishes aliases of @@ -4264,7 +4264,7 @@ private static: alias Implementation = AutoImplement!(Issue17177, how, templateNot!isFinalFunction); } -version(StdUnittest) +version (StdUnittest) { // Issue 10647 // Add prefix "issue10647_" as a workaround for issue 1238 @@ -5235,7 +5235,7 @@ private template TypeMod(T) enum TypeMod = cast(TypeModifier)(mod1 | mod2); } -version(StdUnittest) +version (StdUnittest) { private template UnittestFuncInfo(alias f) { @@ -5679,7 +5679,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 == @@ -7017,14 +7017,14 @@ template scoped(T) // 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 @@ -7116,7 +7116,7 @@ private uintptr_t _alignUp(uintptr_t alignment)(uintptr_t n) alignmentTest(); - version(DigitalMars) + version (DigitalMars) { void test(size_t size) { diff --git a/std/uni.d b/std/uni.d index 2cc1e7f6c51..cd8f98f4439 100644 --- a/std/uni.d +++ b/std/uni.d @@ -719,7 +719,7 @@ debug(std_uni) import std.stdio; // writefln, writeln private: -version(StdUnittest) +version (StdUnittest) { private: struct TestAliasedString @@ -762,9 +762,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 @@ -3130,7 +3130,7 @@ private: @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 @@ -3142,7 +3142,7 @@ private: @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; @@ -3160,7 +3160,7 @@ private: @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; @@ -3170,7 +3170,7 @@ private: @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); @@ -3492,7 +3492,7 @@ private: }} } -version(StdUnittest) +version (StdUnittest) { private alias AllSets = AliasSeq!(InversionList!GcPolicy, InversionList!ReallocPolicy); } @@ -3746,7 +3746,7 @@ version(StdUnittest) ), text(a.byInterval)); // same @@@BUG as in issue 8949 ? - version(bug8949) + version (bug8949) { import std.range : retro; assert(equal(retro(a.byInterval), @@ -3971,7 +3971,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]" @@ -3995,7 +3995,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" @@ -5629,7 +5629,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---"); @@ -5639,7 +5639,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) @@ -5927,7 +5927,7 @@ static assert(isInputRange!DecompressedIntervals); static assert(isForwardRange!DecompressedIntervals); //============================================================================ -version(std_uni_bootstrap){} +version (std_uni_bootstrap){} else { @@ -7224,7 +7224,7 @@ if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) } // For testing non-forward-range input ranges -version(StdUnittest) +version (StdUnittest) private static struct InputRangeString { private string s; @@ -8763,7 +8763,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 @@ -10455,4 +10455,4 @@ private: } -}// version(!std_uni_bootstrap) +}// version (!std_uni_bootstrap) diff --git a/std/utf.d b/std/utf.d index 71681d368f7..857e651bf7f 100644 --- a/std/utf.d +++ b/std/utf.d @@ -1736,11 +1736,11 @@ unittest } -version(StdUnittest) private void testDecode(R)(R range, - size_t index, - dchar expectedChar, - size_t expectedIndex, - size_t line = __LINE__) +version (StdUnittest) private void testDecode(R)(R range, + size_t index, + dchar expectedChar, + size_t expectedIndex, + size_t line = __LINE__) { import core.exception : AssertError; import std.string : format; @@ -1765,10 +1765,10 @@ version(StdUnittest) private void testDecode(R)(R range, } } -version(StdUnittest) private void testDecodeFront(R)(ref R range, - dchar expectedChar, - size_t expectedNumCodeUnits, - size_t line = __LINE__) +version (StdUnittest) private void testDecodeFront(R)(ref R range, + dchar expectedChar, + size_t expectedNumCodeUnits, + size_t line = __LINE__) { import core.exception : AssertError; import std.string : format; @@ -1790,10 +1790,10 @@ version(StdUnittest) private void testDecodeFront(R)(ref R range, } } -version(StdUnittest) private void testDecodeBack(R)(ref R range, - dchar expectedChar, - size_t expectedNumCodeUnits, - size_t line = __LINE__) +version (StdUnittest) private void testDecodeBack(R)(ref R range, + dchar expectedChar, + size_t expectedNumCodeUnits, + size_t line = __LINE__) { // This condition is to allow unit testing all `decode` functions together static if (!isBidirectionalRange!R) @@ -1821,10 +1821,10 @@ version(StdUnittest) private void testDecodeBack(R)(ref R range, } } -version(StdUnittest) private void testAllDecode(R)(R range, - dchar expectedChar, - size_t expectedIndex, - size_t line = __LINE__) +version (StdUnittest) private void testAllDecode(R)(R range, + dchar expectedChar, + size_t expectedIndex, + size_t line = __LINE__) { testDecode(range, 0, expectedChar, expectedIndex, line); static if (isBidirectionalRange!R) @@ -1835,7 +1835,7 @@ version(StdUnittest) private void testAllDecode(R)(R range, testDecodeFront(range, expectedChar, expectedIndex, line); } -version(StdUnittest) private void testBadDecode(R)(R range, size_t index, size_t line = __LINE__) +version (StdUnittest) private void testBadDecode(R)(R range, size_t index, size_t line = __LINE__) { import core.exception : AssertError; import std.string : format; @@ -1861,7 +1861,7 @@ version(StdUnittest) private void testBadDecode(R)(R range, size_t index, size_t assertThrown!UTFException(decodeFront(range, index), null, __FILE__, line); } -version(StdUnittest) private void testBadDecodeBack(R)(R range, size_t line = __LINE__) +version (StdUnittest) 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) @@ -3152,7 +3152,7 @@ if (isSomeChar!C) // Ranges of code units for testing. -version(StdUnittest) +version (StdUnittest) { struct InputCU(C) { @@ -3906,7 +3906,7 @@ pure @safe nothrow @nogc unittest foreach (c; s[].byDchar()) { } } -version(StdUnittest) +version (StdUnittest) int impureVariable; @system unittest diff --git a/std/variant.d b/std/variant.d index 3d5e0d7caa5..b97f4737909 100644 --- a/std/variant.d +++ b/std/variant.d @@ -697,7 +697,7 @@ public: } /// - version(StdUnittest) + version (StdUnittest) @system unittest { Variant a; @@ -730,7 +730,7 @@ public: } /// - version(StdUnittest) + version (StdUnittest) @system unittest { Variant a = 5; @@ -1122,7 +1122,7 @@ public: } /// - version(StdUnittest) + version (StdUnittest) @system unittest { Variant a = new int[10]; @@ -1839,7 +1839,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 12778c80c0d..21a73255fad 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(StdUnittest) import std.string : startsWith, endsWith; +version (StdUnittest) 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 863e0c1700c..73863607dd1 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 6b2c5f2e742..a395c379066 100644 --- a/std/zip.d +++ b/std/zip.d @@ -965,8 +965,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;