Showing with 20 additions and 9 deletions.
  1. +18 −8 src/rt/config.d
  2. +2 −1 src/rt/lifetime.d
26 changes: 18 additions & 8 deletions src/rt/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ string rt_configOption(string opt, scope rt_configCallBack dg = null, bool rever
if (!dg)
dg = (string s) => s;

if (string s = (reverse ? rt_linkOption(opt, dg) : rt_cmdlineOption(opt, dg)))
string s = (reverse ? rt_linkOption(opt, dg) : rt_cmdlineOption(opt, dg));
if (s != null)
return s;
if (string s = rt_envvarsOption(opt, dg))
s = rt_envvarsOption(opt, dg);
if (s != null)
return s;
if (string s = (reverse ? rt_cmdlineOption(opt, dg) : rt_linkOption(opt, dg)))
return s;
return null;
s = (reverse ? rt_cmdlineOption(opt, dg) : rt_linkOption(opt, dg));
return s;
}

string rt_cmdlineOption(string opt, scope rt_configCallBack dg) @nogc nothrow
Expand All @@ -97,8 +98,11 @@ string rt_cmdlineOption(string opt, scope rt_configCallBack dg) @nogc nothrow
{
if (a.length >= opt.length + 7 && a[0..6] == "--DRT-" &&
a[6 .. 6 + opt.length] == opt && a[6 + opt.length] == '=')
if (string s = dg(a[7 + opt.length .. $]))
{
string s = dg(a[7 + opt.length .. $]);
if (s != null)
return s;
}
}
}
return null;
Expand All @@ -119,8 +123,11 @@ string rt_envvarsOption(string opt, scope rt_configCallBack dg) @nogc nothrow

auto p = getenv(var.ptr);
if (p)
if (string s = dg(cast(string) p[0 .. strlen(p)]))
{
string s = dg(cast(string) p[0 .. strlen(p)]);
if (s != null)
return s;
}
}
return null;
}
Expand All @@ -130,8 +137,11 @@ string rt_linkOption(string opt, scope rt_configCallBack dg) @nogc nothrow
foreach (a; rt_options!())
{
if(a.length > opt.length && a[0..opt.length] == opt && a[opt.length] == '=')
if (string s = dg(a[opt.length + 1 .. $]))
{
string s = dg(a[opt.length + 1 .. $]);
if (s != null)
return s;
}
}
return null;
}
3 changes: 2 additions & 1 deletion src/rt/lifetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ extern (C) void lifetime_init()
{
// this is run before static ctors, so it is safe to modify immutables
import rt.config;
if (string s = rt_configOption("callStructDtorsDuringGC"))
string s = rt_configOption("callStructDtorsDuringGC");
if (s != null)
cast() callStructDtorsDuringGC = s[0] == '1' || s[0] == 'y' || s[0] == 'Y';
else
cast() callStructDtorsDuringGC = true;
Expand Down