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 ef7be4b commit 203755d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion std/algorithm/sorting.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions std/internal/math/biguintcore.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
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 @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions std/mmfile.d
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion std/regex/internal/ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down
22 changes: 11 additions & 11 deletions std/uni.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 203755d

Please sign in to comment.