@@ -148,11 +148,11 @@ static std::string readfile(const char code[], std::size_t size, simplecpp::Outp
148
148
return makeTokenList (code,size,files,std::string (),outputList).stringify ();
149
149
}
150
150
151
- static std::string preprocess (const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList)
151
+ static std::string preprocess (const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList, const std::string &file = std::string() )
152
152
{
153
153
std::vector<std::string> files;
154
154
std::map<std::string, simplecpp::TokenList*> filedata;
155
- simplecpp::TokenList tokens = makeTokenList (code,files);
155
+ simplecpp::TokenList tokens = makeTokenList (code,files,file );
156
156
tokens.removeComments ();
157
157
simplecpp::TokenList tokens2 (files);
158
158
simplecpp::preprocess (tokens2, tokens, files, filedata, dui, outputList);
@@ -164,6 +164,11 @@ static std::string preprocess(const char code[])
164
164
return preprocess (code, simplecpp::DUI (), nullptr );
165
165
}
166
166
167
+ static std::string preprocess (const char code[], const std::string &file)
168
+ {
169
+ return preprocess (code, simplecpp::DUI (), nullptr , file);
170
+ }
171
+
167
172
static std::string preprocess (const char code[], const simplecpp::DUI &dui)
168
173
{
169
174
return preprocess (code, dui, nullptr );
@@ -230,7 +235,7 @@ static void backslash()
230
235
231
236
static void builtin ()
232
237
{
233
- ASSERT_EQUALS (" \"\" 1 0" , preprocess (" __FILE__ __LINE__ __COUNTER__" ));
238
+ ASSERT_EQUALS (" \" test.c \" 1 0" , preprocess (" __FILE__ __LINE__ __COUNTER__" , " test.c " ));
234
239
ASSERT_EQUALS (" \n\n 3" , preprocess (" \n\n __LINE__" ));
235
240
ASSERT_EQUALS (" \n\n 0" , preprocess (" \n\n __COUNTER__" ));
236
241
ASSERT_EQUALS (" \n\n 0 1" , preprocess (" \n\n __COUNTER__ __COUNTER__" ));
0 commit comments