Skip to content

Commit 8259065

Browse files
committed
added DUI::removeComments to remove comment tokens from included files
1 parent 1b29369 commit 8259065

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

simplecpp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,6 +3143,8 @@ std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::To
31433143
continue;
31443144
}
31453145

3146+
if (dui.removeComments)
3147+
tokenlist->removeComments();
31463148
ret[filename] = tokenlist;
31473149
filelist.push_back(tokenlist->front());
31483150
}
@@ -3178,6 +3180,8 @@ std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::To
31783180
f.close();
31793181

31803182
TokenList *tokens = new TokenList(header2, filenames, outputList);
3183+
if (dui.removeComments)
3184+
tokens->removeComments();
31813185
ret[header2] = tokens;
31823186
if (tokens->front())
31833187
filelist.push_back(tokens->front());
@@ -3446,6 +3450,8 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34463450
header2 = openHeader(f, dui, rawtok->location.file(), header, systemheader);
34473451
if (f.is_open()) {
34483452
TokenList * const tokens = new TokenList(f, files, header2, outputList);
3453+
if (dui.removeComments)
3454+
tokens->removeComments();
34493455
filedata[header2] = tokens;
34503456
}
34513457
}

simplecpp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,14 @@ namespace simplecpp {
320320
* On the command line these are configured by -D, -U, -I, --include, -std
321321
*/
322322
struct SIMPLECPP_LIB DUI {
323-
DUI() : clearIncludeCache(false) {}
323+
DUI() : clearIncludeCache(false), removeComments(false) {}
324324
std::list<std::string> defines;
325325
std::set<std::string> undefined;
326326
std::list<std::string> includePaths;
327327
std::list<std::string> includes;
328328
std::string std;
329329
bool clearIncludeCache;
330+
bool removeComments; /** remove comment tokens from included files */
330331
};
331332

332333
SIMPLECPP_LIB long long characterLiteralToLL(const std::string& str);

0 commit comments

Comments
 (0)