@@ -153,11 +153,11 @@ static std::string readfile(const char code[], std::size_t size, simplecpp::Outp
153153 return makeTokenList (code,size,files,std::string (),outputList).stringify ();
154154}
155155
156- static std::string preprocess (const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList)
156+ static std::string preprocess (const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList, const std::string &file = std::string() )
157157{
158158 std::vector<std::string> files;
159159 std::map<std::string, simplecpp::TokenList*> filedata;
160- simplecpp::TokenList tokens = makeTokenList (code,files);
160+ simplecpp::TokenList tokens = makeTokenList (code,files,file );
161161 tokens.removeComments ();
162162 simplecpp::TokenList tokens2 (files);
163163 simplecpp::preprocess (tokens2, tokens, files, filedata, dui, outputList);
@@ -169,6 +169,11 @@ static std::string preprocess(const char code[])
169169 return preprocess (code, simplecpp::DUI (), nullptr );
170170}
171171
172+ static std::string preprocess (const char code[], const std::string &file)
173+ {
174+ return preprocess (code, simplecpp::DUI (), nullptr , file);
175+ }
176+
172177static std::string preprocess (const char code[], const simplecpp::DUI &dui)
173178{
174179 return preprocess (code, dui, nullptr );
@@ -235,7 +240,7 @@ static void backslash()
235240
236241static void builtin ()
237242{
238- ASSERT_EQUALS (" \"\" 1 0" , preprocess (" __FILE__ __LINE__ __COUNTER__" ));
243+ ASSERT_EQUALS (" \" test.c \" 1 0" , preprocess (" __FILE__ __LINE__ __COUNTER__" , " test.c " ));
239244 ASSERT_EQUALS (" \n\n 3" , preprocess (" \n\n __LINE__" ));
240245 ASSERT_EQUALS (" \n\n 0" , preprocess (" \n\n __COUNTER__" ));
241246 ASSERT_EQUALS (" \n\n 0 1" , preprocess (" \n\n __COUNTER__ __COUNTER__" ));
0 commit comments