Skip to content

Commit 993352d

Browse files
committed
Merge branch 'master' of github.com:D-Programming-Language/phobos
2 parents d0e52a1 + 8b2ff4c commit 993352d

23 files changed

+6651
-3321
lines changed

changelog.dd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ $(VERSION 053, ddd mm, 2011, =================================================,
33
$(WHATSNEW
44
$(LI Added bindings for libcurl: etc.c.curl)
55
$(LI Added std.net.isemail)
6+
$(LI Added std.parallelism)
67
)
78
$(LIBBUGSFIXED
89
$(LI $(BUGZILLA 4644): assertExceptionThrown to assert that a particular exception was thrown)
@@ -13,7 +14,9 @@ $(VERSION 053, ddd mm, 2011, =================================================,
1314
$(LI $(BUGZILLA 5616): std.datetime: not cross-platform)
1415
$(LI $(BUGZILLA 5654): BigInt returns ZERO with strings of single digit number with leading zeros)
1516
$(LI $(BUGZILLA 5731): std.datetime.SysTime prints UTC offsets backwards)
17+
$(LI $(BUGZILLA 5761): std.datetime: Date.this(int day) conversion fails for Dec 30 of leap years)
1618
$(LI $(BUGZILLA 5780): [patch] std.traits.hasIndirections incorrectly handles static arrays)
17-
)
19+
$(LI $(BUGZILLA 5781): std.datetime: On Windows, times off by one hour in some years due to DST rule changes)
20+
)
1821

1922
)

index.d

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ D language compiler. Also, check out the
160160
<dt><a href="std_gc.html"><b>std.gc</b></a>
161161
<dd>Control the garbage collector.
162162
163-
<dt><a href="std_intrinsic.html"><b>std.intrinsic</b></a>
164-
<dd>Compiler built in intrinsic functions
165-
166163
<dt><a href="std_math.html"><b>std.math</b></a>
167164
<dd>Include all the usual math functions like sin, cos, atan, etc.
168165

posix.mak

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ endif
152152
MAIN = $(ROOT)/emptymain.d
153153

154154
# Stuff in std/
155-
STD_MODULES = $(addprefix std/, algorithm array base64 bigint bitmanip \
156-
compiler complex concurrency container contracts conv cpuid \
157-
cstream ctype date datetime datebase dateparse demangle \
158-
encoding exception file format functional getopt gregorian \
159-
intrinsic json loader math mathspecial md5 metastrings mmfile \
160-
numeric outbuffer path perf process random range regex regexp \
161-
signals socket socketstream stdint stdio stdiobase stream \
162-
string syserror system traits typecons typetuple uni uri utf \
163-
variant xml zip zlib)
155+
STD_MODULES = $(addprefix std/, algorithm array base64 bigint \
156+
bitmanip compiler complex concurrency container contracts \
157+
conv cpuid cstream ctype date datetime datebase dateparse \
158+
demangle encoding exception file format functional getopt \
159+
gregorian json loader math mathspecial md5 metastrings mmfile \
160+
numeric outbuffer parallelism path perf process random range \
161+
regex regexp signals socket socketstream stdint stdio \
162+
stdiobase stream string syserror system traits typecons \
163+
typetuple uni uri utf variant xml zip zlib)
164164

165165
STD_NET_MODULES = $(addprefix std/net/, isemail)
166166

