@@ -140,11 +140,11 @@ static std::string readfile(const char code[], std::size_t size, simplecpp::Outp
140140 return makeTokenList (code,size,files,std::string (),outputList).stringify ();
141141}
142142
143- static std::string preprocess (const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList)
143+ static std::string preprocess (const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList, const std::string &file = std::string() )
144144{
145145 std::vector<std::string> files;
146146 std::map<std::string, simplecpp::TokenList*> filedata;
147- simplecpp::TokenList tokens = makeTokenList (code,files);
147+ simplecpp::TokenList tokens = makeTokenList (code,files,file );
148148 tokens.removeComments ();
149149 simplecpp::TokenList tokens2 (files);
150150 simplecpp::preprocess (tokens2, tokens, files, filedata, dui, outputList);
@@ -156,6 +156,11 @@ static std::string preprocess(const char code[])
156156 return preprocess (code, simplecpp::DUI (), nullptr );
157157}
158158
159+ static std::string preprocess (const char code[], const std::string &file)
160+ {
161+ return preprocess (code, simplecpp::DUI (), nullptr , file);
162+ }
163+
159164static std::string preprocess (const char code[], const simplecpp::DUI &dui)
160165{
161166 return preprocess (code, dui, nullptr );
@@ -222,7 +227,7 @@ static void backslash()
222227
223228static void builtin ()
224229{
225- ASSERT_EQUALS (" \"\" 1 0" , preprocess (" __FILE__ __LINE__ __COUNTER__" ));
230+ ASSERT_EQUALS (" \" test.c \" 1 0" , preprocess (" __FILE__ __LINE__ __COUNTER__" , " test.c " ));
226231 ASSERT_EQUALS (" \n\n 3" , preprocess (" \n\n __LINE__" ));
227232 ASSERT_EQUALS (" \n\n 0" , preprocess (" \n\n __COUNTER__" ));
228233 ASSERT_EQUALS (" \n\n 0 1" , preprocess (" \n\n __COUNTER__ __COUNTER__" ));
0 commit comments