◐ Shell
reader mode source ↗
Skip to content
Merged
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
55 changes: 47 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
#define SIMPLECPP_TOKENLIST_ALLOW_PTR 0
#include "simplecpp.h"

#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <sys/stat.h>
#include <string>
#include <utility>
#include <vector>

Expand All @@ -28,7 +30,12 @@ int main(int argc, char **argv)
{
bool error = false;
const char *filename = nullptr;
bool use_istream = false;
bool fail_on_error = false;
bool linenrs = false;

Expand Down Expand Up @@ -86,9 +93,28 @@ int main(int argc, char **argv)
break;
}
dui.includes.emplace_back(std::move(value));
} else if (std::strcmp(arg, "-is")==0) {
found = true;
use_istream = true;
}
break;
case 's':
Expand Down Expand Up @@ -117,8 +143,8 @@ int main(int argc, char **argv)
break;
case 'f':
if (std::strcmp(arg, "-f")==0) {
found = true;
fail_on_error = true;
}
break;
case 'l':
Expand Down Expand Up @@ -157,7 +183,7 @@ int main(int argc, char **argv)
std::cout << " -UNAME Undefine NAME." << std::endl;
std::cout << " -std=STD Specify standard." << std::endl;
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::cout << " -f Fail when errors were encountered (exitcode 1)." << std::endl;
std::cout << " -l Print lines numbers." << std::endl;
Expand Down Expand Up @@ -197,8 +223,21 @@ int main(int argc, char **argv)
simplecpp::TokenList outputTokens(files);
{
simplecpp::TokenList *rawtokens;
if (use_istream) {
rawtokens = new simplecpp::TokenList(f, files,filename,&outputList);
} else {
f.close();
rawtokens = new simplecpp::TokenList(filename,files,&outputList);
Expand Down
Loading
Toggle all file notes Toggle all file annotations