Boost logo

Boost-Build :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-03-27 18:26:11


The attached patch to print.jam does two things:

1) It changes the \" -> '' transformation into \" -> \\\", i.e., instead of
transforming the double-quote character into two single quotes, we transform
it into a correctly-escaped double quote.

2) Add an "overwrite" option to print.text that, well, allows you to
overwrite the file you're writing to.

The motivation is BoostBook XML catalog generation. Works like a charm on
Linux, but I can't currently test on Windows. If the patch is okay, I'll
check it in?

Doug --Boundary-00=_Ti4g+md134gqTjI Content-Type: text/x-diff;
charset="us-ascii";
name="print.jam.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="print.jam.patch"

Index: print.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/new/print.jam,v
retrieving revision 1.12
diff -c -3 -p -r1.12 print.jam
*** print.jam 22 Feb 2003 07:29:59 -0000 1.12
--- print.jam 27 Mar 2003 23:10:17 -0000
*************** rule lines (
*** 218,224 ****
# Output text directly to the current target.
#
rule text (
! strings * # The strings of text to output.
)
{
if $(output-target) = console
--- 218,225 ----
# Output text directly to the current target.
#
rule text (
! strings * # The strings of text to output.
! : overwrite ? # true to overwrite the output (if it is a file)
)
{
if $(output-target) = console
*************** rule text (
*** 243,253 ****
{
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) ;
! text-action $(output-target) : $(line-v) ;
strings = $(strings[2-]) ;
$(output-target).line = [ numbers.increment $($(output-target).line) ] ;
}
--- 244,263 ----
{
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) ;
! if $(overwrite) = "true"
! {
! overwrite = false ;
! ALWAYS $(output-target) ;
! text-overwrite-action $(output-target) : $(line-v) ;
! }
! else
! {
! text-action $(output-target) : $(line-v) ;
! }
strings = $(strings[2-]) ;
$(output-target).line = [ numbers.increment $($(output-target).line) ] ;
}
*************** rule wrapped-text ( text + )
*** 267,272 ****
--- 277,288 ----
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__ ( )
 --Boundary-00=_Ti4g+md134gqTjI--


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