Skip to content

Commit

Permalink
Don't file-open stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
vanceism7 committed Oct 23, 2024
1 parent e579c05 commit f6e1362
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions source/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -884,10 +884,14 @@ class source
{
// If filename is stdin, we read from stdin, otherwise we try to read the file
//
std::ifstream fss{ filename };
std::istream& in = filename == "stdin" ? std::cin : fss;
if (filename != "stdin" && !fss.is_open())
return false;
auto is_stdin = filename == "stdin";
std::ifstream fss;
if (is_stdin)
{
fss.open(filename);
if( !fss.is_open()) { return false; }
}
std::istream& in = is_stdin ? std::cin : fss;

auto in_comment = false;
auto in_string_literal = false;
Expand Down

0 comments on commit f6e1362

Please sign in to comment.