Boost logo

Boost-Build :

Subject: [Boost-build] trim newlines
From: codemonkey (codemonkey_at_[hidden])
Date: 2010-07-26 17:29:10


I may have asked this before and, if so, I apologize for the

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

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 :

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'" ] ;




Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at