diff --git a/new/boostbook.jam b/new/boostbook.jam index bdfc4a3e0..b5c996a0d 100644 --- a/new/boostbook.jam +++ b/new/boostbook.jam @@ -72,18 +72,14 @@ rule init ( docbook-xsl-dir ? : docbook-dtd-dir ? : xsltproc ? ) xsltroc = [ modules.peek : XSLTPROC ] ; } - boostbook-xsl-dir = [ modules.peek : BOOST_ROOT ] ; - boostbook-xsl-dir = $(boostbook-xsl-dir)/tools/boostbook/xsl ; - boostbook-dtd-dir = [ modules.peek : BOOST_ROOT ] ; - boostbook-dtd-dir = $(boostbook-dtd-dir)/tools/boostbook/dtd ; - if ! $(.initialized) { $(.initialized) = true ; - .docbook-xsl-dir = $(docbook-xsl-dir) ; - .docbook-dtd-dir = $(docbook-dtd-dir) ; - .boostbook-xsl-dir = $(boostbook-xsl-dir) ; - .boostbook-dtd-dir = $(boostbook-dtd-dir) ; + .docbook-xsl-dir = [ path.make $(docbook-xsl-dir) ] ; + .docbook-dtd-dir = [ path.make $(docbook-dtd-dir) ] ; + local boost-root = [ path.make [ modules.peek : BOOST_ROOT ] ] ; + .boostbook-xsl-dir = [ path.join $(boost-root) tools boostbook xsl/ ] ; + .boostbook-dtd-dir = [ path.join $(boost-root) tools boostbook dtd/ ] ; .xsltproc = $(xsltproc) ; } } @@ -93,6 +89,21 @@ rule xsl-dir return $(.boostbook-xsl-dir) ; } +rule dtd-dir +{ + return $(.boostbook-dtd-dir) ; +} + +rule docbook-xsl-dir +{ + return $(.docbook-xsl-dir) ; +} + +rule docbook-dtd-dir +{ + return $(.docbook-dtd-dir) ; +} + rule xslt ( target : source stylesheet : properties * ) { local flags ; @@ -101,7 +112,6 @@ rule xslt ( target : source stylesheet : properties * ) local namevalue = [ regex.split $(param) "=" ] ; flags += --stringparam $(namevalue[1]) $(namevalue[2]) ; } - STYLESHEET on $(target) = $(stylesheet) ; FLAGS on $(target) = $(flags) ; NAME on $(target) = $(.xsltproc) ; @@ -132,40 +142,43 @@ rule dtdxml-to-boostbook ( target : source : properties * ) rule boostbook-to-docbook ( target : source : properties * ) { - xslt $(target) : $(source) "$(.boostbook-xsl-dir)/docbook.xsl" : $(properties) ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=docbook:S=.xsl) ; + xslt $(target) : $(source) $(stylesheet) : $(properties) ; } rule docbook-to-onehtml ( target : source : properties * ) { - xslt $(target) : $(source) "$(.boostbook-xsl-dir)/html-single.xsl" : $(properties) ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=html-single:S=.xsl) ; + xslt $(target) : $(source) $(stylesheet) : $(properties) ; } rule docbook-to-htmldir ( target : source : properties * ) { - xslt-dir $(target) : $(source) "$(.boostbook-xsl-dir)/html.xsl" : $(properties) : html ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=html:S=.xsl) ; + xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : html ; } rule docbook-to-manpages ( target : source : properties * ) { - xslt-dir $(target) : $(source) "$(.boostbook-xsl-dir)/manpages.xsl" : $(properties) : man ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=manpages:S=.xsl) ; + xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : man ; } rule docbook-to-fo ( target : source : properties * ) { - xslt $(target) : $(source) "$(.boostbook-xsl-dir)/fo.xsl" : $(properties) ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=fo:S=.xsl) ; + xslt $(target) : $(source) $(stylesheet) : $(properties) ; } rule xml-catalog-action ( target : property-set ? : catalog-entries * ) { action.__init__ $(target) : : generate-xml-catalog : $(property-set) ; - self.docbook-xsl-dir = - [ feature.get-values : $(catalog-entries) ] ; - self.docbook-dtd-dir = - [ feature.get-values : $(catalog-entries) ] ; - self.boostbook-dtd-dir = - [ feature.get-values : $(catalog-entries) ] ; - rule actualize ( ) { if ! $(self.actualized) @@ -180,9 +193,12 @@ rule xml-catalog-action ( target : property-set ? : catalog-entries * ) text += "" ; # BoostBook DTD catalog entry - text += " " ; + local boostbook-dtd-dir = [ boostbook.dtd-dir ] ; - if ! $(self.docbook-xsl-dir) + text += " " ; + + local docbook-xsl-dir = [ boostbook.docbook-xsl-dir ] ; + if ! $(docbook-xsl-dir) { ECHO "BoostBook warning: no DocBook XSL directory specified." ; ECHO " If you have the DocBook XSL stylesheets installed, please " ; @@ -194,10 +210,11 @@ rule xml-catalog-action ( target : property-set ? : catalog-entries * ) } else { - text += " " ; + text += " " ; } - if ! $(self.docbook-dtd-dir) + local docbook-dtd-dir = [ boostbook.docbook-dtd-dir ] ; + if ! $(docbook-dtd-dir) { ECHO "BoostBook warning: no DocBook DTD directory specified." ; ECHO " If you have the DocBook DTD installed, please set " ; @@ -209,7 +226,7 @@ rule xml-catalog-action ( target : property-set ? : catalog-entries * ) } else { - text += " " ; + text += " " ; } text += "" ; @@ -217,7 +234,9 @@ rule xml-catalog-action ( target : property-set ? : catalog-entries * ) print.output $(actual) ; print.text $(text) : true ; - ALWAYS $(actual) ; +# ALWAYS $(actual) ; + TEMPORARY $(actual) ; + NOUPDATE $(actual) ; } } } @@ -310,8 +329,6 @@ rule boostbook ( target-name : sources * : requirements * : default-build * ) [ new boostbook-target-class $(target-name) : $(project) : $(sources) : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] - : $(.docbook-xsl-dir) $(.docbook-dtd-dir) - $(.boostbook-dtd-dir) ] ; } @@ -388,7 +405,10 @@ rule testsuite-to-jamfiles ( target : source : properties * ) { ECHO $(target) ; local boost_root = [ modules.peek : BOOST_ROOT ] ; - xslt $(target) : $(source) "$(.boostbook-xsl-dir)/testing/Jamfile.xsl" + local native-path = + [ path.native [ path.join $(.boostbook-xsl-dir) testing/ ] ] ; + local stylesheet = $(native-path:B=Jamfile:S=.xsl) ; + xslt $(target) : $(source) $(stylesheet) : $(properties) boost.root=$(boost_root) ; } @@ -398,5 +418,6 @@ rule testsuite ( target-name : source : requirements * ) local project = [ CALLER_MODULE ] ; make $(target-name) : $(source) : boostbook.testsuite-to-jamfiles - : $(requirements) : $(project) ; + : $(requirements) + ; } diff --git a/new/print.jam b/new/print.jam index 1ae996eba..9a4f722fe 100644 --- a/new/print.jam +++ b/new/print.jam @@ -243,8 +243,7 @@ rule text ( while $(strings) { local line-v = $(output-target).line.$($(output-target).line) ; - local echo-string = [ regex.split $(strings[1]) "\"" ] ; - echo-string = $(echo-string:J="\\\"") ; + local echo-string = [ escape $(strings[1]) ] ; $(line-v) on $(output-target) = $(echo-string) ; NOCARE $(line-v) ; NOTFILE $(line-v) ; @@ -275,13 +274,29 @@ rule wrapped-text ( text + ) # actions quietly text-action { - echo "$($(>))" >> $(<) + echo $($(>)) >> $(<) } # Writes a single line to target file (overwriting or creating the # file as necessary) actions quietly text-overwrite-action { - echo "$($(>))" > $(<) + echo $($(>)) > $(<) +} + +if [ modules.peek : NT ] +{ + rule escape ( string ) + { + return [ regex.escape $(string) : "&|()<>^" : "^" ] ; + } +} +else +{ + rule escape ( string ) + { + local escaped = [ regex.escape $(string) : "\\\"" : "\\" ] ; + return "\"$(escaped)\"" ; + } } local rule __test__ ( ) diff --git a/new/regex.jam b/new/regex.jam index 98a110811..de272651b 100644 --- a/new/regex.jam +++ b/new/regex.jam @@ -58,6 +58,26 @@ rule transform ( list * : pattern ) return $(result) ; } +# Escapes all of the characters in symbols using the escape symbol +# escape-symbol for the given string, and returns the escaped string +rule escape ( string : symbols : escape-symbol ) +{ + local result = "" ; + local m = 1 ; + while $(m) + { + m = [ MATCH ^([^$(symbols)]*)([$(symbols)])(.*) : $(string) ] ; + if $(m) + { + m += "" ; # Supposedly a bug fix; borrowed from regex.split + result = "$(result)$(m[1])$(escape-symbol)$(m[2])" ; + string = $(m[3]) ; + } + } + string ?= "" ; + result = "$(result)$(string)" ; + return $(result) ; +} rule __test__ ( ) { @@ -81,4 +101,10 @@ rule __test__ ( ) assert.result a.h c.h : transform \"b.h\" : <(.*)> ; + + assert.result "^" + : escape "" : "&|()<>^" : "^" ; + + assert.result "" + : escape "" : "\\\"" : "\\" ; } diff --git a/v2/boostbook.jam b/v2/boostbook.jam index bdfc4a3e0..b5c996a0d 100644 --- a/v2/boostbook.jam +++ b/v2/boostbook.jam @@ -72,18 +72,14 @@ rule init ( docbook-xsl-dir ? : docbook-dtd-dir ? : xsltproc ? ) xsltroc = [ modules.peek : XSLTPROC ] ; } - boostbook-xsl-dir = [ modules.peek : BOOST_ROOT ] ; - boostbook-xsl-dir = $(boostbook-xsl-dir)/tools/boostbook/xsl ; - boostbook-dtd-dir = [ modules.peek : BOOST_ROOT ] ; - boostbook-dtd-dir = $(boostbook-dtd-dir)/tools/boostbook/dtd ; - if ! $(.initialized) { $(.initialized) = true ; - .docbook-xsl-dir = $(docbook-xsl-dir) ; - .docbook-dtd-dir = $(docbook-dtd-dir) ; - .boostbook-xsl-dir = $(boostbook-xsl-dir) ; - .boostbook-dtd-dir = $(boostbook-dtd-dir) ; + .docbook-xsl-dir = [ path.make $(docbook-xsl-dir) ] ; + .docbook-dtd-dir = [ path.make $(docbook-dtd-dir) ] ; + local boost-root = [ path.make [ modules.peek : BOOST_ROOT ] ] ; + .boostbook-xsl-dir = [ path.join $(boost-root) tools boostbook xsl/ ] ; + .boostbook-dtd-dir = [ path.join $(boost-root) tools boostbook dtd/ ] ; .xsltproc = $(xsltproc) ; } } @@ -93,6 +89,21 @@ rule xsl-dir return $(.boostbook-xsl-dir) ; } +rule dtd-dir +{ + return $(.boostbook-dtd-dir) ; +} + +rule docbook-xsl-dir +{ + return $(.docbook-xsl-dir) ; +} + +rule docbook-dtd-dir +{ + return $(.docbook-dtd-dir) ; +} + rule xslt ( target : source stylesheet : properties * ) { local flags ; @@ -101,7 +112,6 @@ rule xslt ( target : source stylesheet : properties * ) local namevalue = [ regex.split $(param) "=" ] ; flags += --stringparam $(namevalue[1]) $(namevalue[2]) ; } - STYLESHEET on $(target) = $(stylesheet) ; FLAGS on $(target) = $(flags) ; NAME on $(target) = $(.xsltproc) ; @@ -132,40 +142,43 @@ rule dtdxml-to-boostbook ( target : source : properties * ) rule boostbook-to-docbook ( target : source : properties * ) { - xslt $(target) : $(source) "$(.boostbook-xsl-dir)/docbook.xsl" : $(properties) ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=docbook:S=.xsl) ; + xslt $(target) : $(source) $(stylesheet) : $(properties) ; } rule docbook-to-onehtml ( target : source : properties * ) { - xslt $(target) : $(source) "$(.boostbook-xsl-dir)/html-single.xsl" : $(properties) ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=html-single:S=.xsl) ; + xslt $(target) : $(source) $(stylesheet) : $(properties) ; } rule docbook-to-htmldir ( target : source : properties * ) { - xslt-dir $(target) : $(source) "$(.boostbook-xsl-dir)/html.xsl" : $(properties) : html ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=html:S=.xsl) ; + xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : html ; } rule docbook-to-manpages ( target : source : properties * ) { - xslt-dir $(target) : $(source) "$(.boostbook-xsl-dir)/manpages.xsl" : $(properties) : man ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=manpages:S=.xsl) ; + xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : man ; } rule docbook-to-fo ( target : source : properties * ) { - xslt $(target) : $(source) "$(.boostbook-xsl-dir)/fo.xsl" : $(properties) ; + local native-path = [ path.native $(.boostbook-xsl-dir) ] ; + local stylesheet = $(native-path:B=fo:S=.xsl) ; + xslt $(target) : $(source) $(stylesheet) : $(properties) ; } rule xml-catalog-action ( target : property-set ? : catalog-entries * ) { action.__init__ $(target) : : generate-xml-catalog : $(property-set) ; - self.docbook-xsl-dir = - [ feature.get-values : $(catalog-entries) ] ; - self.docbook-dtd-dir = - [ feature.get-values : $(catalog-entries) ] ; - self.boostbook-dtd-dir = - [ feature.get-values : $(catalog-entries) ] ; - rule actualize ( ) { if ! $(self.actualized) @@ -180,9 +193,12 @@ rule xml-catalog-action ( target : property-set ? : catalog-entries * ) text += "" ; # BoostBook DTD catalog entry - text += " " ; + local boostbook-dtd-dir = [ boostbook.dtd-dir ] ; - if ! $(self.docbook-xsl-dir) + text += " " ; + + local docbook-xsl-dir = [ boostbook.docbook-xsl-dir ] ; + if ! $(docbook-xsl-dir) { ECHO "BoostBook warning: no DocBook XSL directory specified." ; ECHO " If you have the DocBook XSL stylesheets installed, please " ; @@ -194,10 +210,11 @@ rule xml-catalog-action ( target : property-set ? : catalog-entries * ) } else { - text += " " ; + text += " " ; } - if ! $(self.docbook-dtd-dir) + local docbook-dtd-dir = [ boostbook.docbook-dtd-dir ] ; + if ! $(docbook-dtd-dir) { ECHO "BoostBook warning: no DocBook DTD directory specified." ; ECHO " If you have the DocBook DTD installed, please set " ; @@ -209,7 +226,7 @@ rule xml-catalog-action ( target : property-set ? : catalog-entries * ) } else { - text += " " ; + text += " " ; } text += "" ; @@ -217,7 +234,9 @@ rule xml-catalog-action ( target : property-set ? : catalog-entries * ) print.output $(actual) ; print.text $(text) : true ; - ALWAYS $(actual) ; +# ALWAYS $(actual) ; + TEMPORARY $(actual) ; + NOUPDATE $(actual) ; } } } @@ -310,8 +329,6 @@ rule boostbook ( target-name : sources * : requirements * : default-build * ) [ new boostbook-target-class $(target-name) : $(project) : $(sources) : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] - : $(.docbook-xsl-dir) $(.docbook-dtd-dir) - $(.boostbook-dtd-dir) ] ; } @@ -388,7 +405,10 @@ rule testsuite-to-jamfiles ( target : source : properties * ) { ECHO $(target) ; local boost_root = [ modules.peek : BOOST_ROOT ] ; - xslt $(target) : $(source) "$(.boostbook-xsl-dir)/testing/Jamfile.xsl" + local native-path = + [ path.native [ path.join $(.boostbook-xsl-dir) testing/ ] ] ; + local stylesheet = $(native-path:B=Jamfile:S=.xsl) ; + xslt $(target) : $(source) $(stylesheet) : $(properties) boost.root=$(boost_root) ; } @@ -398,5 +418,6 @@ rule testsuite ( target-name : source : requirements * ) local project = [ CALLER_MODULE ] ; make $(target-name) : $(source) : boostbook.testsuite-to-jamfiles - : $(requirements) : $(project) ; + : $(requirements) + ; } diff --git a/v2/util/print.jam b/v2/util/print.jam index 1ae996eba..9a4f722fe 100644 --- a/v2/util/print.jam +++ b/v2/util/print.jam @@ -243,8 +243,7 @@ rule text ( while $(strings) { local line-v = $(output-target).line.$($(output-target).line) ; - local echo-string = [ regex.split $(strings[1]) "\"" ] ; - echo-string = $(echo-string:J="\\\"") ; + local echo-string = [ escape $(strings[1]) ] ; $(line-v) on $(output-target) = $(echo-string) ; NOCARE $(line-v) ; NOTFILE $(line-v) ; @@ -275,13 +274,29 @@ rule wrapped-text ( text + ) # actions quietly text-action { - echo "$($(>))" >> $(<) + echo $($(>)) >> $(<) } # Writes a single line to target file (overwriting or creating the # file as necessary) actions quietly text-overwrite-action { - echo "$($(>))" > $(<) + echo $($(>)) > $(<) +} + +if [ modules.peek : NT ] +{ + rule escape ( string ) + { + return [ regex.escape $(string) : "&|()<>^" : "^" ] ; + } +} +else +{ + rule escape ( string ) + { + local escaped = [ regex.escape $(string) : "\\\"" : "\\" ] ; + return "\"$(escaped)\"" ; + } } local rule __test__ ( ) diff --git a/v2/util/regex.jam b/v2/util/regex.jam index 98a110811..de272651b 100644 --- a/v2/util/regex.jam +++ b/v2/util/regex.jam @@ -58,6 +58,26 @@ rule transform ( list * : pattern ) return $(result) ; } +# Escapes all of the characters in symbols using the escape symbol +# escape-symbol for the given string, and returns the escaped string +rule escape ( string : symbols : escape-symbol ) +{ + local result = "" ; + local m = 1 ; + while $(m) + { + m = [ MATCH ^([^$(symbols)]*)([$(symbols)])(.*) : $(string) ] ; + if $(m) + { + m += "" ; # Supposedly a bug fix; borrowed from regex.split + result = "$(result)$(m[1])$(escape-symbol)$(m[2])" ; + string = $(m[3]) ; + } + } + string ?= "" ; + result = "$(result)$(string)" ; + return $(result) ; +} rule __test__ ( ) { @@ -81,4 +101,10 @@ rule __test__ ( ) assert.result a.h c.h : transform \"b.h\" : <(.*)> ; + + assert.result "^" + : escape "" : "&|()<>^" : "^" ; + + assert.result "" + : escape "" : "\\\"" : "\\" ; }