From af42d8df3d19d93d84f90f46b10e94418b633ff5 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 23 Feb 2017 00:38:44 +0100 Subject: [PATCH 1/7] Add initial style check to enforce space between binary operators --- posix.mak | 3 +++ 1 file changed, 3 insertions(+) diff --git a/posix.mak b/posix.mak index 51ea4d6689c..7c1ac40a8aa 100644 --- a/posix.mak +++ b/posix.mak @@ -522,6 +522,9 @@ style: ../dscanner/dsc @echo "Enforce space between a .. b" grep -nrE '[[:alnum:]][.][.][[:alnum:]]|[[:alnum:]] [.][.][[:alnum:]]|[[:alnum:]][.][.] [[:alnum:]]' $$(find . -name '*.d' | grep -vE 'std/string.d|std/uni.d') ; test $$? -eq 1 + @echo "Enforce space between binary operators" + grep -nrE "[[:alnum:]](==|!=|<=|<<|>>|>>>|^^)[[:alnum:]]|[[:alnum:]] (==|!=|<=|<<|>>|>>>|^^)[[:alnum:]]|[[:alnum:]](==|!=|<=|<<|>>|>>>|^^) [[:alnum:]]" $$(find . -name '*.d'); test $$? -eq 1 + # at the moment libdparse has problems to parse some modules (->excludes) @echo "Running DScanner" ../dscanner/dsc --config .dscanner.ini --styleCheck $$(find etc std -type f -name '*.d' | grep -vE 'std/traits.d|std/typecons.d') -I. From a2c6398332b1750facfc344e55030eff79396324 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 23 Feb 2017 00:44:37 +0100 Subject: [PATCH 2/7] Automatically add spaces to binary operators (==) command: sed -E "s/([[:alnum:]]) == ([[:alnum:]])/\1 == \2/g" -i **/*.d sed -E "s/([[:alnum:]])== ([[:alnum:]])/\1 == \2/g" -i **/*.d sed -E "s/([[:alnum:]]) ==([[:alnum:]])/\1 == \2/g" -i **/*.d --- etc/c/sqlite3.d | 2 +- std/algorithm/mutation.d | 2 +- std/algorithm/searching.d | 14 +++++++------- std/algorithm/setops.d | 2 +- std/bigint.d | 2 +- std/container/array.d | 2 +- std/datetime.d | 2 +- std/digest/sha.d | 12 ++++++------ std/encoding.d | 4 ++-- std/functional.d | 6 +++--- std/getopt.d | 4 ++-- std/internal/math/biguintcore.d | 28 ++++++++++++++-------------- std/internal/math/biguintnoasm.d | 2 +- std/internal/math/biguintx86.d | 10 +++++----- std/internal/math/gammafunction.d | 8 ++++---- std/math.d | 12 ++++++------ std/numeric.d | 10 +++++----- std/process.d | 2 +- std/random.d | 2 +- std/socket.d | 6 +++--- std/stdio.d | 2 +- std/traits.d | 4 ++-- std/typecons.d | 4 ++-- std/utf.d | 6 +++--- 24 files changed, 74 insertions(+), 74 deletions(-) diff --git a/etc/c/sqlite3.d b/etc/c/sqlite3.d index ce5421f262d..254814db772 100644 --- a/etc/c/sqlite3.d +++ b/etc/c/sqlite3.d @@ -1182,7 +1182,7 @@ int sqlite3_key_v2( /** ** Change the key on an open database. If the current database is not -** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the +** encrypted, this routine will encrypt it. If pNew == 0 or nNew == 0, the ** database is decrypted. ** ** The code to implement this API is not available in the public release diff --git a/std/algorithm/mutation.d b/std/algorithm/mutation.d index fefd4610a24..95d406b3402 100644 --- a/std/algorithm/mutation.d +++ b/std/algorithm/mutation.d @@ -747,7 +747,7 @@ if (isInputRange!InputRange InputRange range; fill(range,[1,2]); foreach (i,value;range.arr) - assert(value == (i%2==0?1:2)); + assert(value == (i%2 == 0?1:2)); //test with a input being a "reference forward" range fill(a, new ReferenceForwardRange!int([8, 9])); diff --git a/std/algorithm/searching.d b/std/algorithm/searching.d index 475e80daf0c..639ee5bf800 100644 --- a/std/algorithm/searching.d +++ b/std/algorithm/searching.d @@ -1575,11 +1575,11 @@ if (isInputRange!InputRange && { int[] a1 = [1, 2, 3]; assert(!find ([1, 2, 3], 2).empty); - assert(!find!((a,b)=>a==b)([1, 2, 3], 2).empty); + assert(!find!((a,b)=>a == b)([1, 2, 3], 2).empty); ubyte[] a2 = [1, 2, 3]; ubyte b2 = 2; assert(!find ([1, 2, 3], 2).empty); - assert(!find!((a,b)=>a==b)([1, 2, 3], 2).empty); + assert(!find!((a,b)=>a == b)([1, 2, 3], 2).empty); } @safe pure unittest @@ -1592,11 +1592,11 @@ if (isInputRange!InputRange && R r1 = "hello world"; E e1 = 'w'; assert(find ("hello world", 'w') == "world"); - assert(find!((a,b)=>a==b)("hello world", 'w') == "world"); + assert(find!((a,b)=>a == b)("hello world", 'w') == "world"); R r2 = "日c語"; E e2 = 'c'; assert(find ("日c語", 'c') == "c語"); - assert(find!((a,b)=>a==b)("日c語", 'c') == "c語"); + assert(find!((a,b)=>a == b)("日c語", 'c') == "c語"); R r3 = "0123456789"; E e3 = 'A'; assert(find ("0123456789", 'A').empty); @@ -1605,7 +1605,7 @@ if (isInputRange!InputRange && R r4 = "hello world"; E e4 = 'w'; assert(find ("日本語", '本') == "本語"); - assert(find!((a,b)=>a==b)("日本語", '本') == "本語"); + assert(find!((a,b)=>a == b)("日本語", '本') == "本語"); } } } @@ -1621,11 +1621,11 @@ if (isInputRange!InputRange && int[] a1 = [1, 2, 3]; static assert(find ([1, 2, 3], 2)); - static assert(find!((a,b)=>a==b)([1, 2, 3], 2)); + static assert(find!((a,b)=>a == b)([1, 2, 3], 2)); ubyte[] a2 = [1, 2, 3]; ubyte b2 = 2; static assert(find ([1, 2, 3], 2)); - static assert(find!((a,b)=>a==b)([1, 2, 3], 2)); + static assert(find!((a,b)=>a == b)([1, 2, 3], 2)); } @safe unittest diff --git a/std/algorithm/setops.d b/std/algorithm/setops.d index dfff65ddb67..48b998a967d 100644 --- a/std/algorithm/setops.d +++ b/std/algorithm/setops.d @@ -389,7 +389,7 @@ if (ranges.length >= 2 && r.popFront(); if (!r.empty) break; - static if (i==0) + static if (i == 0) empty = true; else r = ranges[i].save; // rollover diff --git a/std/bigint.d b/std/bigint.d index a2b1a97d19c..ed1c4bfeaf0 100644 --- a/std/bigint.d +++ b/std/bigint.d @@ -658,7 +658,7 @@ public: else { if (l <= ulong(T.max)+1) - return cast(T)-long(l); // -long.min==long.min + return cast(T)-long(l); // -long.min == long.min } } diff --git a/std/container/array.d b/std/container/array.d index 496902522c1..cc595b8b649 100644 --- a/std/container/array.d +++ b/std/container/array.d @@ -1372,7 +1372,7 @@ $(D r) assert(i == 1); //Just to make sure the GC doesn't collect before the above test. - assert(c.dummy ==1); + assert(c.dummy == 1); } @system unittest //6998-2 { diff --git a/std/datetime.d b/std/datetime.d index aed740a3b91..be9ac8eaf07 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -21384,7 +21384,7 @@ private: Date(2010, 9, 12), Date(2010, 10, 1) ).fwdRange( - everyDayOfWeek!Date(DayOfWeek.fri), Yes.popFirst).front ==Date(2010, 9, 17)); + everyDayOfWeek!Date(DayOfWeek.fri), Yes.popFirst).front == Date(2010, 9, 17)); } //Verify Examples. diff --git a/std/digest/sha.d b/std/digest/sha.d index 7534211de72..5494e7b3186 100644 --- a/std/digest/sha.d +++ b/std/digest/sha.d @@ -208,7 +208,7 @@ struct SHA(uint hashBlockSize, uint digestSize) static assert(!(blockSize == 1024 && digestSize < 224), "Invalid SHA digestSize for a blockSize of 1024. The digestSize must be 224, 256, 384 or 512."); - static if (digestSize==160) /* SHA-1 */ + static if (digestSize == 160) /* SHA-1 */ { version(USE_SSSE3) { @@ -636,7 +636,7 @@ struct SHA(uint hashBlockSize, uint digestSize) T_SHA2_16_79!Word(62, W, C, D, E, F, G, H, A, B, constants[62]); T_SHA2_16_79!Word(63, W, B, C, D, E, F, G, H, A, constants[63]); - static if (is(Word==ulong)) + static if (is(Word == ulong)) { T_SHA2_16_79!Word(64, W, A, B, C, D, E, F, G, H, constants[64]); T_SHA2_16_79!Word(65, W, H, A, B, C, D, E, F, G, constants[65]); @@ -706,9 +706,9 @@ struct SHA(uint hashBlockSize, uint digestSize) index = (cast(uint) count[0] >> 3) & (blockSizeInBytes - 1); /* Update number of bits */ - static if (blockSize==512) + static if (blockSize == 512) count[0] += inputLen * 8; - else static if (blockSize==1024) + else static if (blockSize == 1024) { /* ugly hack to work around lack of ucent */ auto oldCount0 = count[0]; @@ -756,7 +756,7 @@ struct SHA(uint hashBlockSize, uint digestSize) */ ubyte[digestSize/8] finish() @trusted pure nothrow @nogc { - static if (blockSize==512) + static if (blockSize == 512) { ubyte[32] data = void; uint index, padLen; @@ -780,7 +780,7 @@ struct SHA(uint hashBlockSize, uint digestSize) start(); return data[0 .. digestSize/8]; } - else static if (blockSize==1024) + else static if (blockSize == 1024) { ubyte[64] data = void; uint index, padLen; diff --git a/std/encoding.d b/std/encoding.d index 63a085e7534..9e27c2eedbe 100644 --- a/std/encoding.d +++ b/std/encoding.d @@ -3339,11 +3339,11 @@ version(unittest) { void transcodeReverse(Src,Dst)(immutable(Src)[] s, out immutable(Dst)[] r) { - static if (is(Src==Dst)) + static if (is(Src == Dst)) { return s; } - else static if (is(Src==AsciiChar)) + else static if (is(Src == AsciiChar)) { transcodeReverse!(char,Dst)(cast(string) s,r); } diff --git a/std/functional.d b/std/functional.d index 200b05af280..f12bcd12ea2 100644 --- a/std/functional.d +++ b/std/functional.d @@ -334,7 +334,7 @@ private uint _ctfeMatchUnary(string fun, string name) static assert(_ctfeMatchUnary("a+a", "a")); static assert(_ctfeMatchUnary("a + 10", "a")); static assert(_ctfeMatchUnary("4 == a", "a")); - static assert(_ctfeMatchUnary("2==a", "a")); + static assert(_ctfeMatchUnary("2 == a", "a")); static assert(_ctfeMatchUnary("1 != a", "a")); static assert(_ctfeMatchUnary("a!=4", "a")); static assert(_ctfeMatchUnary("a< 1", "a")); @@ -382,7 +382,7 @@ private uint _ctfeMatchBinary(string fun, string name1, string name2) static assert(_ctfeMatchBinary("a+a", "a", "b")); static assert(_ctfeMatchBinary("a + 10", "a", "b")); static assert(_ctfeMatchBinary("4 == a", "a", "b")); - static assert(_ctfeMatchBinary("2==a", "a", "b")); + static assert(_ctfeMatchBinary("2 == a", "a", "b")); static assert(_ctfeMatchBinary("1 != a", "a", "b")); static assert(_ctfeMatchBinary("a!=4", "a", "b")); static assert(_ctfeMatchBinary("a< 1", "a", "b")); @@ -402,7 +402,7 @@ private uint _ctfeMatchBinary(string fun, string name1, string name2) static assert(_ctfeMatchBinary("a+b", "b", "a")); static assert(_ctfeMatchBinary("a + b", "b", "a")); static assert(_ctfeMatchBinary("b == a", "b", "a")); - static assert(_ctfeMatchBinary("b==a", "b", "a")); + static assert(_ctfeMatchBinary("b == a", "b", "a")); static assert(_ctfeMatchBinary("b != a", "b", "a")); static assert(_ctfeMatchBinary("a!=b", "b", "a")); static assert(_ctfeMatchBinary("a< b", "b", "a")); diff --git a/std/getopt.d b/std/getopt.d index 42ecfad17e5..e5b2c2ef793 100644 --- a/std/getopt.d +++ b/std/getopt.d @@ -542,7 +542,7 @@ private template optionValidator(A...) import std.format : format; enum fmt = "getopt validator: %s (at position %d)"; - enum isReceiver(T) = isPointer!T || (is(T==function)) || (is(T==delegate)); + enum isReceiver(T) = isPointer!T || (is(T == function)) || (is(T == delegate)); enum isOptionStr(T) = isSomeString!T || isSomeChar!T; auto validator() @@ -1077,7 +1077,7 @@ private bool optMatch(string arg, string optPattern, ref string value, } else { - if (!isLong && eqPos==1) + if (!isLong && eqPos == 1) { // argument looks like -o=value value = arg[2 .. $]; diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 92a24ac8123..4e1ea7d8536 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -225,7 +225,7 @@ public: if (data.length >= i+1) { // Since ZERO is [0], so we cannot simply return 1 here, as - // data[i] would be 0 for i==0 in that case. + // data[i] would be 0 for i == 0 in that case. return (data[i] > 0) ? 1 : 0; } else @@ -250,9 +250,9 @@ public: return false; uint ylo = cast(uint)(y & 0xFFFF_FFFF); uint yhi = cast(uint)(y >> 32); - if (data.length==2 && data[1]!=yhi) + if (data.length == 2 && data[1]!=yhi) return false; - if (data.length==1 && yhi!=0) + if (data.length == 1 && yhi!=0) return false; return (data[0] == ylo); } @@ -463,7 +463,7 @@ public: uint bits = cast(uint) y & BIGDIGITSHIFTMASK; if ((y>>LG2BIGDIGITBITS) >= data.length) return BigUint(ZERO); uint words = cast(uint)(y >> LG2BIGDIGITBITS); - if (bits==0) + if (bits == 0) { return BigUint(data[words..$]); } @@ -489,7 +489,7 @@ public: uint words = cast(uint)(y >> LG2BIGDIGITBITS); BigDigit [] result = new BigDigit[data.length + words+1]; result[0 .. words] = 0; - if (bits==0) + if (bits == 0) { result[words .. words+data.length] = data[]; return BigUint(trustedAssumeUnique(result[0 .. words+data.length])); @@ -497,7 +497,7 @@ public: else { immutable c = multibyteShl(result[words .. words+data.length], data, bits); - if (c==0) return BigUint(trustedAssumeUnique(result[0 .. words+data.length])); + if (c == 0) return BigUint(trustedAssumeUnique(result[0 .. words+data.length])); result[$-1] = c; return BigUint(trustedAssumeUnique(result)); } @@ -581,7 +581,7 @@ public: // y must not be zero. static BigUint mulInt(T = ulong)(BigUint x, T y) pure nothrow { - if (y==0 || x == 0) return BigUint(ZERO); + if (y == 0 || x == 0) return BigUint(ZERO); uint hi = cast(uint)(y >>> 32); uint lo = cast(uint)(y & 0xFFFF_FFFF); uint [] result = new BigDigit[x.data.length+1+(hi!=0)]; @@ -598,7 +598,7 @@ public: */ static BigUint mul(BigUint x, BigUint y) pure nothrow { - if (y==0 || x == 0) + if (y == 0 || x == 0) return BigUint(ZERO); auto len = x.data.length + y.data.length; BigDigit [] result = new BigDigit[len]; @@ -736,9 +736,9 @@ public: static BigUint pow(BigUint x, ulong y) pure nothrow { // Deal with the degenerate cases first. - if (y==0) return BigUint(ONE); - if (y==1) return x; - if (x==0 || x==1) return x; + if (y == 0) return BigUint(ONE); + if (y == 1) return x; + if (x == 0 || x == 1) return x; BigUint result; @@ -975,7 +975,7 @@ pure @system unittest BigUint r = BigUint([5]); BigUint t = BigUint([7]); BigUint s = BigUint.mod(r, t); - assert(s==5); + assert(s == 5); } @@ -1478,7 +1478,7 @@ void squareInternal(BigDigit[] result, const BigDigit[] x) pure nothrow assert(result.length == 2*x.length); if (x.length <= KARATSUBASQUARELIMIT) { - if (x.length==1) + if (x.length == 1) { result[1] = multibyteMul(result[0 .. 1], x, x[0], 0); return; @@ -1903,7 +1903,7 @@ body { result[right.length .. left.length] = left[right.length .. $]; carry = multibyteIncrementAssign!('-')(result[right.length..$], carry); - } //else if (result.length==left.length+1) { result[$-1] = carry; carry=0; } + } //else if (result.length == left.length+1) { result[$-1] = carry; carry=0; } return carry; } diff --git a/std/internal/math/biguintnoasm.d b/std/internal/math/biguintnoasm.d index 58274a24e8a..5d75527000c 100644 --- a/std/internal/math/biguintnoasm.d +++ b/std/internal/math/biguintnoasm.d @@ -64,7 +64,7 @@ uint multibyteAddSub(char op)(uint[] dest, const(uint) [] src1, assert(c[0]==0x8000_0003); assert(c[1]==4); assert(c[19]==0x3333_3333); // check for overrun - assert(carry==1); + assert(carry == 1); for (size_t i = 0; i < a.length; ++i) { a[i] = b[i] = c[i] = 0; diff --git a/std/internal/math/biguintx86.d b/std/internal/math/biguintx86.d index b5a2d2c2565..4c504a54add 100644 --- a/std/internal/math/biguintx86.d +++ b/std/internal/math/biguintx86.d @@ -190,7 +190,7 @@ done: } c[19]=0x3333_3333; uint carry = multibyteAddSub!('+')(c[0 .. 18], a[0 .. 18], b[0 .. 18], 0); - assert(carry==1); + assert(carry == 1); assert(c[0]==0x8000_0003); assert(c[1]==4); assert(c[19]==0x3333_3333); // check for overrun @@ -546,14 +546,14 @@ L_last: uint r = multibyteShl(aa[2 .. 4], aa[2 .. 4], 4); assert(aa[0] == 0xF0FF_FFFF && aa[1]==0x1222_2223 && aa[2]==0x5555_5560 && aa[3]==0x9999_99A4 && aa[4]==0xBCCC_CCCD); - assert(r==8); + assert(r == 8); aa = [0xF0FF_FFFF, 0x1222_2223, 0x4555_5556, 0x8999_999A, 0xBCCC_CCCD, 0xEEEE_EEEE]; r = multibyteShl(aa[1 .. 4], aa[1 .. 4], 4); assert(aa[0] == 0xF0FF_FFFF && aa[2]==0x5555_5561); assert(aa[3]==0x9999_99A4 && aa[4]==0xBCCC_CCCD); - assert(r==8); + assert(r == 8); assert(aa[1]==0x2222_2230); aa = [0xF0FF_FFFF, 0x1222_2223, 0x4555_5556, 0x8999_999A, 0xBCCC_CCCD, 0xEEEE_EEEE]; @@ -1022,7 +1022,7 @@ Lc: uint overflow = multibyteMul(aa, aa, 0x8EFD_FCFB, 0x33FF_7461); uint r = multibyteDivAssign(aa, 0x8EFD_FCFB, overflow); for (int i=0; i MAXGAMMA ) return real.infinity; - if (x==0) return 1.0 / x; // +- infinity depending on sign of x, create an exception. + if (x == 0) return 1.0 / x; // +- infinity depending on sign of x, create an exception. q = fabs(x); @@ -1310,7 +1310,7 @@ body { * k=0 | (a+k+1) * */ - if (x==0) + if (x == 0) return 0.0L; if ( (x > 1.0L) && (x > a ) ) @@ -1345,7 +1345,7 @@ in { assert(a > 0); } body { - if (x==0) + if (x == 0) return 1.0L; if ( (x < 1.0L) || (x < a) ) return 1.0L - gammaIncomplete(a,x); @@ -1431,7 +1431,7 @@ in { assert(a>0); } body { - if (p==0) return real.infinity; + if (p == 0) return real.infinity; real y0 = p; const real MAXLOGL = 1.1356523406294143949492E4L; diff --git a/std/math.d b/std/math.d index 8f448e42a59..65345f4c0f2 100644 --- a/std/math.d +++ b/std/math.d @@ -2936,7 +2936,7 @@ float ldexp(float n, int exp) @safe pure nothrow @nogc { return ldexp(cast(real) assert(ldexp(1.0L, -16382) == 0x1p-16382L); int x; real n = frexp(0x1p-16384L, x); - assert(n==0.5L); + assert(n == 0.5L); assert(x==-16383); assert(ldexp(n, x)==0x1p-16384L); } @@ -2946,7 +2946,7 @@ float ldexp(float n, int exp) @safe pure nothrow @nogc { return ldexp(cast(real) assert(ldexp(1.0L, -1022) == 0x1p-1022L); int x; real n = frexp(0x1p-1024L, x); - assert(n==0.5L); + assert(n == 0.5L); assert(x==-1023); assert(ldexp(n, x)==0x1p-1024L); } @@ -2961,7 +2961,7 @@ typed_allocator.d assert(ldexp(1.0, -1022) == 0x1p-1022); int x; double n = frexp(0x1p-1024, x); - assert(n==0.5); + assert(n == 0.5); assert(x==-1023); assert(ldexp(n, x)==0x1p-1024); } @@ -2972,7 +2972,7 @@ typed_allocator.d assert(ldexp(1.0f, -126) == 0x1p-126f); int x; float n = frexp(0x1p-128f, x); - assert(n==0.5f); + assert(n == 0.5f); assert(x==-127); assert(ldexp(n, x)==0x1p-128f); } @@ -4561,7 +4561,7 @@ public: assert(!ieeeFlags.divByZero); // Perform a division by zero. a/=0.0L; - assert(a==real.infinity); + assert(a == real.infinity); assert(ieeeFlags.divByZero); // Create a NaN a*=0.0L; @@ -6534,7 +6534,7 @@ if (isFloatingPoint!(X)) // AND with 0x7FFF to form the absolute value. // To avoid out-by-1 errors, we subtract 1 so it rounds down // if the exponents were different. This means 'bitsdiff' is - // always 1 lower than we want, except that if bitsdiff==0, + // always 1 lower than we want, except that if bitsdiff == 0, // they could have 0 or 1 bits in common. int bitsdiff = ((( (pa[F.EXPPOS_SHORT] & F.EXPMASK) diff --git a/std/numeric.d b/std/numeric.d index dfff33580a5..0bf63e220eb 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -239,7 +239,7 @@ private: } if ((~flags&Flags.storeNormalized) || // Convert denormalized form to normalized form - ((flags&Flags.allowDenorm) && exp==0)) + ((flags&Flags.allowDenorm) && exp == 0)) { if (sig > 0) { @@ -1087,7 +1087,7 @@ whileloop: // DAC: If the secant predicts a value equal to an endpoint, it's // probably false. - if (c==a || c==b || c.isNaN() || fabs(c - u) > (b - a) / 2) + if (c == a || c == b || c.isNaN() || fabs(c - u) > (b - a) / 2) { if ((a-b) == a || (b-a) == b) { @@ -1095,9 +1095,9 @@ whileloop: c = 0; else { - if (a==0) + if (a == 0) c = ieeeMean(copysign(T(0), b), b); - else if (b==0) + else if (b == 0) c = ieeeMean(copysign(T(0), a), a); else c = ieeeMean(a, b); @@ -1120,7 +1120,7 @@ whileloop: // yet, or if we don't yet know what the exponent is, // perform a binary chop. - if ((a==0 || b==0 || + if ((a == 0 || b == 0 || (fabs(a) >= T(0.5) * fabs(b) && fabs(b) >= T(0.5) * fabs(a))) && (b - a) < T(0.25) * (b0 - a0)) { diff --git a/std/process.d b/std/process.d index 37b5196bada..bf95e6af725 100644 --- a/std/process.d +++ b/std/process.d @@ -2847,7 +2847,7 @@ version(Windows) version(unittest) { auto q = escapeWindowsArgument(s); auto args = parseCommandLine("Dummy.exe " ~ q); - assert(args.length==2, s ~ " => " ~ q ~ " #" ~ text(args.length-1)); + assert(args.length == 2, s ~ " => " ~ q ~ " #" ~ text(args.length-1)); assert(args[1] == s, s ~ " => " ~ q ~ " => " ~ args[1]); } } diff --git a/std/random.d b/std/random.d index b8b103b0afa..5fbaa9e88b7 100644 --- a/std/random.d +++ b/std/random.d @@ -2790,7 +2790,7 @@ to remaining data values is sufficiently large. size_t s; double v, quot, top; - if (_toSelect==1) + if (_toSelect == 1) { static if (is(UniformRNG == void)) { diff --git a/std/socket.d b/std/socket.d index ed4f0297b3a..d5b4693700b 100644 --- a/std/socket.d +++ b/std/socket.d @@ -1299,10 +1299,10 @@ abstract class Address if (!numeric) { - if (ret==EAI_NONAME) + if (ret == EAI_NONAME) return null; version(Windows) - if (ret==WSANO_DATA) + if (ret == WSANO_DATA) return null; } @@ -2164,7 +2164,7 @@ private: // type (declared in core.sys.posix.sys.select) is a structure // containing a single field, a static array. - static assert(fd_set.tupleof.length==1); + static assert(fd_set.tupleof.length == 1); // This is the type used in the fd_set array. // Using the type of the correct size is important for big-endian diff --git a/std/stdio.d b/std/stdio.d index 49ed793af76..2db0e3c9401 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -1759,7 +1759,7 @@ is recommended if you want to process a complete file. assert(i < witness.length); assert(buf == witness[i++]); } - assert(buf.length==0); + assert(buf.length == 0); } } diff --git a/std/traits.d b/std/traits.d index 62cf732a3c5..3384707f6c7 100644 --- a/std/traits.d +++ b/std/traits.d @@ -991,9 +991,9 @@ template arity(alias func) @safe unittest { void foo(){} - static assert(arity!foo==0); + static assert(arity!foo == 0); void bar(uint){} - static assert(arity!bar==1); + static assert(arity!bar == 1); void variadicFoo(uint...){} static assert(!__traits(compiles, arity!variadicFoo)); } diff --git a/std/typecons.d b/std/typecons.d index 664a5e8b31a..b9bdffad7db 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -6179,7 +6179,7 @@ mixin template Proxy(alias a) } static void allFail(T0, T1)(T0 a, T1 b) { - assert(!(a==b)); + assert(!(a == b)); assert(!(ab)); @@ -6206,7 +6206,7 @@ mixin template Proxy(alias a) assert(!(a>=b)); a = 4; - assert(a==b); + assert(a == b); assert(!(ab)); diff --git a/std/utf.d b/std/utf.d index 0993cc9f53a..f41eeee701a 100644 --- a/std/utf.d +++ b/std/utf.d @@ -1494,7 +1494,7 @@ if ( @safe pure @nogc nothrow unittest { - // Add tests for useReplacemendDchar==yes path + // Add tests for useReplacemendDchar == yes path static struct R { @@ -1611,7 +1611,7 @@ if (is(S : const wchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S @safe pure @nogc nothrow unittest { - // Add tests for useReplacemendDchar==true path + // Add tests for useReplacemendDchar == true path static struct R { @@ -1675,7 +1675,7 @@ if (is(S : const dchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S @safe pure @nogc nothrow unittest { - // Add tests for useReplacemendDchar==true path + // Add tests for useReplacemendDchar == true path static struct R { From 0b33b5081257ca4b9268135d8124b460a3824643 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 23 Feb 2017 00:46:59 +0100 Subject: [PATCH 3/7] Automatically add spaces to binary operators (!=) command: sed -E "s/([[:alnum:]]) != ([[:alnum:]])/\1 != \2/g" -i **/*.d sed -E "s/([[:alnum:]])!= ([[:alnum:]])/\1 != \2/g" -i **/*.d sed -E "s/([[:alnum:]]) !=([[:alnum:]])/\1 != \2/g" -i **/*.d --- std/bigint.d | 8 +++---- std/functional.d | 6 +++--- std/internal/math/biguintcore.d | 36 ++++++++++++++++---------------- std/internal/math/biguintnoasm.d | 2 +- std/internal/math/biguintx86.d | 2 +- std/math.d | 12 +++++------ std/numeric.d | 4 ++-- std/regex/internal/thompson.d | 2 +- std/typecons.d | 2 +- std/uni.d | 2 +- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/std/bigint.d b/std/bigint.d index ed1c4bfeaf0..5f2e2b2b07a 100644 --- a/std/bigint.d +++ b/std/bigint.d @@ -238,7 +238,7 @@ public: } else static if (op=="/") { - assert(y!=0, "Division by zero"); + assert(y != 0, "Division by zero"); static if (T.sizeof <= uint.sizeof) { data = BigUint.divInt(data, cast(uint) u); @@ -251,7 +251,7 @@ public: } else static if (op=="%") { - assert(y!=0, "Division by zero"); + assert(y != 0, "Division by zero"); static if (is(immutable(T) == immutable(long)) || is( immutable(T) == immutable(ulong) )) { this %= BigInt(y); @@ -424,7 +424,7 @@ public: auto opBinary(string op, T)(T y) pure nothrow const if (op == "%" && isIntegral!T) { - assert(y!=0); + assert(y != 0); // BigInt % long => long // BigInt % ulong => BigInt @@ -761,7 +761,7 @@ public: /// ditto int opCmp(T:BigInt)(const T y) pure nothrow @nogc const { - if (sign!=y.sign) + if (sign != y.sign) return sign ? -1 : 1; immutable cmp = data.opCmp(y.data); return sign? -cmp: cmp; diff --git a/std/functional.d b/std/functional.d index f12bcd12ea2..e8db7f864e2 100644 --- a/std/functional.d +++ b/std/functional.d @@ -336,7 +336,7 @@ private uint _ctfeMatchUnary(string fun, string name) static assert(_ctfeMatchUnary("4 == a", "a")); static assert(_ctfeMatchUnary("2 == a", "a")); static assert(_ctfeMatchUnary("1 != a", "a")); - static assert(_ctfeMatchUnary("a!=4", "a")); + static assert(_ctfeMatchUnary("a != 4", "a")); static assert(_ctfeMatchUnary("a< 1", "a")); static assert(_ctfeMatchUnary("434 < a", "a")); static assert(_ctfeMatchUnary("132 > a", "a")); @@ -384,7 +384,7 @@ private uint _ctfeMatchBinary(string fun, string name1, string name2) static assert(_ctfeMatchBinary("4 == a", "a", "b")); static assert(_ctfeMatchBinary("2 == a", "a", "b")); static assert(_ctfeMatchBinary("1 != a", "a", "b")); - static assert(_ctfeMatchBinary("a!=4", "a", "b")); + static assert(_ctfeMatchBinary("a != 4", "a", "b")); static assert(_ctfeMatchBinary("a< 1", "a", "b")); static assert(_ctfeMatchBinary("434 < a", "a", "b")); static assert(_ctfeMatchBinary("132 > a", "a", "b")); @@ -404,7 +404,7 @@ private uint _ctfeMatchBinary(string fun, string name1, string name2) static assert(_ctfeMatchBinary("b == a", "b", "a")); static assert(_ctfeMatchBinary("b == a", "b", "a")); static assert(_ctfeMatchBinary("b != a", "b", "a")); - static assert(_ctfeMatchBinary("a!=b", "b", "a")); + static assert(_ctfeMatchBinary("a != b", "b", "a")); static assert(_ctfeMatchBinary("a< b", "b", "a")); static assert(_ctfeMatchBinary("b < a", "b", "a")); static assert(_ctfeMatchBinary("b > a", "b", "a")); diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 4e1ea7d8536..1ab7fa22f3e 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -252,7 +252,7 @@ public: uint yhi = cast(uint)(y >> 32); if (data.length == 2 && data[1]!=yhi) return false; - if (data.length == 1 && yhi!=0) + if (data.length == 1 && yhi != 0) return false; return (data[0] == ylo); } @@ -584,9 +584,9 @@ public: if (y == 0 || x == 0) return BigUint(ZERO); uint hi = cast(uint)(y >>> 32); uint lo = cast(uint)(y & 0xFFFF_FFFF); - uint [] result = new BigDigit[x.data.length+1+(hi!=0)]; + uint [] result = new BigDigit[x.data.length+1+(hi != 0)]; result[x.data.length] = multibyteMul(result[0 .. x.data.length], x.data, lo, 0); - if (hi!=0) + if (hi != 0) { result[x.data.length+1] = multibyteMulAdd!('+')(result[1 .. x.data.length+1], x.data, hi, 0); @@ -626,10 +626,10 @@ public: uint [] result = new BigDigit[x.data.length]; if ((y&(-y))==y) { - assert(y!=0, "BigUint division by zero"); + assert(y != 0, "BigUint division by zero"); // perfect power of 2 uint b = 0; - for (;y!=1; y>>=1) + for (;y != 1; y>>=1) { ++b; } @@ -663,7 +663,7 @@ public: { import core.memory : GC; uint y = y_; - assert(y!=0); + assert(y != 0); if ((y&(-y)) == y) { // perfect power of 2 return x.data[0] & (y-1); @@ -752,7 +752,7 @@ public: // If true, then x0 is that digit // and the result will be (x0 ^^ y) * (2^^(firstnonzero*y*BigDigitBits)) BigDigit x0 = x.data[firstnonzero]; - assert(x0 !=0); + assert(x0 != 0); // Length of the non-zero portion size_t nonzerolength = x.data.length - firstnonzero; ulong y0; @@ -874,7 +874,7 @@ public: } y <<=1; - while (y!=0) + while (y != 0) { // For each bit of y: Set r1 = r1 * r1 // If the bit is 1, set r1 = r1 * x @@ -915,7 +915,7 @@ public: } } - if (finalMultiplier!=1) + if (finalMultiplier != 1) { const BigDigit carry = multibyteMul(r1, r1, finalMultiplier, 0); if (carry) @@ -927,7 +927,7 @@ public: if (evenshiftbits) { const BigDigit carry = multibyteShl(r1, r1, evenshiftbits); - if (carry!=0) + if (carry != 0) { r1 = t1[0 .. r1.length + 1]; r1[$ - 1] = carry; @@ -1293,16 +1293,16 @@ BigDigit [] addInt(const BigDigit[] x, ulong y) pure nothrow uint hi = cast(uint)(y >>> 32); uint lo = cast(uint)(y& 0xFFFF_FFFF); auto len = x.length; - if (x.length < 2 && hi!=0) ++len; + if (x.length < 2 && hi != 0) ++len; BigDigit [] result = new BigDigit[len+1]; result[0 .. x.length] = x[]; - if (x.length < 2 && hi!=0) + if (x.length < 2 && hi != 0) { result[1]=hi; hi=0; } uint carry = multibyteIncrementAssign!('+')(result[0..$-1], lo); - if (hi!=0) carry += multibyteIncrementAssign!('+')(result[1..$-1], hi); + if (hi != 0) carry += multibyteIncrementAssign!('+')(result[1..$-1], hi); if (carry) { result[$-1] = carry; @@ -1512,7 +1512,7 @@ void divModInternal(BigDigit [] quotient, BigDigit[] remainder, const BigDigit [ BigDigit [] un = new BigDigit[u.length + 1]; // How much to left shift v, so that its MSB is set. uint s = BIGDIGITSHIFTMASK - bsr(v[$-1]); - if (s!=0) + if (s != 0) { multibyteShl(vn, v, s); un[$-1] = multibyteShl(un[0..$-1], u, s); @@ -1675,7 +1675,7 @@ size_t biguintToDecimal(char [] buff, BigDigit [] data) pure nothrow itoaZeroPadded(buff[sofar-10 .. sofar], data[0]); sofar -= 10; // and strip off the leading zeros - while (sofar!= buff.length-1 && buff[sofar] == '0') + while (sofar != buff.length-1 && buff[sofar] == '0') sofar++; return sofar; } @@ -1762,7 +1762,7 @@ body hi = 2; uint c = multibyteIncrementAssign!('+')(data[0 .. hi], cast(uint)(y&0xFFFF_FFFF)); c += multibyteIncrementAssign!('+')(data[1 .. hi], cast(uint)(y>>32)); - if (c!=0) + if (c != 0) { data[hi]=c; ++hi; @@ -1805,7 +1805,7 @@ body while (lo>0) { immutable c = multibyteMul(data[0 .. hi], data[0 .. hi], 10, 0); - if (c!=0) + if (c != 0) { data[hi]=c; ++hi; @@ -1817,7 +1817,7 @@ body { c += multibyteIncrementAssign!('+')(data[1 .. hi], cast(uint)(y>>32)); } - if (c!=0) + if (c != 0) { data[hi]=c; ++hi; diff --git a/std/internal/math/biguintnoasm.d b/std/internal/math/biguintnoasm.d index 5d75527000c..52c4c12cea8 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; diff --git a/std/internal/math/biguintx86.d b/std/internal/math/biguintx86.d index 4c504a54add..2f49340c8c5 100644 --- a/std/internal/math/biguintx86.d +++ b/std/internal/math/biguintx86.d @@ -205,7 +205,7 @@ done: a[5] =0x44444444; carry = multibyteAddSub!('-')(a[0 .. 12], a[0 .. 12], b[0 .. 12], 0); assert(a[11]==0); - for (int i=0; i<10; ++i) if (i!=5) assert(a[i]==0); + for (int i=0; i<10; ++i) if (i != 5) assert(a[i]==0); for (int q=3; q<36;++q) { diff --git a/std/math.d b/std/math.d index 65345f4c0f2..9614879021c 100644 --- a/std/math.d +++ b/std/math.d @@ -951,7 +951,7 @@ Lret: {} r = -r; t = tan(x); //printf("tan(%Lg) = %Lg, should be %Lg\n", x, t, r); - if (!isIdentical(r, t) && !(r!=r && t!=t)) assert(fabs(r-t) <= .0000001); + if (!isIdentical(r, t) && !(r != r && t != t)) assert(fabs(r-t) <= .0000001); } // overflow assert(isNaN(tan(real.infinity))); @@ -1770,7 +1770,7 @@ L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; - test AX, 0x0400; // NaN_or_zero, but we already know x!=0 + test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x test AX, 0x0200; jnz L_largenegative; @@ -1858,7 +1858,7 @@ L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; - test AX, 0x0400; // NaN_or_zero, but we already know x!=0 + test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x test AX, 0x0200; jnz L_largenegative; @@ -2023,7 +2023,7 @@ L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; - test AX, 0x0400; // NaN_or_zero, but we already know x!=0 + test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x // set scratchreal = real.min_normal // squaring it will return 0, setting underflow flag @@ -2124,7 +2124,7 @@ L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; - test AX, 0x0400; // NaN_or_zero, but we already know x!=0 + test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x // set scratchreal = real.min // squaring it will return 0, setting underflow flag @@ -6518,7 +6518,7 @@ if (isFloatingPoint!(X)) || F.realFormat == RealFormat.ieeeQuadruple); if (x == y) - return X.mant_dig; // ensure diff!=0, cope with INF. + return X.mant_dig; // ensure diff != 0, cope with INF. Unqual!X diff = fabs(x - y); diff --git a/std/numeric.d b/std/numeric.d index 0bf63e220eb..82f271261d8 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -924,7 +924,7 @@ body */ static T secant_interpolate(T a, T b, R fa, R fb) { - if (( ((a - b) == a) && b!=0) || (a!=0 && ((b - a) == b))) + if (( ((a - b) == a) && b != 0) || (a != 0 && ((b - a) == b))) { // Catastrophic cancellation if (a == 0) @@ -1188,7 +1188,7 @@ T findRoot(T, R)(scope R delegate(T) f, in T a, in T b, auto flo = f(result[0]); auto fhi = f(result[1]); - if (flo!=0) + if (flo != 0) { assert(oppositeSigns(flo, fhi)); } diff --git a/std/regex/internal/thompson.d b/std/regex/internal/thompson.d index 500b0293785..103726edb62 100644 --- a/std/regex/internal/thompson.d +++ b/std/regex/internal/thompson.d @@ -1075,7 +1075,7 @@ if (is(Char : dchar)) { writefln("-- Threaded matching threads at %s", s[index .. s.lastIndex]); } - if (startPc!=RestartPc) + if (startPc != RestartPc) { state.t = createStart(index, startPc); genCounter++; diff --git a/std/typecons.d b/std/typecons.d index b9bdffad7db..28e5454db08 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -6199,7 +6199,7 @@ mixin template Proxy(alias a) allFail(a, b); b = 4; - assert(a!=b); + assert(a != b); assert(ab)); diff --git a/std/uni.d b/std/uni.d index 238373194e9..26dadd36df7 100644 --- a/std/uni.d +++ b/std/uni.d @@ -5304,7 +5304,7 @@ if (is(C : wchar) || is(C : char)) assert(testAll(ascii, c8) || len != 1); assert(testAll(uni2, c8) || len != 2); assert(testAll(uni3, c8) || len != 3); - assert(testAll(uni24, c8) || (len != 2 && len !=4)); + assert(testAll(uni24, c8) || (len != 2 && len != 4)); } } From d905ef53b156dc9a894afb0fa109858f3f492118 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 23 Feb 2017 00:49:03 +0100 Subject: [PATCH 4/7] Automatically add spaces to binary operators (<=) command: sed -E "s/([[:alnum:]]) <= ([[:alnum:]])/\1 <= \2/g" -i **/*.d sed -E "s/([[:alnum:]])<= ([[:alnum:]])/\1 <= \2/g" -i **/*.d sed -E "s/([[:alnum:]]) <=([[:alnum:]])/\1 <= \2/g" -i **/*.d --- std/algorithm/sorting.d | 8 ++++---- std/internal/math/biguintcore.d | 2 +- std/internal/math/biguintnoasm.d | 4 ++-- std/internal/math/errorfunction.d | 4 ++-- std/internal/math/gammafunction.d | 2 +- std/math.d | 4 ++-- std/mathspecial.d | 2 +- std/numeric.d | 4 ++-- std/random.d | 2 +- std/typecons.d | 6 +++--- std/uni.d | 12 ++++++------ 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index 8cfb6cbd04f..c50df8dca9b 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -3955,15 +3955,15 @@ if (isRandomAccessRange!Range && hasLength!Range && static if (flag == No.leanRight) { // Eliminate the rightmost from the competition - if (lt(r[d], r[c])) r.swapAt(c, d); // c<=d - if (lt(r[d], r[b])) r.swapAt(b, d); // b<=d + if (lt(r[d], r[c])) r.swapAt(c, d); // c <= d + if (lt(r[d], r[b])) r.swapAt(b, d); // b <= d medianOf!lt(r, a, b, c); } else { // Eliminate the leftmost from the competition - if (lt(r[b], r[a])) r.swapAt(a, b); // a<=b - if (lt(r[c], r[a])) r.swapAt(a, c); // a<=c + if (lt(r[b], r[a])) r.swapAt(a, b); // a <= b + if (lt(r[c], r[a])) r.swapAt(a, c); // a <= c medianOf!lt(r, b, c, d); } } diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 1ab7fa22f3e..24b5fb0b5ad 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -1959,7 +1959,7 @@ bool less(const(BigDigit)[] x, const(BigDigit)[] y) pure nothrow return x[k] < y[k]; } -// Set result = abs(x-y), return true if result is negative(x=0.0L && p<=1.0L, "Domain error"); + assert(p>=0.0L && p <= 1.0L, "Domain error"); } body { @@ -419,7 +419,7 @@ static immutable real[8] Q3 = 0x1.e05268dd3c07989ep-3, 0x1.239c6aff14afbf82p+1, 1.0 ]; - if (p<=0.0L || p>=1.0L) + if (p <= 0.0L || p>=1.0L) { if (p == 0.0L) return -real.infinity; diff --git a/std/internal/math/gammafunction.d b/std/internal/math/gammafunction.d index f662f72155d..66516662e6d 100644 --- a/std/internal/math/gammafunction.d +++ b/std/internal/math/gammafunction.d @@ -1427,7 +1427,7 @@ body { */ real gammaIncompleteComplInv(real a, real p) in { - assert(p>=0 && p<= 1); + assert(p>=0 && p <= 1); assert(a>0); } body { diff --git a/std/math.d b/std/math.d index 9614879021c..0dcf08af2ca 100644 --- a/std/math.d +++ b/std/math.d @@ -3284,7 +3284,7 @@ real log1p(real x) @safe pure nothrow @nogc 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 + // ie if -0.29 <= x <= 0.414 return (fabs(x) <= 0.25) ? core.math.yl2xp1(x, LN2) : core.math.yl2x(x+1, LN2); } else @@ -6647,7 +6647,7 @@ body { // Runtime behaviour for contract violation: // If signs are opposite, or one is a NaN, return 0. - if (!((x>=0 && y>=0) || (x<=0 && y<=0))) return 0.0; + if (!((x>=0 && y>=0) || (x <= 0 && y <= 0))) return 0.0; // The implementation is simple: cast x and y to integers, // average them (avoiding overflow), and cast the result back to a floating-point number. diff --git a/std/mathspecial.d b/std/mathspecial.d index 91f50daa218..0e6fd6aeb8f 100644 --- a/std/mathspecial.d +++ b/std/mathspecial.d @@ -351,7 +351,7 @@ real normalDistribution(real x) */ real normalDistributionInverse(real p) in { - assert(p>=0.0L && p<=1.0L, "Domain error"); + assert(p>=0.0L && p <= 1.0L, "Domain error"); } body { diff --git a/std/numeric.d b/std/numeric.d index 82f271261d8..7306006ab29 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -588,7 +588,7 @@ public: { auto x = get!real; auto y = cast(real) b; - return (x>=y)-(x<=y); + return (x>=y)-(x <= y); } /// ditto @@ -1304,7 +1304,7 @@ T findRoot(T, R)(scope R delegate(T) f, in T a, in T b, numProblems=0; //testFindRoot(&alefeld0, PI_2, PI); - for (n=1; n<=10; ++n) + for (n=1; n <= 10; ++n) { //testFindRoot(&alefeld0, n*n+1e-9L, (n+1)*(n+1)-1e-9L); } diff --git a/std/random.d b/std/random.d index 5fbaa9e88b7..a7b0b67c69d 100644 --- a/std/random.d +++ b/std/random.d @@ -2497,7 +2497,7 @@ if (isRandomAccessRange!Range) auto range = iota(10); auto randy = range.randomCover; - for (int i=1; i<=range.length; i++) + for (int i=1; i <= range.length; i++) { randy.popFront; assert(randy.length == range.length - i); diff --git a/std/typecons.d b/std/typecons.d index 28e5454db08..fe7b31e12ef 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -6181,7 +6181,7 @@ mixin template Proxy(alias a) { assert(!(a == b)); assert(!(ab)); assert(!(a>=b)); } @@ -6201,14 +6201,14 @@ mixin template Proxy(alias a) b = 4; assert(a != b); assert(ab)); assert(!(a>=b)); a = 4; assert(a == b); assert(!(ab)); assert(a>=b); } diff --git a/std/uni.d b/std/uni.d index 26dadd36df7..45348778a93 100644 --- a/std/uni.d +++ b/std/uni.d @@ -2102,8 +2102,8 @@ public: bool opIndex(uint val) const { // the <= ensures that searching in interval of [a, b) for 'a' you get .length == 1 - // return assumeSorted!((a,b) => a<=b)(data[]).lowerBound(val).length & 1; - return sharSwitchLowerBound!"a<=b"(data[], val) & 1; + // return assumeSorted!((a,b) => a <= b)(data[]).lowerBound(val).length & 1; + return sharSwitchLowerBound!"a <= b"(data[], val) & 1; } /// @@ -2957,7 +2957,7 @@ private: } body { - auto range = assumeSorted!"a<=b"(data[pos .. data.length]); + auto range = assumeSorted!"a <= b"(data[pos .. data.length]); if (range.empty) return pos; size_t idx = pos; @@ -2995,7 +2995,7 @@ private: body { assert(data.length % 2 == 0); - auto range = assumeSorted!"a<=b"(data[pos .. data.length]); + auto range = assumeSorted!"a <= b"(data[pos .. data.length]); size_t idx = pos+range.lowerBound(a).length; if (idx >= data.length) // could have Marker point to recently removed stuff @@ -4619,7 +4619,7 @@ mixin template ForwardStrings() template Utf8Matcher() { - enum validSize(int sz) = sz >= 1 && sz <=4; + enum validSize(int sz) = sz >= 1 && sz <= 4; void badEncoding() pure @safe { @@ -4902,7 +4902,7 @@ template Utf8Matcher() template Utf16Matcher() { - enum validSize(int sz) = sz >= 1 && sz <=2; + enum validSize(int sz) = sz >= 1 && sz <= 2; void badEncoding() pure { From ef7be4b60d7e9b1f63f0d1f96b823f5f66bf0054 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 23 Feb 2017 00:50:14 +0100 Subject: [PATCH 5/7] Automatically add spaces to binary operators (<<) command: sed -E "s/([[:alnum:]]) << ([[:alnum:]])/\1 << \2/g" -i **/*.d sed -E "s/([[:alnum:]])<< ([[:alnum:]])/\1 << \2/g" -i **/*.d sed -E "s/([[:alnum:]]) <<([[:alnum:]])/\1 << \2/g" -i **/*.d --- etc/c/sqlite3.d | 106 +++++++++++++++--------------- std/algorithm/sorting.d | 2 +- std/conv.d | 8 +-- std/internal/math/biguintnoasm.d | 2 +- std/math.d | 16 ++--- std/regex/internal/backtracking.d | 6 +- std/regex/internal/ir.d | 10 +-- std/regex/internal/kickstart.d | 24 +++---- std/regex/internal/shiftor.d | 24 +++---- std/typecons.d | 22 +++---- std/uni.d | 44 ++++++------- 11 files changed, 132 insertions(+), 132 deletions(-) diff --git a/etc/c/sqlite3.d b/etc/c/sqlite3.d index 254814db772..e87993840ed 100644 --- a/etc/c/sqlite3.d +++ b/etc/c/sqlite3.d @@ -149,59 +149,59 @@ enum */ enum { - SQLITE_IOERR_READ = (SQLITE_IOERR | (1<<8)), - SQLITE_IOERR_SHORT_READ = (SQLITE_IOERR | (2<<8)), - SQLITE_IOERR_WRITE = (SQLITE_IOERR | (3<<8)), - SQLITE_IOERR_FSYNC = (SQLITE_IOERR | (4<<8)), - SQLITE_IOERR_DIR_FSYNC = (SQLITE_IOERR | (5<<8)), - SQLITE_IOERR_TRUNCATE = (SQLITE_IOERR | (6<<8)), - SQLITE_IOERR_FSTAT = (SQLITE_IOERR | (7<<8)), - SQLITE_IOERR_UNLOCK = (SQLITE_IOERR | (8<<8)), - SQLITE_IOERR_RDLOCK = (SQLITE_IOERR | (9<<8)), - SQLITE_IOERR_DELETE = (SQLITE_IOERR | (10<<8)), - SQLITE_IOERR_BLOCKED = (SQLITE_IOERR | (11<<8)), - SQLITE_IOERR_NOMEM = (SQLITE_IOERR | (12<<8)), - SQLITE_IOERR_ACCESS = (SQLITE_IOERR | (13<<8)), - SQLITE_IOERR_CHECKRESERVEDLOCK = (SQLITE_IOERR | (14<<8)), - SQLITE_IOERR_LOCK = (SQLITE_IOERR | (15<<8)), - SQLITE_IOERR_CLOSE = (SQLITE_IOERR | (16<<8)), - SQLITE_IOERR_DIR_CLOSE = (SQLITE_IOERR | (17<<8)), - SQLITE_IOERR_SHMOPEN = (SQLITE_IOERR | (18<<8)), - SQLITE_IOERR_SHMSIZE = (SQLITE_IOERR | (19<<8)), - SQLITE_IOERR_SHMLOCK = (SQLITE_IOERR | (20<<8)), - SQLITE_IOERR_SHMMAP = (SQLITE_IOERR | (21<<8)), - SQLITE_IOERR_SEEK = (SQLITE_IOERR | (22<<8)), - SQLITE_IOERR_DELETE_NOENT = (SQLITE_IOERR | (23<<8)), - SQLITE_IOERR_MMAP = (SQLITE_IOERR | (24<<8)), - SQLITE_LOCKED_SHAREDCACHE = (SQLITE_LOCKED | (1<<8)), - SQLITE_BUSY_RECOVERY = (SQLITE_BUSY | (1<<8)), - SQLITE_CANTOPEN_NOTEMPDIR = (SQLITE_CANTOPEN | (1<<8)), - SQLITE_IOERR_GETTEMPPATH = (SQLITE_IOERR | (25<<8)), - SQLITE_IOERR_CONVPATH = (SQLITE_IOERR | (26<<8)), - SQLITE_BUSY_SNAPSHOT = (SQLITE_BUSY | (2<<8)), - SQLITE_CANTOPEN_ISDIR = (SQLITE_CANTOPEN | (2<<8)), - SQLITE_CANTOPEN_FULLPATH = (SQLITE_CANTOPEN | (3<<8)), - SQLITE_CANTOPEN_CONVPATH = (SQLITE_CANTOPEN | (4<<8)), - SQLITE_CORRUPT_VTAB = (SQLITE_CORRUPT | (1<<8)), - SQLITE_READONLY_RECOVERY = (SQLITE_READONLY | (1<<8)), - SQLITE_READONLY_CANTLOCK = (SQLITE_READONLY | (2<<8)), - SQLITE_READONLY_ROLLBACK = (SQLITE_READONLY | (3<<8)), - SQLITE_READONLY_DBMOVED = (SQLITE_READONLY | (4<<8)), - SQLITE_ABORT_ROLLBACK = (SQLITE_ABORT | (2<<8)), - SQLITE_CONSTRAINT_CHECK = (SQLITE_CONSTRAINT | (1<<8)), - SQLITE_CONSTRAINT_COMMITHOOK = (SQLITE_CONSTRAINT | (2<<8)), - SQLITE_CONSTRAINT_FOREIGNKEY = (SQLITE_CONSTRAINT | (3<<8)), - SQLITE_CONSTRAINT_FUNCTION = (SQLITE_CONSTRAINT | (4<<8)), - SQLITE_CONSTRAINT_NOTNULL = (SQLITE_CONSTRAINT | (5<<8)), - SQLITE_CONSTRAINT_PRIMARYKEY = (SQLITE_CONSTRAINT | (6<<8)), - SQLITE_CONSTRAINT_TRIGGER = (SQLITE_CONSTRAINT | (7<<8)), - SQLITE_CONSTRAINT_UNIQUE = (SQLITE_CONSTRAINT | (8<<8)), - SQLITE_CONSTRAINT_VTAB = (SQLITE_CONSTRAINT | (9<<8)), - SQLITE_CONSTRAINT_ROWID = (SQLITE_CONSTRAINT |(10<<8)), - SQLITE_NOTICE_RECOVER_WAL = (SQLITE_NOTICE | (1<<8)), - SQLITE_NOTICE_RECOVER_ROLLBACK = (SQLITE_NOTICE | (2<<8)), - SQLITE_WARNING_AUTOINDEX = (SQLITE_WARNING | (1<<8)), - SQLITE_AUTH_USER = (SQLITE_AUTH | (1<<8)) + SQLITE_IOERR_READ = (SQLITE_IOERR | (1 << 8)), + SQLITE_IOERR_SHORT_READ = (SQLITE_IOERR | (2 << 8)), + SQLITE_IOERR_WRITE = (SQLITE_IOERR | (3 << 8)), + SQLITE_IOERR_FSYNC = (SQLITE_IOERR | (4 << 8)), + SQLITE_IOERR_DIR_FSYNC = (SQLITE_IOERR | (5 << 8)), + SQLITE_IOERR_TRUNCATE = (SQLITE_IOERR | (6 << 8)), + SQLITE_IOERR_FSTAT = (SQLITE_IOERR | (7 << 8)), + SQLITE_IOERR_UNLOCK = (SQLITE_IOERR | (8 << 8)), + SQLITE_IOERR_RDLOCK = (SQLITE_IOERR | (9 << 8)), + SQLITE_IOERR_DELETE = (SQLITE_IOERR | (10 << 8)), + SQLITE_IOERR_BLOCKED = (SQLITE_IOERR | (11 << 8)), + SQLITE_IOERR_NOMEM = (SQLITE_IOERR | (12 << 8)), + SQLITE_IOERR_ACCESS = (SQLITE_IOERR | (13 << 8)), + SQLITE_IOERR_CHECKRESERVEDLOCK = (SQLITE_IOERR | (14 << 8)), + SQLITE_IOERR_LOCK = (SQLITE_IOERR | (15 << 8)), + SQLITE_IOERR_CLOSE = (SQLITE_IOERR | (16 << 8)), + SQLITE_IOERR_DIR_CLOSE = (SQLITE_IOERR | (17 << 8)), + SQLITE_IOERR_SHMOPEN = (SQLITE_IOERR | (18 << 8)), + SQLITE_IOERR_SHMSIZE = (SQLITE_IOERR | (19 << 8)), + SQLITE_IOERR_SHMLOCK = (SQLITE_IOERR | (20 << 8)), + SQLITE_IOERR_SHMMAP = (SQLITE_IOERR | (21 << 8)), + SQLITE_IOERR_SEEK = (SQLITE_IOERR | (22 << 8)), + SQLITE_IOERR_DELETE_NOENT = (SQLITE_IOERR | (23 << 8)), + SQLITE_IOERR_MMAP = (SQLITE_IOERR | (24 << 8)), + SQLITE_LOCKED_SHAREDCACHE = (SQLITE_LOCKED | (1 << 8)), + SQLITE_BUSY_RECOVERY = (SQLITE_BUSY | (1 << 8)), + SQLITE_CANTOPEN_NOTEMPDIR = (SQLITE_CANTOPEN | (1 << 8)), + SQLITE_IOERR_GETTEMPPATH = (SQLITE_IOERR | (25 << 8)), + SQLITE_IOERR_CONVPATH = (SQLITE_IOERR | (26 << 8)), + SQLITE_BUSY_SNAPSHOT = (SQLITE_BUSY | (2 << 8)), + SQLITE_CANTOPEN_ISDIR = (SQLITE_CANTOPEN | (2 << 8)), + SQLITE_CANTOPEN_FULLPATH = (SQLITE_CANTOPEN | (3 << 8)), + SQLITE_CANTOPEN_CONVPATH = (SQLITE_CANTOPEN | (4 << 8)), + SQLITE_CORRUPT_VTAB = (SQLITE_CORRUPT | (1 << 8)), + SQLITE_READONLY_RECOVERY = (SQLITE_READONLY | (1 << 8)), + SQLITE_READONLY_CANTLOCK = (SQLITE_READONLY | (2 << 8)), + SQLITE_READONLY_ROLLBACK = (SQLITE_READONLY | (3 << 8)), + SQLITE_READONLY_DBMOVED = (SQLITE_READONLY | (4 << 8)), + SQLITE_ABORT_ROLLBACK = (SQLITE_ABORT | (2 << 8)), + SQLITE_CONSTRAINT_CHECK = (SQLITE_CONSTRAINT | (1 << 8)), + SQLITE_CONSTRAINT_COMMITHOOK = (SQLITE_CONSTRAINT | (2 << 8)), + SQLITE_CONSTRAINT_FOREIGNKEY = (SQLITE_CONSTRAINT | (3 << 8)), + SQLITE_CONSTRAINT_FUNCTION = (SQLITE_CONSTRAINT | (4 << 8)), + SQLITE_CONSTRAINT_NOTNULL = (SQLITE_CONSTRAINT | (5 << 8)), + SQLITE_CONSTRAINT_PRIMARYKEY = (SQLITE_CONSTRAINT | (6 << 8)), + SQLITE_CONSTRAINT_TRIGGER = (SQLITE_CONSTRAINT | (7 << 8)), + SQLITE_CONSTRAINT_UNIQUE = (SQLITE_CONSTRAINT | (8 << 8)), + SQLITE_CONSTRAINT_VTAB = (SQLITE_CONSTRAINT | (9 << 8)), + SQLITE_CONSTRAINT_ROWID = (SQLITE_CONSTRAINT |(10 << 8)), + SQLITE_NOTICE_RECOVER_WAL = (SQLITE_NOTICE | (1 << 8)), + SQLITE_NOTICE_RECOVER_ROLLBACK = (SQLITE_NOTICE | (2 << 8)), + SQLITE_WARNING_AUTOINDEX = (SQLITE_WARNING | (1 << 8)), + SQLITE_AUTH_USER = (SQLITE_AUTH | (1 << 8)) } /** diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index c50df8dca9b..7d16bbbe732 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -2327,7 +2327,7 @@ private template TimSortImpl(alias pred, R) size_t minRunLength()(size_t n) { immutable shift = bsr(n)-5; - auto result = (n>>shift) + !!(n & ~((1<>shift) + !!(n & ~((1 << shift)-1)); return result; } diff --git a/std/conv.d b/std/conv.d index ab12eedffd0..00b2e2a35fe 100644 --- a/std/conv.d +++ b/std/conv.d @@ -1372,18 +1372,18 @@ if (!isImplicitlyConvertible!(S, T) && // Narrowing conversions from enum -> integral should be allowed, but they // should throw at runtime if the enum value doesn't fit in the target // type. - enum E1 : ulong { A = 1, B = 1UL<<48, C = 0 } + enum E1 : ulong { A = 1, B = 1UL << 48, C = 0 } assert(to!int(E1.A) == 1); assert(to!bool(E1.A) == true); assertThrown!ConvOverflowException(to!int(E1.B)); // E1.B overflows int assertThrown!ConvOverflowException(to!bool(E1.B)); // E1.B overflows bool assert(to!bool(E1.C) == false); - enum E2 : long { A = -1L<<48, B = -1<<31, C = 1<<31 } + enum E2 : long { A = -1L << 48, B = -1 << 31, C = 1 << 31 } assertThrown!ConvOverflowException(to!int(E2.A)); // E2.A overflows int assertThrown!ConvOverflowException(to!uint(E2.B)); // E2.B overflows uint - assert(to!int(E2.B) == -1<<31); // but does not overflow int - assert(to!int(E2.C) == 1<<31); // E2.C does not overflow int + assert(to!int(E2.B) == -1 << 31); // but does not overflow int + assert(to!int(E2.C) == 1 << 31); // E2.C does not overflow int enum E3 : int { A = -1, B = 1, C = 255, D = 0 } assertThrown!ConvOverflowException(to!ubyte(E3.A)); diff --git a/std/internal/math/biguintnoasm.d b/std/internal/math/biguintnoasm.d index 81c1ba19db3..eb8f34fbb4e 100644 --- a/std/internal/math/biguintnoasm.d +++ b/std/internal/math/biguintnoasm.d @@ -288,7 +288,7 @@ uint multibyteDivAssign(uint [] dest, uint divisor, uint overflow) ulong c = cast(ulong) overflow; for (ptrdiff_t i = dest.length-1; i>= 0; --i) { - c = (c<<32) + cast(ulong)(dest[i]); + c = (c << 32) + cast(ulong)(dest[i]); uint q = cast(uint)(c/divisor); c -= divisor * q; dest[i] = q; diff --git a/std/math.d b/std/math.d index 0dcf08af2ca..2d286537a31 100644 --- a/std/math.d +++ b/std/math.d @@ -7537,10 +7537,10 @@ if (isFloatingPoint!T) { foreach (ulong i; 1 .. 62) { - assert(nextPow2(1UL<= 2 && seq < maxSequence); raw = code << 24 | (seq - 2)<<22 | data; } diff --git a/std/regex/internal/kickstart.d b/std/regex/internal/kickstart.d index 2bf559e3a38..162ef7cc88d 100644 --- a/std/regex/internal/kickstart.d +++ b/std/regex/internal/kickstart.d @@ -425,8 +425,8 @@ public: assert((cast(size_t) p & (Char.sizeof-1)) == orginalAlign); static if (charSize == 3) { - state = (state<<1) | table[p[1]]; - state = (state<<1) | table[p[2]]; + state = (state << 1) | table[p[1]]; + state = (state << 1) | table[p[2]]; p += 4; } else @@ -441,14 +441,14 @@ public: //use the usual shift-or cycle static if (charSize == 3) { - state = (state<<1) | table[p[0]]; - state = (state<<1) | table[p[1]]; - state = (state<<1) | table[p[2]]; + state = (state << 1) | table[p[0]]; + state = (state << 1) | table[p[1]]; + state = (state << 1) | table[p[2]]; p += 4; } else { - state = (state<<1) | table[p[0]]; + state = (state << 1) | table[p[0]]; p++; } if (!(state & limit)) @@ -466,9 +466,9 @@ public: const(ubyte)* end = cast(ubyte*)(haystack.ptr + haystack.length); while (p != end) { - state = (state<<1) | table[p[0]]; - state = (state<<1) | table[p[1]]; - state = (state<<1) | table[p[2]]; + state = (state << 1) | table[p[0]]; + state = (state << 1) | table[p[1]]; + state = (state << 1) | table[p[2]]; p += 4; if (!(state & limit))//division rounds down for dchar return (p-cast(ubyte*) haystack.ptr)/Char.sizeof @@ -481,17 +481,17 @@ public: size_t i = 0; if (len & 1) { - state = (state<<1) | table[p[i++]]; + state = (state << 1) | table[p[i++]]; if (!(state & limit)) return idx+i/Char.sizeof-length; } while (i < len) { - state = (state<<1) | table[p[i++]]; + state = (state << 1) | table[p[i++]]; if (!(state & limit)) return idx+i/Char.sizeof -length; - state = (state<<1) | table[p[i++]]; + state = (state << 1) | table[p[i++]]; if (!(state & limit)) return idx+i/Char.sizeof -length; diff --git a/std/regex/internal/shiftor.d b/std/regex/internal/shiftor.d index fd3ffc00e01..a438c5b6bed 100644 --- a/std/regex/internal/shiftor.d +++ b/std/regex/internal/shiftor.d @@ -414,8 +414,8 @@ public: assert((cast(size_t) p & (Char.sizeof-1)) == orginalAlign); static if (charSize == 3) { - state = (state<<1) | table[p[1]]; - state = (state<<1) | table[p[2]]; + state = (state << 1) | table[p[1]]; + state = (state << 1) | table[p[2]]; p += 4; } else @@ -432,14 +432,14 @@ public: //use the usual shift-or cycle static if (charSize == 3) { - state = (state<<1) | table[p[0]]; - state = (state<<1) | table[p[1]]; - state = (state<<1) | table[p[2]]; + state = (state << 1) | table[p[0]]; + state = (state << 1) | table[p[1]]; + state = (state << 1) | table[p[2]]; p += 4; } else { - state = (state<<1) | table[p[0]]; + state = (state << 1) | table[p[0]]; p++; } if (!(state & limit)) @@ -459,9 +459,9 @@ public: const(ubyte)* end = cast(ubyte*)(haystack.ptr + haystack.length); while (p != end) { - state = (state<<1) | table[p[0]]; - state = (state<<1) | table[p[1]]; - state = (state<<1) | table[p[2]]; + state = (state << 1) | table[p[0]]; + state = (state << 1) | table[p[1]]; + state = (state << 1) | table[p[2]]; p += 4; if (!(state & limit))//division rounds down for dchar { @@ -476,7 +476,7 @@ public: size_t i = 0; if (len & 1) { - state = (state<<1) | table[p[i++]]; + state = (state << 1) | table[p[i++]]; if (!(state & limit)) { s._index += i/Char.sizeof-length; @@ -485,13 +485,13 @@ public: } while (i < len) { - state = (state<<1) | table[p[i++]]; + state = (state << 1) | table[p[i++]]; if (!(state & limit)) { s._index += i/Char.sizeof-length; return true; } - state = (state<<1) | table[p[i++]]; + state = (state << 1) | table[p[i++]]; if (!(state & limit)) { s._index += i/Char.sizeof-length; diff --git a/std/typecons.d b/std/typecons.d index fe7b31e12ef..5aeda09bfb8 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -7087,10 +7087,10 @@ template isBitFlagEnum(E) enum A { None, - A = 1<<0, - B = 1<<1, - C = 1<<2, - D = 1<<3, + A = 1 << 0, + B = 1 << 1, + C = 1 << 2, + D = 1 << 3, } static assert(isBitFlagEnum!A); @@ -7107,8 +7107,8 @@ template isBitFlagEnum(E) enum C: double { - A = 1<<0, - B = 1<<1 + A = 1 << 0, + B = 1 << 1 } static assert(!isBitFlagEnum!C); @@ -7126,8 +7126,8 @@ the OR combination, which can produce surprising effects like this: ---- enum E { - A = 1<<0, - B = 1<<1 + A = 1 << 0, + B = 1 << 1 } E e = E.A | E.B; // will throw SwitchError @@ -7274,9 +7274,9 @@ public: enum Enum { None, - A = 1<<0, - B = 1<<1, - C = 1<<2 + A = 1 << 0, + B = 1 << 1, + C = 1 << 2 } BitFlags!Enum flags1; assert(!(flags1 & (Enum.A | Enum.B | Enum.C))); diff --git a/std/uni.d b/std/uni.d index 45348778a93..71f78b07779 100644 --- a/std/uni.d +++ b/std/uni.d @@ -774,12 +774,12 @@ size_t replicateBits(size_t times, size_t bits)(size_t val) @safe pure nothrow @ static if (times == size_t.sizeof*8) return val ? size_t.max : 0; else - return val ? (1<= max) { if (pred(range[idx+m], needle)) @@ -3073,7 +3073,7 @@ private: version(LittleEndian) *dest = val | (*dest & 0xFF00_0000); else - *dest = (val<<8) | (*dest & 0xFF); + *dest = (val << 8) | (*dest & 0xFF); } @system private uint read24(scope const ubyte* ptr, size_t idx) pure nothrow @nogc @@ -3782,7 +3782,7 @@ private: void addValue(size_t level, T)(T val, size_t numVals) { alias j = idx!level; - enum pageSize = 1<> from) & ((1<<(to-from))-1); } @@ -5699,15 +5699,15 @@ if (is(Char1 : dchar) && is(Char2 : dchar)) // not optimized as usually done 1 time (and not public interface) if (val < 128) arr ~= cast(ubyte) val; - else if (val < (1<<13)) + else if (val < (1 << 13)) { - arr ~= (0b1_00<<5) | cast(ubyte)(val>>8); + arr ~= (0b1_00 << 5) | cast(ubyte)(val>>8); arr ~= val & 0xFF; } else { - assert(val < (1<<21)); - arr ~= (0b1_01<<5) | cast(ubyte)(val>>16); + assert(val < (1 << 21)); + arr ~= (0b1_01 << 5) | cast(ubyte)(val>>16); arr ~= (val >> 8) & 0xFF; arr ~= val & 0xFF; } @@ -5723,7 +5723,7 @@ if (is(Char1 : dchar) && is(Char2 : dchar)) uint val = (first & 0x1F); enforce(idx + extra <= arr.length, "bad code point interval encoding"); foreach (j; 0 .. extra) - val = (val<<8) | arr[idx+j]; + val = (val << 8) | arr[idx+j]; idx += extra; return val; } @@ -5753,20 +5753,20 @@ if (isInputRange!Range && isIntegralPair!(ElementType!Range)) import std.algorithm.comparison : equal; import std.typecons : tuple; - auto run = [tuple(80, 127), tuple(128, (1<<10)+128)]; - ubyte[] enc = [cast(ubyte) 80, 47, 1, (0b1_00<<5) | (1<<2), 0]; + auto run = [tuple(80, 127), tuple(128, (1 << 10)+128)]; + ubyte[] enc = [cast(ubyte) 80, 47, 1, (0b1_00 << 5) | (1 << 2), 0]; assert(compressIntervals(run) == enc); - auto run2 = [tuple(0, (1<<20)+512+1), tuple((1<<20)+512+4, lastDchar+1)]; - ubyte[] enc2 = [cast(ubyte) 0, (0b1_01<<5) | (1<<4), 2, 1, 3]; // odd length-ed + auto run2 = [tuple(0, (1 << 20)+512+1), tuple((1 << 20)+512+4, lastDchar+1)]; + ubyte[] enc2 = [cast(ubyte) 0, (0b1_01 << 5) | (1 << 4), 2, 1, 3]; // odd length-ed assert(compressIntervals(run2) == enc2); size_t idx = 0; assert(decompressFrom(enc, idx) == 80); assert(decompressFrom(enc, idx) == 47); assert(decompressFrom(enc, idx) == 1); - assert(decompressFrom(enc, idx) == (1<<10)); + assert(decompressFrom(enc, idx) == (1 << 10)); idx = 0; assert(decompressFrom(enc2, idx) == 0); - assert(decompressFrom(enc2, idx) == (1<<20)+512+1); + assert(decompressFrom(enc2, idx) == (1 << 20)+512+1); assert(equal(decompressIntervals(compressIntervals(run)), run)); assert(equal(decompressIntervals(compressIntervals(run2)), run2)); } From 203755d296fb6bdabc0070ae6cd17b2a5b1ae4a5 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 23 Feb 2017 00:51:09 +0100 Subject: [PATCH 6/7] Automatically add spaces to binary operators (>>) command: sed -E "s/([[:alnum:]]) >> ([[:alnum:]])/\1 >> \2/g" -i **/*.d sed -E "s/([[:alnum:]])>> ([[:alnum:]])/\1 >> \2/g" -i **/*.d sed -E "s/([[:alnum:]]) >>([[:alnum:]])/\1 >> \2/g" -i **/*.d --- std/algorithm/sorting.d | 2 +- std/internal/math/biguintcore.d | 10 +++++----- std/internal/math/biguintnoasm.d | 2 +- std/mmfile.d | 4 ++-- std/regex/internal/ir.d | 2 +- std/uni.d | 22 +++++++++++----------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index 7d16bbbe732..20d30c9280e 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -2327,7 +2327,7 @@ private template TimSortImpl(alias pred, R) size_t minRunLength()(size_t n) { immutable shift = bsr(n)-5; - auto result = (n>>shift) + !!(n & ~((1 << shift)-1)); + auto result = (n >> shift) + !!(n & ~((1 << shift)-1)); return result; } diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 24b5fb0b5ad..44e937f266e 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -461,7 +461,7 @@ public: { assert(y>0); uint bits = cast(uint) y & BIGDIGITSHIFTMASK; - if ((y>>LG2BIGDIGITBITS) >= data.length) return BigUint(ZERO); + if ((y >> LG2BIGDIGITBITS) >= data.length) return BigUint(ZERO); uint words = cast(uint)(y >> LG2BIGDIGITBITS); if (bits == 0) { @@ -485,7 +485,7 @@ public: assert(y>0); if (isZero()) return this; uint bits = cast(uint) y & BIGDIGITSHIFTMASK; - assert((y>>LG2BIGDIGITBITS) < cast(ulong)(uint.max)); + assert((y >> LG2BIGDIGITBITS) < cast(ulong)(uint.max)); uint words = cast(uint)(y >> LG2BIGDIGITBITS); BigDigit [] result = new BigDigit[data.length + words+1]; result[0 .. words] = 0; @@ -538,7 +538,7 @@ public: } if (d > uint.max) { - r.data = [cast(uint)(d & 0xFFFF_FFFF), cast(uint)(d>>32)]; + r.data = [cast(uint)(d & 0xFFFF_FFFF), cast(uint)(d >> 32)]; } else { @@ -1761,7 +1761,7 @@ body else hi = 2; uint c = multibyteIncrementAssign!('+')(data[0 .. hi], cast(uint)(y&0xFFFF_FFFF)); - c += multibyteIncrementAssign!('+')(data[1 .. hi], cast(uint)(y>>32)); + c += multibyteIncrementAssign!('+')(data[1 .. hi], cast(uint)(y >> 32)); if (c != 0) { data[hi]=c; @@ -1815,7 +1815,7 @@ body uint c = multibyteIncrementAssign!('+')(data[0 .. hi], cast(uint)(y&0xFFFF_FFFF)); if (y > 0xFFFF_FFFFL) { - c += multibyteIncrementAssign!('+')(data[1 .. hi], cast(uint)(y>>32)); + c += multibyteIncrementAssign!('+')(data[1 .. hi], cast(uint)(y >> 32)); } if (c != 0) { diff --git a/std/internal/math/biguintnoasm.d b/std/internal/math/biguintnoasm.d index eb8f34fbb4e..e1c57c627c4 100644 --- a/std/internal/math/biguintnoasm.d +++ b/std/internal/math/biguintnoasm.d @@ -235,7 +235,7 @@ uint multibyteMulAdd(char op)(uint [] dest, const(uint)[] src, c += cast(ulong) multiplier * src[i]; ulong t = cast(ulong) dest[i] - cast(uint) c; dest[i] = cast(uint) t; - c = cast(uint)((c>>32) - (t>>32)); + c = cast(uint)((c >> 32) - (t >> 32)); } } return cast(uint) c; diff --git a/std/mmfile.d b/std/mmfile.d index 12b031f77f5..f07df348aa4 100644 --- a/std/mmfile.d +++ b/std/mmfile.d @@ -244,7 +244,7 @@ class MmFile } } - int hi = cast(int)(size>>32); + int hi = cast(int)(size >> 32); hFileMap = CreateFileMappingW(hFile, null, flProtect, hi, cast(uint) size, null); wenforce(hFileMap, "CreateFileMapping"); @@ -523,7 +523,7 @@ class MmFile len = cast(size_t)(size-start); version(Windows) { - uint hi = cast(uint)(start>>32); + uint hi = cast(uint)(start >> 32); p = MapViewOfFileEx(hFileMap, dwDesiredAccess, hi, cast(uint) start, len, address); wenforce(p, "MapViewOfFileEx"); } diff --git a/std/regex/internal/ir.d b/std/regex/internal/ir.d index 749be501d43..755eca176c7 100644 --- a/std/regex/internal/ir.d +++ b/std/regex/internal/ir.d @@ -277,7 +277,7 @@ struct Bytecode //ditto //0-arg template due to @@@BUG@@@ 10985 - @property IR code()() const { return cast(IR)(raw>>24); } + @property IR code()() const { return cast(IR)(raw >> 24); } //ditto @property bool hotspot() const { return hasMerge(code); } diff --git a/std/uni.d b/std/uni.d index 71f78b07779..de05ca70a39 100644 --- a/std/uni.d +++ b/std/uni.d @@ -3045,13 +3045,13 @@ private: version(LittleEndian) { ptr[idx] = val & 0xFF; - ptr[idx+1] = (val>>8) & 0xFF; - ptr[idx+2] = (val>>16) & 0xFF; + ptr[idx+1] = (val >> 8) & 0xFF; + ptr[idx+2] = (val >> 16) & 0xFF; } else { - ptr[idx] = (val>>16) & 0xFF; - ptr[idx+1] = (val>>8) & 0xFF; + ptr[idx] = (val >> 16) & 0xFF; + ptr[idx+1] = (val >> 8) & 0xFF; ptr[idx+2] = val & 0xFF; } } @@ -4931,7 +4931,7 @@ template Utf16Matcher() assert(ch <= 0xF_FFFF); wchar[2] ret; //do not put surrogate bits, they are sliced off - ret[0] = cast(wchar)(ch>>10); + ret[0] = cast(wchar)(ch >> 10); ret[1] = (ch & 0xFFF); return ret; } @@ -5701,13 +5701,13 @@ if (is(Char1 : dchar) && is(Char2 : dchar)) arr ~= cast(ubyte) val; else if (val < (1 << 13)) { - arr ~= (0b1_00 << 5) | cast(ubyte)(val>>8); + arr ~= (0b1_00 << 5) | cast(ubyte)(val >> 8); arr ~= val & 0xFF; } else { assert(val < (1 << 21)); - arr ~= (0b1_01 << 5) | cast(ubyte)(val>>16); + arr ~= (0b1_01 << 5) | cast(ubyte)(val >> 16); arr ~= (val >> 8) & 0xFF; arr ~= val & 0xFF; } @@ -5719,7 +5719,7 @@ if (is(Char1 : dchar) && is(Char2 : dchar)) immutable first = arr[idx++]; if (!(first & 0x80)) // no top bit -> [0 .. 127] return first; - immutable extra = ((first>>5) & 1) + 1; // [1, 2] + immutable extra = ((first >> 5) & 1) + 1; // [1, 2] uint val = (first & 0x1F); enforce(idx + extra <= arr.length, "bad code point interval encoding"); foreach (j; 0 .. extra) @@ -8134,7 +8134,7 @@ if (isSomeString!S) { auto val = tableFn(idx); // unpack length + codepoint - immutable uint len = val>>24; + immutable uint len = val >> 24; result.put(cast(dchar)(val & 0xFF_FFFF)); foreach (j; idx+1 .. idx+len) result.put(tableFn(j)); @@ -8736,7 +8736,7 @@ private template toCaseLength(alias indexFn, uint maxIdx, alias tableFn) codeLen += startIdx - lastNonTrivial; lastNonTrivial = curIdx; immutable val = tableFn(caseIndex); - immutable len = val>>24; + immutable len = val >> 24; immutable dchar cased = val & 0xFF_FFFF; codeLen += codeLength!C(cased); foreach (j; caseIndex+1 .. caseIndex+len) @@ -8796,7 +8796,7 @@ private template toCaseInPlaceAlloc(alias indexFn, uint maxIdx, alias tableFn) destIdx += toCopy; auto val = tableFn(caseIndex); // unpack length + codepoint - immutable uint len = val>>24; + immutable uint len = val >> 24; destIdx = encodeTo(ns, destIdx, cast(dchar)(val & 0xFF_FFFF)); foreach (j; caseIndex+1 .. caseIndex+len) destIdx = encodeTo(ns, destIdx, tableFn(j)); From a1bb0515fc16ff9f67b78fa60ae3326641f76edf Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 23 Feb 2017 00:54:17 +0100 Subject: [PATCH 7/7] Automatically add spaces to binary operators (>=) command: sed -E "s/([[:alnum:]]) >= ([[:alnum:]])/\1 >= \2/g" -i **/*.d sed -E "s/([[:alnum:]])>= ([[:alnum:]])/\1 >= \2/g" -i **/*.d sed -E "s/([[:alnum:]]) >=([[:alnum:]])/\1 >= \2/g" -i **/*.d --- std/internal/math/biguintcore.d | 14 +++++++------- std/internal/math/biguintnoasm.d | 2 +- std/internal/math/errorfunction.d | 4 ++-- std/internal/math/gammafunction.d | 4 ++-- std/math.d | 6 +++--- std/mathspecial.d | 2 +- std/numeric.d | 4 ++-- std/typecons.d | 8 ++++---- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 44e937f266e..3dc4cea3c0d 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -1567,7 +1567,7 @@ char [] biguintToHex(char [] buff, const BigDigit [] data, char separator=0, LetterCase letterCase = LetterCase.upper) pure nothrow @safe { int x=0; - for (ptrdiff_t i=data.length - 1; i>=0; --i) + for (ptrdiff_t i=data.length - 1; i >= 0; --i) { toHexZeroPadded(buff[x .. x+8], data[i], letterCase); x+=8; @@ -1772,10 +1772,10 @@ body } } // Now set y = all remaining digits. - if (lo>=18) + if (lo >= 18) { } - else if (lo>=9) + else if (lo >= 9) { for (int k=9; k= y.length); auto k = x.length-1; - while (x[k]==0 && k>=y.length) + while (x[k]==0 && k >= y.length) --k; - if (k>=y.length) + if (k >= y.length) return false; while (k>0 && x[k]==y[k]) --k; @@ -2286,7 +2286,7 @@ void toHexZeroPadded(char[] output, uint value, ptrdiff_t x = output.length - 1; static immutable string upperHexDigits = "0123456789ABCDEF"; static immutable string lowerHexDigits = "0123456789abcdef"; - for ( ; x>=0; --x) + for ( ; x >= 0; --x) { if (letterCase == LetterCase.upper) { @@ -2440,7 +2440,7 @@ body } // rem -= quot * v[0 .. k]. -// If would make rem negative, decrease quot until rem is >=0. +// If would make rem negative, decrease quot until rem is >= 0. // Needs (quot.length * k) scratch space to store the result of the multiply. void adjustRemainder(BigDigit[] quot, BigDigit[] rem, const(BigDigit)[] v, ptrdiff_t k, diff --git a/std/internal/math/biguintnoasm.d b/std/internal/math/biguintnoasm.d index e1c57c627c4..ff06808d8f6 100644 --- a/std/internal/math/biguintnoasm.d +++ b/std/internal/math/biguintnoasm.d @@ -286,7 +286,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); diff --git a/std/internal/math/errorfunction.d b/std/internal/math/errorfunction.d index 4ecc27b89b3..f2e60d96e32 100644 --- a/std/internal/math/errorfunction.d +++ b/std/internal/math/errorfunction.d @@ -365,7 +365,7 @@ assert(isIdentical(normalDistributionImpl(NaN(0x325)), NaN(0x325))); */ real normalDistributionInvImpl(real p) in { - assert(p>=0.0L && p <= 1.0L, "Domain error"); + assert(p >= 0.0L && p <= 1.0L, "Domain error"); } body { @@ -419,7 +419,7 @@ static immutable real[8] Q3 = 0x1.e05268dd3c07989ep-3, 0x1.239c6aff14afbf82p+1, 1.0 ]; - if (p <= 0.0L || p>=1.0L) + if (p <= 0.0L || p >= 1.0L) { if (p == 0.0L) return -real.infinity; diff --git a/std/internal/math/gammafunction.d b/std/internal/math/gammafunction.d index 66516662e6d..557f14ad10d 100644 --- a/std/internal/math/gammafunction.d +++ b/std/internal/math/gammafunction.d @@ -1427,7 +1427,7 @@ body { */ real gammaIncompleteComplInv(real a, real p) in { - assert(p>=0 && p <= 1); + assert(p >= 0 && p <= 1); assert(a>0); } body { @@ -1688,7 +1688,7 @@ done: for (int k=1; k<40; ++k) { real y=0; - for (int u=k; u>=1; --u) + for (int u=k; u >= 1; --u) { y += 1.0L/u; } diff --git a/std/math.d b/std/math.d index 2d286537a31..db8071632ff 100644 --- a/std/math.d +++ b/std/math.d @@ -514,7 +514,7 @@ if (is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) && static if (isFloatingPoint!(Num)) return fabs(x); else - return x>=0 ? x : -x; + return x >= 0 ? x : -x; } /// ditto @@ -2827,7 +2827,7 @@ if (isIntegral!T && isSigned!T) import std.traits : Unsigned; // Note: abs(x) can not be used because the return type is not Unsigned and // the return value would be wrong for x == int.min - Unsigned!T absx = x>=0 ? x : -x; + Unsigned!T absx = x >= 0 ? x : -x; return ilogb(absx); } @@ -6647,7 +6647,7 @@ body { // Runtime behaviour for contract violation: // If signs are opposite, or one is a NaN, return 0. - if (!((x>=0 && y>=0) || (x <= 0 && y <= 0))) return 0.0; + if (!((x >= 0 && y >= 0) || (x <= 0 && y <= 0))) return 0.0; // The implementation is simple: cast x and y to integers, // average them (avoiding overflow), and cast the result back to a floating-point number. diff --git a/std/mathspecial.d b/std/mathspecial.d index 0e6fd6aeb8f..896b035c12b 100644 --- a/std/mathspecial.d +++ b/std/mathspecial.d @@ -351,7 +351,7 @@ real normalDistribution(real x) */ real normalDistributionInverse(real p) in { - assert(p>=0.0L && p <= 1.0L, "Domain error"); + assert(p >= 0.0L && p <= 1.0L, "Domain error"); } body { diff --git a/std/numeric.d b/std/numeric.d index 7306006ab29..4b9fc271688 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -588,7 +588,7 @@ public: { auto x = get!real; auto y = cast(real) b; - return (x>=y)-(x <= y); + return (x >= y)-(x <= y); } /// ditto @@ -2602,7 +2602,7 @@ T gcd(T)(T a, T b) { static if (T.min < 0) { - assert(a >= 0 && b >=0); + assert(a >= 0 && b >= 0); } while (b) { diff --git a/std/typecons.d b/std/typecons.d index 5aeda09bfb8..66c27aa6c78 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -2115,7 +2115,7 @@ string alignForSize(E...)(const char[][] names...) foreach (i, T; E) { auto a = T.alignof; - auto k = a>=64? 0 : a>=32? 1 : a>=16? 2 : a>=8? 3 : a>=4? 4 : a>=2? 5 : 6; + auto k = a >= 64? 0 : a >= 32? 1 : a >= 16? 2 : a >= 8? 3 : a >= 4? 4 : a >= 2? 5 : 6; declaration[k] ~= T.stringof ~ " " ~ names[i] ~ ";\n"; } @@ -6183,7 +6183,7 @@ mixin template Proxy(alias a) assert(!(ab)); - assert(!(a>=b)); + assert(!(a >= b)); } foreach (T1; AliasSeq!(MyFloatImpl, Typedef!float, Typedef!double, float, real, Typedef!int, int)) @@ -6203,14 +6203,14 @@ mixin template Proxy(alias a) assert(ab)); - assert(!(a>=b)); + assert(!(a >= b)); a = 4; assert(a == b); assert(!(ab)); - assert(a>=b); + assert(a >= b); } } }