Allow commandline defines with string values

issue#70
Houtan Bastani 2011-06-10 11:52:55 +02:00
parent 2fcdf21f6e
commit 3023aa2c13
1 changed files with 10 additions and 1 deletions

View File

@ -21,6 +21,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <boost/lexical_cast.hpp>
#include "MacroDriver.hh"
@ -55,7 +56,15 @@ MacroDriver::parse(const string &f, ostream &out, bool debug, bool no_line_macro
stringstream file_with_endl;
for (map<string,string>::iterator it=defines.begin();
it!=defines.end(); it++)
file_with_endl << "@#define " << it->first << " = " << it->second << endl;
try
{
boost::lexical_cast<int>(it->second);
file_with_endl << "@#define " << it->first << " = " << it->second << endl;
}
catch(boost::bad_lexical_cast &)
{
file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl;
}
file_with_endl << in.rdbuf() << endl;
lexer = new MacroFlex(&file_with_endl, &out, no_line_macro);