Skip to content

Commit

Permalink
Automatically add spaces to binary operators (>=)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wilzbach committed Feb 22, 2017
1 parent 203755d commit a1bb051
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions std/internal/math/biguintcore.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<lo; ++k) y*=10;
y+=x;
Expand Down Expand Up @@ -1950,9 +1950,9 @@ bool less(const(BigDigit)[] x, const(BigDigit)[] y) pure nothrow
{
assert(x.length >= 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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion std/internal/math/biguintnoasm.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions std/internal/math/errorfunction.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions std/internal/math/gammafunction.d
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions std/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion std/mathspecial.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions std/numeric.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down Expand Up @@ -6183,7 +6183,7 @@ mixin template Proxy(alias a)
assert(!(a<b));
assert(!(a <= b));
assert(!(a>b));
assert(!(a>=b));
assert(!(a >= b));
}
foreach (T1; AliasSeq!(MyFloatImpl, Typedef!float, Typedef!double,
float, real, Typedef!int, int))
Expand All @@ -6203,14 +6203,14 @@ mixin template Proxy(alias a)
assert(a<b);
assert(a <= b);
assert(!(a>b));
assert(!(a>=b));
assert(!(a >= b));

a = 4;
assert(a == b);
assert(!(a<b));
assert(a <= b);
assert(!(a>b));
assert(a>=b);
assert(a >= b);
}
}
}
Expand Down

0 comments on commit a1bb051

Please sign in to comment.