Boost logo

Boost-Build :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-03-30 21:50:41


On Saturday 29 March 2003 11:29 am, Douglas Gregor wrote:
> Can anyone give me a hint on implementing this in Jam? The regex MATCH
> seems to be of little use, unfortunately :(

Or, perhaps, my understanding of MATCH was of little use :).

The patch below properly escapes strings for use with the "echo" command.
Tested with the BoostBook XML catalog (lots of escaped characters there)
under Windows XP cmd.exe, Cygwin, and Linux (bash); no problems. Okay to
commit?

Doug

Index: print.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/new/print.jam,v
retrieving revision 1.14
diff -c -3 -p -r1.14 print.jam
*** print.jam 30 Mar 2003 15:17:52 -0000 1.14
--- print.jam 31 Mar 2003 02:42:39 -0000
*************** rule text (
*** 243,250 ****
while $(strings)
{
local line-v = $(output-target).line.$($(output-target).line) ;
! local echo-string = [ regex.split $(strings[1]) "\"" ] ;
! echo-string = $(echo-string:J="\\\"") ;
$(line-v) on $(output-target) = $(echo-string) ;
NOCARE $(line-v) ;
NOTFILE $(line-v) ;
--- 243,249 ----
while $(strings)
{
local line-v = $(output-target).line.$($(output-target).line) ;
! local echo-string = [ escape $(strings[1]) ] ;
$(line-v) on $(output-target) = $(echo-string) ;
NOCARE $(line-v) ;
NOTFILE $(line-v) ;
*************** rule wrapped-text ( text + )
*** 275,287 ****
#
actions quietly text-action
{
! echo "$($(>))" >> $(<)
}

# Writes a single line to target file (overwriting or creating the
# file as necessary)
actions quietly text-overwrite-action {
! echo "$($(>))" > $(<)
}

local rule __test__ ( )
--- 274,323 ----
#
actions quietly text-action
{
! echo $($(>)) >> $(<)
}

# Writes a single line to target file (overwriting or creating the
# file as necessary)
actions quietly text-overwrite-action {
! echo $($(>)) > $(<)
! }
!
! if [ modules.peek : NT ]
! {
! rule escape ( string )
! {
! local result = "" ;
! local m = [ MATCH ^([^&|()<>^]*)([&|()<>^])(.*) : $(string) ] ;
! while $(m)
! {
! m += "" ; # Supposedly a bug fix; borrowed from regex.split
! result = "$(result)$(m[1])^$(m[2])" ;
! string = $(m[3]) ;
! m = [ MATCH ^([^&|()<>^]*)([&|()<>^])(.*) : $(string) ] ;
! }
! string ?= "" ;
! result = "$(result)$(string)" ;
! return $(result) ;
! }
! }
! else
! {
! rule escape ( string )
! {
! local result = "" ;
! local m = [ MATCH ^([^\\\"]*)([\\\"])(.*) : $(string) ] ;
! while $(m)
! {
! m += "" ; # Supposedly a bug fix; borrowed from regex.split
! result = "$(result)$(m[1])\\$(m[2])" ;
! string = $(m[3]) ;
! m = [ MATCH ^([^\\\"]*)([\\\"])(.*) : $(string) ] ;
! }
! string ?= "" ;
! result = "\"$(result)$(string)\"" ;
! return $(result) ;
! }
}

local rule __test__ ( )

 


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