I've got a rather largish pile of c++ code that makes a lot of calls to
boost::format. I'm having trouble compiling the code on my FPGA platform
(can't figure out how to install boost::format into the tool flow). So, I
thought maybe I'd try to do a perl script to convert all the files to use
sprintf.
So I need to convert
(format("blah %s de %d bleh") % expression1 % expression2 ).str()
to
sprintf("blah %s de %d bleh", expression1 , expression2 )
A single format() call might span multiple lines,
so I figured I'd slurp all the text in at once
and do a search and replace. There might be more
than one occurrence per file, so I'd add the /g modifier.
s/format\((.*?)\)(.*?)\.str\(\)/something/g
The problem is I need $1 and $2 to put into sprintf
but I before I do that, I also need to take the '%'
operators in $2 and replace them with ',' and THEN
put it back in.
Things started to get hairy, and I was wondering
if I'm overlooking a solution that would make this
a lot easier.
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm