From cbab15fbad2b0bd47a3f564fc5e64626a9911f99 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 28 Mar 2003 15:12:29 +0000 Subject: [PATCH] - 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] --- new/print.jam | 22 +++++++++++++++++++--- v2/util/print.jam | 22 +++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/new/print.jam b/new/print.jam index 1a5dc2efe..1f0581d7b 100644 --- a/new/print.jam +++ b/new/print.jam @@ -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 ; diff --git a/v2/util/print.jam b/v2/util/print.jam index 1a5dc2efe..1f0581d7b 100644 --- a/v2/util/print.jam +++ b/v2/util/print.jam @@ -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 ;