Browse files

Merge pull request #960 from 9rnsr/fix7444

Supplemental changes for Issue 7444 - Require [] for array copies too
  • Loading branch information...
2 parents 5274ebc + 28dedee commit 9a6dad8a2ac5841bdcfa2b86082450818f6eefab Jonathan M Davis committed Nov 20, 2012
Showing with 29 additions and 29 deletions.
  1. +1 −1 std/algorithm.d
  2. +4 −4 std/array.d
  3. +6 −6 std/digest/md.d
  4. +7 −7 std/digest/ripemd.d
  5. +1 −1 std/digest/sha.d
  6. +1 −1 std/outbuffer.d
  7. +1 −1 std/regex.d
  8. +1 −1 std/string.d
  9. +1 −1 std/uuid.d
  10. +6 −6 std/zip.d
View
2 std/algorithm.d
@@ -6003,7 +6003,7 @@ if (isInputRange!Range1 && isOutputRange!(Range2, ElementType!Range1))
// generic implementation.
enforce(target.length >= source.length,
"Cannot copy a source array into a smaller target array.");
- target[0..source.length] = source;
+ target[0..source.length] = source[];
return target[source.length..$];
}
View
8 std/array.d
@@ -1778,7 +1778,7 @@ void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff
{
// replacement reduces length
immutable stuffEnd = from + stuff.length;
- array[from .. stuffEnd] = stuff;
+ array[from .. stuffEnd] = stuff[];
array = remove(array, tuple(stuffEnd, to));
}
else
@@ -1957,7 +1957,7 @@ body
auto result = new T[s.length - slice.length + replacement.length];
immutable so = slice.ptr - s.ptr;
result[0 .. so] = s[0 .. so];
- result[so .. so + replacement.length] = replacement;
+ result[so .. so + replacement.length] = replacement[];
result[so + replacement.length .. result.length] =
s[so + slice.length .. s.length];
@@ -2205,9 +2205,9 @@ Appends an entire range to the managed array.
immutable len = _data.arr.length;
immutable newlen = len + items.length;
_data.arr = _data.arr.ptr[0..newlen];
- static if(is(typeof(_data.arr[] = items)))
+ static if(is(typeof(_data.arr[] = items[])))
{
- _data.arr.ptr[len..newlen] = items;
+ _data.arr.ptr[len..newlen] = items[];
}
else
{
View
12 std/digest/md.d
@@ -440,8 +440,8 @@ struct MD5
uint index, padLen;
//Save number of bits
- bits[0 .. 4] = nativeToLittleEndian((cast(uint*)&_count)[0]);
- bits[4 .. 8] = nativeToLittleEndian((cast(uint*)&_count)[1]);
+ bits[0 .. 4] = nativeToLittleEndian((cast(uint*)&_count)[0])[];
+ bits[4 .. 8] = nativeToLittleEndian((cast(uint*)&_count)[1])[];
//Pad out to 56 mod 64
index = (cast(uint)_count >> 3) & (64 - 1);
@@ -452,10 +452,10 @@ struct MD5
put(bits);
//Store state in digest
- data[0 .. 4] = nativeToLittleEndian(_state[0]);
- data[4 .. 8] = nativeToLittleEndian(_state[1]);
- data[8 .. 12] = nativeToLittleEndian(_state[2]);
- data[12 .. 16] = nativeToLittleEndian(_state[3]);
+ data[0 .. 4] = nativeToLittleEndian(_state[0])[];
+ data[4 .. 8] = nativeToLittleEndian(_state[1])[];
+ data[8 .. 12] = nativeToLittleEndian(_state[2])[];
+ data[12 .. 16] = nativeToLittleEndian(_state[3])[];
/* Zeroize sensitive information. */
start();
View
14 std/digest/ripemd.d
@@ -585,8 +585,8 @@ struct RIPEMD160
uint index, padLen;
//Save number of bits
- bits[0 .. 4] = nativeToLittleEndian((cast(uint*)&_count)[0]);
- bits[4 .. 8] = nativeToLittleEndian((cast(uint*)&_count)[1]);
+ bits[0 .. 4] = nativeToLittleEndian((cast(uint*)&_count)[0])[];
+ bits[4 .. 8] = nativeToLittleEndian((cast(uint*)&_count)[1])[];
//Pad out to 56 mod 64
index = (cast(uint)_count >> 3) & (64 - 1);
@@ -597,11 +597,11 @@ struct RIPEMD160
put(bits);
//Store state in digest
- data[0 .. 4] = nativeToLittleEndian(_state[0]);
- data[4 .. 8] = nativeToLittleEndian(_state[1]);
- data[8 .. 12] = nativeToLittleEndian(_state[2]);
- data[12 .. 16] = nativeToLittleEndian(_state[3]);
- data[16 .. 20] = nativeToLittleEndian(_state[4]);
+ data[0 .. 4] = nativeToLittleEndian(_state[0])[];
+ data[4 .. 8] = nativeToLittleEndian(_state[1])[];
+ data[8 .. 12] = nativeToLittleEndian(_state[2])[];
+ data[12 .. 16] = nativeToLittleEndian(_state[3])[];
+ data[16 .. 20] = nativeToLittleEndian(_state[4])[];
/* Zeroize sensitive information. */
start();
View
2 std/digest/sha.d
@@ -482,7 +482,7 @@ struct SHA1
/* Store state in digest */
for (auto i = 0; i < 5; i++)
- data[i*4..(i+1)*4] = nativeToBigEndian(state[i]);
+ data[i*4..(i+1)*4] = nativeToBigEndian(state[i])[];
/* Zeroize sensitive information. */
start();
View
2 std/outbuffer.d
@@ -92,7 +92,7 @@ class OutBuffer
void write(const(ubyte)[] bytes)
{
reserve(bytes.length);
- data[offset .. offset + bytes.length] = bytes;
+ data[offset .. offset + bytes.length] = bytes[];
offset += bytes.length;
}
View
2 std/regex.d
@@ -3785,7 +3785,7 @@ template BacktrackingMatcher(bool CTregex)
*cast(State*)&memory[lastState] =
State(index, pc, counter, infiniteNesting);
lastState += stateSize;
- memory[lastState..lastState+2*matches.length] = cast(size_t[])matches[];
+ memory[lastState..lastState+2*matches.length] = (cast(size_t[])matches)[];
lastState += 2*matches.length;
debug(fred_matching)
writefln("Saved(pc=%s) front: %s src: %s"
View
2 std/string.d
@@ -270,7 +270,7 @@ body
// Need to make a copy
auto copy = new char[s.length + 1];
- copy[0..s.length] = s;
+ copy[0..s.length] = s[];
copy[s.length] = 0;
return assumeUnique(copy).ptr;
View
2 std/uuid.d
@@ -1103,7 +1103,7 @@ UUID randomUUID(RNG)(ref RNG randomGen) if(isUniformRNG!(RNG) &&
{
randomGen.popFront();
immutable randomValue = randomGen.front;
- u.data[i .. i + elemSize] = *cast(ubyte[elemSize]*)&randomValue;
+ u.data[i .. i + elemSize] = (*cast(ubyte[elemSize]*)&randomValue)[];
}
//set variant
View
12 std/zip.d
@@ -233,9 +233,9 @@ class ZipArchive
putUshort(i + 28, cast(ushort)de.extra.length);
i += 30;
- data[i .. i + de.name.length] = cast(ubyte[])de.name[];
+ data[i .. i + de.name.length] = (cast(ubyte[])de.name)[];
i += de.name.length;
- data[i .. i + de.extra.length] = cast(ubyte[])de.extra[];
+ data[i .. i + de.extra.length] = (cast(ubyte[])de.extra)[];
i += de.extra.length;
data[i .. i + de.compressedSize] = de.compressedData[];
i += de.compressedSize;
@@ -264,11 +264,11 @@ class ZipArchive
putUint (i + 42, de.offset);
i += 46;
- data[i .. i + de.name.length] = cast(ubyte[])de.name[];
+ data[i .. i + de.name.length] = (cast(ubyte[])de.name)[];
i += de.name.length;
- data[i .. i + de.extra.length] = cast(ubyte[])de.extra[];
+ data[i .. i + de.extra.length] = (cast(ubyte[])de.extra)[];
i += de.extra.length;
- data[i .. i + de.comment.length] = cast(ubyte[])de.comment[];
+ data[i .. i + de.comment.length] = (cast(ubyte[])de.comment)[];
i += de.comment.length;
numEntries++;
}
@@ -288,7 +288,7 @@ class ZipArchive
// Write archive comment
assert(i + comment.length == data.length);
- data[i .. data.length] = cast(ubyte[])comment[];
+ data[i .. data.length] = (cast(ubyte[])comment)[];
return cast(void[])data;
}

0 comments on commit 9a6dad8

Please sign in to comment.