Boost logo

Boost-Build :

Subject: Re: [Boost-build] trim newlines
From: Ray Lambert (codemonkey_at_[hidden])
Date: 2010-07-26 21:36:30


On 07/26/2010 09:13 PM, Steven Watanabe wrote:
> AMDG
>
> codemonkey wrote:
>> ... 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).
>
> Use \n.
>

hmm... my original post had the "\" in there; not sure why it's missing
in your quote.

In any case, I did try \n but it didn't seem to work. Here's a rule I
wrote (based on the aforementioned strip-eol from mpi.jam):

rule rtrim ( string )
{
   local match = [ MATCH "^(.*)[\n]$" : $(string) ] ;
   if $(match)
   {
     return $(match[1]) ;
   }
   else
   {
     return $(string) ;
   }
}

Note that I've tried it with and without the [] .

I looked at regexp.c and I can't see where it handles \n -- I'm not sure
it actually does. Unless I missed something, I think it treats '\n' as
just 'n'.

~ray



Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk