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
This commit is contained in:
Sebastian Wilzbach 2017-02-23 00:44:37 +01:00
parent af42d8df3d
commit a2c6398332
24 changed files with 74 additions and 74 deletions

View file

@ -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

View file

@ -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]));

View file

@ -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

View file

@ -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

View file

@ -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
}
}

View file

@ -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
{

View file

@ -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.

View file

@ -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;

View file

@ -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);
}

View file

@ -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"));

View file

@ -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 .. $];

View file

@ -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;
}

View file

@ -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;

View file

@ -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<aa.length-1; ++i) assert(aa[i] == 0x8765_4321 * (i+3));
assert(r==0x33FF_7461);
assert(r == 0x33FF_7461);
}
// Set dest[2*i .. 2*i+1]+=src[i]*src[i]
@ -1193,7 +1193,7 @@ length_is_3:
// now EDX: EAX = c + x[$-3] * x[$-1]
add [EDI-1*4], EAX; // ECX:dest[$-4] += (EDX:EAX)
adc ECX, EDX; // ECX holds dest[$-3], it acts as carry for the last row
// do length==2
// do length == 2
mov EAX, [ESI - 4*2];
mul EAX, [ESI - 4*1];
add ECX, EAX;

View file

@ -293,7 +293,7 @@ real gamma(real x)
if (isNaN(x)) return x;
if (x == -x.infinity) return real.nan;
if ( fabs(x) > 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;

View file

@ -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)

View file

@ -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))
{

View file

@ -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]);
}
}

View file

@ -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))
{

View file

@ -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

View file

@ -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);
}
}

View file

@ -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));
}

View file

@ -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(!(a<b));
assert(!(a<=b));
assert(!(a>b));
@ -6206,7 +6206,7 @@ mixin template Proxy(alias a)
assert(!(a>=b));
a = 4;
assert(a==b);
assert(a == b);
assert(!(a<b));
assert(a<=b);
assert(!(a>b));

View file

@ -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
{