@@ -117,25 +117,24 @@ ScopedFile::~ScopedFile() {
117117// TODO: we should be using the actual Preprocessor implementation
118118std::string PreprocessorHelper::getcode (const Settings& settings, ErrorLogger& errorlogger, const std::string &filedata, const std::string &cfg, const std::string &filename, SuppressionList *inlineSuppression)
119119{
120- std::map<std::string, std::string> cfgcode = getcode (settings, errorlogger, filedata.c_str (), std::set<std::string>{cfg}, filename, inlineSuppression);
120+ std::map<std::string, std::string> cfgcode = getcode (settings, errorlogger, filedata.c_str (), filedata. size (), std::set<std::string>{cfg}, filename, inlineSuppression);
121121 const auto it = cfgcode.find (cfg);
122122 if (it == cfgcode.end ())
123123 return " " ;
124124 return it->second ;
125125}
126126
127- std::map<std::string, std::string> PreprocessorHelper::getcode (const Settings& settings, ErrorLogger& errorlogger, const char code[], const std::string &filename, SuppressionList *inlineSuppression)
127+ std::map<std::string, std::string> PreprocessorHelper::getcode (const Settings& settings, ErrorLogger& errorlogger, const char code[], std:: size_t size, const std::string &filename, SuppressionList *inlineSuppression)
128128{
129- return getcode (settings, errorlogger, code, {}, filename, inlineSuppression);
129+ return getcode (settings, errorlogger, code, size, {}, filename, inlineSuppression);
130130}
131131
132- std::map<std::string, std::string> PreprocessorHelper::getcode (const Settings& settings, ErrorLogger& errorlogger, const char code[], std::set<std::string> cfgs, const std::string &filename, SuppressionList *inlineSuppression)
132+ std::map<std::string, std::string> PreprocessorHelper::getcode (const Settings& settings, ErrorLogger& errorlogger, const char code[], std::size_t size, std:: set<std::string> cfgs, const std::string &filename, SuppressionList *inlineSuppression)
133133{
134134 simplecpp::OutputList outputList;
135135 std::vector<std::string> files;
136136
137- std::istringstream istr (code);
138- simplecpp::TokenList tokens (istr, files, Path::simplifyPath (filename), &outputList);
137+ simplecpp::TokenList tokens (code, size, files, Path::simplifyPath (filename), &outputList);
139138 Preprocessor preprocessor (settings, errorlogger, Path::identify (tokens.getFiles ()[0 ], false ));
140139 if (inlineSuppression)
141140 preprocessor.inlineSuppressions (tokens, *inlineSuppression);
@@ -162,11 +161,9 @@ std::map<std::string, std::string> PreprocessorHelper::getcode(const Settings& s
162161 return cfgcode;
163162}
164163
165- void SimpleTokenizer2::preprocess (const char code[] , std::vector<std::string> &files, const std::string& file0, Tokenizer& tokenizer, ErrorLogger& errorlogger)
164+ void SimpleTokenizer2::preprocess (const char * code, std:: size_t size , std::vector<std::string> &files, const std::string& file0, Tokenizer& tokenizer, ErrorLogger& errorlogger)
166165{
167- // TODO: get rid of stream
168- std::istringstream istr (code);
169- const simplecpp::TokenList tokens1 (istr, files, file0);
166+ const simplecpp::TokenList tokens1 (code, size, files, file0);
170167
171168 Preprocessor preprocessor (tokenizer.getSettings (), errorlogger, Path::identify (tokens1.getFiles ()[0 ], false ));
172169 simplecpp::TokenList tokens2 = preprocessor.preprocess (tokens1, " " , files, true );
0 commit comments