std/algorithm.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,9 @@ template reduce(fun...) if (fun.length >= 1)
658658
alias args[0] r;
659659
static if (fun.length == 1)
660660
{
661-
return reduce(r.front, (r.popFront(), r));
661+
auto seed = r.front;
662+
r.popFront();
663+
return reduce(seed, r);
662664
}
663665
else
664666
{

std/array.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Source: $(PHOBOSSRC std/_array.d)
1212
*/
1313
module std.array;
1414

15-
import core.memory;
15+
import core.memory, core.bitop;
1616
import std.algorithm, std.conv, std.ctype, std.encoding, std.exception,
17-
std.intrinsic, std.range, std.string, std.traits, std.typecons, std.utf;
17+
std.range, std.string, std.traits, std.typecons, std.utf;
1818
import std.c.string : memcpy;
1919
version(unittest) import core.exception, std.stdio, std.typetuple;
2020

std/bitmanip.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module std.bitmanip;
2323

2424
//debug = bitarray; // uncomment to turn on debugging printf's
2525

26-
private import std.intrinsic;
26+
import core.bitop;
2727

2828
string myToStringx(ulong n)
2929
{ enum s = "0123456789";

std/c/windows/winsock.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ version(BigEndian)
316316
}
317317
else version(LittleEndian)
318318
{
319-
private import std.intrinsic;
319+
private import core.bitop;
320320

321321

322322
uint16_t htons(uint16_t x)

std/complex.d

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ import std.traits;
1919

2020

2121

22-
/** A complex number parametrised by a type T.
23-
24-
Bugs:
25-
Some operators, such as opAssign and opOpAssign, should return by ref,
26-
but currently don't. This will be implemented as soon as
27-
$(LINK2 http://d.puremagic.com/issues/show_bug.cgi?id=2460, DMD bug 2460)
28-
is fixed.
29-
*/
22+
/** A complex number parametrised by a type T. */
3023
struct Complex(T) if (isFloatingPoint!T)
3124
{
3225
/** The real part of the number. */
@@ -38,7 +31,7 @@ struct Complex(T) if (isFloatingPoint!T)
3831

3932
@safe pure nothrow // The following functions depend only on std.math.
4033
{
41-
34+
4235
/** Calculate the absolute value (or modulus) of the number. */
4336
@property T abs() const
4437
{
@@ -68,7 +61,7 @@ struct Complex(T) if (isFloatingPoint!T)
6861

6962

7063
// this = complex
71-
Complex opAssign(R : T)(Complex!R z)
64+
ref Complex opAssign(R : T)(Complex!R z)
7265
{
7366
re = z.re;
7467
im = z.im;
@@ -77,7 +70,7 @@ struct Complex(T) if (isFloatingPoint!T)
7770

7871

7972
// this = numeric
80-
Complex opAssign(R : T)(R r)
73+
ref Complex opAssign(R : T)(R r)
8174
{
8275
re = r;
8376
im = 0;
@@ -196,7 +189,7 @@ struct Complex(T) if (isFloatingPoint!T)
196189

197190

198191
// complex += complex, complex -= complex
199-
Complex opOpAssign(string op, C)(C z)
192+
ref Complex opOpAssign(string op, C)(C z)
200193
if ((op == "+" || op == "-") && is(C R == Complex!R))
201194
{
202195
mixin ("re "~op~"= z.re;");
@@ -206,7 +199,7 @@ struct Complex(T) if (isFloatingPoint!T)
206199

207200

208201
// complex *= complex
209-
Complex opOpAssign(string op, C)(C z)
202+
ref Complex opOpAssign(string op, C)(C z)
210203
if (op == "*" && is(C R == Complex!R))
211204
{
212205
auto temp = re*z.re - im*z.im;
@@ -217,7 +210,7 @@ struct Complex(T) if (isFloatingPoint!T)
217210

218211

219212
// complex /= complex
220-
Complex opOpAssign(string op, C)(C z)
213+
ref Complex opOpAssign(string op, C)(C z)
221214
if (op == "/" && is(C R == Complex!R))
222215
{
223216
if (fabs(z.re) < fabs(z.im))
@@ -243,7 +236,7 @@ struct Complex(T) if (isFloatingPoint!T)
243236

244237

245238
// complex ^^= complex
246-
Complex opOpAssign(string op, C)(C z)
239+
ref Complex opOpAssign(string op, C)(C z)
247240
if (op == "^^" && is(C R == Complex!R))
248241
{
249242
FPTemporary!T r = abs;
@@ -258,7 +251,7 @@ struct Complex(T) if (isFloatingPoint!T)
258251

259252

260253
// complex += numeric, complex -= numeric
261-
Complex opOpAssign(string op, U : T)(U a)
254+
ref Complex opOpAssign(string op, U : T)(U a)
262255
if (op == "+" || op == "-")
263256
{
264257
mixin ("re "~op~"= a;");
@@ -267,7 +260,7 @@ struct Complex(T) if (isFloatingPoint!T)
267260

268261

269262
// complex *= numeric, complex /= numeric
270-
Complex opOpAssign(string op, U : T)(U a)
263+
ref Complex opOpAssign(string op, U : T)(U a)
271264
if (op == "*" || op == "/")
272265
{
273266
mixin ("re "~op~"= a;");
@@ -277,7 +270,7 @@ struct Complex(T) if (isFloatingPoint!T)
277270

278271

279272
// complex ^^= real
280-
Complex opOpAssign(string op, R)(R r)
273+
ref Complex opOpAssign(string op, R)(R r)
281274
if (op == "^^" && isFloatingPoint!R)
282275
{
283276
FPTemporary!T ab = abs^^r;
@@ -289,7 +282,7 @@ struct Complex(T) if (isFloatingPoint!T)
289282

290283

291284
// complex ^^= int
292-
Complex opOpAssign(string op, U)(U i)
285+
ref Complex opOpAssign(string op, U)(U i)
293286
if (op == "^^" && isIntegral!U)
294287
{
295288
switch (i)

std/container.d

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ struct Array(T) if (!is(T : const(bool)))
15031503
{
15041504
foreach (ref e; _payload.ptr[newLength .. _payload.length])
15051505
{
1506-
clear(e);
1506+
.clear(e);
15071507
}
15081508
}
15091509
_payload = _payload.ptr[0 .. newLength];
@@ -1545,9 +1545,9 @@ struct Array(T) if (!is(T : const(bool)))
15451545
0,
15461546
(elements - oldLength) * T.sizeof);
15471547
GC.addRange(newPayload.ptr, sz);
1548-
GC.removeRange(_data._payload.ptr);
1549-
free(_data._payload.ptr);
1550-
_data._payload = newPayload;
1548+
GC.removeRange(_payload.ptr);
1549+
free(_payload.ptr);
1550+
_payload = newPayload;
15511551
}
15521552
else
15531553
{
@@ -2320,6 +2320,63 @@ unittest
23202320
assert(a.length == 7);
23212321
assert(equal(a[1..4], [1, 2, 3]));
23222322
}
2323+
// Test issue 5920
2324+
version(unittest)
2325+
{
2326+
//@@@BUG4274@@@: This cannot be declared as an inner struct.
2327+
private struct structBug5920
2328+
{
2329+
int order;
2330+
uint* pDestructionMask;
2331+
~this()
2332+
{
2333+
if (pDestructionMask)
2334+
*pDestructionMask += 1 << order;
2335+
}
2336+
}
2337+
}
2338+
unittest
2339+
{
2340+
alias structBug5920 S;
2341+
uint dMask;
2342+
2343+
auto arr = Array!S(cast(S[])[]);
2344+
foreach (i; 0..8)
2345+
arr.insertBack(S(i, &dMask));
2346+
// don't check dMask now as S may be copied multiple times (it's ok?)
2347+
{
2348+
assert(arr.length == 8);
2349+
dMask = 0;
2350+
arr.length = 6;
2351+
assert(arr.length == 6); // make sure shrinking calls the d'tor
2352+
assert(dMask == 0b1100_0000);
2353+
arr.removeBack();
2354+
assert(arr.length == 5); // make sure removeBack() calls the d'tor
2355+
assert(dMask == 0b1110_0000);
2356+
arr.removeBack(3);
2357+
assert(arr.length == 2); // ditto
2358+
assert(dMask == 0b1111_1100);
2359+
arr.clear();
2360+
assert(arr.length == 0); // make sure clear() calls the d'tor
2361+
assert(dMask == 0b1111_1111);
2362+
}
2363+
assert(dMask == 0b1111_1111); // make sure the d'tor is called once only.
2364+
}
2365+
// Test issue 5792 (mainly just to check if this piece of code is compilable)
2366+
unittest
2367+
{
2368+
auto a = Array!(int[])([[1,2],[3,4]]);
2369+
a.reserve(4);
2370+
assert(a.capacity >= 4);
2371+
assert(a.length == 2);
2372+
assert(a[0] == [1,2]);
2373+
assert(a[1] == [3,4]);
2374+
a.reserve(16);
2375+
assert(a.capacity >= 16);
2376+
assert(a.length == 2);
2377+
assert(a[0] == [1,2]);
2378+
assert(a[1] == [3,4]);
2379+
}
23232380

23242381
// BinaryHeap
23252382
/**

0 commit comments

Comments
 (0)