11 changes: 8 additions & 3 deletions std/concurrency.d
Original file line number Diff line number Diff line change
Expand Up @@ -1716,11 +1716,16 @@ void yield(T)(T value)
}


version (Win64) {
version (Win64)
{
// fibers are broken on Win64
} else version (Win32) {
}
else version (Win32)
{
// fibers are broken in Win32 under server 2012: bug 13821
} else unittest {
}
else unittest
{
import core.exception;
import std.exception;

Expand Down
3 changes: 2 additions & 1 deletion std/container/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,8 @@ unittest
}

// Test issue 11194
unittest {
unittest
{
static struct S {
int i = 1337;
void* p;
Expand Down
3 changes: 2 additions & 1 deletion std/container/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ Complexity: $(BIGOH n)
}
}

unittest {
unittest
{
TotalContainer!int test;
}
3 changes: 2 additions & 1 deletion std/container/rbtree.d
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,8 @@ pure unittest
assert(array(rt4[]) == ["hello"]);
}

unittest {
unittest
{
import std.conv : to;

auto rt1 = redBlackTree!string();
Expand Down
9 changes: 6 additions & 3 deletions std/cstream.d
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ class CFile : Stream {
}

// run a few tests
unittest {
unittest
{
import std.file : deleteme;
import std.internal.cstring : tempCString;

Expand Down Expand Up @@ -203,7 +204,8 @@ class CFile : Stream {
file.writeLine("That was blank");
file.position = 0;
char[][] lines;
foreach (char[] line; file) {
foreach (char[] line; file)
{
lines ~= line.dup;
}
assert( lines.length == 5 );
Expand All @@ -213,7 +215,8 @@ class CFile : Stream {
assert( lines[3] == "That was blank");
file.position = 0;
lines = new char[][5];
foreach (ulong n, char[] line; file) {
foreach (ulong n, char[] line; file)
{
lines[cast(size_t)(n-1)] = line.dup;
}
assert( lines[0] == "Testing stream.d:");
Expand Down
22 changes: 15 additions & 7 deletions std/csv.d
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ unittest
(str, ["b","a"], ',', '"');

auto ans2 = [["Hello","65"],["World","123"]];
foreach (record; records2) {
foreach (record; records2)
{
assert(equal(record, ans2.front));
ans2.popFront();
}
Expand All @@ -624,7 +625,8 @@ unittest
(str, ["a","b","c","d"], ',', '"');

ans2 = [["Joe","Carpenter"],["Fred","Fly"]];
foreach (record; records2) {
foreach (record; records2)
{
assert(equal(record, ans2.front));
ans2.popFront();
}
Expand Down Expand Up @@ -826,7 +828,8 @@ public:
* auto records = CsvReader!(int,Malformed.ignore,string,char,string[])
* (str, ';', '^');
*
* foreach (record; records) {
* foreach (record; records)
* {
* assert(equal(record, ans));
* }
* -------
Expand All @@ -850,7 +853,8 @@ public:
* (str, ["high","low"], ';', '^');
*
* int[] ans = [76,22];
* foreach (record; records) {
* foreach (record; records)
* {
* assert(equal(record, ans));
* }
* -------
Expand Down Expand Up @@ -1161,7 +1165,8 @@ public:
// to eliminate so many tokens. This calculates
// how many will be skipped to get to the next header column
size_t normalizer;
foreach (ref c; _popCount) {
foreach (ref c; _popCount)
{
static if (ErrorLevel == Malformed.ignore)
{
// If we are not throwing exceptions
Expand Down Expand Up @@ -1244,7 +1249,9 @@ public:
"previous length of %s.", _input.row,
_input.col, _input.rowLength));
return;
} else {
}
else
{
static if (ErrorLevel == Malformed.throwException)
if (_input.rowLength != 0)
if (_input.col > _input.rowLength)
Expand Down Expand Up @@ -1314,7 +1321,8 @@ public:
if (!_popCount.empty)
_popCount.popFront();

if (skipNum == size_t.max) {
if (skipNum == size_t.max)
{
while (!recordEnd())
prime(1);
_empty = true;
Expand Down
3 changes: 2 additions & 1 deletion std/datetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -30314,7 +30314,8 @@ private:
throw new DateTimeException(format("Both timezone files %s and %s do not exist.",
combinedFile, indexFile));

foreach (Unused; 0 .. indexEntries) {
foreach (Unused; 0 .. indexEntries)
{
string tzName = to!string(readVal!(char[])(tzFile, 40).ptr);
uint tzOffset = readVal!uint(tzFile);
readVal!(uint[])(tzFile, 2);
Expand Down
3 changes: 2 additions & 1 deletion std/experimental/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ if (Targets.length >= 1 && !allSatisfy!(isMutable, Targets))
alias implementsInterface = .implementsInterface!(Source, staticMap!(Unqual, Targets));
}

unittest {
unittest
{
interface Foo {
void foo();
}
Expand Down
3 changes: 2 additions & 1 deletion std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -4884,7 +4884,8 @@ private TypeInfo primitiveTypeInfo(Mangle m)
{
// BUG: should fix this in static this() to avoid double checked locking bug
__gshared TypeInfo[Mangle] dic;
if (!dic.length) {
if (!dic.length)
{
dic = [
Mangle.Tvoid : typeid(void),
Mangle.Tbool : typeid(bool),
Expand Down
6 changes: 4 additions & 2 deletions std/functional.d
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ private uint _ctfeMatchBinary(string fun, string name1, string name2)
return fun.length == 0;
}

unittest {
unittest
{

static assert(!_ctfeMatchBinary("sqrt(Ñ‘)", "Ñ‘", "b"));
static assert(!_ctfeMatchBinary("Ñ‘.sqrt", "Ñ‘", "b"));
Expand Down Expand Up @@ -1272,7 +1273,8 @@ auto toDelegate(F)(auto ref F fp) if (isCallable!(F))
}
}

unittest {
unittest
{
static int inc(ref uint num) {
num++;
return 8675309;
Expand Down
3 changes: 2 additions & 1 deletion std/internal/math/biguintcore.d
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,8 @@ T intpow(T)(T x, ulong n) pure nothrow @safe

default:
p = 1;
while (1){
while (1)
{
if (n & 1)
p *= x;
n >>= 1;
Expand Down
3 changes: 2 additions & 1 deletion std/internal/math/biguintnoasm.d
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ unittest
It is defined in this way to allow cache-efficient multiplication.
This function is equivalent to:
----
for (size_t i = 0; i< right.length; ++i) {
for (size_t i = 0; i< right.length; ++i)
{
dest[left.length + i] = multibyteMulAdd(dest[i..left.length+i],
left, right[i], 0);
}
Expand Down
48 changes: 33 additions & 15 deletions std/internal/math/biguintx86.d
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ nothrow:
(b) compiler bugs prevent the use of .ptr when a frame pointer is used.
*/

version(D_InlineAsm_X86) {
version(D_InlineAsm_X86)
{

private:

Expand All @@ -72,12 +73,15 @@ private:
string indexedLoopUnroll(int n, string s) pure @safe
{
string u;
for (int i = 0; i<n; ++i) {
for (int i = 0; i<n; ++i)
{
string nstr= (i>9 ? ""~ cast(char)('0'+i/10) : "") ~ cast(char)('0' + i%10);

int last = 0;
for (int j = 0; j<s.length; ++j) {
if (s[j]=='@') {
for (int j = 0; j<s.length; ++j)
{
if (s[j]=='@')
{
u ~= s[last..j] ~ nstr;
last = j+1;
}
Expand Down Expand Up @@ -203,7 +207,8 @@ unittest
assert(a[11]==0);
for (int i=0; i<10; ++i) if (i!=5) assert(a[i]==0);

for (int q=3; q<36;++q) {
for (int q=3; q<36;++q)
{
for (int i=0; i<a.length; ++i)
{
a[i]=b[i]=c[i]=0;
Expand Down Expand Up @@ -741,9 +746,12 @@ uint multibyteMulAdd(char op)(uint [] dest, const uint [] src, uint
// ESI = src

enum string OP = (op=='+')? "add" : "sub";
version(D_PIC) {
version(D_PIC)
{
enum { zero = 0 }
} else {
}
else
{
// use p2 (load unit) instead of the overworked p0 or p1 (ALU units)
// when initializing registers to zero.
__gshared int zero = 0;
Expand Down Expand Up @@ -804,7 +812,8 @@ unittest
It is defined in this way to allow cache-efficient multiplication.
This function is equivalent to:
----
for (int i = 0; i< right.length; ++i) {
for (int i = 0; i< right.length; ++i)
{
dest[left.length + i] = multibyteMulAdd(dest[i..left.length+i],
left, right[i], 0);
}
Expand All @@ -821,9 +830,12 @@ void multibyteMultiplyAccumulate(uint [] dest, const uint[] left,
// ESI = end of left. never changes
// [ESP] = M = right[i] = multiplier for this pass through the loop.
// right.length is changed into dest.ptr+dest.length
version(D_PIC) {
version(D_PIC)
{
enum { zero = 0 }
} else {
}
else
{
// use p2 (load unit) instead of the overworked p0 or p1 (ALU units)
// when initializing registers to zero.
__gshared int zero = 0;
Expand Down Expand Up @@ -1070,7 +1082,8 @@ unittest

void multibyteTriangleAccumulateD(uint[] dest, uint[] x) pure
{
for (int i = 0; i < x.length-3; ++i) {
for (int i = 0; i < x.length-3; ++i)
{
dest[i+x.length] = multibyteMulAdd!('+')(
dest[i+i+1 .. i+x.length], x[i+1..$], x[i], 0);
}
Expand Down Expand Up @@ -1101,9 +1114,12 @@ void multibyteTriangleAccumulateAsm(uint[] dest, const uint[] src) pure
// ESI = end of src. never changes
// [ESP] = M = src[i] = multiplier for this pass through the loop.
// dest.length is changed into dest.ptr+dest.length
version(D_PIC) {
version(D_PIC)
{
enum { zero = 0 }
} else {
}
else
{
// use p2 (load unit) instead of the overworked p0 or p1 (ALU units)
// when initializing registers to zero.
__gshared int zero = 0;
Expand Down Expand Up @@ -1242,7 +1258,8 @@ unittest

void multibyteSquare(BigDigit[] result, const BigDigit [] x) pure
{
if (x.length < 4) {
if (x.length < 4)
{
// Special cases, not worth doing triangular.
result[x.length] = multibyteMul(result[0..x.length], x, x[0], 0);
multibyteMultiplyAccumulate(result[1..$], x, x[1..$]);
Expand All @@ -1259,7 +1276,8 @@ void multibyteSquare(BigDigit[] result, const BigDigit [] x) pure
multibyteAddDiagonalSquares(result, x);
}

version(BignumPerformanceTest) {
version(BignumPerformanceTest)
{
import core.stdc.stdio;
int clock() { asm { push EBX; xor EAX, EAX; cpuid; pop EBX; rdtsc; } }

Expand Down
48 changes: 33 additions & 15 deletions std/internal/math/errorfunction.d
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ real erfc(real a)

real z = -a * a;

if (z < -MAXLOG){
if (z < -MAXLOG)
{
// mtherr( "erfcl", UNDERFLOW );
if (a < 0) return 2.0;
else return 0.0;
Expand All @@ -141,7 +142,8 @@ real erfc(real a)
if (a < 0.0L)
y = 2.0L - y;

if (y == 0.0) {
if (y == 0.0)
{
// mtherr( "erfcl", UNDERFLOW );
if (a < 0) return 2.0;
else return 0.0;
Expand All @@ -161,9 +163,12 @@ real erfce(real x)
{
real y = 1.0/x;

if (x < 8.0) {
if (x < 8.0)
{
return rationalPoly( y, P, Q);
} else {
}
else
{
return y * rationalPoly(y*y, R, S);
}
}
Expand Down Expand Up @@ -204,7 +209,8 @@ real erf(real x)
return x * rationalPoly(z, T, U);
}

unittest {
unittest
{
// High resolution test points.
enum real erfc0_250 = 0.723663330078125 + 1.0279753638067014931732235184287934646022E-5;
enum real erfc0_375 = 0.5958709716796875 + 1.2118885490201676174914080878232469565953E-5;
Expand Down Expand Up @@ -283,7 +289,8 @@ real expx2(real x, int sign)
real u = m * m;
real u1 = 2 * m * f + f * f;

if (sign < 0) {
if (sign < 0)
{
u = -u;
u1 = -u1;
}
Expand Down Expand Up @@ -325,7 +332,8 @@ real normalDistributionImpl(real a)

if ( z < 1.0 )
return 0.5L + 0.5L * erf(x);
else {
else
{
real y = 0.5L * erfce(z);
/* Multiply by exp(-x^2 / 2) */
z = expx2(a, -1);
Expand All @@ -336,7 +344,8 @@ real normalDistributionImpl(real a)
}
}

unittest {
unittest
{
assert(fabs(normalDistributionImpl(1L) - (0.841344746068543))< 0.0000000000000005);
assert(isIdentical(normalDistributionImpl(NaN(0x325)), NaN(0x325)));
}
Expand Down Expand Up @@ -420,14 +429,16 @@ static immutable real[8] Q3 =
}
int code = 1;
real y = p;
if ( y > (1.0L - EXP_2) ) {
if ( y > (1.0L - EXP_2) )
{
y = 1.0L - y;
code = 0;
}

real x, z, y2, x0, x1;

if ( y > EXP_2 ) {
if ( y > EXP_2 )
{
y = y - 0.5L;
y2 = y * y;
x = y + y * (y2 * rationalPoly( y2, P0, Q0));
Expand All @@ -437,22 +448,29 @@ static immutable real[8] Q3 =
x = sqrt( -2.0L * log(y) );
x0 = x - log(x)/x;
z = 1.0L/x;
if ( x < 8.0L ) {
if ( x < 8.0L )
{
x1 = z * rationalPoly( z, P1, Q1);
} else if ( x < 32.0L ) {
}
else if ( x < 32.0L )
{
x1 = z * rationalPoly( z, P2, Q2);
} else {
}
else
{
x1 = z * rationalPoly( z, P3, Q3);
}
x = x0 - x1;
if ( code != 0 ) {
if ( code != 0 )
{
x = -x;
}
return x;
}


unittest {
unittest
{
// TODO: Use verified test points.
// The values below are from Excel 2003.
assert(fabs(normalDistributionInvImpl(0.001) - (-3.09023230616779))< 0.00000000000005);
Expand Down
358 changes: 245 additions & 113 deletions std/internal/math/gammafunction.d

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions std/internal/unicode_tables.d
Original file line number Diff line number Diff line change
Expand Up @@ -3958,7 +3958,8 @@ bool isHangT(dchar ch) @safe pure nothrow
return false;
}

static if (size_t.sizeof == 8) {
static if (size_t.sizeof == 8)
{
//1536 bytes
enum lowerCaseTrieEntries = TrieEntry!(bool, 8, 4, 9)([0x0, 0x20, 0x40],
[0x100, 0x80, 0x2000], [0x402030202020100, 0x206020202020205,
Expand Down Expand Up @@ -7430,7 +7431,8 @@ enum toTitleSimpleIndexTrieEntries = TrieEntry!(ushort, 8, 7, 6)([0x0, 0x20,

}

static if (size_t.sizeof == 4) {
static if (size_t.sizeof == 4)
{
//1536 bytes
enum lowerCaseTrieEntries = TrieEntry!(bool, 8, 4, 9)([0x0, 0x40, 0x80],
[0x100, 0x80, 0x2000], [0x2020100, 0x4020302, 0x2020205, 0x2060202,
Expand Down
30 changes: 20 additions & 10 deletions std/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ struct JSONValue
{
static assert(is(Key : string), "AA key must be string");
type_tag = JSON_TYPE.OBJECT;
static if (is(Value : JSONValue)) {
static if (is(Value : JSONValue))
{
store.object = arg;
}
else
Expand Down Expand Up @@ -848,7 +849,8 @@ if (isInputRange!T)
}

bool tryGetSpecialFloat(string str, out double val) {
switch (str) {
switch (str)
{
case JSONFloatLiteral.nan:
val = double.nan;
return true;
Expand Down Expand Up @@ -1233,25 +1235,32 @@ string toJSON(const ref JSONValue root, in bool pretty = false, in JSONOptions o

auto val = value.store.floating;

if (val.isNaN) {
if (options & JSONOptions.specialFloatLiterals) {
if (val.isNaN)
{
if (options & JSONOptions.specialFloatLiterals)
{
toString(JSONFloatLiteral.nan);
}
else {
else
{
throw new JSONException(
"Cannot encode NaN. Consider passing the specialFloatLiterals flag.");
}
}
else if (val.isInfinity) {
if (options & JSONOptions.specialFloatLiterals) {
else if (val.isInfinity)
{
if (options & JSONOptions.specialFloatLiterals)
{
toString((val > 0) ? JSONFloatLiteral.inf : JSONFloatLiteral.negativeInf);
}
else {
else
{
throw new JSONException(
"Cannot encode Infinity. Consider passing the specialFloatLiterals flag.");
}
}
else {
else
{
json.put(to!string(val));
}
break;
Expand Down Expand Up @@ -1570,7 +1579,8 @@ unittest
}`);
}

unittest {
unittest
{
auto json = `"hello\nworld"`;
const jv = parseJSON(json);
assert(jv.toString == json);
Expand Down
12 changes: 8 additions & 4 deletions std/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -3500,7 +3500,8 @@ real modf(real x, ref real i) @trusted nothrow @nogc
*/
real scalbn(real x, int n) @trusted nothrow @nogc
{
version(InlineAsm_X86_Any) {
version(InlineAsm_X86_Any)
{
// scalbnl is not supported on DMD-Windows, so use asm pure nothrow @nogc.
version (Win64)
{
Expand Down Expand Up @@ -4393,7 +4394,8 @@ private:
}
}
public:
version (IeeeFlagsSupport) {
version (IeeeFlagsSupport)
{

/// The result cannot be represented exactly, so rounding occurred.
/// (example: x = sin(0.1); )
Expand Down Expand Up @@ -6033,7 +6035,8 @@ typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @trusted pur
default:
v = x;
p = 1;
while (1){
while (1)
{
if (m & 1)
p *= v;
m >>= 1;
Expand Down Expand Up @@ -6722,7 +6725,8 @@ body
assert(poly(x, pp) == y);
}

unittest {
unittest
{
static assert(poly(3.0, [1.0, 2.0, 3.0]) == 34);
}

Expand Down
12 changes: 8 additions & 4 deletions std/mathspecial.d
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ real sgnGamma(real x)
return real.nan;
}
long n = rndtol(x);
if (x == n) {
if (x == n)
{
return x == 0 ? copysign(1, x) : real.nan;
}
return n & 1 ? 1.0 : -1.0;
}

unittest {
unittest
{
assert(sgnGamma(5.0) == 1.0);
assert(isNaN(sgnGamma(-3.0)));
assert(sgnGamma(-0.1) == -1.0);
Expand All @@ -151,12 +153,14 @@ unittest {
*/
real beta(real x, real y)
{
if ((x+y)> MAXGAMMA) {
if ((x+y)> MAXGAMMA)
{
return exp(logGamma(x) + logGamma(y) - logGamma(x+y));
} else return gamma(x) * gamma(y) / gamma(x+y);
}

unittest {
unittest
{
assert(isIdentical(beta(NaN(0xABC), 4), NaN(0xABC)));
assert(isIdentical(beta(2, NaN(0xABC)), NaN(0xABC)));
}
Expand Down
51 changes: 36 additions & 15 deletions std/mmfile.d
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ class MmFile
size_t initial_map = (window && 2*window<size)
? 2*window : cast(size_t)size;
auto p = mmap(address, initial_map, prot, flags, fd, 0);
if (p == MAP_FAILED) {
if (p == MAP_FAILED)
{
errnoEnforce(false, "Could not map file into memory");
}
data = p[0 .. initial_map];
Expand Down Expand Up @@ -501,9 +502,12 @@ class MmFile
private void unmap()
{
debug (MMFILE) printf("MmFile.unmap()\n");
version(Windows) {
version(Windows)
{
wenforce(!data.ptr || UnmapViewOfFile(data.ptr) != FALSE, "UnmapViewOfFile");
} else {
}
else
{
errnoEnforce(!data.ptr || munmap(cast(void*)data, data.length) == 0,
"munmap failed");
}
Expand All @@ -517,11 +521,14 @@ class MmFile
void* p;
if (start+len > size)
len = cast(size_t)(size-start);
version(Windows) {
version(Windows)
{
uint hi = cast(uint)(start>>32);
p = MapViewOfFileEx(hFileMap, dwDesiredAccess, hi, cast(uint)start, len, address);
wenforce(p, "MapViewOfFileEx");
} else {
}
else
{
p = mmap(address, len, prot, flags, fd, cast(off_t)start);
errnoEnforce(p != MAP_FAILED);
}
Expand All @@ -533,11 +540,15 @@ class MmFile
private void ensureMapped(ulong i)
{
debug (MMFILE) printf("MmFile.ensureMapped(%lld)\n", i);
if (!mapped(i)) {
if (!mapped(i))
{
unmap();
if (window == 0) {
if (window == 0)
{
map(0,cast(size_t)size);
} else {
}
else
{
ulong block = i/window;
if (block == 0)
map(0,2*window);
Expand All @@ -551,16 +562,23 @@ class MmFile
private void ensureMapped(ulong i, ulong j)
{
debug (MMFILE) printf("MmFile.ensureMapped(%lld, %lld)\n", i, j);
if (!mapped(i) || !mapped(j-1)) {
if (!mapped(i) || !mapped(j-1))
{
unmap();
if (window == 0) {
if (window == 0)
{
map(0,cast(size_t)size);
} else {
}
else
{
ulong iblock = i/window;
ulong jblock = (j-1)/window;
if (iblock == 0) {
if (iblock == 0)
{
map(0,cast(size_t)(window*(jblock+2)));
} else {
}
else
{
map(window*(iblock-1),cast(size_t)(window*(jblock-iblock+3)));
}
}
Expand Down Expand Up @@ -619,13 +637,16 @@ unittest

const size_t K = 1024;
size_t win = 64*K; // assume the page size is 64K
version(Windows) {
version(Windows)
{
/+ these aren't defined in core.sys.windows.windows so let's use default
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
win = sysinfo.dwAllocationGranularity;
+/
} else version (linux) {
}
else version (linux)
{
// getpagesize() is not defined in the unix D headers so use the guess
}
string test_file = std.file.deleteme ~ "-testing.txt";
Expand Down
3 changes: 2 additions & 1 deletion std/net/curl.d
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,8 @@ private auto _basicHTTP(T)(const(char)[] url, const(void)[] sendData, HTTP clien
client.onReceiveHeader = (in char[] key,
in char[] value)
{
if (key == "content-length") {
if (key == "content-length")
{
import std.conv : to;
content.reserve(value.to!size_t);
}
Expand Down
12 changes: 8 additions & 4 deletions std/parallelism.d
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,8 @@ private:
tail = task;
tail.prev = null;
}
else {
else
{
assert(tail);
task.prev = tail;
tail.next = task;
Expand Down Expand Up @@ -2740,7 +2741,8 @@ public:
{
auto filesHandles = new File[taskPool.size + 1];
scope(exit) {
foreach (ref handle; fileHandles) {
foreach (ref handle; fileHandles)
{
handle.close();
}
}
Expand Down Expand Up @@ -2825,7 +2827,8 @@ public:
{
return num;
}
else {
else
{
return ((num / cacheLineSize) + 1) * cacheLineSize;
}
}
Expand Down Expand Up @@ -3299,7 +3302,8 @@ Example:
// default TaskPool instance.
auto logs = new double[1_000_000];

foreach (i, ref elem; parallel(logs)) {
foreach (i, ref elem; parallel(logs))
{
elem = log(i + 1.0);
}
---
Expand Down
113 changes: 80 additions & 33 deletions std/range/interfaces.d
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ interface RandomAccessFinite(E) : BidirectionalRange!(E) {

// Can't support slicing until issues with requiring slicing for all
// finite random access ranges are fully resolved.
version(none) {
version(none)
{
///
RandomAccessFinite!E opSlice(size_t, size_t);
}
Expand Down Expand Up @@ -274,33 +275,56 @@ class OutputRangeObject(R, E...) : staticMap!(OutputRange, E) {


/**Returns the interface type that best matches $(D R).*/
template MostDerivedInputRange(R) if (isInputRange!(Unqual!R)) {
template MostDerivedInputRange(R)
if (isInputRange!(Unqual!R))
{
private alias E = ElementType!R;

static if (isRandomAccessRange!R) {
static if (isInfinite!R) {
static if (isRandomAccessRange!R)
{
static if (isInfinite!R)
{
alias MostDerivedInputRange = RandomAccessInfinite!E;
} else static if (hasAssignableElements!R) {
}
else static if (hasAssignableElements!R)
{
alias MostDerivedInputRange = RandomFiniteAssignable!E;
} else {
}
else
{
alias MostDerivedInputRange = RandomAccessFinite!E;
}
} else static if (isBidirectionalRange!R) {
static if (hasAssignableElements!R) {
}
else static if (isBidirectionalRange!R)
{
static if (hasAssignableElements!R)
{
alias MostDerivedInputRange = BidirectionalAssignable!E;
} else {
}
else
{
alias MostDerivedInputRange = BidirectionalRange!E;
}
} else static if (isForwardRange!R) {
static if (hasAssignableElements!R) {
}
else static if (isForwardRange!R)
{
static if (hasAssignableElements!R)
{
alias MostDerivedInputRange = ForwardAssignable!E;
} else {
}
else
{
alias MostDerivedInputRange = ForwardRange!E;
}
} else {
static if (hasAssignableElements!R) {
}
else
{
static if (hasAssignableElements!R)
{
alias MostDerivedInputRange = InputAssignable!E;
} else {
}
else
{
alias MostDerivedInputRange = InputRange!E;
}
}
Expand All @@ -310,12 +334,19 @@ template MostDerivedInputRange(R) if (isInputRange!(Unqual!R)) {
* all relevant range primitives in virtual functions. If $(D R) is already
* derived from the $(D InputRange) interface, aliases itself away.
*/
template InputRangeObject(R) if (isInputRange!(Unqual!R)) {
static if (is(R : InputRange!(ElementType!R))) {
template InputRangeObject(R)
if (isInputRange!(Unqual!R))
{
static if (is(R : InputRange!(ElementType!R)))
{
alias InputRangeObject = R;
} else static if (!is(Unqual!R == R)) {
}
else static if (!is(Unqual!R == R))
{
alias InputRangeObject = InputRangeObject!(Unqual!R);
} else {
}
else
{

///
class InputRangeObject : MostDerivedInputRange!(R) {
Expand All @@ -335,19 +366,22 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) {
void popFront() { _range.popFront(); }
@property bool empty() { return _range.empty; }

static if (isForwardRange!R) {
static if (isForwardRange!R)
{
@property typeof(this) save() {
return new typeof(this)(_range.save);
}
}

static if (hasAssignableElements!R) {
static if (hasAssignableElements!R)
{
@property void front(E newVal) {
_range.front = newVal;
}
}

static if (isBidirectionalRange!R) {
static if (isBidirectionalRange!R)
{
@property E back() { return _range.back; }

E moveBack() {
Expand All @@ -356,14 +390,16 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) {

void popBack() { return _range.popBack(); }

static if (hasAssignableElements!R) {
static if (hasAssignableElements!R)
{
@property void back(E newVal) {
_range.back = newVal;
}
}
}

static if (isRandomAccessRange!R) {
static if (isRandomAccessRange!R)
{
E opIndex(size_t index) {
return _range[index];
}
Expand All @@ -372,13 +408,15 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) {
return _range.moveAt(index);
}

static if (hasAssignableElements!R) {
static if (hasAssignableElements!R)
{
void opIndexAssign(E val, size_t index) {
_range[index] = val;
}
}

static if (!isInfinite!R) {
static if (!isInfinite!R)
{
@property size_t length() {
return _range.length;
}
Expand All @@ -388,7 +426,8 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) {
// Can't support slicing until all the issues with
// requiring slicing support for finite random access
// ranges are resolved.
version(none) {
version(none)
{
typeof(this) opSlice(size_t lower, size_t upper) {
return new typeof(this)(_range[lower..upper]);
}
Expand All @@ -401,7 +440,8 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) {
int opApply(int delegate(E) dg) {
int res;

for (auto r = _range; !r.empty; r.popFront()) {
for (auto r = _range; !r.empty; r.popFront())
{
res = dg(r.front);
if (res) break;
}
Expand All @@ -413,7 +453,8 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) {
int res;

size_t i = 0;
for (auto r = _range; !r.empty; r.popFront()) {
for (auto r = _range; !r.empty; r.popFront())
{
res = dg(i, r.front);
if (res) break;
i++;
Expand All @@ -428,10 +469,15 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) {
/**Convenience function for creating an $(D InputRangeObject) of the proper type.
* See $(LREF InputRange) for an example.
*/
InputRangeObject!R inputRangeObject(R)(R range) if (isInputRange!R) {
static if (is(R : InputRange!(ElementType!R))) {
InputRangeObject!R inputRangeObject(R)(R range)
if (isInputRange!R)
{
static if (is(R : InputRange!(ElementType!R)))
{
return range;
} else {
}
else
{
return new InputRangeObject!R(range);
}
}
Expand Down Expand Up @@ -483,7 +529,8 @@ unittest

assert(inputRangeObject(arrWrapped) is arrWrapped);

foreach (DummyType; AllDummyRanges) {
foreach (DummyType; AllDummyRanges)
{
auto d = DummyType.init;
static assert(propagatesRangeType!(DummyType,
typeof(inputRangeObject(d))));
Expand Down
92 changes: 62 additions & 30 deletions std/range/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,14 @@ if (isBidirectionalRange!(Unqual!Range))
{
import std.internal.test.dummyrange;

foreach (DummyType; AllDummyRanges) {
static if (!isBidirectionalRange!DummyType) {
foreach (DummyType; AllDummyRanges)
{
static if (!isBidirectionalRange!DummyType)
{
static assert(!__traits(compiles, Retro!DummyType));
} else {
}
else
{
DummyType dummyRange;
dummyRange.reinit();

Expand All @@ -363,11 +367,13 @@ if (isBidirectionalRange!(Unqual!Range))
assert(myRetro.moveFront() == 10);
assert(myRetro.moveBack() == 1);

static if (isRandomAccessRange!DummyType && hasLength!DummyType) {
static if (isRandomAccessRange!DummyType && hasLength!DummyType)
{
assert(myRetro[0] == myRetro.front);
assert(myRetro.moveAt(2) == 8);

static if (DummyType.r == ReturnBy.Reference) {
static if (DummyType.r == ReturnBy.Reference)
{
{
myRetro[9]++;
scope(exit) myRetro[9]--;
Expand Down Expand Up @@ -689,31 +695,36 @@ debug unittest
// Check for infiniteness propagation.
static assert(isInfinite!(typeof(stride(repeat(1), 3))));

foreach (DummyType; AllDummyRanges) {
foreach (DummyType; AllDummyRanges)
{
DummyType dummyRange;
dummyRange.reinit();

auto myStride = stride(dummyRange, 4);

// Should fail if no length and bidirectional b/c there's no way
// to know how much slack we have.
static if (hasLength!DummyType || !isBidirectionalRange!DummyType) {
static if (hasLength!DummyType || !isBidirectionalRange!DummyType)
{
static assert(propagatesRangeType!(typeof(myStride), DummyType));
}
assert(myStride.front == 1);
assert(myStride.moveFront() == 1);
assert(equal(myStride, [1, 5, 9]));

static if (hasLength!DummyType) {
static if (hasLength!DummyType)
{
assert(myStride.length == 3);
}

static if (isBidirectionalRange!DummyType && hasLength!DummyType) {
static if (isBidirectionalRange!DummyType && hasLength!DummyType)
{
assert(myStride.back == 9);
assert(myStride.moveBack() == 9);
}

static if (isRandomAccessRange!DummyType && hasLength!DummyType) {
static if (isRandomAccessRange!DummyType && hasLength!DummyType)
{
assert(myStride[0] == 1);
assert(myStride[1] == 5);
assert(myStride.moveAt(1) == 5);
Expand All @@ -722,7 +733,8 @@ debug unittest
static assert(hasSlicing!(typeof(myStride)));
}

static if (DummyType.r == ReturnBy.Reference) {
static if (DummyType.r == ReturnBy.Reference)
{
// Make sure reference is propagated.

{
Expand All @@ -736,7 +748,8 @@ debug unittest
assert(dummyRange.front == 4);
}

static if (isBidirectionalRange!DummyType && hasLength!DummyType) {
static if (isBidirectionalRange!DummyType && hasLength!DummyType)
{
{
myStride.back++;
scope(exit) myStride.back--;
Expand All @@ -748,7 +761,8 @@ debug unittest
assert(myStride.back == 111);
}

static if (isRandomAccessRange!DummyType) {
static if (isRandomAccessRange!DummyType)
{
{
myStride[1]++;
scope(exit) myStride[1]--;
Expand Down Expand Up @@ -1172,9 +1186,11 @@ unittest
// Check that chain at least instantiates and compiles with every possible
// pair of DummyRange types, in either order.

foreach (DummyType1; AllDummyRanges) {
foreach (DummyType1; AllDummyRanges)
{
DummyType1 dummy1;
foreach (DummyType2; AllDummyRanges) {
foreach (DummyType2; AllDummyRanges)
{
DummyType2 dummy2;
auto myChain = chain(dummy1, dummy2);

Expand All @@ -1183,7 +1199,8 @@ unittest
);

assert(myChain.front == 1);
foreach (i; 0..dummyLength) {
foreach (i; 0..dummyLength)
{
myChain.popFront();
}
assert(myChain.front == 1);
Expand Down Expand Up @@ -2030,18 +2047,22 @@ if (isInputRange!(Unqual!R) && (isInfinite!(Unqual!R) || !hasSlicing!(Unqual!R)
takeMyStrAgain = take(takeMyStr, 10);
assert(equal(takeMyStrAgain, "This is"));

foreach (DummyType; AllDummyRanges) {
foreach (DummyType; AllDummyRanges)
{
DummyType dummy;
auto t = take(dummy, 5);
alias T = typeof(t);

static if (isRandomAccessRange!DummyType) {
static if (isRandomAccessRange!DummyType)
{
static assert(isRandomAccessRange!T);
assert(t[4] == 5);

assert(moveAt(t, 1) == t[1]);
assert(t.back == moveBack(t));
} else static if (isForwardRange!DummyType) {
}
else static if (isForwardRange!DummyType)
{
static assert(isForwardRange!T);
}

Expand Down Expand Up @@ -4011,7 +4032,8 @@ unittest

alias FOO = Zip!(immutable(int)[], immutable(float)[]);

foreach (t; stuff.expand) {
foreach (t; stuff.expand)
{
auto arr1 = t[0];
auto arr2 = t[1];
auto zShortest = zip(arr1, arr2);
Expand Down Expand Up @@ -4052,15 +4074,18 @@ unittest
// make -fwin32.mak unittest makes the compiler completely run out of RAM.
// You need to test just this module.
/+
foreach (DummyType1; AllDummyRanges) {
foreach (DummyType1; AllDummyRanges)
{
DummyType1 d1;
foreach (DummyType2; AllDummyRanges) {
foreach (DummyType2; AllDummyRanges)
{
DummyType2 d2;
auto r = zip(d1, d2);
assert(equal(map!"a[0]"(r), [1,2,3,4,5,6,7,8,9,10]));
assert(equal(map!"a[1]"(r), [1,2,3,4,5,6,7,8,9,10]));

static if (isForwardRange!DummyType1 && isForwardRange!DummyType2) {
static if (isForwardRange!DummyType1 && isForwardRange!DummyType2)
{
static assert(isForwardRange!(typeof(r)));
}

Expand Down Expand Up @@ -4401,7 +4426,8 @@ unittest
uint[] res1;
float[] res2;

foreach (a, ref b; l) {
foreach (a, ref b; l)
{
res1 ~= a;
res2 ~= b;
}
Expand Down Expand Up @@ -4760,7 +4786,8 @@ auto sequence(alias fun, State...)(State args)

auto odds = Sequence!("a[0] + n * a[1]", Tuple!(int, int))(
tuple(1, 2));
for (int currentOdd = 1; currentOdd <= 21; currentOdd += 2) {
for (int currentOdd = 1; currentOdd <= 21; currentOdd += 2)
{
assert(odds.front == odds[0]);
assert(odds[0] == currentOdd);
odds.popFront();
Expand Down Expand Up @@ -5671,17 +5698,20 @@ FrontTransversal!(RangeOfRanges, opt) frontTransversal(

static assert(is(FrontTransversal!(immutable int[][])));

foreach (DummyType; AllDummyRanges) {
foreach (DummyType; AllDummyRanges)
{
auto dummies =
[DummyType.init, DummyType.init, DummyType.init, DummyType.init];

foreach (i, ref elem; dummies) {
foreach (i, ref elem; dummies)
{
// Just violate the DummyRange abstraction to get what I want.
elem.arr = elem.arr[i..$ - (3 - i)];
}

auto ft = frontTransversal!(TransverseOptions.assumeNotJagged)(dummies);
static if (isForwardRange!DummyType) {
static if (isForwardRange!DummyType)
{
static assert(isForwardRange!(typeof(ft)));
}

Expand All @@ -5699,7 +5729,8 @@ FrontTransversal!(RangeOfRanges, opt) frontTransversal(
// Test infiniteness propagation.
static assert(isInfinite!(typeof(frontTransversal(repeat("foo")))));

static if (DummyType.r == ReturnBy.Reference) {
static if (DummyType.r == ReturnBy.Reference)
{
{
ft.front++;
scope(exit) ft.front--;
Expand Down Expand Up @@ -6004,7 +6035,8 @@ Transversal!(RangeOfRanges, opt) transversal
// Test w/o ref return.
alias D = DummyRange!(ReturnBy.Value, Length.Yes, RangeType.Random);
auto drs = [D.init, D.init];
foreach (num; 0..10) {
foreach (num; 0..10)
{
auto t = transversal!(TransverseOptions.enforceNotJagged)(drs, num);
assert(t[0] == t[1]);
assert(t[1] == num + 1);
Expand Down
54 changes: 39 additions & 15 deletions std/range/primitives.d
Original file line number Diff line number Diff line change
Expand Up @@ -1854,14 +1854,21 @@ void popBackExactly(Range)(ref Range r, size_t n)
*/
ElementType!R moveFront(R)(R r)
{
static if (is(typeof(&r.moveFront))) {
static if (is(typeof(&r.moveFront)))
{
return r.moveFront();
} else static if (!hasElaborateCopyConstructor!(ElementType!R)) {
}
else static if (!hasElaborateCopyConstructor!(ElementType!R))
{
return r.front;
} else static if (is(typeof(&(r.front())) == ElementType!R*)) {
}
else static if (is(typeof(&(r.front())) == ElementType!R*))
{
import std.algorithm.mutation : move;
return move(r.front);
} else {
}
else
{
static assert(0,
"Cannot move front of a range with a postblit and an rvalue front.");
}
Expand Down Expand Up @@ -1905,14 +1912,21 @@ ElementType!R moveFront(R)(R r)
*/
ElementType!R moveBack(R)(R r)
{
static if (is(typeof(&r.moveBack))) {
static if (is(typeof(&r.moveBack)))
{
return r.moveBack();
} else static if (!hasElaborateCopyConstructor!(ElementType!R)) {
}
else static if (!hasElaborateCopyConstructor!(ElementType!R))
{
return r.back;
} else static if (is(typeof(&(r.back())) == ElementType!R*)) {
}
else static if (is(typeof(&(r.back())) == ElementType!R*))
{
import std.algorithm.mutation : move;
return move(r.back);
} else {
}
else
{
static assert(0,
"Cannot move back of a range with a postblit and an rvalue back.");
}
Expand Down Expand Up @@ -1944,14 +1958,21 @@ ElementType!R moveBack(R)(R r)
*/
ElementType!R moveAt(R)(R r, size_t i)
{
static if (is(typeof(&r.moveAt))) {
static if (is(typeof(&r.moveAt)))
{
return r.moveAt(i);
} else static if (!hasElaborateCopyConstructor!(ElementType!(R))) {
}
else static if (!hasElaborateCopyConstructor!(ElementType!(R)))
{
return r[i];
} else static if (is(typeof(&r[i]) == ElementType!R*)) {
}
else static if (is(typeof(&r[i]) == ElementType!R*))
{
import std.algorithm.mutation : move;
return move(r[i]);
} else {
}
else
{
static assert(0,
"Cannot move element of a range with a postblit and rvalue elements.");
}
Expand All @@ -1971,15 +1992,18 @@ ElementType!R moveAt(R)(R r, size_t i)
{
import std.internal.test.dummyrange;

foreach (DummyType; AllDummyRanges) {
foreach (DummyType; AllDummyRanges)
{
auto d = DummyType.init;
assert(moveFront(d) == 1);

static if (isBidirectionalRange!DummyType) {
static if (isBidirectionalRange!DummyType)
{
assert(moveBack(d) == 10);
}

static if (isRandomAccessRange!DummyType) {
static if (isRandomAccessRange!DummyType)
{
assert(moveAt(d, 2) == 3);
}
}
Expand Down
6 changes: 4 additions & 2 deletions std/regex/internal/ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ static assert (IRL!(IR.LookaheadStart) == 3);

//how many parameters follow the IR, should be optimized fixing some IR bits
int immediateParamsIR(IR i){
switch (i){
switch (i)
{
case IR.OrEnd,IR.InfiniteEnd,IR.InfiniteQEnd:
return 1; // merge table index
case IR.InfiniteBloomEnd:
Expand Down Expand Up @@ -740,7 +741,8 @@ struct BitTable {
uint[4] filter;

this(CodepointSet set){
foreach (iv; set.byInterval){
foreach (iv; set.byInterval)
{
foreach (v; iv.a..iv.b)
add(v);
}
Expand Down
3 changes: 2 additions & 1 deletion std/regex/internal/kickstart.d
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public:
ulong hash(uint[] tab)
{
ulong h = 0xcbf29ce484222325;
foreach (v; tab){
foreach (v; tab)
{
h ^= v;
h *= 0x100000001b3;
}
Expand Down
6 changes: 4 additions & 2 deletions std/regex/internal/tests.d
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@ unittest
//issue 4574
//empty successful match still advances the input
string[] pres, posts, hits;
foreach (m; matchFn("abcabc", regex("","g"))) {
foreach (m; matchFn("abcabc", regex("","g")))
{
pres ~= m.pre;
posts ~= m.post;
assert(m.hit.empty);
Expand Down Expand Up @@ -719,7 +720,8 @@ unittest
auto w2 = ["", "abc", "de", "fg", "hi"];

uint cnt;
foreach (e; sp2) {
foreach (e; sp2)
{
assert(w2[cnt++] == e);
}
assert(equal(sp2, w2));
Expand Down
3 changes: 2 additions & 1 deletion std/regex/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ public alias StaticRegex(Char) = std.regex.internal.ir.StaticRegex!(Char);
if (patterns.length > 1)
{
auto app = appender!S();
foreach (i, p; patterns){
foreach (i, p; patterns)
{
if (i != 0)
app.put("|");
app.put("(?:");
Expand Down
3 changes: 2 additions & 1 deletion std/signals.d
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ unittest
a.value = 7;
}

unittest {
unittest
{
class Observer
{
int i;
Expand Down
12 changes: 9 additions & 3 deletions std/socket.d
Original file line number Diff line number Diff line change
Expand Up @@ -3027,7 +3027,9 @@ public:
return buf.length
? .recv(sock, buf.ptr, capToInt(buf.length), cast(int)flags)
: 0;
} else {
}
else
{
return buf.length
? .recv(sock, buf.ptr, buf.length, cast(int)flags)
: 0;
Expand Down Expand Up @@ -3060,7 +3062,9 @@ public:
assert(from.addressFamily == _family);
// if (!read) //connection closed
return read;
} else {
}
else
{
auto read = .recvfrom(sock, buf.ptr, buf.length, cast(int)flags, from.name, &nameLen);
assert(from.addressFamily == _family);
// if (!read) //connection closed
Expand All @@ -3087,7 +3091,9 @@ public:
auto read = .recvfrom(sock, buf.ptr, capToInt(buf.length), cast(int)flags, null, null);
// if (!read) //connection closed
return read;
} else {
}
else
{
auto read = .recvfrom(sock, buf.ptr, buf.length, cast(int)flags, null, null);
// if (!read) //connection closed
return read;
Expand Down
42 changes: 28 additions & 14 deletions std/stdio.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Written in the D programming language.
// Written in the D programming language.

/**
Standard I/O functions that extend $(B core.stdc.stdio). $(B core.stdc.stdio)
Expand Down Expand Up @@ -1628,11 +1628,16 @@ is recommended if you want to process a complete file.
auto last = terminator.back;
C[] buf2;
swap(buf, buf2);
for (;;) {
if (!readln(buf2, last) || endsWith(buf2, terminator)) {
if (buf.empty) {
for (;;)
{
if (!readln(buf2, last) || endsWith(buf2, terminator))
{
if (buf.empty)
{
buf = buf2;
} else {
}
else
{
buf ~= buf2;
}
break;
Expand Down Expand Up @@ -2578,7 +2583,7 @@ $(D Range) that locks the file and allows fast writing to it.
}

// @@@BUG@@@ 2340
//void front(C)(C c) if (is(C : dchar)) {
//void front(C)(C c) if (is(C : dchar))
/// ditto
void put(C)(C c) @safe if (is(C : const(dchar)))
{
Expand Down Expand Up @@ -3950,7 +3955,8 @@ unittest
alias TestedWith =
AliasSeq!(string, wstring, dstring,
char[], wchar[], dchar[]);
foreach (T; TestedWith) {
foreach (T; TestedWith)
{
// test looping with an empty file
std.file.write(deleteme, "");
auto f = File(deleteme, "r");
Expand Down Expand Up @@ -3991,7 +3997,8 @@ unittest

// test with ubyte[] inputs
alias TestedWith2 = AliasSeq!(immutable(ubyte)[], ubyte[]);
foreach (T; TestedWith2) {
foreach (T; TestedWith2)
{
// test looping with an empty file
std.file.write(deleteme, "");
auto f = File(deleteme, "r");
Expand Down Expand Up @@ -4124,9 +4131,12 @@ private struct ChunksImpl
if (!f.eof) throw new StdioException(null);
buffer.length = r;
}
static if (is(typeof(dg(tally, buffer)))) {
static if (is(typeof(dg(tally, buffer))))
{
if ((result = dg(tally, buffer)) != 0) break;
} else {
}
else
{
if ((result = dg(buffer)) != 0) break;
}
++tally;
Expand Down Expand Up @@ -4451,9 +4461,11 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orie
*/
L1:
int c;
while ((c = FGETC(fp)) != -1) {
while ((c = FGETC(fp)) != -1)
{
app.putchar(cast(char) c);
if (c == terminator) {
if (c == terminator)
{
buf = app.data;
return buf.length;
}
Expand Down Expand Up @@ -4535,9 +4547,11 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orie
app.initialize(buf);

int c;
while ((c = FGETC(fp)) != -1) {
while ((c = FGETC(fp)) != -1)
{
app.putchar(cast(char) c);
if (c == terminator) {
if (c == terminator)
{
buf = app.data;
return buf.length;
}
Expand Down
575 changes: 397 additions & 178 deletions std/stream.d

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion std/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,8 @@ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
}

///
@safe pure unittest {
@safe pure unittest
{
import std.conv : to;

ptrdiff_t i = "helloWorld".indexOfAny("Wr");
Expand Down
10 changes: 7 additions & 3 deletions std/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,8 @@ template arity(alias func)
}

///
unittest {
unittest
{
void foo(){}
static assert(arity!foo==0);
void bar(uint){}
Expand Down Expand Up @@ -6739,9 +6740,12 @@ template getUDAs(alias symbol, alias attribute)
import std.typetuple : Filter;

template isDesiredUDA(alias S) {
static if (__traits(compiles, is(typeof(S) == attribute))) {
static if (__traits(compiles, is(typeof(S) == attribute)))
{
enum isDesiredUDA = is(typeof(S) == attribute);
} else {
}
else
{
enum isDesiredUDA = isInstanceOf!(attribute, typeof(S));
}
}
Expand Down
24 changes: 16 additions & 8 deletions std/uni.d
Original file line number Diff line number Diff line change
Expand Up @@ -5304,7 +5304,8 @@ unittest
alias fails8 = AliasSeq!("\xC1", "\x80\x00","\xC0\x00", "\xCF\x79",
"\xFF\x00\0x00\0x00\x00", "\xC0\0x80\0x80\x80", "\x80\0x00\0x00\x00",
"\xCF\x00\0x00\0x00\x00");
foreach (msg; fails8){
foreach (msg; fails8)
{
assert(collectException((){
auto s = msg;
size_t idx = 0;
Expand All @@ -5313,7 +5314,8 @@ unittest
}
//decode failure cases UTF-16
alias fails16 = AliasSeq!([0xD811], [0xDC02]);
foreach (msg; fails16){
foreach (msg; fails16)
{
assert(collectException((){
auto s = msg.map!(x => cast(wchar)x);
utf16.test(s);
Expand Down Expand Up @@ -5580,7 +5582,8 @@ unittest
auto trie4 = buildTrie!(bool, size_t, max4,
sliceBits!(13, 16), sliceBits!(9, 13), sliceBits!(6, 9) , sliceBits!(0, 6)
)(redundant4.byInterval);
foreach (i; 0..max4){
foreach (i; 0..max4)
{
if (i in redundant4)
assert(trie4[i], text(cast(uint)i));
}
Expand Down Expand Up @@ -5899,7 +5902,8 @@ else
target |= asSet(uniProps.So);
target |= asSet(uniProps.Po);
}
else if (ucmp(name, "graphical") == 0){
else if (ucmp(name, "graphical") == 0)
{
target = asSet(uniProps.Alphabetic);

target |= asSet(uniProps.Mn);
Expand Down Expand Up @@ -7287,7 +7291,8 @@ ubyte combiningClass(dchar ch) @safe pure nothrow @nogc
}

///
unittest{
unittest
{
// shorten the code
alias CC = combiningClass;

Expand Down Expand Up @@ -7362,7 +7367,8 @@ public dchar compose(dchar first, dchar second) pure nothrow
}

///
unittest{
unittest
{
assert(compose('A','\u0308') == '\u00C4');
assert(compose('A', 'B') == dchar.init);
assert(compose('C', '\u0301') == '\u0106');
Expand Down Expand Up @@ -7780,14 +7786,16 @@ private size_t recompose(size_t start, dchar[] input, ubyte[] ccc) pure nothrow
// current was merged so its CCC shouldn't affect
// composing with the next one
}
else {
else
{
// if it was a starter then accumCC is now 0, end of loop
accumCC = curCC;
if (accumCC == 0)
break;
}
}
else{
else
{
// ditto here
accumCC = curCC;
if (accumCC == 0)
Expand Down
12 changes: 8 additions & 4 deletions std/uri.d
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ private string URI_Encode(dstring string, uint unescapedSet)
char* R2;

Rsize *= 2;
if (Rsize > 1024) {
if (Rsize > 1024)
{
R2 = (new char[Rsize]).ptr;
}
else
Expand Down Expand Up @@ -182,7 +183,8 @@ private string URI_Encode(dstring string, uint unescapedSet)
char *R2;

Rsize = 2 * (Rlen + L * 3);
if (Rsize > 1024) {
if (Rsize > 1024)
{
R2 = (new char[Rsize]).ptr;
}
else
Expand Down Expand Up @@ -232,7 +234,8 @@ private dstring URI_Decode(Char)(in Char[] uri, uint reservedSet) if (isSomeChar

// Preallocate result buffer R guaranteed to be large enough for result
auto Rsize = len;
if (Rsize > 1024 / dchar.sizeof) {
if (Rsize > 1024 / dchar.sizeof)
{
R = (new dchar[Rsize]).ptr;
}
else
Expand Down Expand Up @@ -428,7 +431,8 @@ ptrdiff_t uriLength(Char)(in Char[] s) if (isSomeChar!Char)
if (s.length <= 4)
return -1;

if (s.length > 7 && icmp(s[0 .. 7], "http://") == 0) {
if (s.length > 7 && icmp(s[0 .. 7], "http://") == 0)
{
i = 7;
}
else
Expand Down
20 changes: 14 additions & 6 deletions std/zlib.d
Original file line number Diff line number Diff line change
Expand Up @@ -686,31 +686,39 @@ unittest // by Dave


// smallish buffers
for (int idx = 0; idx < 25; idx++) {
for (int idx = 0; idx < 25; idx++)
{
char[] buf = new char[uniform(0, 100)];

// Alternate between more & less compressible
foreach (ref char c; buf)
c = cast(char) (' ' + (uniform(0, idx % 2 ? 91 : 2)));

if (CompressThenUncompress(buf)) {
if (CompressThenUncompress(buf))
{
debug(zlib) writeln("; Success.");
} else {
}
else
{
return;
}
}

// larger buffers
for (int idx = 0; idx < 25; idx++) {
for (int idx = 0; idx < 25; idx++)
{
char[] buf = new char[uniform(0, 1000/*0000*/)];

// Alternate between more & less compressible
foreach (ref char c; buf)
c = cast(char) (' ' + (uniform(0, idx % 2 ? 91 : 10)));

if (CompressThenUncompress(buf)) {
if (CompressThenUncompress(buf))
{
debug(zlib) writefln("; Success.");
} else {
}
else
{
return;
}
}
Expand Down