mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +03:00
Fix 21131. Detect certain string appending situations and properly
handle them.
This commit is contained in:
parent
50751f4392
commit
6065ce793c
2 changed files with 22 additions and 1 deletions
21
std/array.d
21
std/array.d
|
@ -3501,6 +3501,17 @@ if (isDynamicArray!A)
|
|||
//We do this at the end, in case of exceptions
|
||||
_data.arr = bigData;
|
||||
}
|
||||
else static if (isSomeChar!T && isSomeChar!(ElementType!Range) &&
|
||||
!is(immutable T == immutable ElementType!Range))
|
||||
{
|
||||
// need to decode and encode
|
||||
import std.utf : decodeFront;
|
||||
while (!items.empty)
|
||||
{
|
||||
auto c = items.decodeFront;
|
||||
put(c);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//pragma(msg, Range.stringof);
|
||||
|
@ -3717,6 +3728,16 @@ if (isDynamicArray!A)
|
|||
assert(result.value != 23);
|
||||
}
|
||||
|
||||
@safe unittest
|
||||
{
|
||||
import std.conv : to;
|
||||
import std.utf : byCodeUnit;
|
||||
auto str = "ウェブサイト";
|
||||
auto wstr = appender!wstring();
|
||||
put(wstr, str.byCodeUnit);
|
||||
assert(wstr.data == str.to!wstring);
|
||||
}
|
||||
|
||||
//Calculates an efficient growth scheme based on the old capacity
|
||||
//of data, and the minimum requested capacity.
|
||||
//arg curLen: The current length
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue