Fix remaining import deprecation messages

This commit is contained in:
Steven Schveighoffer 2016-02-22 16:03:12 -05:00
parent 972227d286
commit b0acb7a394
17 changed files with 81 additions and 62 deletions

View file

@ -663,8 +663,8 @@ int cmp(alias pred = "a < b", R1, R2)(R1 r1, R2 r2) if (isSomeString!R1 && isSom
{ {
if (i1 == r1.length) return threeWay(i2, r2.length); if (i1 == r1.length) return threeWay(i2, r2.length);
if (i2 == r2.length) return threeWay(r1.length, i1); if (i2 == r2.length) return threeWay(r1.length, i1);
immutable c1 = std.utf.decode(r1, i1), immutable c1 = decode(r1, i1),
c2 = std.utf.decode(r2, i2); c2 = decode(r2, i2);
if (c1 != c2) return threeWayInt(cast(int) c1, cast(int) c2); if (c1 != c2) return threeWayInt(cast(int) c1, cast(int) c2);
} }
} }
@ -1157,7 +1157,7 @@ size_t levenshteinDistance(alias equals = (a,b) => a == b, Range1, Range2)
assert(levenshteinDistance("abcde", "abcde") == 0); assert(levenshteinDistance("abcde", "abcde") == 0);
assert(levenshteinDistance("abcde", "abCde") == 1); assert(levenshteinDistance("abcde", "abCde") == 1);
assert(levenshteinDistance("kitten", "sitting") == 3); assert(levenshteinDistance("kitten", "sitting") == 3);
assert(levenshteinDistance!((a, b) => std.uni.toUpper(a) == std.uni.toUpper(b)) assert(levenshteinDistance!((a, b) => toUpper(a) == toUpper(b))
("parks", "SPARK") == 2); ("parks", "SPARK") == 2);
assert(levenshteinDistance("parks".filter!"true", "spark".filter!"true") == 2); assert(levenshteinDistance("parks".filter!"true", "spark".filter!"true") == 2);
assert(levenshteinDistance("ID", "I♥D") == 1); assert(levenshteinDistance("ID", "I♥D") == 1);

View file

@ -1960,7 +1960,7 @@ if (isNarrowString!(Char[]) && !is(Char == const) && !is(Char == immutable))
auto r = representation(s); auto r = representation(s);
for (size_t i = 0; i < s.length; ) for (size_t i = 0; i < s.length; )
{ {
immutable step = std.utf.stride(s, i); immutable step = stride(s, i);
if (step > 1) if (step > 1)
{ {
.reverse(r[i .. i + step]); .reverse(r[i .. i + step]);

View file

@ -473,7 +473,7 @@ if (isNarrowString!R1 && isNarrowString!R2)
immutable limit = min(r1.length, r2.length); immutable limit = min(r1.length, r2.length);
for (size_t i = 0; i < limit;) for (size_t i = 0; i < limit;)
{ {
immutable codeLen = std.utf.stride(r1, i); immutable codeLen = stride(r1, i);
size_t j = 0; size_t j = 0;
for (; j < codeLen && i < limit; ++i, ++j) for (; j < codeLen && i < limit; ++i, ++j)

View file

@ -284,7 +284,7 @@ struct Complex(T) if (isFloatingPoint!T)
Complex!(CommonType!(T, R)) opBinaryRight(string op, R)(R lhs) const Complex!(CommonType!(T, R)) opBinaryRight(string op, R)(R lhs) const
if (op == "^^" && isNumeric!R) if (op == "^^" && isNumeric!R)
{ {
import std.math : log, exp, PI; static import std.math;
Unqual!(CommonType!(T, R)) ab = void, ar = void; Unqual!(CommonType!(T, R)) ab = void, ar = void;
if (lhs >= 0) if (lhs >= 0)
@ -292,14 +292,14 @@ struct Complex(T) if (isFloatingPoint!T)
// r = lhs // r = lhs
// theta = 0 // theta = 0
ab = lhs ^^ this.re; ab = lhs ^^ this.re;
ar = log(lhs) * this.im; ar = std.math.log(lhs) * this.im;
} }
else else
{ {
// r = -lhs // r = -lhs
// theta = PI // theta = PI
ab = (-lhs) ^^ this.re * exp(-PI * this.im); ab = (-lhs) ^^ this.re * std.math.exp(-std.math.PI * this.im);
ar = PI * this.re + log(-lhs) * this.im; ar = std.math.PI * this.re + std.math.log(-lhs) * this.im;
} }
return typeof(return)(ab * std.math.cos(ar), ab * std.math.sin(ar)); return typeof(return)(ab * std.math.cos(ar), ab * std.math.sin(ar));
@ -356,11 +356,11 @@ struct Complex(T) if (isFloatingPoint!T)
ref Complex opOpAssign(string op, C)(C z) ref Complex opOpAssign(string op, C)(C z)
if (op == "^^" && is(C R == Complex!R)) if (op == "^^" && is(C R == Complex!R))
{ {
import std.math : exp, log; static import std.math;
immutable r = abs(this); immutable r = abs(this);
immutable t = arg(this); immutable t = arg(this);
immutable ab = r^^z.re * exp(-t*z.im); immutable ab = r^^z.re * std.math.exp(-t*z.im);
immutable ar = t*z.re + log(r)*z.im; immutable ar = t*z.re + std.math.log(r)*z.im;
re = ab*std.math.cos(ar); re = ab*std.math.cos(ar);
im = ab*std.math.sin(ar); im = ab*std.math.sin(ar);
@ -388,6 +388,7 @@ struct Complex(T) if (isFloatingPoint!T)
ref Complex opOpAssign(string op, R)(R r) ref Complex opOpAssign(string op, R)(R r)
if (op == "^^" && isFloatingPoint!R) if (op == "^^" && isFloatingPoint!R)
{ {
static import std.math;
immutable ab = abs(this)^^r; immutable ab = abs(this)^^r;
immutable ar = arg(this)*r; immutable ar = arg(this)*r;
re = ab*std.math.cos(ar); re = ab*std.math.cos(ar);
@ -663,6 +664,7 @@ T abs(T)(Complex!T z) @safe pure nothrow @nogc
/// ///
unittest unittest
{ {
static import std.math;
assert (abs(complex(1.0)) == 1.0); assert (abs(complex(1.0)) == 1.0);
assert (abs(complex(0.0, 1.0)) == 1.0); assert (abs(complex(0.0, 1.0)) == 1.0);
assert (abs(complex(1.0L, -2.0L)) == std.math.sqrt(5.0L)); assert (abs(complex(1.0L, -2.0L)) == std.math.sqrt(5.0L));
@ -757,6 +759,7 @@ unittest
Complex!(CommonType!(T, U)) fromPolar(T, U)(T modulus, U argument) Complex!(CommonType!(T, U)) fromPolar(T, U)(T modulus, U argument)
@safe pure nothrow @nogc @safe pure nothrow @nogc
{ {
static import std.math;
return Complex!(CommonType!(T,U)) return Complex!(CommonType!(T,U))
(modulus*std.math.cos(argument), modulus*std.math.sin(argument)); (modulus*std.math.cos(argument), modulus*std.math.sin(argument));
} }
@ -788,6 +791,7 @@ Complex!T sin(T)(Complex!T z) @safe pure nothrow @nogc
/// ///
unittest unittest
{ {
static import std.math;
assert(sin(complex(0.0)) == 0.0); assert(sin(complex(0.0)) == 0.0);
assert(sin(complex(2.0L, 0)) == std.math.sin(2.0L)); assert(sin(complex(2.0L, 0)) == std.math.sin(2.0L));
} }
@ -831,6 +835,8 @@ Complex!real expi(real y) @trusted pure nothrow @nogc
/// ///
unittest unittest
{ {
static import std.math;
assert(expi(1.3e5L) == complex(std.math.cos(1.3e5L), std.math.sin(1.3e5L))); assert(expi(1.3e5L) == complex(std.math.cos(1.3e5L), std.math.sin(1.3e5L)));
assert(expi(0.0L) == 1.0L); assert(expi(0.0L) == 1.0L);
auto z1 = expi(1.234); auto z1 = expi(1.234);
@ -845,7 +851,7 @@ unittest
*/ */
Complex!T sqrt(T)(Complex!T z) @safe pure nothrow @nogc Complex!T sqrt(T)(Complex!T z) @safe pure nothrow @nogc
{ {
import std.math : fabs; static import std.math;
typeof(return) c; typeof(return) c;
real x,y,w,r; real x,y,w,r;
@ -858,8 +864,8 @@ Complex!T sqrt(T)(Complex!T z) @safe pure nothrow @nogc
real z_re = z.re; real z_re = z.re;
real z_im = z.im; real z_im = z.im;
x = fabs(z_re); x = std.math.fabs(z_re);
y = fabs(z_im); y = std.math.fabs(z_im);
if (x >= y) if (x >= y)
{ {
r = y / x; r = y / x;
@ -890,6 +896,7 @@ Complex!T sqrt(T)(Complex!T z) @safe pure nothrow @nogc
/// ///
unittest unittest
{ {
static import std.math;
assert (sqrt(complex(0.0)) == 0.0); assert (sqrt(complex(0.0)) == 0.0);
assert (sqrt(complex(1.0L, 0)) == std.math.sqrt(1.0L)); assert (sqrt(complex(1.0L, 0)) == std.math.sqrt(1.0L));
assert (sqrt(complex(-1.0L, 0)) == complex(0, 1.0L)); assert (sqrt(complex(-1.0L, 0)) == complex(0, 1.0L));

View file

@ -700,13 +700,14 @@ unittest
unittest unittest
{ {
import std.algorithm; static import std.algorithm;
import std.range: take;
// insertAfter documentation example // insertAfter documentation example
auto sl = SList!string(["a", "b", "d"]); auto sl = SList!string(["a", "b", "d"]);
sl.insertAfter(sl[], "e"); // insert at the end (slowest) sl.insertAfter(sl[], "e"); // insert at the end (slowest)
assert(std.algorithm.equal(sl[], ["a", "b", "d", "e"])); assert(std.algorithm.equal(sl[], ["a", "b", "d", "e"]));
sl.insertAfter(std.range.take(sl[], 2), "c"); // insert after "b" sl.insertAfter(take(sl[], 2), "c"); // insert after "b"
assert(std.algorithm.equal(sl[], ["a", "b", "c", "d", "e"])); assert(std.algorithm.equal(sl[], ["a", "b", "c", "d", "e"]));
} }

View file

@ -4803,9 +4803,10 @@ unittest //@@@9559@@@
{ {
import std.algorithm : map; import std.algorithm : map;
import std.typecons : Nullable; import std.typecons : Nullable;
import std.array: array;
alias I = Nullable!int; alias I = Nullable!int;
auto ints = [0, 1, 2].map!(i => i & 1 ? I.init : I(i))(); auto ints = [0, 1, 2].map!(i => i & 1 ? I.init : I(i))();
auto asArray = std.array.array(ints); auto asArray = array(ints);
} }
unittest //http://forum.dlang.org/post/nxbdgtdlmwscocbiypjs@forum.dlang.org unittest //http://forum.dlang.org/post/nxbdgtdlmwscocbiypjs@forum.dlang.org

View file

@ -153,7 +153,7 @@ class CFile : Stream {
import std.file : deleteme; import std.file : deleteme;
import std.internal.cstring : tempCString; import std.internal.cstring : tempCString;
auto stream_file = (std.file.deleteme ~ "-stream.txt").tempCString(); auto stream_file = (deleteme ~ "-stream.txt").tempCString();
FILE* f = fopen(stream_file,"w"); FILE* f = fopen(stream_file,"w");
assert(f !is null); assert(f !is null);
CFile file = new CFile(f,FileMode.Out); CFile file = new CFile(f,FileMode.Out);

View file

@ -31629,7 +31629,7 @@ SysTime parseRFC822DateTime(R)(R value) @safe
(is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte))) (is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte)))
{ {
import std.functional : not; import std.functional : not;
import std.ascii : isDigit; import std.ascii : isDigit, isAlpha, isPrintable;
import std.typecons : Rebindable; import std.typecons : Rebindable;
import std.string : capitalize, format; import std.string : capitalize, format;
import std.conv : to; import std.conv : to;
@ -31663,7 +31663,7 @@ SysTime parseRFC822DateTime(R)(R value) @safe
} }
// day-of-week // day-of-week
if(std.ascii.isAlpha(value[0])) if(isAlpha(value[0]))
{ {
auto dowStr = sliceAsString(value[0 .. 3]); auto dowStr = sliceAsString(value[0 .. 3]);
switch(dowStr) switch(dowStr)
@ -31683,7 +31683,7 @@ afterDoW: stripAndCheckLen(value[3 .. value.length], ",7Dec1200:00A".length);
} }
// day // day
immutable digits = std.ascii.isDigit(value[1]) ? 2 : 1; immutable digits = isDigit(value[1]) ? 2 : 1;
immutable day = _convDigits!short(value[0 .. digits]); immutable day = _convDigits!short(value[0 .. digits]);
if(day == -1) if(day == -1)
throw new DateTimeException("Invalid day"); throw new DateTimeException("Invalid day");
@ -31817,7 +31817,7 @@ afterMon: stripAndCheckLen(value[3 .. value.length], "1200:00A".length);
// that if the next character is printable (and not part of CFWS), then it // that if the next character is printable (and not part of CFWS), then it
// might be part of the timezone and thus affect what the timezone was // might be part of the timezone and thus affect what the timezone was
// supposed to be, so we'll throw, but otherwise, we'll just ignore it. // supposed to be, so we'll throw, but otherwise, we'll just ignore it.
if(!value.empty && std.ascii.isPrintable(value[0]) && value[0] != ' ' && value[0] != '(') if(!value.empty && isPrintable(value[0]) && value[0] != ' ' && value[0] != '(')
throw new DateTimeException("Invalid timezone"); throw new DateTimeException("Invalid timezone");
try try
@ -33699,7 +33699,7 @@ T _convDigits(T, R)(R str)
{ {
if(i != 0) if(i != 0)
num *= 10; num *= 10;
if(!std.ascii.isDigit(str[i])) if(!isDigit(str[i]))
return -1; return -1;
num += str[i] - '0'; num += str[i] - '0';
} }

View file

@ -3267,6 +3267,7 @@ version(Windows) unittest
version(Posix) unittest version(Posix) unittest
{ {
import std.process: executeShell;
collectException(rmdirRecurse(deleteme)); collectException(rmdirRecurse(deleteme));
auto d = deleteme~"/a/b/c/d/e/f/g"; auto d = deleteme~"/a/b/c/d/e/f/g";
enforce(collectException(mkdir(d))); enforce(collectException(mkdir(d)));
@ -3282,7 +3283,7 @@ version(Posix) unittest
mkdirRecurse(d); mkdirRecurse(d);
version(Android) string link_cmd = "ln -s "; version(Android) string link_cmd = "ln -s ";
else string link_cmd = "ln -sf "; else string link_cmd = "ln -sf ";
std.process.executeShell(link_cmd~deleteme~"/a/b/c "~deleteme~"/link"); executeShell(link_cmd~deleteme~"/a/b/c "~deleteme~"/link");
rmdirRecurse(deleteme); rmdirRecurse(deleteme);
enforce(!exists(deleteme)); enforce(!exists(deleteme));
} }

View file

@ -419,13 +419,14 @@ void download(Conn = AutoProtocol)(const(char)[] url, string saveToPath, Conn co
unittest unittest
{ {
static import std.file;
foreach (host; [testServer.addr, "http://"~testServer.addr]) foreach (host; [testServer.addr, "http://"~testServer.addr])
{ {
testServer.handle((s) { testServer.handle((s) {
assert(s.recvReq.hdrs.canFind("GET /")); assert(s.recvReq.hdrs.canFind("GET /"));
s.send(httpOK("Hello world")); s.send(httpOK("Hello world"));
}); });
auto fn = deleteme; auto fn = std.file.deleteme;
scope (exit) std.file.remove(fn); scope (exit) std.file.remove(fn);
download(host, fn); download(host, fn);
assert(std.file.readText(fn) == "Hello world"); assert(std.file.readText(fn) == "Hello world");
@ -482,9 +483,10 @@ void upload(Conn = AutoProtocol)(string loadFromPath, const(char)[] url, Conn co
unittest unittest
{ {
static import std.file;
foreach (host; [testServer.addr, "http://"~testServer.addr]) foreach (host; [testServer.addr, "http://"~testServer.addr])
{ {
auto fn = deleteme; auto fn = std.file.deleteme;
scope (exit) std.file.remove(fn); scope (exit) std.file.remove(fn);
std.file.write(fn, "upload data\n"); std.file.write(fn, "upload data\n");
testServer.handle((s) { testServer.handle((s) {

View file

@ -4140,7 +4140,7 @@ unittest
{ {
import std.file : deleteme; import std.file : deleteme;
string temp_file = std.file.deleteme ~ "-tempDelMe.txt"; string temp_file = deleteme ~ "-tempDelMe.txt";
auto file = File(temp_file, "wb"); auto file = File(temp_file, "wb");
scope(exit) scope(exit)
{ {

View file

@ -9214,7 +9214,8 @@ if (is(typeof(fun) == void) || isSomeFunction!fun)
bool isVowel(dchar c) bool isVowel(dchar c)
{ {
return std.string.indexOf("AaEeIiOoUu", c) != -1; import std.string : indexOf;
return "AaEeIiOoUu".indexOf(c) != -1;
} }
int vowelCount = 0; int vowelCount = 0;

View file

@ -2161,8 +2161,9 @@ version(unittest)
void popBack(T)(ref T[] a) @safe pure void popBack(T)(ref T[] a) @safe pure
if (isNarrowString!(T[])) if (isNarrowString!(T[]))
{ {
import std.utf: strideBack;
assert(a.length, "Attempting to popBack() past the front of an array of " ~ T.stringof); assert(a.length, "Attempting to popBack() past the front of an array of " ~ T.stringof);
a = a[0 .. $ - std.utf.strideBack(a, $)]; a = a[0 .. $ - strideBack(a, $)];
} }
@safe pure unittest @safe pure unittest
@ -2273,8 +2274,8 @@ if (!isNarrowString!(T[]))
// Specialization for strings // Specialization for strings
@property dchar back(T)(T[] a) @safe pure if (isNarrowString!(T[])) @property dchar back(T)(T[] a) @safe pure if (isNarrowString!(T[]))
{ {
import std.utf : decode; import std.utf : decode, strideBack;
assert(a.length, "Attempting to fetch the back of an empty array of " ~ T.stringof); assert(a.length, "Attempting to fetch the back of an empty array of " ~ T.stringof);
size_t i = a.length - std.utf.strideBack(a, a.length); size_t i = a.length - strideBack(a, a.length);
return decode(a, i); return decode(a, i);
} }

View file

@ -966,6 +966,7 @@ package void replaceFmt(R, Capt, OutR)
isOutputRange!(OutR, ElementEncodingType!(Capt.String)[])) isOutputRange!(OutR, ElementEncodingType!(Capt.String)[]))
{ {
import std.algorithm, std.conv; import std.algorithm, std.conv;
import std.ascii: isDigit, isAlpha;
enum State { Normal, Dollar } enum State { Normal, Dollar }
auto state = State.Normal; auto state = State.Normal;
size_t offset; size_t offset;
@ -988,7 +989,7 @@ L_Replace_Loop:
format = format[offset .. $]; format = format[offset .. $];
break; break;
case State.Dollar: case State.Dollar:
if(std.ascii.isDigit(format[0])) if(isDigit(format[0]))
{ {
uint digit = parse!uint(format); uint digit = parse!uint(format);
enforce(ignoreBadSubs || digit < captures.length, text("invalid submatch number ", digit)); enforce(ignoreBadSubs || digit < captures.length, text("invalid submatch number ", digit));
@ -997,7 +998,7 @@ L_Replace_Loop:
} }
else if(format[0] == '{') else if(format[0] == '{')
{ {
auto x = find!(a => !std.ascii.isAlpha(a))(format[1..$]); auto x = find!(a => !isAlpha(a))(format[1..$]);
enforce(!x.empty && x[0] == '}', "no matching '}' in replacement format"); enforce(!x.empty && x[0] == '}', "no matching '}' in replacement format");
auto name = format[1 .. $ - x.length]; auto name = format[1 .. $ - x.length];
format = x[1..$]; format = x[1..$];

View file

@ -2008,7 +2008,7 @@ static if (is(sockaddr_un))
immutable ubyte[] data = [1, 2, 3, 4]; immutable ubyte[] data = [1, 2, 3, 4];
Socket[2] pair; Socket[2] pair;
auto name = std.file.deleteme ~ "-unix-socket"; auto name = deleteme ~ "-unix-socket";
auto address = new UnixAddress(name); auto address = new UnixAddress(name);
auto listener = new Socket(AddressFamily.UNIX, SocketType.STREAM); auto listener = new Socket(AddressFamily.UNIX, SocketType.STREAM);

View file

@ -1479,20 +1479,21 @@ private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)(
} }
else else
{ {
import std.uni: toLower;
if (needles.length <= 16 && needles.walkLength(17)) if (needles.length <= 16 && needles.walkLength(17))
{ {
size_t si = 0; size_t si = 0;
dchar[16] scratch = void; dchar[16] scratch = void;
foreach ( dchar c; needles) foreach ( dchar c; needles)
{ {
scratch[si++] = std.uni.toLower(c); scratch[si++] = toLower(c);
} }
static if (forward) static if (forward)
{ {
foreach (i, dchar c; haystack) foreach (i, dchar c; haystack)
{ {
if (canFind(scratch[0 .. si], std.uni.toLower(c)) == any) if (canFind(scratch[0 .. si], toLower(c)) == any)
{ {
return i; return i;
} }
@ -1502,7 +1503,7 @@ private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)(
{ {
foreach_reverse (i, dchar c; haystack) foreach_reverse (i, dchar c; haystack)
{ {
if (canFind(scratch[0 .. si], std.uni.toLower(c)) == any) if (canFind(scratch[0 .. si], toLower(c)) == any)
{ {
return i; return i;
} }
@ -1513,14 +1514,14 @@ private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)(
{ {
static bool f(dchar a, dchar b) static bool f(dchar a, dchar b)
{ {
return std.uni.toLower(a) == b; return toLower(a) == b;
} }
static if (forward) static if (forward)
{ {
foreach (i, dchar c; haystack) foreach (i, dchar c; haystack)
{ {
if (canFind!f(needles, std.uni.toLower(c)) == any) if (canFind!f(needles, toLower(c)) == any)
{ {
return i; return i;
} }
@ -1530,7 +1531,7 @@ private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)(
{ {
foreach_reverse (i, dchar c; haystack) foreach_reverse (i, dchar c; haystack)
{ {
if (canFind!f(needles, std.uni.toLower(c)) == any) if (canFind!f(needles, toLower(c)) == any)
{ {
return i; return i;
} }
@ -2914,12 +2915,12 @@ auto stripRight(Range)(Range str)
!isConvertibleToString!Range && !isConvertibleToString!Range &&
isSomeChar!(ElementEncodingType!Range)) isSomeChar!(ElementEncodingType!Range))
{ {
import std.uni : isWhite;
alias C = Unqual!(ElementEncodingType!(typeof(str))); alias C = Unqual!(ElementEncodingType!(typeof(str)));
static if (isSomeString!(typeof(str))) static if (isSomeString!(typeof(str)))
{ {
import std.utf : codeLength; import std.utf : codeLength;
import std.uni : isWhite;
foreach_reverse (i, dchar c; str) foreach_reverse (i, dchar c; str)
{ {
@ -2936,7 +2937,7 @@ auto stripRight(Range)(Range str)
{ {
static if (C.sizeof == 4) static if (C.sizeof == 4)
{ {
if (std.uni.isWhite(str[i])) if (isWhite(str[i]))
continue; continue;
break; break;
} }
@ -2945,7 +2946,7 @@ auto stripRight(Range)(Range str)
auto c2 = str[i]; auto c2 = str[i];
if (c2 < 0xD800 || c2 >= 0xE000) if (c2 < 0xD800 || c2 >= 0xE000)
{ {
if (std.uni.isWhite(c2)) if (isWhite(c2))
continue; continue;
} }
else if (c2 >= 0xDC00) else if (c2 >= 0xDC00)
@ -2956,7 +2957,7 @@ auto stripRight(Range)(Range str)
if (c1 >= 0xD800 && c1 < 0xDC00) if (c1 >= 0xD800 && c1 < 0xDC00)
{ {
dchar c = ((c1 - 0xD7C0) << 10) + (c2 - 0xDC00); dchar c = ((c1 - 0xD7C0) << 10) + (c2 - 0xDC00);
if (std.uni.isWhite(c)) if (isWhite(c))
{ {
--i; --i;
continue; continue;
@ -2973,7 +2974,7 @@ auto stripRight(Range)(Range str)
char cx = str[i]; char cx = str[i];
if (cx <= 0x7F) if (cx <= 0x7F)
{ {
if (std.uni.isWhite(cx)) if (isWhite(cx))
continue; continue;
break; break;
} }
@ -2992,7 +2993,7 @@ auto stripRight(Range)(Range str)
--i; --i;
} }
if (!std.uni.isWhite(str[i .. i + stride].byDchar.front)) if (!str[i .. i + stride].byDchar.front.isWhite)
return str[0 .. i + stride]; return str[0 .. i + stride];
} }
} }
@ -5349,7 +5350,7 @@ S removechars(S)(S s, in S pattern) @safe pure if (isSomeString!S)
} }
if (changed) if (changed)
{ {
std.utf.encode(r, c); encode(r, c);
} }
} }
if (changed) if (changed)
@ -5383,7 +5384,7 @@ S removechars(S)(S s, in S pattern) @safe pure if (isSomeString!S)
S squeeze(S)(S s, in S pattern = null) S squeeze(S)(S s, in S pattern = null)
{ {
import std.utf : encode; import std.utf : encode, stride;
Unqual!(typeof(s[0]))[] r; Unqual!(typeof(s[0]))[] r;
dchar lastc; dchar lastc;
@ -5404,10 +5405,10 @@ S squeeze(S)(S s, in S pattern = null)
{ {
if (r is null) if (r is null)
r = s[0 .. lasti].dup; r = s[0 .. lasti].dup;
std.utf.encode(r, c); encode(r, c);
} }
else else
lasti = i + std.utf.stride(s, i); lasti = i + stride(s, i);
lastc = c; lastc = c;
} }
else else
@ -5417,7 +5418,7 @@ S squeeze(S)(S s, in S pattern = null)
{ {
if (r is null) if (r is null)
r = s[0 .. lasti].dup; r = s[0 .. lasti].dup;
std.utf.encode(r, c); encode(r, c);
} }
} }
} }
@ -5506,7 +5507,7 @@ S succ(S)(S s) @safe pure if (isSomeString!S)
{ {
import std.ascii : isAlphaNum; import std.ascii : isAlphaNum;
if (s.length && std.ascii.isAlphaNum(s[$ - 1])) if (s.length && isAlphaNum(s[$ - 1]))
{ {
auto r = s.dup; auto r = s.dup;
size_t i = r.length - 1; size_t i = r.length - 1;
@ -5539,7 +5540,7 @@ S succ(S)(S s) @safe pure if (isSomeString!S)
break; break;
default: default:
if (std.ascii.isAlphaNum(c)) if (isAlphaNum(c))
r[i]++; r[i]++;
return r; return r;
} }
@ -5653,10 +5654,10 @@ C1[] tr(C1, C2, C3, C4 = immutable char)
for (size_t i = 0; i < from.length; ) for (size_t i = 0; i < from.length; )
{ {
dchar f = std.utf.decode(from, i); dchar f = decode(from, i);
if (f == '-' && lastf != dchar.init && i < from.length) if (f == '-' && lastf != dchar.init && i < from.length)
{ {
dchar nextf = std.utf.decode(from, i); dchar nextf = decode(from, i);
if (lastf <= c && c <= nextf) if (lastf <= c && c <= nextf)
{ {
n += c - lastf - 1; n += c - lastf - 1;
@ -5686,10 +5687,10 @@ C1[] tr(C1, C2, C3, C4 = immutable char)
// Find the nth character in to[] // Find the nth character in to[]
dchar nextt; dchar nextt;
for (size_t i = 0; i < to.length; ) for (size_t i = 0; i < to.length; )
{ dchar t = std.utf.decode(to, i); { dchar t = decode(to, i);
if (t == '-' && lastt != dchar.init && i < to.length) if (t == '-' && lastt != dchar.init && i < to.length)
{ {
nextt = std.utf.decode(to, i); nextt = decode(to, i);
n -= nextt - lastt; n -= nextt - lastt;
if (n < 0) if (n < 0)
{ {
@ -6475,6 +6476,7 @@ unittest
S wrap(S)(S s, in size_t columns = 80, S firstindent = null, S wrap(S)(S s, in size_t columns = 80, S firstindent = null,
S indent = null, in size_t tabsize = 8) if (isSomeString!S) S indent = null, in size_t tabsize = 8) if (isSomeString!S)
{ {
import std.uni: isWhite;
typeof(s.dup) result; typeof(s.dup) result;
bool inword; bool inword;
bool first = true; bool first = true;
@ -6488,7 +6490,7 @@ S wrap(S)(S s, in size_t columns = 80, S firstindent = null,
auto col = column(firstindent, tabsize); auto col = column(firstindent, tabsize);
foreach (size_t i, dchar c; s) foreach (size_t i, dchar c; s)
{ {
if (std.uni.isWhite(c)) if (isWhite(c))
{ {
if (inword) if (inword)
{ {

View file

@ -5304,8 +5304,8 @@ package auto units(C)(C[] s) @safe pure nothrow @nogc
import std.utf : encode; import std.utf : encode;
char[4] buf; char[4] buf;
wchar[2] buf16; wchar[2] buf16;
auto len = std.utf.encode(buf, ch); auto len = encode(buf, ch);
auto len16 = std.utf.encode(buf16, ch); auto len16 = encode(buf16, ch);
auto c8 = buf[0..len].decoder; auto c8 = buf[0..len].decoder;
auto c16 = buf16[0..len16].decoder; auto c16 = buf16[0..len16].decoder;
assert(testAll(utf16, c16)); assert(testAll(utf16, c16));
@ -7811,7 +7811,7 @@ private auto seekStable(NormalizationForm norm, C)(size_t idx, in C[] input)
dchar ch = br.back; dchar ch = br.back;
if(combiningClass(ch) == 0 && allowedIn!norm(ch)) if(combiningClass(ch) == 0 && allowedIn!norm(ch))
{ {
region_start = br.length - std.utf.codeLength!C(ch); region_start = br.length - codeLength!C(ch);
break; break;
} }
br.popFront(); br.popFront();
@ -8799,6 +8799,7 @@ S toLower(S)(S s) @trusted pure
@trusted unittest //@@@BUG std.format is not @safe @trusted unittest //@@@BUG std.format is not @safe
{ {
import std.format : format; import std.format : format;
static import std.ascii;
foreach(ch; 0..0x80) foreach(ch; 0..0x80)
assert(std.ascii.toLower(ch) == toLower(ch)); assert(std.ascii.toLower(ch) == toLower(ch));
assert(toLower('Я') == 'я'); assert(toLower('Я') == 'я');
@ -8924,6 +8925,7 @@ unittest
@trusted unittest @trusted unittest
{ {
import std.format : format; import std.format : format;
static import std.ascii;
foreach(ch; 0..0x80) foreach(ch; 0..0x80)
assert(std.ascii.toUpper(ch) == toUpper(ch)); assert(std.ascii.toUpper(ch) == toUpper(ch));
assert(toUpper('я') == 'Я'); assert(toUpper('я') == 'Я');