Hi,
I may have asked this before and, if so, I apologize for the duplication...
Does anyone know a trick for trimming newlines off the end of a string in jam?
I found a rule called strip-eol in tools/mpi.jam that claims to do this however it actually truncates the string at the first newline -- I only want to remove the last one and leave embedded ones intact.
strip-eol uses MATCH and, given the constraints on jam variables and the MATCH rule, it appears to be quite hard -- if even possible -- to do what I want only with regexps. If I could express a literal newline (e.g. \n) in a regex then I could do it with something like this: "^(.*)[\n]$" but I can't find a way to do that (so far).
One example of a reason to do this is this:
local WX_CPP_FLAGS = [ SHELL "wx-config --cxxflags --unicode=yes --debug=no" ] ;
exe foo : foo.cpp : <cxxflags>$(WX_CPP_FLAGS) ;
SHELL leaves a newline on the end which ends up on the compiler command line and causes the build to fail. To work around this I've been using:
local WX_CPP_FLAGS = [ SHELL "wx-config --cxxflags --unicode=yes --debug=no | tr -d '\n'" ] ;
Thanks,
~ray