@@ -710,8 +710,9 @@ void Preprocessor::preprocess(std::istream &istr, std::map<std::string, std::str
710710 std::string data;
711711 preprocess (istr, data, configs, filename, includePaths);
712712 for (std::list<std::string>::const_iterator it = configs.begin (); it != configs.end (); ++it) {
713- if (_settings && (_settings->userUndefs .find (*it) == _settings->userUndefs .end ()))
713+ if (_settings && (_settings->userUndefs .find (*it) == _settings->userUndefs .end ())) {
714714 result[ *it ] = getcode (data, *it, filename);
715+ }
715716 }
716717}
717718
@@ -803,7 +804,7 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe
803804
804805 processedFile = read (srcCodeStream, filename);
805806
806- if (_settings && ! _settings->userIncludes . empty () ) {
807+ if (_settings && _settings->_maxConfigs == 1U ) {
807808 for (std::list<std::string>::iterator it = _settings->userIncludes .begin ();
808809 it != _settings->userIncludes .end ();
809810 ++it) {
@@ -870,9 +871,9 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe
870871 processedFile = ostr.str ();
871872 }
872873
873- if (_settings && !_settings->userDefines .empty ()) {
874- std::map<std::string, std::string> defs;
874+ std::map<std::string, std::string> defs;
875875
876+ if (_settings && !_settings->userDefines .empty ()) {
876877 // TODO: break out this code. There is other similar code.
877878 std::string::size_type pos1 = 0 ;
878879 while (pos1 != std::string::npos) {
@@ -897,19 +898,18 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe
897898 if (pos1 != std::string::npos)
898899 pos1++;
899900 }
901+ }
900902
903+ if (_settings && _settings->_maxConfigs == 1U ) {
901904 processedFile = handleIncludes (processedFile, filename, includePaths, defs);
902- if (_settings->userIncludes .empty ())
903- resultConfigurations = getcfgs (processedFile, filename);
904-
905+ resultConfigurations = getcfgs (processedFile, filename, defs);
905906 } else {
906-
907907 handleIncludes (processedFile, filename, includePaths);
908908
909909 processedFile = replaceIfDefined (processedFile);
910910
911911 // Get all possible configurations..
912- resultConfigurations = getcfgs (processedFile, filename);
912+ resultConfigurations = getcfgs (processedFile, filename, defs );
913913
914914 // Remove configurations that are disabled by -U
915915 handleUndef (resultConfigurations);
@@ -1050,7 +1050,7 @@ static void simplifyVarMap(std::map<std::string, std::string> &variables)
10501050 }
10511051}
10521052
1053- std::list<std::string> Preprocessor::getcfgs (const std::string &filedata, const std::string &filename)
1053+ std::list<std::string> Preprocessor::getcfgs (const std::string &filedata, const std::string &filename, const std::map<std::string, std::string> &defs )
10541054{
10551055 std::list<std::string> ret;
10561056 ret.push_back (" " );
@@ -1169,7 +1169,7 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
11691169
11701170 // Replace defined constants
11711171 {
1172- std::map<std::string, std::string> varmap;
1172+ std::map<std::string, std::string> varmap (defs) ;
11731173 for (std::set<std::string>::const_iterator it = defines.begin (); it != defines.end (); ++it) {
11741174 std::string::size_type pos = it->find_first_of (" =(" );
11751175 if (pos == std::string::npos)
0 commit comments