@@ -3152,7 +3152,7 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDat
31523152
31533153 auto *const data = new FileData {path, TokenList (path, filenames, outputList)};
31543154
3155- if (dui.removeComments )
3155+ if (dui.removeIncludeComments )
31563156 data->tokens .removeComments ();
31573157
31583158 name_it->second = data;
@@ -3293,7 +3293,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
32933293 if (!filedata->tokens .front ())
32943294 continue ;
32953295
3296- if (dui.removeComments )
3296+ if (dui.removeIncludeComments )
32973297 filedata->tokens .removeComments ();
32983298
32993299 filelist.emplace_back (filedata->tokens .front ());
@@ -3332,7 +3332,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
33323332 if (!filedata->tokens .front ())
33333333 continue ;
33343334
3335- if (dui.removeComments )
3335+ if (dui.removeIncludeComments )
33363336 filedata->tokens .removeComments ();
33373337
33383338 filelist.emplace_back (filedata->tokens .front ());
@@ -3341,7 +3341,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
33413341 return cache;
33423342}
33433343
3344- static bool preprocessToken (simplecpp::TokenList &output, const simplecpp::Token *&tok1, simplecpp::MacroMap ¯os, std::vector<std::string> &files, simplecpp::OutputList *outputList)
3344+ static bool preprocessToken (simplecpp::TokenList &output, const simplecpp::Token *&tok1, simplecpp::MacroMap ¯os, std::vector<std::string> &files, simplecpp::OutputList *outputList, const simplecpp:: DUI &dui )
33453345{
33463346 const simplecpp::Token * const tok = tok1;
33473347 const simplecpp::MacroMap::const_iterator it = tok->name ? macros.find (tok->str ()) : macros.end ();
@@ -3372,7 +3372,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
33723372 }
33733373 output.takeTokens (value);
33743374 } else {
3375- if (!tok->comment )
3375+ if (!tok->comment || !dui. removeSourceComments )
33763376 output.push_back (new simplecpp::Token (*tok));
33773377 tok1 = tok->next ;
33783378 }
@@ -3647,7 +3647,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36473647 TokenList inc2 (files);
36483648 if (!inc1.empty () && inc1.cfront ()->name ) {
36493649 const Token *inctok = inc1.cfront ();
3650- if (!preprocessToken (inc2, inctok, macros, files, outputList)) {
3650+ if (!preprocessToken (inc2, inctok, macros, files, outputList, dui )) {
36513651 output.clear ();
36523652 return ;
36533653 }
@@ -3817,7 +3817,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
38173817 maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
38183818
38193819 const Token *tmp = tok;
3820- if (!preprocessToken (expr, tmp, macros, files, outputList)) {
3820+ if (!preprocessToken (expr, tmp, macros, files, outputList, dui )) {
38213821 output.clear ();
38223822 return ;
38233823 }
@@ -3915,7 +3915,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
39153915 const Location loc (rawtok->location );
39163916 TokenList tokens (files);
39173917
3918- if (!preprocessToken (tokens, rawtok, macros, files, outputList)) {
3918+ if (!preprocessToken (tokens, rawtok, macros, files, outputList, dui )) {
39193919 output.clear ();
39203920 return ;
39213921 }
0 commit comments