Allow stdin everywhere fix #317
This commit is contained in:
parent
f283650c12
commit
0aee4eaf40
|
@ -117,7 +117,7 @@ void generateReport(string[] fileNames, const StaticAnalysisConfig config,
|
||||||
ulong lineOfCodeCount;
|
ulong lineOfCodeCount;
|
||||||
foreach (fileName; fileNames)
|
foreach (fileName; fileNames)
|
||||||
{
|
{
|
||||||
auto code = fileName == "stdin" ? readStdin() : readFile(fileName);
|
auto code = readFile(fileName);
|
||||||
// Skip files that could not be read and continue with the rest
|
// Skip files that could not be read and continue with the rest
|
||||||
if (code.length == 0)
|
if (code.length == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -155,7 +155,7 @@ bool analyze(string[] fileNames, const StaticAnalysisConfig config,
|
||||||
bool hasErrors = false;
|
bool hasErrors = false;
|
||||||
foreach (fileName; fileNames)
|
foreach (fileName; fileNames)
|
||||||
{
|
{
|
||||||
auto code = fileName == "stdin" ? readStdin() : readFile(fileName);
|
auto code = readFile(fileName);
|
||||||
// Skip files that could not be read and continue with the rest
|
// Skip files that could not be read and continue with the rest
|
||||||
if (code.length == 0)
|
if (code.length == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -33,7 +33,7 @@ void printCtags(File output, string[] fileNames)
|
||||||
foreach (fileName; fileNames)
|
foreach (fileName; fileNames)
|
||||||
{
|
{
|
||||||
RollbackAllocator rba;
|
RollbackAllocator rba;
|
||||||
File f = File(fileName);
|
File f = fileName == "stdin" ? std.stdio.stdin : File(fileName);
|
||||||
if (f.size == 0)
|
if (f.size == 0)
|
||||||
continue;
|
continue;
|
||||||
auto bytes = uninitializedArray!(ubyte[])(to!size_t(f.size));
|
auto bytes = uninitializedArray!(ubyte[])(to!size_t(f.size));
|
||||||
|
|
|
@ -42,7 +42,7 @@ void printEtags(File output, bool tagAll, string[] fileNames)
|
||||||
foreach (fileName; fileNames)
|
foreach (fileName; fileNames)
|
||||||
{
|
{
|
||||||
RollbackAllocator rba;
|
RollbackAllocator rba;
|
||||||
File f = File(fileName);
|
File f = fileName == "stdin" ? std.stdio.stdin : File(fileName);
|
||||||
if (f.size == 0)
|
if (f.size == 0)
|
||||||
continue;
|
continue;
|
||||||
auto bytes = uninitializedArray!(ubyte[])(to!size_t(f.size));
|
auto bytes = uninitializedArray!(ubyte[])(to!size_t(f.size));
|
||||||
|
|
|
@ -21,6 +21,8 @@ ubyte[] readStdin()
|
||||||
|
|
||||||
ubyte[] readFile(string fileName)
|
ubyte[] readFile(string fileName)
|
||||||
{
|
{
|
||||||
|
if (fileName == "stdin")
|
||||||
|
return readStdin();
|
||||||
if (!exists(fileName))
|
if (!exists(fileName))
|
||||||
{
|
{
|
||||||
stderr.writefln("%s does not exist", fileName);
|
stderr.writefln("%s does not exist", fileName);
|
||||||
|
@ -54,7 +56,7 @@ string[] expandArgs(string[] args)
|
||||||
args ~= ".";
|
args ~= ".";
|
||||||
foreach (arg; args[1 .. $])
|
foreach (arg; args[1 .. $])
|
||||||
{
|
{
|
||||||
if (isFileSafe(arg))
|
if (arg == "stdin" || isFileSafe(arg))
|
||||||
rVal ~= arg;
|
rVal ~= arg;
|
||||||
else
|
else
|
||||||
foreach (item; dirEntries(arg, SpanMode.breadth).map!(a => a.name))
|
foreach (item; dirEntries(arg, SpanMode.breadth).map!(a => a.name))
|
||||||
|
|
|
@ -23,8 +23,8 @@ void findDeclarationOf(File output, string symbolName, string[] fileNames)
|
||||||
auto visitor = new FinderVisitor(output, symbolName);
|
auto visitor = new FinderVisitor(output, symbolName);
|
||||||
foreach (fileName; fileNames)
|
foreach (fileName; fileNames)
|
||||||
{
|
{
|
||||||
File f = File(fileName);
|
File f = fileName == "stdin" ? std.stdio.stdin : File(fileName);
|
||||||
assert(isFile(fileName));
|
assert(fileName == "stdin" || isFile(fileName));
|
||||||
if (f.size == 0)
|
if (f.size == 0)
|
||||||
continue;
|
continue;
|
||||||
auto bytes = uninitializedArray!(ubyte[])(to!size_t(f.size));
|
auto bytes = uninitializedArray!(ubyte[])(to!size_t(f.size));
|
||||||
|
|
Loading…
Reference in New Issue