From c8d9afedeafa7a64a2a0826b3693b691e43e1387 Mon Sep 17 00:00:00 2001 From: Ilya Yaroshenko Date: Fri, 21 Nov 2014 00:08:35 +0300 Subject: [PATCH] clean scope imports imports of `std.range, std.algorithm, std.array, std.string, std.format, std.uni` are affected. --- std/algorithm.d | 17 +++++++------- std/array.d | 4 ++-- std/bitmanip.d | 6 ++--- std/complex.d | 4 ++-- std/csv.d | 2 +- std/datetime.d | 48 +++++++++++++++++++------------------- std/net/isemail.d | 2 +- std/parallelism.d | 2 +- std/path.d | 4 +++- std/regex/internal/tests.d | 4 ++-- std/stdio.d | 4 ++-- std/traits.d | 4 ++-- std/uni.d | 20 ++++++++-------- std/uri.d | 6 ++--- std/uuid.d | 2 +- std/variant.d | 2 +- 16 files changed, 67 insertions(+), 64 deletions(-) diff --git a/std/algorithm.d b/std/algorithm.d index 6d8d1de58b5..e4d4d126823 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -409,7 +409,7 @@ private T* addressOf(T)(ref T val) { return &val; } private template algoFormat() { import std.format : format; - alias algoFormat = std.string.format; + alias algoFormat = format; } /** @@ -3119,7 +3119,7 @@ if (is(typeof(ElementType!Range.init == Separator.init)) @safe unittest { import std.internal.test.dummyrange; - import std.range; + import std.algorithm; debug(std_algorithm) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done."); @@ -3181,6 +3181,7 @@ if (is(typeof(ElementType!Range.init == Separator.init)) } @safe unittest { + import std.algorithm; import std.range; auto L = retro(iota(1L, 10L)); auto s = splitter(L, 5L); @@ -3658,14 +3659,14 @@ if (isSomeChar!C) { import std.uni : isWhite; - auto r = find!(std.uni.isWhite)(_s); + auto r = find!(isWhite)(_s); _frontLength = _s.length - r.length; } public: this(C[] s) pure @safe { - import std.string; + import std.string : strip; _s = s.strip(); getFirst(); } @@ -3731,7 +3732,7 @@ if (isSomeChar!C) lines[1] = "line \ttwo".dup; lines[2] = "yah last line\ryah".dup; foreach (line; lines) { - foreach (word; std.array.splitter(std.string.strip(line))) { + foreach (word; splitter(strip(line))) { if (word in dictionary) continue; // Nothing to do auto newID = dictionary.length; dictionary[to!string(word)] = cast(uint)newID; @@ -3748,7 +3749,7 @@ if (isSomeChar!C) @safe unittest { import std.conv : text; - import std.string : split; + import std.array : split; // Check consistency: // All flavors of split should produce the same results @@ -5624,7 +5625,7 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles)))) @safe unittest { - import std.string : toUpper; + import std.uni : toUpper; debug(std_algorithm) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done."); @@ -10383,7 +10384,7 @@ unittest unittest { import std.random : Random, unpredictableSeed, uniform; - import std.string : toUpper; + import std.uni : toUpper; debug(std_algorithm) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done."); diff --git a/std/array.d b/std/array.d index 231c640088b..0d737c6556b 100644 --- a/std/array.d +++ b/std/array.d @@ -1250,7 +1250,7 @@ if (isSomeString!S) unittest { import std.conv : to; - import std.string; + import std.format; import std.typecons; static auto makeEntry(S)(string l, string[] r) @@ -2702,7 +2702,7 @@ unittest{ unittest { - import std.string : format; + import std.format : format; auto app = appender!(int[])(); app.put(1); app.put(2); diff --git a/std/bitmanip.d b/std/bitmanip.d index 55ecb8820a1..ad498acd6ee 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -1570,7 +1570,7 @@ public: /// unittest { - import std.string : format; + import std.format : format; debug(bitarray) printf("BitArray.toString unittest\n"); BitArray b; @@ -1680,7 +1680,7 @@ public: unittest { - import std.string : format; + import std.format : format; BitArray b; @@ -3424,7 +3424,7 @@ unittest unittest { - import std.string : format; + import std.format : format; import std.array; import std.typetuple; foreach(endianness; TypeTuple!(Endian.bigEndian, Endian.littleEndian)) diff --git a/std/complex.d b/std/complex.d index b7d1b51ad45..ceb06f810f4 100644 --- a/std/complex.d +++ b/std/complex.d @@ -141,7 +141,7 @@ struct Complex(T) if (isFloatingPoint!T) // Formatting with std.string.format specs: the precision and width // specifiers apply to both the real and imaginary parts of the // complex number. - import std.string : format; + import std.format : format; assert(format("%.2f", c) == "1.20+3.40i"); assert(format("%4.1f", c) == " 1.2+ 3.4i"); } @@ -866,7 +866,7 @@ unittest // Issue 10881: support %f formatting of complex numbers unittest { - import std.string : format; + import std.format : format; auto x = complex(1.2, 3.4); assert(format("%.2f", x) == "1.20+3.40i"); diff --git a/std/csv.d b/std/csv.d index 4774ddeae93..6f50c1e814a 100644 --- a/std/csv.d +++ b/std/csv.d @@ -1209,7 +1209,7 @@ public: void popFront() { static if (ErrorLevel == Malformed.throwException) - import std.string : format; + import std.format : format; // Skip last of record when header is depleted. if (_popCount.ptr && _popCount.empty) while(!recordEnd()) diff --git a/std/datetime.d b/std/datetime.d index 156b523196f..09640c35a0a 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -496,7 +496,7 @@ private: +/ struct SysTime { - import std.string : format; + import std.format : format; import std.typecons : Rebindable; public: @@ -8835,7 +8835,7 @@ private: +/ struct Date { - import std.string : format; + import std.format : format; public: @@ -13079,7 +13079,7 @@ private: +/ struct TimeOfDay { - import std.string : format; + import std.format : format; public: @@ -14294,7 +14294,7 @@ private: +/ struct DateTime { - import std.string : format; + import std.format : format; public: @@ -17298,7 +17298,7 @@ private: +/ struct Interval(TP) { - import std.string : format; + import std.format : format; public: @@ -20198,7 +20198,7 @@ unittest +/ struct PosInfInterval(TP) { - import std.string : format; + import std.format : format; public: @@ -22385,7 +22385,7 @@ unittest +/ struct NegInfInterval(TP) { - import std.string : format; + import std.format : format; public: @@ -25087,7 +25087,7 @@ unittest struct IntervalRange(TP, Direction dir) if(isTimePoint!TP && dir != Direction.both) { - import std.string : format; + import std.format : format; public: @@ -25585,7 +25585,7 @@ unittest struct PosInfIntervalRange(TP) if(isTimePoint!TP) { - import std.string : format; + import std.format : format; public: @@ -25873,7 +25873,7 @@ unittest struct NegInfIntervalRange(TP) if(isTimePoint!TP) { - import std.string : format; + import std.format : format; public: @@ -26136,7 +26136,7 @@ unittest +/ abstract class TimeZone { - import std.string : format; + import std.format : format; public: /++ @@ -26277,7 +26277,7 @@ auto tz = TimeZone.getTimeZone("America/Los_Angeles"); return PosixTimeZone.getTimeZone(name); else version(Windows) { - import std.string : format; + import std.format : format; if(auto windowsTZName = tzDatabaseNameToWindowsTZName(name)) { try @@ -27258,7 +27258,7 @@ private: +/ final class UTC : TimeZone { - import std.string : format; + import std.format : format; public: @@ -27392,7 +27392,7 @@ private: +/ final class SimpleTimeZone : TimeZone { - import std.string : format; + import std.format : format; public: @@ -28718,7 +28718,7 @@ else version(Windows) { final class WindowsTimeZone : TimeZone { - import std.string : format; + import std.format : format; import std.conv : to; import std.algorithm : sort; import std.array : appender; @@ -29547,7 +29547,7 @@ string tzDatabaseNameToWindowsTZName(string tzName) @safe pure nothrow @nogc version(Windows) unittest { - import std.string : format; + import std.format : format; foreach(tzName; TimeZone.getInstalledTZNames()) assert(tzDatabaseNameToWindowsTZName(tzName) !is null, format("TZName which failed: %s", tzName)); } @@ -29692,7 +29692,7 @@ string windowsTZNameToTZDatabaseName(string tzName) @safe pure nothrow @nogc version(Windows) unittest { - import std.string : format; + import std.format : format; foreach(tzName; WindowsTimeZone.getInstalledTZNames()) assert(windowsTZNameToTZDatabaseName(tzName) !is null, format("TZName which failed: %s", tzName)); } @@ -30205,7 +30205,7 @@ static bool yearIsLeapYear(int year) @safe pure nothrow unittest { - import std.string : format; + import std.format : format; foreach(year; [1, 2, 3, 5, 6, 7, 100, 200, 300, 500, 600, 700, 1998, 1999, 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010, 2011]) { @@ -31471,7 +31471,7 @@ bool validTimeUnits(string[] units...) @safe pure nothrow +/ int cmpTimeUnits(string lhs, string rhs) @safe pure { - import std.string : format; + import std.format : format; import std.algorithm : countUntil; auto tstrings = timeStrings; @@ -31643,7 +31643,7 @@ void enforceValid(string units)(int value, string file = __FILE__, size_t line = units == "minutes" || units == "seconds") { - import std.string : format; + import std.format : format; static if(units == "months") { @@ -31685,7 +31685,7 @@ void enforceValid(string units) (int year, Month month, int day, string file = __FILE__, size_t line = __LINE__) @safe pure if(units == "days") { - import std.string : format; + import std.format : format; if(!valid!"days"(year, month, day)) throw new DateTimeException(format("%s is not a valid day in %s in %s", day, month, year), file, line); } @@ -32317,7 +32317,7 @@ unittest +/ string monthToString(Month month) @safe pure { - import std.string : format; + import std.format : format; assert(month >= Month.jan && month <= Month.dec, format("Invalid month: %s", month)); return _monthNames[month - Month.jan]; } @@ -32350,7 +32350,7 @@ unittest +/ Month monthFromString(string monthStr) @safe pure { - import std.string : format; + import std.format : format; switch(monthStr) { case "Jan": @@ -32456,7 +32456,7 @@ unittest +/ static string fracSecsToISOString(int hnsecs) @safe pure nothrow { - import std.string : format; + import std.format : format; assert(hnsecs >= 0); try diff --git a/std/net/isemail.d b/std/net/isemail.d index a6dd1d1ccbf..c920e60f96e 100644 --- a/std/net/isemail.d +++ b/std/net/isemail.d @@ -1301,7 +1301,7 @@ struct EmailStatus /// Returns a textual representation of the email status string toString () { - import std.string; + import std.format : format; return format("EmailStatus\n{\n\tvalid: %s\n\tlocalPart: %s\n\tdomainPart: %s\n\tstatusCode: %s\n}", valid, localPart, domainPart, statusCode); } diff --git a/std/parallelism.d b/std/parallelism.d index 79312035975..5200563e9e8 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -4187,7 +4187,7 @@ unittest void next(ref char[] buf) { file.readln(buf); - import std.string; + import std.string : chomp; buf = chomp(buf); } diff --git a/std/path.d b/std/path.d index 4542d056756..61cf36d2c8e 100644 --- a/std/path.d +++ b/std/path.d @@ -2895,12 +2895,14 @@ string expandTilde(string inputPath) } else { + import std.string : indexOf; + assert(path.length > 2 || (path.length == 2 && !isDirSeparator(path[1]))); assert(path[0] == '~'); // Extract username, searching for path separator. string username; - auto last_char = std.string.indexOf(path, dirSeparator[0]); + auto last_char = indexOf(path, dirSeparator[0]); if (last_char == -1) { diff --git a/std/regex/internal/tests.d b/std/regex/internal/tests.d index a4b2c88901c..2f3b9414c27 100644 --- a/std/regex/internal/tests.d +++ b/std/regex/internal/tests.d @@ -646,14 +646,14 @@ unittest { void test(alias matchFn)() { - import std.string : toUpper; + import std.uni : toUpper; foreach(i, v; TypeTuple!(string, wstring, dstring)) { auto baz(Cap)(Cap m) if (is(Cap == Captures!(Cap.String))) { - return std.string.toUpper(m.hit); + return toUpper(m.hit); } alias String = v; assert(std.regex.replace!(matchFn)(to!String("ark rapacity"), regex(to!String("r")), to!String("c")) diff --git a/std/stdio.d b/std/stdio.d index b45bb43e2ac..39f40b8985e 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -490,7 +490,7 @@ Throws: $(D ErrnoException) in case of error. void windowsHandleOpen(HANDLE handle, in char[] stdioOpenmode) { import std.exception : errnoEnforce; - import std.string : format; + import std.format : format; // Create file descriptors from the handles version (DIGITAL_MARS_STDIO) @@ -630,7 +630,7 @@ Throws: $(D ErrnoException) on error. scope(exit) _p.handle = null; // nullify the handle anyway version (Posix) { - import std.string : format; + import std.format : format; if (_p.isPopened) { diff --git a/std/traits.d b/std/traits.d index f4e60761beb..4539bb98230 100644 --- a/std/traits.d +++ b/std/traits.d @@ -534,7 +534,7 @@ unittest private template fqnType(T, bool alreadyConst, bool alreadyImmutable, bool alreadyShared, bool alreadyInout) { - import std.string : format; + import std.format : format; // Convenience tags enum { @@ -740,7 +740,7 @@ private template fqnType(T, unittest { - import std.string : format; + import std.format : format; alias fqn = fullyQualifiedName; // Verify those 2 are the same for simple case diff --git a/std/uni.d b/std/uni.d index fcff5333665..6c76c54caf2 100644 --- a/std/uni.d +++ b/std/uni.d @@ -2350,7 +2350,7 @@ public: unittest { import std.conv : to; - import std.string : format; + import std.format : format; import std.uni : unicode; assert(unicode.Cyrillic.to!string == @@ -2369,7 +2369,7 @@ public: unittest { import std.exception : assertThrown; - import std.string : format; + import std.format : format; assertThrown!FormatException(format("%a", unicode.ASCII)); } @@ -2538,7 +2538,7 @@ public: string toSourceCode(string funcName="") { import std.array : array; - import std.string : format; + import std.format : format; import std.algorithm : countUntil; enum maxBinary = 3; static string linearScope(R)(R ivals, string indent) @@ -4740,7 +4740,7 @@ template Utf8Matcher() // from 3 primitives: tab!(size), lookup and Sizes mixin template DefMatcher() { - import std.string : format; + import std.format : format; enum hasASCII = staticIndexOf!(1, Sizes) >= 0; alias UniSizes = Erase!(1, Sizes); @@ -5376,7 +5376,7 @@ package auto units(C)(C[] s) unittest { import std.exception : collectException; - import std.string : format; + import std.format : format; import std.algorithm; auto utf16 = utfMatcher!wchar(unicode.L); auto utf8 = utfMatcher!char(unicode.L); @@ -8496,7 +8496,7 @@ S toLower(S)(S s) @trusted pure @trusted unittest //@@@BUG std.format is not @safe { - import std.string : format; + import std.format : format; foreach(ch; 0..0x80) assert(std.ascii.toLower(ch) == toLower(ch)); assert(toLower('Я') == 'я'); @@ -8603,7 +8603,7 @@ dchar toUpper(dchar c) @trusted unittest { - import std.string : format; + import std.format : format; foreach(ch; 0..0x80) assert(std.ascii.toUpper(ch) == toUpper(ch)); assert(toUpper('я') == 'Я'); @@ -8671,7 +8671,7 @@ unittest { static void doTest(C)(const(C)[] s, const(C)[] trueUp, const(C)[] trueLow) { - import std.string : format; + import std.format : format; string diff = "src: %( %x %)\nres: %( %x %)\ntru: %( %x %)"; auto low = s.toLower() , up = s.toUpper(); auto lowInp = s.dup, upInp = s.dup; @@ -8834,7 +8834,7 @@ bool isSymbol(dchar c) unittest { - import std.string; + import std.format : format; assert(isSymbol('\u0024')); assert(isSymbol('\u002B')); assert(isSymbol('\u005E')); @@ -8881,7 +8881,7 @@ bool isGraphical(dchar c) unittest { auto set = unicode("Graphical"); - import std.string; + import std.format : format; foreach(ch; set.byCodepoint) assert(isGraphical(ch), format("%4x", ch)); foreach(ch; 0..0x4000) diff --git a/std/uri.d b/std/uri.d index 1f5b744d5b9..ac960b0945e 100644 --- a/std/uri.d +++ b/std/uri.d @@ -397,19 +397,19 @@ size_t uriLength(Char)(in Char[] s) if (isSomeChar!Char) * https:// * www. */ - import std.string : icmp; + import std.uni : icmp; size_t i; if (s.length <= 4) return -1; - if (s.length > 7 && std.string.icmp(s[0 .. 7], "http://") == 0) { + if (s.length > 7 && icmp(s[0 .. 7], "http://") == 0) { i = 7; } else { - if (s.length > 8 && std.string.icmp(s[0 .. 8], "https://") == 0) + if (s.length > 8 && icmp(s[0 .. 8], "https://") == 0) i = 8; else return -1; diff --git a/std/uuid.d b/std/uuid.d index d03b5a96f20..00b31ad0d97 100644 --- a/std/uuid.d +++ b/std/uuid.d @@ -1565,7 +1565,7 @@ public class UUIDParsingException : Exception Throwable next = null, string file = __FILE__, size_t line = __LINE__) pure @trusted { import std.array : replace; - import std.string : format; + import std.format : format; this.input = input; this.position = pos; this.reason = why; diff --git a/std/variant.d b/std/variant.d index bcc12049a96..c625147dd4f 100644 --- a/std/variant.d +++ b/std/variant.d @@ -954,7 +954,7 @@ public: { string tryUseType(string tp) { - import std.string : format; + import std.format : format; return q{ static if (allowed!%1$s && T.allowed!%1$s) if (convertsTo!%1$s && other.convertsTo!%1$s)