summaryrefslogtreecommitdiff
path: root/libphobos/src/std/getopt.d
diff options
context:
space:
mode:
Diffstat (limited to 'libphobos/src/std/getopt.d')
-rw-r--r--libphobos/src/std/getopt.d8
1 files changed, 5 insertions, 3 deletions
diff --git a/libphobos/src/std/getopt.d b/libphobos/src/std/getopt.d
index 482aae6306a..c1c5cd2b36e 100644
--- a/libphobos/src/std/getopt.d
+++ b/libphobos/src/std/getopt.d
@@ -438,7 +438,7 @@ GetoptResult getopt(T...)(ref string[] args, T opts)
}
///
-@system unittest
+@safe unittest
{
auto args = ["prog", "--foo", "-b"];
@@ -1646,11 +1646,13 @@ Params:
text = The text to printed at the beginning of the help output.
opt = The `Option` extracted from the `getopt` parameter.
*/
-void defaultGetoptPrinter(string text, Option[] opt)
+void defaultGetoptPrinter(string text, Option[] opt) @safe
{
import std.stdio : stdout;
+ // stdout global __gshared is trusted with a locked text writer
+ auto w = (() @trusted => stdout.lockingTextWriter())();
- defaultGetoptFormatter(stdout.lockingTextWriter(), text, opt);
+ defaultGetoptFormatter(w, text, opt);
}
/** This function writes the passed text and `Option` into an output range