Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,47 @@ int main(int argc, char **argv)
}
} else if (filename) {
std::cout << "error: multiple filenames specified" << std::endl;
std::exit(1);
return 1;
} else {
filename = arg;
}
}

if (error)
std::exit(1);
return 1;

if (quiet && error_only) {
std::cout << "error: -e cannot be used in conjunction with -q" << std::endl;
std::exit(1);
return 1;
}

// TODO: move this logic into simplecpp?
{
bool inc_missing = false;
for (const std::string& inc : dui.includes) {
std::ifstream f(inc);
if (!f.is_open()) {
inc_missing = true;
std::cout << "error: could not open include '" << inc << "'" << std::endl;
}
}
if (inc_missing)
return 1;
}
{
bool inc_missing = false;
for (const std::string& inc : dui.includePaths) {
// TODO: check if this is a directory
std::ifstream f(inc);
if (!f.is_open()) {
inc_missing = true;
std::cout << "error: could not find include path '" << inc << "'" << std::endl;
}
}
if (inc_missing)
return 1;
}

if (!filename) {
std::cout << "Syntax:" << std::endl;
std::cout << "simplecpp [options] filename" << std::endl;
Expand All @@ -102,7 +129,7 @@ int main(int argc, char **argv)
std::cout << " -q Quiet mode (no output)." << std::endl;
std::cout << " -is Use std::istream interface." << std::endl;
std::cout << " -e Output errors only." << std::endl;
std::exit(0);
return 0;
}

dui.removeComments = true;
Expand All @@ -115,7 +142,7 @@ int main(int argc, char **argv)
std::ifstream f(filename);
if (!f.is_open()) {
std::cout << "error: could not open file '" << filename << "'" << std::endl;
std::exit(1);
return 1;
}
rawtokens = new simplecpp::TokenList(f, files,filename,&outputList);
} else {
Expand Down
Loading