Skip to content

Commit 4c479b5

Browse files
committed
CommandLineInterface: Accept the standard input stream as a parameter
1 parent bb64d36 commit 4c479b5

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

solc/CommandLineInterface.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ ostream& CommandLineInterface::serr(bool _markAsUsed)
9999
return m_serr;
100100
}
101101

102+
#define cin
102103
#define cout
103104
#define cerr
104105

@@ -415,7 +416,7 @@ bool CommandLineInterface::readInputFilesAndConfigureFileReader()
415416
}
416417

417418
if (m_options.input.addStdin)
418-
m_fileReader.setSource(g_stdinFileName, readUntilEnd(cin));
419+
m_fileReader.setSource(g_stdinFileName, readUntilEnd(m_sin));
419420

420421
if (m_fileReader.sourceCodes().size() == 0)
421422
{
@@ -513,7 +514,7 @@ bool CommandLineInterface::processInput()
513514
{
514515
string input;
515516
if (m_options.input.standardJsonFile.empty())
516-
input = readUntilEnd(cin);
517+
input = readUntilEnd(m_sin);
517518
else
518519
{
519520
try

solc/CommandLineInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ class CommandLineInterface
4040
{
4141
public:
4242
explicit CommandLineInterface(
43+
std::istream& _sin,
4344
std::ostream& _sout,
4445
std::ostream& _serr,
4546
CommandLineOptions const& _options = CommandLineOptions{}
4647
):
48+
m_sin(_sin),
4749
m_sout(_sout),
4850
m_serr(_serr),
4951
m_options(_options)
@@ -121,6 +123,7 @@ class CommandLineInterface
121123
/// stream has ever been used unless @arg _markAsUsed is set to false.
122124
std::ostream& serr(bool _markAsUsed = true);
123125

126+
std::istream& m_sin;
124127
std::ostream& m_sout;
125128
std::ostream& m_serr;
126129
bool m_hasOutput = false;

solc/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void setDefaultOrCLocale()
5454
int main(int argc, char** argv)
5555
{
5656
setDefaultOrCLocale();
57-
solidity::frontend::CommandLineInterface cli(cout, cerr);
57+
solidity::frontend::CommandLineInterface cli(cin, cout, cerr);
5858
if (!cli.parseArguments(argc, argv))
5959
return 1;
6060
if (!cli.processInput())

0 commit comments

Comments
 (0)