Added shebang detection
This commit is contained in:
parent
f4d39e4dfc
commit
5313345853
16
src/main.cpp
16
src/main.cpp
|
@ -158,9 +158,15 @@ int main(int argc, char *argv[])
|
||||||
if (out.is_open())
|
if (out.is_open())
|
||||||
{
|
{
|
||||||
string buf;
|
string buf;
|
||||||
std::getline(in, buf); // Shebang
|
|
||||||
std::getline(in, buf);
|
std::getline(in, buf);
|
||||||
if (buf.substr(0, 16).compare("//compilescript:") == 0)
|
if (!(buf.substr(0, 2) == "#!"))
|
||||||
|
{
|
||||||
|
out << buf << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::getline(in, buf);
|
||||||
|
if (buf.substr(0, 16) == "//compilescript:")
|
||||||
{
|
{
|
||||||
compiler_arguments = buf.substr(16);
|
compiler_arguments = buf.substr(16);
|
||||||
}
|
}
|
||||||
|
@ -168,24 +174,26 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
out << buf << endl;
|
out << buf << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!in.eof())
|
while (!in.eof())
|
||||||
{
|
{
|
||||||
std::getline(in, buf);
|
std::getline(in, buf);
|
||||||
out << buf << endl;
|
out << buf << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
in.close();
|
in.close();
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "ERROR: Could not open file: " << source << endl;
|
cerr << "ERROR: Could not open file: " << source << endl;
|
||||||
std::exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "ERROR: Could not open file: " << original << endl;
|
cerr << "ERROR: Could not open file: " << original << endl;
|
||||||
std::exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::system((compiler + " " + source.string() + " " + compiler_arguments
|
std::system((compiler + " " + source.string() + " " + compiler_arguments
|
||||||
|
|
Reference in New Issue