2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-17 01:32:12 +00:00

- 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.

- Add an "overwrite" option to print.text that overwrites the file instead of
appending to it.


[SVN r18124]
This commit is contained in:
Douglas Gregor
2003-03-28 15:12:29 +00:00
parent f2658f847b
commit cbab15fbad
2 changed files with 38 additions and 6 deletions

View File

@@ -218,7 +218,8 @@ rule lines (
# Output text directly to the current target.
#
rule text (
strings * # The strings of text to output.
strings * # The strings of text to output.
: overwrite ? # true to overwrite the output (if it is a file)
)
{
if $(output-target) = console
@@ -243,11 +244,20 @@ rule text (
{
local line-v = $(output-target).line.$($(output-target).line) ;
local echo-string = [ regex.split $(strings[1]) "\"" ] ;
echo-string = $(echo-string:J="''") ;
echo-string = $(echo-string:J="\\\"") ;
$(line-v) on $(output-target) = $(echo-string) ;
NOCARE $(line-v) ;
NOTFILE $(line-v) ;
text-action $(output-target) : $(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) ] ;
}
@@ -269,6 +279,12 @@ 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__ ( )
{
import assert ;

View File

@@ -218,7 +218,8 @@ rule lines (
# Output text directly to the current target.
#
rule text (
strings * # The strings of text to output.
strings * # The strings of text to output.
: overwrite ? # true to overwrite the output (if it is a file)
)
{
if $(output-target) = console
@@ -243,11 +244,20 @@ rule text (
{
local line-v = $(output-target).line.$($(output-target).line) ;
local echo-string = [ regex.split $(strings[1]) "\"" ] ;
echo-string = $(echo-string:J="''") ;
echo-string = $(echo-string:J="\\\"") ;
$(line-v) on $(output-target) = $(echo-string) ;
NOCARE $(line-v) ;
NOTFILE $(line-v) ;
text-action $(output-target) : $(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) ] ;
}
@@ -269,6 +279,12 @@ 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__ ( )
{
import assert ;