From 2fe96002563a60c4c9e1f646f0a8c411ca09b9de Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 6 Aug 2002 15:21:02 +0000 Subject: [PATCH] Kill all uses of SUBST, which fails on long input. [SVN r14714] --- allyourbase.jam | 6 +++--- boost-base.jam | 25 ++++++++++++++++++++----- distribution.jam | 12 ++++++++---- python.jam | 5 +++-- v1/allyourbase.jam | 6 +++--- v1/boost-base.jam | 25 ++++++++++++++++++++----- v1/distribution.jam | 12 ++++++++---- v1/python.jam | 5 +++-- 8 files changed, 68 insertions(+), 28 deletions(-) diff --git a/allyourbase.jam b/allyourbase.jam index 18a0f76f0..eb6ea3535 100644 --- a/allyourbase.jam +++ b/allyourbase.jam @@ -1440,7 +1440,7 @@ rule split ( string separator ) while $(s) { - local match = [ SUBST $(s) ^(.*)$(separator)(.*) $1 $2 ] ; + local match = [ MATCH ^(.*)$(separator)(.*) : $(s) ] ; local tail = $(match[2]) ; tail ?= $(s) ; @@ -1456,7 +1456,7 @@ rule split-path ( path ) if ! $(gSPLIT_PATH_CACHE($(path))) { gSPLIT_PATH_CACHE($(path)) = - [ SUBST $(path) "^([/$(SLASH)]+).*" $1 ] # rooting slash(es), if any + [ MATCH "^([/$(SLASH)]+).*" : $(path) ] # rooting slash(es), if any [ split $(path) "[/$(SLASH)]" ] # the rest. ; } @@ -1678,7 +1678,7 @@ rule remember-binding ( target : bound-path ) { rule subst-list ( list + : pattern ) { local result ; for local i in $(list) { - result += [ SUBST $(i) $(pattern) "$1" ] ; + result += [ MATCH "($(pattern))" : $(i) ] ; } return $(result) ; } diff --git a/boost-base.jam b/boost-base.jam index 431bf1d8d..0bcbfe8e7 100644 --- a/boost-base.jam +++ b/boost-base.jam @@ -380,6 +380,20 @@ rule select-gristed ( list * ) return $(result) ; } +# Returns grist without "<"/">" for elements matching "<.*>", +# and ignores other elements. +rule ungrist ( names * ) +{ + local result ; + for local name in $(names) + { + local stripped = [ MATCH ^<(.*)>$ : $(name) ] ; + result += $(stripped) ; + } + return $(result) ; +} + + # Split a qualified property into 3 elements. # # Grammar description of qualified-property : @@ -1150,7 +1164,7 @@ rule expand-source-names ( sources * ) local x-sources = ; for local source in $(sources) { - local grist = [ SUBST $(source:G) (<)(.*)(>) $2 ] ; + local grist = [ ungrist $(source:G) ] ; local type = $(gTARGET_TYPE_ID($(grist))) ; if $(type) { @@ -1246,7 +1260,7 @@ rule declare-local-target ( target : sources * : requirements * : default-build local dependencies ; for local source in [ select-gristed $(x-sources) ] { - local dependency-type = [ SUBST $(source:G:L) (<)(.*)(>) $2 ] ; + local dependency-type = [ ungrist $(source:G:L) ] ; local dependency-type-id = $(gTARGET_TYPE_ID($(dependency-type))) ; if $(gIS_DEPENDENCY($(dependency-type-id))) { @@ -1268,7 +1282,7 @@ rule declare-local-target ( target : sources * : requirements * : default-build # for local mod in $(gTARGET_DEPS($(target-id))) { - local dependency-type-id = [ SUBST $(mod:G) (<)(.*)(>) $2 ] ; + local dependency-type-id = [ ungrist $(mod:G) ] ; local modifier-function = $(gMODIFIER_FUNCTION($(dependency-type-id))) ; if $(modifier-function) { @@ -1728,7 +1742,7 @@ rule expand-target-subvariants ( target : local-build * : tools + : ) # rule split-target-subvariant ( target-var properties-var toolset-var variant-var : subvariant ) { - local subvariant-items = [ SUBST $(subvariant) (.*)[|](.*)[|](.*)[|](.*) $1 $2 $3 $4 ] ; + local subvariant-items = [ MATCH (.*)[|](.*)[|](.*)[|](.*) : $(subvariant) ] ; $(target-var) = $(subvariant-items[1]) ; $(properties-var) = [ split-path-at-grist $(subvariant-items[2]) ] ; $(toolset-var) = $(subvariant-items[3]) ; @@ -1917,7 +1931,8 @@ rule rename-target ( target + : subvariant * : tags * ) local tag-values = ; for local tag in $(tags) { - local tag-tokens = [ SUBST $(tag:G=) (<)(.*)(>)(.*) $2 $4 ] ; + local tag-tokens = [ MATCH (<)(.*)(>)(.*) : $(tag:G=) ] ; + tag-tokens = $(tag-tokens[2]) $(tag-tokens[4]) ; tag-values += $(tag-tokens[2]:G=$(tag-tokens[1])) ; } diff --git a/distribution.jam b/distribution.jam index caea5db19..e8021eaba 100644 --- a/distribution.jam +++ b/distribution.jam @@ -66,14 +66,18 @@ rule version-header ( target : name version comment-text * ) # Translat the name & version into the various version info definitions. # local s = " " ; - local target-suffix = [ SUBST $(target:S) .(.*) $1 ] ; + local target-suffix = [ MATCH .(.*) : $(target:S) ] ; local target-tag = [ join [ split-path $(target-dir) ] $(target:B) $(target-suffix) : "_" ] ; target-tag = $(target-tag:U) ; local name-tag = [ join [ split $(name:U) "\\." ] : "_" ] ; local version-parts = ; - version-parts += [ SUBST $(version) ^(.*)\\.(.*) $1 ] ; - version-parts += [ SUBST $(version) ^(.*)\\.(.*)\\.* $2 ] ; - version-parts += [ SUBST $(version) ^(.*)\\.(.*)\\.(.*) $3 ] ; + local t ; + t = [ MATCH ^(.*)\\.(.*) : $(version) ] ; + version-parts += $(t[1]) ; + t = [ MATCH ^(.*)\\.(.*)\\.* : $(version) ] ; + version-parts += $(t[2]) ; + t = [ MATCH ^(.*)\\.(.*)\\.(.*) : $(version) ] ; + version-parts += $(t[3]) ; if ! $(version-parts[2]) { version-parts += 0 0 ; } if ! $(version-parts[3]) { version-parts += 0 ; } local version-id = $(version-parts[1]) ; diff --git a/python.jam b/python.jam index 3b5f10d83..6e8f833a8 100644 --- a/python.jam +++ b/python.jam @@ -17,8 +17,9 @@ else if $(UNIX) # Strip the dot from the Python version in order to be able to name # libraries PYTHON_VERSION_NODOT - = [ SUBST $(PYTHON_VERSION) ([0-9]*)\.([0-9]*) $1$2 ] + = [ MATCH ([0-9]*)\.([0-9]*) : $(PYTHON_VERSION) ] ; +PYTHON_VERSION_NODOT = $(PYTHON_VERSION_NODOT:J=) ; local RUN_PATH = $(RUN_PATH) ; @@ -429,7 +430,7 @@ rule python-runtest-aux ( target : sources + ) if $(p:R=xx) = $(p) { p = [ split-path $(p) ] ; - p = [ join-path /cygdrive [ SUBST $(p[1]) ^(.).* $1 ] $(p[2-]) ] ; + p = [ join-path /cygdrive [ MATCH ^(.).* : $(p[1]) ] $(p[2-]) ] ; } pp += $(p) ; } diff --git a/v1/allyourbase.jam b/v1/allyourbase.jam index 18a0f76f0..eb6ea3535 100644 --- a/v1/allyourbase.jam +++ b/v1/allyourbase.jam @@ -1440,7 +1440,7 @@ rule split ( string separator ) while $(s) { - local match = [ SUBST $(s) ^(.*)$(separator)(.*) $1 $2 ] ; + local match = [ MATCH ^(.*)$(separator)(.*) : $(s) ] ; local tail = $(match[2]) ; tail ?= $(s) ; @@ -1456,7 +1456,7 @@ rule split-path ( path ) if ! $(gSPLIT_PATH_CACHE($(path))) { gSPLIT_PATH_CACHE($(path)) = - [ SUBST $(path) "^([/$(SLASH)]+).*" $1 ] # rooting slash(es), if any + [ MATCH "^([/$(SLASH)]+).*" : $(path) ] # rooting slash(es), if any [ split $(path) "[/$(SLASH)]" ] # the rest. ; } @@ -1678,7 +1678,7 @@ rule remember-binding ( target : bound-path ) { rule subst-list ( list + : pattern ) { local result ; for local i in $(list) { - result += [ SUBST $(i) $(pattern) "$1" ] ; + result += [ MATCH "($(pattern))" : $(i) ] ; } return $(result) ; } diff --git a/v1/boost-base.jam b/v1/boost-base.jam index 431bf1d8d..0bcbfe8e7 100644 --- a/v1/boost-base.jam +++ b/v1/boost-base.jam @@ -380,6 +380,20 @@ rule select-gristed ( list * ) return $(result) ; } +# Returns grist without "<"/">" for elements matching "<.*>", +# and ignores other elements. +rule ungrist ( names * ) +{ + local result ; + for local name in $(names) + { + local stripped = [ MATCH ^<(.*)>$ : $(name) ] ; + result += $(stripped) ; + } + return $(result) ; +} + + # Split a qualified property into 3 elements. # # Grammar description of qualified-property : @@ -1150,7 +1164,7 @@ rule expand-source-names ( sources * ) local x-sources = ; for local source in $(sources) { - local grist = [ SUBST $(source:G) (<)(.*)(>) $2 ] ; + local grist = [ ungrist $(source:G) ] ; local type = $(gTARGET_TYPE_ID($(grist))) ; if $(type) { @@ -1246,7 +1260,7 @@ rule declare-local-target ( target : sources * : requirements * : default-build local dependencies ; for local source in [ select-gristed $(x-sources) ] { - local dependency-type = [ SUBST $(source:G:L) (<)(.*)(>) $2 ] ; + local dependency-type = [ ungrist $(source:G:L) ] ; local dependency-type-id = $(gTARGET_TYPE_ID($(dependency-type))) ; if $(gIS_DEPENDENCY($(dependency-type-id))) { @@ -1268,7 +1282,7 @@ rule declare-local-target ( target : sources * : requirements * : default-build # for local mod in $(gTARGET_DEPS($(target-id))) { - local dependency-type-id = [ SUBST $(mod:G) (<)(.*)(>) $2 ] ; + local dependency-type-id = [ ungrist $(mod:G) ] ; local modifier-function = $(gMODIFIER_FUNCTION($(dependency-type-id))) ; if $(modifier-function) { @@ -1728,7 +1742,7 @@ rule expand-target-subvariants ( target : local-build * : tools + : ) # rule split-target-subvariant ( target-var properties-var toolset-var variant-var : subvariant ) { - local subvariant-items = [ SUBST $(subvariant) (.*)[|](.*)[|](.*)[|](.*) $1 $2 $3 $4 ] ; + local subvariant-items = [ MATCH (.*)[|](.*)[|](.*)[|](.*) : $(subvariant) ] ; $(target-var) = $(subvariant-items[1]) ; $(properties-var) = [ split-path-at-grist $(subvariant-items[2]) ] ; $(toolset-var) = $(subvariant-items[3]) ; @@ -1917,7 +1931,8 @@ rule rename-target ( target + : subvariant * : tags * ) local tag-values = ; for local tag in $(tags) { - local tag-tokens = [ SUBST $(tag:G=) (<)(.*)(>)(.*) $2 $4 ] ; + local tag-tokens = [ MATCH (<)(.*)(>)(.*) : $(tag:G=) ] ; + tag-tokens = $(tag-tokens[2]) $(tag-tokens[4]) ; tag-values += $(tag-tokens[2]:G=$(tag-tokens[1])) ; } diff --git a/v1/distribution.jam b/v1/distribution.jam index caea5db19..e8021eaba 100644 --- a/v1/distribution.jam +++ b/v1/distribution.jam @@ -66,14 +66,18 @@ rule version-header ( target : name version comment-text * ) # Translat the name & version into the various version info definitions. # local s = " " ; - local target-suffix = [ SUBST $(target:S) .(.*) $1 ] ; + local target-suffix = [ MATCH .(.*) : $(target:S) ] ; local target-tag = [ join [ split-path $(target-dir) ] $(target:B) $(target-suffix) : "_" ] ; target-tag = $(target-tag:U) ; local name-tag = [ join [ split $(name:U) "\\." ] : "_" ] ; local version-parts = ; - version-parts += [ SUBST $(version) ^(.*)\\.(.*) $1 ] ; - version-parts += [ SUBST $(version) ^(.*)\\.(.*)\\.* $2 ] ; - version-parts += [ SUBST $(version) ^(.*)\\.(.*)\\.(.*) $3 ] ; + local t ; + t = [ MATCH ^(.*)\\.(.*) : $(version) ] ; + version-parts += $(t[1]) ; + t = [ MATCH ^(.*)\\.(.*)\\.* : $(version) ] ; + version-parts += $(t[2]) ; + t = [ MATCH ^(.*)\\.(.*)\\.(.*) : $(version) ] ; + version-parts += $(t[3]) ; if ! $(version-parts[2]) { version-parts += 0 0 ; } if ! $(version-parts[3]) { version-parts += 0 ; } local version-id = $(version-parts[1]) ; diff --git a/v1/python.jam b/v1/python.jam index 3b5f10d83..6e8f833a8 100644 --- a/v1/python.jam +++ b/v1/python.jam @@ -17,8 +17,9 @@ else if $(UNIX) # Strip the dot from the Python version in order to be able to name # libraries PYTHON_VERSION_NODOT - = [ SUBST $(PYTHON_VERSION) ([0-9]*)\.([0-9]*) $1$2 ] + = [ MATCH ([0-9]*)\.([0-9]*) : $(PYTHON_VERSION) ] ; +PYTHON_VERSION_NODOT = $(PYTHON_VERSION_NODOT:J=) ; local RUN_PATH = $(RUN_PATH) ; @@ -429,7 +430,7 @@ rule python-runtest-aux ( target : sources + ) if $(p:R=xx) = $(p) { p = [ split-path $(p) ] ; - p = [ join-path /cygdrive [ SUBST $(p[1]) ^(.).* $1 ] $(p[2-]) ] ; + p = [ join-path /cygdrive [ MATCH ^(.).* : $(p[1]) ] $(p[2-]) ] ; } pp += $(p) ; }