Skip to content

Commit

Permalink
Fix five modules where imports were made more local and selective.
Browse files Browse the repository at this point in the history
  • Loading branch information
joakim-noah committed Jun 3, 2016
1 parent 97a8e79 commit a839be6
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 84 deletions.
5 changes: 2 additions & 3 deletions std/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ version (Win64)

static import core.math;
static import core.stdc.math;
import std.traits;// CommonType, isFloatingPoint, isIntegral, isSigned, isUnsigned, Largest, Unqual
import std.traits; // CommonType, isFloatingPoint, isIntegral, isSigned, isUnsigned, Largest, Unqual

version(LDC)
{
Expand Down Expand Up @@ -158,7 +158,7 @@ else version(D_InlineAsm_X86_64)

version(unittest)
{
import core.stdc.stdio : sprintf;
import core.stdc.stdio; // : sprintf;

static if (real.sizeof > double.sizeof)
enum uint useDigits = 16;
Expand Down Expand Up @@ -5267,7 +5267,6 @@ int signbit(X)(X x) @nogc @trusted pure nothrow
///
@nogc @safe pure nothrow unittest
{
debug (math) printf("math.signbit.unittest\n");
assert(!signbit(float.nan));
assert(signbit(-float.nan));
assert(!signbit(168.1234f));
Expand Down
44 changes: 18 additions & 26 deletions std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ Authors: $(WEB digitalmars.com, Walter Bright),
module std.stdio;

public import core.stdc.stdio;
import core.stdc.stddef;// wchar_t
import core.stdc.stddef; // wchar_t
import std.algorithm.mutation; // copy
import std.range.primitives;// ElementEncodingType, front, isBidirectionalRange, isInputRange
import std.range.primitives; // ElementEncodingType, empty, front,
// isBidirectionalRange, isInputRange, put
import std.stdiobase;
import std.traits;// isSomeChar, isSomeString, Unqual
import std.typecons;// Flag
import std.traits; // isSomeChar, isSomeString, Unqual
import std.typecons; // Flag


/++
Expand Down Expand Up @@ -279,7 +280,6 @@ public:
import std.conv : text;
import std.exception : enforce;
import std.format : formattedRead;
import std.range.primitives : empty;
import std.string : chomp;

enforce(file.isOpen, "ByRecord: File must be open");
Expand Down Expand Up @@ -346,8 +346,8 @@ Hello, Jimmy!
*/
struct File
{
import std.traits : isScalarType, isArray;
import std.range.primitives : ElementEncodingType;
import std.traits : isScalarType, isArray;
enum Orientation { unknown, narrow, wide }

private struct Impl
Expand Down Expand Up @@ -513,8 +513,8 @@ Throws: $(D ErrnoException) in case of error.

package void fdopen(int fd, in char[] stdioOpenmode, string name) @trusted
{
import std.internal.cstring : tempCString;
import std.exception : errnoEnforce;
import std.internal.cstring : tempCString;

auto modez = stdioOpenmode.tempCString();
detach();
Expand Down Expand Up @@ -708,8 +708,8 @@ Throws: $(D ErrnoException) on error.
scope(exit) _p.handle = null; // nullify the handle anyway
version (Posix)
{
import std.format : format;
import core.sys.posix.stdio : pclose;
import std.format : format;

if (_p.isPopened)
{
Expand Down Expand Up @@ -820,7 +820,7 @@ $(D rawRead) always reads in binary mode on Windows.
scope(exit) ._setmode(fd, mode);
version(DIGITAL_MARS_STDIO)
{
import core.atomic;
import core.atomic : atomicOp;

// @@@BUG@@@ 4243
immutable info = __fhnd_info[fd];
Expand Down Expand Up @@ -877,7 +877,7 @@ Throws: $(D ErrnoException) if the file is not opened or if the call to $(D fwri
scope(exit) ._setmode(fd, mode);
version(DIGITAL_MARS_STDIO)
{
import core.atomic;
import core.atomic : atomicOp;

// @@@BUG@@@ 4243
immutable info = __fhnd_info[fd];
Expand Down Expand Up @@ -918,8 +918,8 @@ Throws: $(D Exception) if the file is not opened.
*/
void seek(long offset, int origin = SEEK_SET) @trusted
{
import std.exception : enforce, errnoEnforce;
import std.conv : to, text;
import std.exception : enforce, errnoEnforce;

enforce(isOpen, "Attempting to seek() in an unopened file");
version (Windows)
Expand Down Expand Up @@ -947,6 +947,7 @@ Throws: $(D Exception) if the file is not opened.
unittest
{
static import std.file;
import std.conv : text;

auto deleteme = testFilename();
auto f = File(deleteme, "w+");
Expand All @@ -955,8 +956,6 @@ Throws: $(D Exception) if the file is not opened.
f.seek(7);
assert(f.readln() == "hijklmnopqrstuvwxyz");

import std.conv : text;

version (CRuntime_DigitalMars)
auto bigOffset = int.max - 100;
else
Expand Down Expand Up @@ -1099,9 +1098,9 @@ Throws: $(D Exception) if the file is not opened.
private int lockImpl(int operation, short l_type,
ulong start, ulong length)
{
import std.conv : to;
import core.sys.posix.fcntl : fcntl, flock, off_t;
import core.sys.posix.unistd : getpid;
import std.conv : to;

flock fl = void;
fl.l_type = l_type;
Expand Down Expand Up @@ -1316,7 +1315,6 @@ Throws: $(D Exception) if the file is not opened.
}
else static if (isSomeString!A)
{
import std.range.primitives : put;
put(w, arg);
}
else static if (isIntegral!A)
Expand All @@ -1331,7 +1329,6 @@ Throws: $(D Exception) if the file is not opened.
}
else static if (isSomeChar!A)
{
import std.range.primitives : put;
put(w, arg);
}
else
Expand Down Expand Up @@ -1623,7 +1620,7 @@ is recommended if you want to process a complete file.
{
import std.algorithm.mutation : swap;
import std.algorithm.searching : endsWith;
import std.range.primitives : back, empty;
import std.range.primitives : back;

auto last = terminator.back;
C[] buf2;
Expand Down Expand Up @@ -1853,7 +1850,6 @@ Allows to directly use range operations on lines of a file.
void popFront()
{
import std.algorithm.searching : endsWith;
import std.range.primitives : empty;
assert(file.isOpen);
line = buffer;
file.readln(line, terminator);
Expand Down Expand Up @@ -2130,9 +2126,9 @@ $(REF readText, std,file)
void test(Terminator)(string txt, in string[] witness,
KeepTerminator kt, Terminator term, bool popFirstLine = false)
{
import std.algorithm.sorting : sort;
import std.array : array;
import std.conv : text;
import std.algorithm.sorting : sort;
import std.range.primitives : walkLength;

uint i;
Expand Down Expand Up @@ -2722,7 +2718,7 @@ See $(LREF byChunk) for an example.
oldMode = ._setmode(fd, _O_BINARY);
version (DIGITAL_MARS_STDIO)
{
import core.atomic;
import core.atomic : atomicOp;

// @@@BUG@@@ 4243
oldInfo = __fhnd_info[fd];
Expand Down Expand Up @@ -2838,11 +2834,10 @@ void main()

unittest
{
import std.algorithm.mutation : reverse;
static import std.file;
import std.algorithm.mutation : reverse;
import std.exception : collectException;
import std.range : only, retro;
import std.range.primitives : put;
import std.string : format;

auto deleteme = testFilename();
Expand Down Expand Up @@ -3896,8 +3891,8 @@ struct lines
// no UTF checking
int opApplyRaw(D)(scope D dg)
{
import std.exception : assumeUnique;
import std.conv : to;
import std.exception : assumeUnique;
import std.traits : Parameters;

alias Parms = Parameters!(dg);
Expand Down Expand Up @@ -4533,8 +4528,6 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orie
version (MICROSOFT_STDIO)
private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orientation /*ignored*/)
{
import core.memory;

FLOCK(fps);
scope(exit) FUNLOCK(fps);

Expand Down Expand Up @@ -4567,7 +4560,6 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orie
version (HAS_GETDELIM)
private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orientation orientation)
{
import core.memory;
import core.stdc.stdlib : free;
import core.stdc.wchar_ : fwide;

Expand Down
8 changes: 4 additions & 4 deletions std/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -1627,8 +1627,8 @@ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,

@safe pure unittest
{
import std.exception : assertCTFEable;
import std.conv : to;
import std.exception : assertCTFEable;

debug(string) trustedPrintf("string.indexOfAny.unittest\n");

Expand Down Expand Up @@ -2867,10 +2867,10 @@ auto stripLeft(Range)(Range input)
}
else
{
auto inputSave = input.save;
auto save = input.save;
auto dc = decodeFront(input);
if (!std.uni.isWhite(dc))
return inputSave;
return save;
}
}
return input;
Expand Down Expand Up @@ -6028,8 +6028,8 @@ bool isNumeric(S)(S s, bool bAllowSep = false) if (isSomeString!S ||
// test ranges
pure unittest
{
import std.utf : byCodeUnit;
import std.range : refRange;
import std.utf : byCodeUnit;

assert("123".byCodeUnit.isNumeric());
assert("123UL".byCodeUnit.isNumeric());
Expand Down
6 changes: 4 additions & 2 deletions std/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -5439,6 +5439,7 @@ unittest

unittest
{
import std.meta : AliasSeq;
foreach (T; AliasSeq!(int[], char[], string, long[3][], double[string][]))
{
foreach (Q; TypeQualifierList)
Expand Down Expand Up @@ -5469,6 +5470,7 @@ unittest

unittest
{
import std.meta : AliasSeq;
foreach (T; AliasSeq!(int[], int[5], void[]))
{
foreach (Q; TypeQualifierList)
Expand Down Expand Up @@ -6826,7 +6828,7 @@ unittest
* nested structs or unions.
*/
template getSymbolsByUDA(alias symbol, alias attribute) {
import std.string : format;
import std.format : format;
import std.meta : AliasSeq, Filter;

// translate a list of strings into symbols. mixing in the entire alias
Expand Down Expand Up @@ -6919,7 +6921,7 @@ unittest
unittest
{
// HasPrivateMembers has, well, private members, one of which has a UDA.
import std.internal.test.uda;
import std.internal.test.uda : Attr, HasPrivateMembers;
static assert(getSymbolsByUDA!(HasPrivateMembers, Attr).length == 2);
static assert(hasUDA!(getSymbolsByUDA!(HasPrivateMembers, Attr)[0], Attr));
static assert(hasUDA!(getSymbolsByUDA!(HasPrivateMembers, Attr)[1], Attr));
Expand Down
Loading

0 comments on commit a839be6

Please sign in to comment.