Skip to content

Commit

Permalink
main.cpp: do not load included files twice
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Feb 16, 2024
1 parent 8259065 commit a403d21
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

int main(int argc, char **argv)
Expand Down Expand Up @@ -110,6 +109,8 @@ int main(int argc, char **argv)
std::exit(0);
}

dui.removeComments = true;

// Perform preprocessing
simplecpp::OutputList outputList;
std::vector<std::string> files;
Expand All @@ -126,11 +127,10 @@ int main(int argc, char **argv)
rawtokens = new simplecpp::TokenList(filename,files,&outputList);
}
rawtokens->removeComments();
std::map<std::string, simplecpp::TokenList*> included = simplecpp::load(*rawtokens, files, dui, &outputList);
for (std::pair<std::string, simplecpp::TokenList *> i : included)
i.second->removeComments();
simplecpp::TokenList outputTokens(files);
simplecpp::preprocess(outputTokens, *rawtokens, files, included, dui, &outputList);
std::map<std::string, simplecpp::TokenList*> filedata;
simplecpp::preprocess(outputTokens, *rawtokens, files, filedata, dui, &outputList);
simplecpp::cleanup(filedata);
delete rawtokens;
rawtokens = nullptr;

Expand Down Expand Up @@ -174,8 +174,5 @@ int main(int argc, char **argv)
}
}

// cleanup included tokenlists
simplecpp::cleanup(included);

return 0;
}

0 comments on commit a403d21

Please sign in to comment.