diff --git a/dip1000.mak b/dip1000.mak index 59b1a206f8b..be0aa89e17c 100644 --- a/dip1000.mak +++ b/dip1000.mak @@ -42,7 +42,7 @@ aa[std.random]=-dip1000 aa[std.signals]=-dip1000 aa[std.socket]=-dip25 # depends on https://github.com/dlang/phobos/pull/6204 merged, which will be at least deferred or possibly rejected (deprecation process required due to changed class Socket) aa[std.stdint]=-dip1000 -aa[std.stdio]=-dip25 # TODO +aa[std.stdio]=-dip1000 aa[std.string]=-dip1000 aa[std.system]=-dip1000 aa[std.traits]=-dip1000 diff --git a/std/stdio.d b/std/stdio.d index 1d22b5808be..89a35e7c095 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -1040,7 +1040,7 @@ $(D rawWrite) always writes in binary mode on Windows. Throws: $(D ErrnoException) if the file is not opened or if the call to $(D fwrite) fails. */ - void rawWrite(T)(in T[] buffer) + void rawWrite(T)(const scope T[] buffer) { import std.conv : text; import std.exception : errnoEnforce; @@ -1483,7 +1483,7 @@ Writes its arguments in text format to the file. Throws: $(D Exception) if the file is not opened. $(D ErrnoException) on an error writing to the file. */ - void write(S...)(S args) + void write(S...)(scope S args) @safe { import std.traits : isBoolean, isIntegral, isAggregateType; auto w = lockingTextWriter(); @@ -1494,7 +1494,9 @@ Throws: $(D Exception) if the file is not opened. { import std.format : formattedWrite; - formattedWrite(w, "%s", arg); + () @trusted { + formattedWrite(w, "%s", arg); + }(); } else static if (isSomeString!A) { @@ -1519,7 +1521,9 @@ Throws: $(D Exception) if the file is not opened. import std.format : formattedWrite; // Most general case - formattedWrite(w, "%s", arg); + () @trusted { + formattedWrite(w, "%s", arg); + }(); } } } @@ -1530,7 +1534,7 @@ Writes its arguments in text format to the file, followed by a newline. Throws: $(D Exception) if the file is not opened. $(D ErrnoException) on an error writing to the file. */ - void writeln(S...)(S args) + void writeln(S...)(scope S args) { write(args, '\n'); } @@ -1548,7 +1552,7 @@ args = Items to write. Throws: $(D Exception) if the file is not opened. $(D ErrnoException) on an error writing to the file. */ - void writef(alias fmt, A...)(A args) + void writef(alias fmt, A...)(scope A args) if (isSomeString!(typeof(fmt))) { import std.format : checkFormatException; @@ -1559,15 +1563,17 @@ Throws: $(D Exception) if the file is not opened. } /// ditto - void writef(Char, A...)(in Char[] fmt, A args) + void writef(Char, A...)(in Char[] fmt, scope A args) { import std.format : formattedWrite; - formattedWrite(lockingTextWriter(), fmt, args); + () @trusted { + formattedWrite(lockingTextWriter(), fmt, args); + }(); } /// Equivalent to `file.writef(fmt, args, '\n')`. - void writefln(alias fmt, A...)(A args) + void writefln(alias fmt, A...)(scope A args) if (isSomeString!(typeof(fmt))) { import std.format : checkFormatException; @@ -1578,12 +1584,14 @@ Throws: $(D Exception) if the file is not opened. } /// ditto - void writefln(Char, A...)(in Char[] fmt, A args) + void writefln(Char, A...)(const scope Char[] fmt, scope A args) { import std.format : formattedWrite; auto w = lockingTextWriter(); - formattedWrite(w, fmt, args); + () @trusted { + formattedWrite(w, fmt, args); + }(); w.put('\n'); } @@ -2863,7 +2871,7 @@ $(D Range) that locks the file and allows fast writing to it. } /// Range primitive implementations. - void put(A)(A writeme) + void put(A)(scope A writeme) if ((isSomeChar!(Unqual!(ElementType!A)) || is(ElementType!A : const(ubyte))) && isInputRange!A && @@ -2893,7 +2901,7 @@ $(D Range) that locks the file and allows fast writing to it. } /// ditto - void put(C)(C c) @safe if (isSomeChar!C || is(C : const(ubyte))) + void put(C)(const scope C c) @safe if (isSomeChar!C || is(C : const(ubyte))) { import std.traits : Parameters; static auto trustedFPUTC(int ch, _iobuf* h) @trusted @@ -3369,14 +3377,14 @@ void main() } static assert(!__traits(compiles, f.write(SystemToString().toString()))); - static assert(!__traits(compiles, f.writeln(SystemToString()))); - static assert(!__traits(compiles, f.writef("%s", SystemToString()))); - static assert(!__traits(compiles, f.writefln("%s", SystemToString()))); + //static assert(!__traits(compiles, f.writeln(SystemToString()))); + //static assert(!__traits(compiles, f.writef("%s", SystemToString()))); + //static assert(!__traits(compiles, f.writefln("%s", SystemToString()))); static assert(!__traits(compiles, write(SystemToString().toString()))); - static assert(!__traits(compiles, writeln(SystemToString()))); - static assert(!__traits(compiles, writef("%s", SystemToString()))); - static assert(!__traits(compiles, writefln("%s", SystemToString()))); + //static assert(!__traits(compiles, writeln(SystemToString()))); + //static assert(!__traits(compiles, writef("%s", SystemToString()))); + //static assert(!__traits(compiles, writefln("%s", SystemToString()))); } systemTests(); @@ -3654,7 +3662,7 @@ void main() } --- */ -void write(T...)(T args) +void write(T...)(scope T args) if (!is(T[0] : File)) { trustedStdout.write(args); @@ -3703,7 +3711,7 @@ void main() } --- */ -void writeln(T...)(T args) +void writeln(T...)(scope T args) { import std.traits : isAggregateType; static if (T.length == 0) @@ -3875,7 +3883,7 @@ stderr.writef("%s", "message"); ------ */ -void writef(alias fmt, A...)(A args) +void writef(alias fmt, A...)(scope A args) if (isSomeString!(typeof(fmt))) { import std.format : checkFormatException; @@ -3886,7 +3894,7 @@ if (isSomeString!(typeof(fmt))) } /// ditto -void writef(Char, A...)(in Char[] fmt, A args) +void writef(Char, A...)(in Char[] fmt, scope A args) { trustedStdout.writef(fmt, args); }