Skip to content

Commit a403d21

Browse files
committed
main.cpp: do not load included files twice
1 parent 8259065 commit a403d21

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

main.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <iostream>
1212
#include <map>
1313
#include <string>
14-
#include <utility>
1514
#include <vector>
1615

1716
int main(int argc, char **argv)
@@ -110,6 +109,8 @@ int main(int argc, char **argv)
110109
std::exit(0);
111110
}
112111

112+
dui.removeComments = true;
113+
113114
// Perform preprocessing
114115
simplecpp::OutputList outputList;
115116
std::vector<std::string> files;
@@ -126,11 +127,10 @@ int main(int argc, char **argv)
126127
rawtokens = new simplecpp::TokenList(filename,files,&outputList);
127128
}
128129
rawtokens->removeComments();
129-
std::map<std::string, simplecpp::TokenList*> included = simplecpp::load(*rawtokens, files, dui, &outputList);
130-
for (std::pair<std::string, simplecpp::TokenList *> i : included)
131-
i.second->removeComments();
132130
simplecpp::TokenList outputTokens(files);
133-
simplecpp::preprocess(outputTokens, *rawtokens, files, included, dui, &outputList);
131+
std::map<std::string, simplecpp::TokenList*> filedata;
132+
simplecpp::preprocess(outputTokens, *rawtokens, files, filedata, dui, &outputList);
133+
simplecpp::cleanup(filedata);
134134
delete rawtokens;
135135
rawtokens = nullptr;
136136

@@ -174,8 +174,5 @@ int main(int argc, char **argv)
174174
}
175175
}
176176

177-
// cleanup included tokenlists
178-
simplecpp::cleanup(included);
179-
180177
return 0;
181178
}

0 commit comments

Comments
 (0)