From 882a1fb8f62b872f3463e9fca2b2e1e04d36effb Mon Sep 17 00:00:00 2001 From: byebye Date: Mon, 30 Jan 2017 18:53:40 +0100 Subject: [PATCH] Fix issue #8471 - allow only pointers as readf parameters --- changelog/std-stdio-readf-only-pointers.dd | 2 ++ std/stdio.d | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog/std-stdio-readf-only-pointers.dd diff --git a/changelog/std-stdio-readf-only-pointers.dd b/changelog/std-stdio-readf-only-pointers.dd new file mode 100644 index 000000000..1bf248a19 --- /dev/null +++ b/changelog/std-stdio-readf-only-pointers.dd @@ -0,0 +1,2 @@ +`std.stdio.readf` now only accepts pointers as input arguments. + diff --git a/std/stdio.d b/std/stdio.d index e80a91a6b..5b6972802 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -16,13 +16,13 @@ module std.stdio; public import core.stdc.stdio; import core.stdc.stddef; // wchar_t import std.algorithm.mutation; // copy +import std.meta; // allSatisfy import std.range.primitives; // ElementEncodingType, empty, front, // isBidirectionalRange, isInputRange, put import std.stdiobase; -import std.traits; // isSomeChar, isSomeString, Unqual +import std.traits; // isSomeChar, isSomeString, Unqual, isPointer import std.typecons; // Flag - /++ If flag $(D KeepTerminator) is set to $(D KeepTerminator.yes), then the delimiter is included in the strings returned. @@ -1769,6 +1769,7 @@ is recommended if you want to process a complete file. * $(REF formattedRead, std,_format). */ uint readf(Data...)(in char[] format, Data data) + if (allSatisfy!(isPointer, Data)) { import std.format : formattedRead; @@ -3646,6 +3647,7 @@ void writefln(T...)(T args) * $(REF formattedRead, std,_format). */ uint readf(A...)(in char[] format, A args) +if (allSatisfy!(isPointer, A)) { return stdin.readf(format, args); }