diff --git a/std/algorithm/comparison.d b/std/algorithm/comparison.d index 7170236ef..0938e70c0 100644 --- a/std/algorithm/comparison.d +++ b/std/algorithm/comparison.d @@ -1870,14 +1870,14 @@ bool isPermutation(alias pred = "a == b", Range1, Range2) // of item in the scanning loop has an index smaller than the current index, // then you know that the element has been seen before size_t index; - outloop: for(auto r1s1 = r1.save; !r1s1.empty; r1s1.popFront, index++) + outloop: for (auto r1s1 = r1.save; !r1s1.empty; r1s1.popFront, index++) { auto item = r1s1.front; r1_count = 0; r2_count = 0; size_t i; - for(auto r1s2 = r1.save; !r1s2.empty; r1s2.popFront, i++) + for (auto r1s2 = r1.save; !r1s2.empty; r1s2.popFront, i++) { auto e = r1s2.front; if (predEquals(e, item) && i < index) diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index 3dabceaf1..c4d7aaf9c 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -1622,7 +1622,7 @@ private template TimSortImpl(alias pred, R) //11 instructions vs 7 in the innermost loop [checked on Win32] //moveAll(retro(range[lower .. sortedLen]), // retro(range[lower+1 .. sortedLen+1])); - for(upper=sortedLen; upper > lower; upper--) + for (upper=sortedLen; upper > lower; upper--) range[upper] = range.moveAt(upper - 1); range[lower] = move(item); } diff --git a/std/bitmanip.d b/std/bitmanip.d index a6221295f..62bfc1e7e 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -2241,7 +2241,7 @@ unittest left <<= (T.sizeof - 1) * 8; T right = 0xffU; - for(size_t i = 1; i < T.sizeof; ++i) + for (size_t i = 1; i < T.sizeof; ++i) { assert(swapEndian(left) == right); assert(swapEndian(right) == left); diff --git a/std/concurrency.d b/std/concurrency.d index e14ad1f73..50f67d48d 100644 --- a/std/concurrency.d +++ b/std/concurrency.d @@ -1390,7 +1390,7 @@ private: import core.time; scope(exit) notified = false; - for( auto limit = MonoTime.currTime + period; + for ( auto limit = MonoTime.currTime + period; !notified && !period.isNegative; period = limit - MonoTime.currTime ) { @@ -1986,7 +1986,7 @@ private bool scan( ref ListT list ) { - for( auto range = list[]; !range.empty; ) + for ( auto range = list[]; !range.empty; ) { // Only the message handler will throw, so if this occurs // we can be certain that the message was handled. @@ -2130,7 +2130,7 @@ private void sweep( ref ListT list ) { - for( auto range = list[]; !range.empty; range.popFront() ) + for ( auto range = list[]; !range.empty; range.popFront() ) { if ( range.front.type == MsgType.linkDead ) onLinkDeadMsg( range.front ); diff --git a/std/container/dlist.d b/std/container/dlist.d index 2d5940563..783f01a75 100644 --- a/std/container/dlist.d +++ b/std/container/dlist.d @@ -771,7 +771,7 @@ private: alias IntList = DList!int; IntList list = IntList([0,1,2,3]); auto range = list[]; - for( ; !range.empty; range.popFront()) + for ( ; !range.empty; range.popFront()) { int item = range.front; if (item == 2) @@ -784,7 +784,7 @@ private: list = IntList([0,1,2,3]); range = list[]; - for( ; !range.empty; range.popFront()) + for ( ; !range.empty; range.popFront()) { int item = range.front; if (item == 2) @@ -797,7 +797,7 @@ private: list = IntList([0,1,2,3]); range = list[]; - for( ; !range.empty; range.popFront()) + for ( ; !range.empty; range.popFront()) { int item = range.front; if (item == 0) @@ -810,7 +810,7 @@ private: list = IntList([0,1,2,3]); range = list[]; - for( ; !range.empty; range.popFront()) + for ( ; !range.empty; range.popFront()) { int item = range.front; if (item == 1) diff --git a/std/container/rbtree.d b/std/container/rbtree.d index cbfc38e40..02b4908b8 100644 --- a/std/container/rbtree.d +++ b/std/container/rbtree.d @@ -1638,14 +1638,14 @@ assert(equal(rbt[], [5])); if (n !is null) { printTree(n.right, indent + 2); - for(int i = 0; i < indent; i++) + for (int i = 0; i < indent; i++) write("."); writeln(n.color == n.color.Black ? "B" : "R"); printTree(n.left, indent + 2); } else { - for(int i = 0; i < indent; i++) + for (int i = 0; i < indent; i++) write("."); writeln("N"); } diff --git a/std/csv.d b/std/csv.d index d280b89fb..39de81263 100644 --- a/std/csv.d +++ b/std/csv.d @@ -1036,7 +1036,7 @@ public: T[U] aa; try { - for(; !recordRange.empty; recordRange.popFront()) + for (; !recordRange.empty; recordRange.popFront()) { aa[header[_input.col-1]] = recordRange.front; } @@ -1057,7 +1057,7 @@ public: size_t colIndex; try { - for(; !recordRange.empty;) + for (; !recordRange.empty;) { auto colData = recordRange.front; scope(exit) colIndex++; diff --git a/std/datetime.d b/std/datetime.d index 846e45bf4..026314a65 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -33892,7 +33892,7 @@ R _stripCFWS(R)(R range) (is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte))) { immutable e = range.length; - outer: for(size_t i = 0; i < e; ) + outer: for (size_t i = 0; i < e; ) { switch (range[i]) { diff --git a/std/digest/md.d b/std/digest/md.d index da6159e37..ac42aed27 100644 --- a/std/digest/md.d +++ b/std/digest/md.d @@ -194,7 +194,7 @@ struct MD5 { import std.bitmanip : littleEndianToNative; - for(size_t i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) { x[i] = littleEndianToNative!uint(*cast(ubyte[4]*)&(*block)[i*4]); } @@ -321,7 +321,7 @@ struct MD5 (&_buffer[index])[0 .. partLen] = data.ptr[0 .. partLen]; transform(&_buffer); - for(i = partLen; i + 63 < inputLen; i += 64) + for (i = partLen; i + 63 < inputLen; i += 64) { transform(cast(const(ubyte[64])*)(data[i .. i + 64].ptr)); } diff --git a/std/digest/ripemd.d b/std/digest/ripemd.d index 2dd2b0606..0a9548de2 100644 --- a/std/digest/ripemd.d +++ b/std/digest/ripemd.d @@ -239,7 +239,7 @@ struct RIPEMD160 { import std.bitmanip : littleEndianToNative; - for(size_t i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) { x[i] = littleEndianToNative!uint(*cast(ubyte[4]*)&(*block)[i*4]); } @@ -477,7 +477,7 @@ struct RIPEMD160 (&_buffer[index])[0 .. partLen] = data.ptr[0 .. partLen]; transform(&_buffer); - for(i = partLen; i + 63 < inputLen; i += 64) + for (i = partLen; i + 63 < inputLen; i += 64) { transform(cast(const(ubyte[64])*)(data[i .. i + 64].ptr)); } diff --git a/std/encoding.d b/std/encoding.d index ff0fd64ba..b2acf2f71 100644 --- a/std/encoding.d +++ b/std/encoding.d @@ -244,7 +244,7 @@ unittest // Make sure we can sanitize everything bad assert(invalidStrings.length == sanitizedStrings.length); - for(int i=0; i=0; --x) + for ( ; x>=0; --x) { if (letterCase == LetterCase.upper) { diff --git a/std/internal/math/biguintnoasm.d b/std/internal/math/biguintnoasm.d index 9d35fd4e7..a3cbee6ed 100644 --- a/std/internal/math/biguintnoasm.d +++ b/std/internal/math/biguintnoasm.d @@ -159,7 +159,7 @@ void multibyteShr(uint [] dest, const(uint) [] src, uint numbits) pure @nogc @safe { ulong c = 0; - for(ptrdiff_t i = dest.length; i!=0; --i) + for (ptrdiff_t i = dest.length; i!=0; --i) { c += (src[i-1] >>numbits) + (cast(ulong)(src[i-1]) << (64 - numbits)); dest[i-1] = cast(uint)c; @@ -195,7 +195,7 @@ uint multibyteMul(uint[] dest, const(uint)[] src, uint multiplier, uint carry) { assert(dest.length == src.length); ulong c = carry; - for(size_t i = 0; i < src.length; ++i) + for (size_t i = 0; i < src.length; ++i) { c += cast(ulong)(src[i]) * multiplier; dest[i] = cast(uint)c; @@ -222,7 +222,7 @@ uint multibyteMulAdd(char op)(uint [] dest, const(uint)[] src, { assert(dest.length == src.length); ulong c = carry; - for(size_t i = 0; i < src.length; ++i) + for (size_t i = 0; i < src.length; ++i) { static if (op=='+') { @@ -285,7 +285,7 @@ uint multibyteDivAssign(uint [] dest, uint divisor, uint overflow) pure @nogc @safe { ulong c = cast(ulong)overflow; - for(ptrdiff_t i = dest.length-1; i>= 0; --i) + for (ptrdiff_t i = dest.length-1; i>= 0; --i) { c = (c<<32) + cast(ulong)(dest[i]); uint q = cast(uint)(c/divisor); @@ -314,7 +314,7 @@ void multibyteAddDiagonalSquares(uint[] dest, const(uint)[] src) pure @nogc @safe { ulong c = 0; - for(size_t i = 0; i < src.length; ++i) + for (size_t i = 0; i < src.length; ++i) { // At this point, c is 0 or 1, since FFFF*FFFF+FFFF_FFFF = 1_0000_0000. c += cast(ulong)(src[i]) * src[i] + dest[2*i]; diff --git a/std/internal/math/gammafunction.d b/std/internal/math/gammafunction.d index 21b023854..b54b5a9ff 100644 --- a/std/internal/math/gammafunction.d +++ b/std/internal/math/gammafunction.d @@ -753,7 +753,7 @@ ihalve: dir = 0; di = 0.5L; - for( i=0; i<400; i++ ) { + for ( i=0; i<400; i++ ) { if ( i != 0 ) { x = x0 + di * (x1 - x0); if ( x == 1.0L ) { @@ -846,7 +846,7 @@ newt: nflg = 1; lgm = logGamma(a+b) - logGamma(a) - logGamma(b); - for( i=0; i<15; i++ ) { + for ( i=0; i<15; i++ ) { /* Compute the function at this point. */ if ( i != 0 ) y = betaIncomplete(a,b,x); @@ -1346,7 +1346,7 @@ body { lgm = logGamma(a); - for( i=0; i<10; i++ ) { + for ( i=0; i<10; i++ ) { if ( x > x0 || x < x1 ) goto ihalve; y = gammaIncompleteCompl(a,x); @@ -1391,7 +1391,7 @@ ihalve: d = 0.5L; dir = 0; - for( i=0; i<400; i++ ) { + for ( i=0; i<400; i++ ) { x = x1 + d * (x0 - x1); y = gammaIncompleteCompl( a, x ); lgm = (x0 - x1)/(x1 + x0); @@ -1603,9 +1603,9 @@ unittest { assert(logmdigamma(-5.0).isNaN()); assert(isIdentical(logmdigamma(NaN(0xABC)), NaN(0xABC))); assert(logmdigamma(0.0) == real.infinity); - for(auto x = 0.01; x < 1.0; x += 0.1) + for (auto x = 0.01; x < 1.0; x += 0.1) assert(approxEqual(digamma(x), log(x) - logmdigamma(x))); - for(auto x = 1.0; x < 15.0; x += 1.0) + for (auto x = 1.0; x < 15.0; x += 1.0) assert(approxEqual(digamma(x), log(x) - logmdigamma(x))); } diff --git a/std/parallelism.d b/std/parallelism.d index df7f75e50..9988c17fe 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -1922,7 +1922,7 @@ public: assert(from !is null); size_t i; - for(; !source.empty && i < from.length; source.popFront()) + for (; !source.empty && i < from.length; source.popFront()) { from[i++] = source.front; } @@ -2180,7 +2180,7 @@ public: assert(buf !is null); size_t i; - for(; !source.empty && i < buf.length; source.popFront()) + for (; !source.empty && i < buf.length; source.popFront()) { buf[i++] = source.front; } @@ -3617,7 +3617,7 @@ enum string parallelApplyMixinInputRange = q{ scope(exit) rangeMutex.unlock(); size_t i = 0; - for(; i < workUnitSize && !range.empty; range.popFront(), i++) + for (; i < workUnitSize && !range.empty; range.popFront(), i++) { temp[i] = addressOf(range.front); } @@ -3647,7 +3647,7 @@ enum string parallelApplyMixinInputRange = q{ scope(exit) rangeMutex.unlock(); size_t i = 0; - for(; i < workUnitSize && !range.empty; range.popFront(), i++) + for (; i < workUnitSize && !range.empty; range.popFront(), i++) { temp[i] = range.front; } @@ -4296,7 +4296,7 @@ version(parallelismStressTest) unittest { size_t attempt; - for(; attempt < 10; attempt++) + for (; attempt < 10; attempt++) foreach (poolSize; [0, 4]) { diff --git a/std/range/interfaces.d b/std/range/interfaces.d index 5dc37205f..17eeab468 100644 --- a/std/range/interfaces.d +++ b/std/range/interfaces.d @@ -404,7 +404,7 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) { int opApply(int delegate(E) dg) { int res; - for(auto r = _range; !r.empty; r.popFront()) { + for (auto r = _range; !r.empty; r.popFront()) { res = dg(r.front); if (res) break; } @@ -416,7 +416,7 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) { int res; size_t i = 0; - for(auto r = _range; !r.empty; r.popFront()) { + for (auto r = _range; !r.empty; r.popFront()) { res = dg(i, r.front); if (res) break; i++; diff --git a/std/range/package.d b/std/range/package.d index d5da4bc4a..888ab9a2a 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -1718,7 +1718,7 @@ if (isRandomAccessRange!(Unqual!R) && hasLength!(Unqual!R)) static assert(isForwardRange!(typeof(radial(a, 1)))); auto r = radial([1,2,3,4,5]); - for(auto rr = r.save; !rr.empty; rr.popFront()) + for (auto rr = r.save; !rr.empty; rr.popFront()) { assert(rr.front == moveFront(rr)); } @@ -2021,7 +2021,7 @@ if (isInputRange!(Unqual!R) && (isInfinite!(Unqual!R) || !hasSlicing!(Unqual!R) static assert(isForwardRange!T); } - for(auto tt = t; !tt.empty; tt.popFront()) + for (auto tt = t; !tt.empty; tt.popFront()) { assert(tt.front == moveFront(tt)); } @@ -4735,7 +4735,7 @@ auto sequence(alias fun, State...)(State args) auto odds = Sequence!("a[0] + n * a[1]", Tuple!(int, int))( tuple(1, 2)); - for(int currentOdd = 1; currentOdd <= 21; currentOdd += 2) { + for (int currentOdd = 1; currentOdd <= 21; currentOdd += 2) { assert(odds.front == odds[0]); assert(odds[0] == currentOdd); odds.popFront(); diff --git a/std/regex/internal/backtracking.d b/std/regex/internal/backtracking.d index f2d935f37..8471d929d 100644 --- a/std/regex/internal/backtracking.d +++ b/std/regex/internal/backtracking.d @@ -218,7 +218,7 @@ template BacktrackingMatcher(bool CTregex) { if (!re.kickstart.empty) { - for(;;) + for (;;) { int val = matchFinalize(); if (val) @@ -240,7 +240,7 @@ template BacktrackingMatcher(bool CTregex) } } //no search available - skip a char at a time - for(;;) + for (;;) { int val = matchFinalize(); if (val) @@ -280,7 +280,7 @@ template BacktrackingMatcher(bool CTregex) auto start = s._index; debug(std_regex_matcher) writeln("Try match starting at ", s[index..s.lastIndex]); - for(;;) + for (;;) { debug(std_regex_matcher) writefln("PC: %s\tCNT: %s\t%s \tfront: %s src: %s", @@ -295,7 +295,7 @@ template BacktrackingMatcher(bool CTregex) uint end = pc + len; if (re.ir[pc].data != front && re.ir[pc+1].data != front) { - for(pc = pc+2; pc < end; pc++) + for (pc = pc+2; pc < end; pc++) if (re.ir[pc].data == front) break; if (pc == end) @@ -976,7 +976,7 @@ struct CtContext CtState[] pieces; CtState r; enum optL = IRL!(IR.Option); - for(;;) + for (;;) { assert(ir[0].code == IR.Option); auto len = ir[0].data; @@ -998,7 +998,7 @@ struct CtContext } } r = pieces[0]; - for(uint i = 1; i < pieces.length; i++) + for (uint i = 1; i < pieces.length; i++) { r.code ~= ctSub(` case $$: @@ -1230,7 +1230,7 @@ struct CtContext if (atEnd) $$`, bailOut); uint len = ir[0].sequence; - for(uint i = 0; i < len; i++) + for (uint i = 0; i < len; i++) { code ~= ctSub( ` if (front == $$) diff --git a/std/regex/internal/generator.d b/std/regex/internal/generator.d index a957b1593..95533b38b 100644 --- a/std/regex/internal/generator.d +++ b/std/regex/internal/generator.d @@ -39,7 +39,7 @@ module std.regex.internal.generator; void compose() { uint pc = 0, counter = 0, dataLenOld = uint.max; - for(;;) + for (;;) { switch (re.ir[pc].code) { @@ -90,7 +90,7 @@ module std.regex.internal.generator; } nOpt++; nOpt = rand(nOpt); - for(;nOpt; nOpt--) + for (;nOpt; nOpt--) { pc += re.ir[pc].data + IRL!(IR.Option); } diff --git a/std/regex/internal/ir.d b/std/regex/internal/ir.d index 89817f12e..228220742 100644 --- a/std/regex/internal/ir.d +++ b/std/regex/internal/ir.d @@ -443,7 +443,7 @@ struct Group(DataIndex) @trusted void printBytecode()(in Bytecode[] slice, in NamedGroup[] dict=[]) { import std.stdio; - for(uint pc=0; pc= maxDigit,"incomplete escape sequence"); uint val; - for(int k = 0; k < maxDigit; k++) + for (int k = 0; k < maxDigit; k++) { auto current = str[k];//accepts ascii only, so it's OK to index directly if ('0' <= current && current <= '9') @@ -729,7 +729,7 @@ struct Parser(R, Generator) switch (current) { case '#': - for(;;) + for (;;) { if (!next()) error("Unexpected end of pattern"); @@ -969,7 +969,7 @@ struct Parser(R, Generator) } L_CharTermLoop: - for(;;) + for (;;) { final switch (state) { @@ -1144,7 +1144,7 @@ struct Parser(R, Generator) enforce(last <= current, "inverted range"); if (re_flags & RegexOption.casefold) { - for(uint ch = last; ch <= current; ch++) + for (uint ch = last; ch <= current; ch++) addWithFlags(set, ch, re_flags); } else @@ -1493,7 +1493,7 @@ struct Parser(R, Generator) auto counterRange = FixedStack!uint(new uint[maxCounterDepth+1], -1); counterRange.push(1); ulong cumRange = 0; - for(uint i = 0; i < ir.length; i += ir[i].length) + for (uint i = 0; i < ir.length; i += ir[i].length) { if (ir[i].hotspot) { @@ -1548,7 +1548,7 @@ void fixupBytecode()(Bytecode[] ir) { Stack!uint fixups; - with(IR) for(uint i=0; i[a-zA-Z0-9_]+):*(?P[a-zA-Z0-9_]*)","gm"); auto uniCapturesNew = match(uniFileOld, r); - for(int i = 0; i < 20; i++) + for (int i = 0; i < 20; i++) foreach (matchNew; uniCapturesNew) {} //a second issue with same symptoms auto r2 = regex(`([а-яА-Я\-_]+\s*)+(?<=[\s\.,\^])`); diff --git a/std/regex/internal/thompson.d b/std/regex/internal/thompson.d index 806f6a076..9035d4eb4 100644 --- a/std/regex/internal/thompson.d +++ b/std/regex/internal/thompson.d @@ -562,7 +562,7 @@ template ThompsonOps(E, S, bool withInput:true) uint len = re.ir[t.pc].sequence; uint end = t.pc + len; static assert(IRL!(IR.OrChar) == 1); - for(; t.pc < end; t.pc++) + for (; t.pc < end; t.pc++) if (re.ir[t.pc].data == front) break; if (t.pc != end) @@ -796,7 +796,7 @@ template ThompsonOps(E,S, bool withInput:false) opCacheBackTrue = arrayInChunk!(OpBackFunc)(re.ir.length, memory); opCacheBackFalse = arrayInChunk!(OpBackFunc)(re.ir.length, memory); - for(uint pc = 0; pc 0; ) + for (size_t i=src.length; i-- > 0; ) dest[i] = src[i]; } void copyForward(T,U)(T[] src, U[] dest) { assert(src.length == dest.length); - for(size_t i=0; i= 0) // no starters?? no recomposition { - for(;;) + for (;;) { auto second = recompose(first, decomposed, ccc); if (second == decomposed.length) @@ -7721,7 +7721,7 @@ private size_t recompose(size_t start, dchar[] input, ubyte[] ccc) pure nothrow // writefln("recomposing %( %04x %)", input); // first one is always a starter thus we start at i == 1 size_t i = start+1; - for(; ; ) + for (; ; ) { if (i == input.length) break; @@ -7804,7 +7804,7 @@ private auto seekStable(NormalizationForm norm, C)(size_t idx, in C[] input) auto br = input[0..idx]; size_t region_start = 0;// default - for(;;) + for (;;) { if (br.empty)// start is 0 break; diff --git a/std/uuid.d b/std/uuid.d index 3ee6de4b2..e24241db1 100644 --- a/std/uuid.d +++ b/std/uuid.d @@ -494,7 +494,7 @@ public struct UUID return data; } - for(size_t i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) { assert(!UUID(getData(i)).empty); } @@ -504,7 +504,7 @@ public struct UUID bool ctfeTest() { - for(size_t i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) { auto ctfeEmpty2 = UUID(getData(i)).empty; assert(!ctfeEmpty2); diff --git a/std/xml.d b/std/xml.d index 17017fdf7..fb3c4d6b4 100644 --- a/std/xml.d +++ b/std/xml.d @@ -2206,7 +2206,7 @@ private if (c != '\u0022' && c != '\u0027') fail("attribute value requires quotes"); s = s[1..$]; - for(;;) + for (;;) { munch(s,"^<&"~c); if (s.length == 0) fail("unterminated attribute value"); diff --git a/std/zlib.d b/std/zlib.d index f37777094..43d4b025a 100644 --- a/std/zlib.d +++ b/std/zlib.d @@ -689,7 +689,7 @@ unittest // by Dave // smallish buffers - for(int idx = 0; idx < 25; idx++) { + for (int idx = 0; idx < 25; idx++) { char[] buf = new char[uniform(0, 100)]; // Alternate between more & less compressible @@ -704,7 +704,7 @@ unittest // by Dave } // larger buffers - for(int idx = 0; idx < 25; idx++) { + for (int idx = 0; idx < 25; idx++) { char[] buf = new char[uniform(0, 1000/*0000*/)]; // Alternate between more & less compressible