mirror of
https://github.com/boostorg/build.git
synced 2026-02-17 13:42:14 +00:00
Major bug fix (gotta fix that Jam lexer!)
Some coding convention fixes [SVN r13612]
This commit is contained in:
@@ -93,14 +93,17 @@ rule parent ( path )
|
||||
}
|
||||
|
||||
#
|
||||
# Returns path2 such that "[ join path path 2 ] = .".
|
||||
# Returns path2 such that "[ join path path2 ] = .".
|
||||
# The path may not contain ".." element or be rooted.
|
||||
#
|
||||
rule reverse ( path )
|
||||
{
|
||||
if $(path) = . {
|
||||
if $(path) = .
|
||||
{
|
||||
return $(path) ;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
local tokens = [ regex.split $(path) "/" ] ;
|
||||
local tokens2 ;
|
||||
for local i in $(tokens) {
|
||||
@@ -115,27 +118,37 @@ rule reverse ( path )
|
||||
#
|
||||
rule join ( path1 path2 )
|
||||
{
|
||||
if $(path1) = . {
|
||||
if $(path1) = .
|
||||
{
|
||||
return $(path2) ;
|
||||
} else if $(path1) = / {
|
||||
}
|
||||
else if $(path1) = /
|
||||
{
|
||||
return /$(path2) ;
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
local parts = [ regex.match "((\.\./)*)(.*)" : $(path2) : 1 3 ] ;
|
||||
|
||||
if $(parts[1]) {
|
||||
|
||||
if $(parts[1])
|
||||
{
|
||||
local up_tokens = [ regex.split $(parts[1]) "/" ] ;
|
||||
for local i in $(up_tokens[1--2]) {
|
||||
for local i in $(up_tokens[1--2])
|
||||
{
|
||||
path1 = [ parent $(path1) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
if $(path1) = . {
|
||||
if $(path1) = .
|
||||
{
|
||||
return $(parts[2]) ;
|
||||
} else if $(path1) = / {
|
||||
}
|
||||
else if $(path1) = /
|
||||
{
|
||||
return /$(parts[2]) ;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return $(path1)/$(parts[2]) ;
|
||||
}
|
||||
}
|
||||
@@ -200,13 +213,17 @@ rule make-NT ( native )
|
||||
{
|
||||
local tokens = [ regex.split $(native) "[/\\]" ] ;
|
||||
local result ;
|
||||
|
||||
# Handle paths ending with slashes
|
||||
if $(tokens[-1) {
|
||||
result = [ sequence.join $(tokens) : "/" ] ;
|
||||
} else {
|
||||
result = [ sequence.join $(tokens[--2]) : "/" ] ;
|
||||
if $(tokens[-1]) = ""
|
||||
{
|
||||
tokens = $(tokens[1--2]) ; # discard the empty element
|
||||
}
|
||||
if [ regex.match "(^.:)" : $(native) ] {
|
||||
|
||||
result = [ sequence.join $(tokens) : "/" ] ;
|
||||
|
||||
if [ regex.match "(^.:)" : $(native) ]
|
||||
{
|
||||
result = /$(result) ;
|
||||
}
|
||||
return $(result) ;
|
||||
@@ -283,6 +300,7 @@ rule __test__ ( ) {
|
||||
assert.result "foo/bar/giz" : make "foo/bar/giz" ;
|
||||
assert.result "foo/bar/giz" : make "foo\\bar\\giz" ;
|
||||
assert.result "/D:/My Documents" : make "D:\\My Documents" ;
|
||||
assert.result "/c:/boost/tools/build/test/../new/project.jam" : make "c:\\boost\\tools\\build\\test\\..\\new\\project.jam" ;
|
||||
|
||||
assert.result "foo\\bar\\giz" : native "foo/bar/giz" ;
|
||||
assert.result "foo" : native "foo" ;
|
||||
|
||||
@@ -93,14 +93,17 @@ rule parent ( path )
|
||||
}
|
||||
|
||||
#
|
||||
# Returns path2 such that "[ join path path 2 ] = .".
|
||||
# Returns path2 such that "[ join path path2 ] = .".
|
||||
# The path may not contain ".." element or be rooted.
|
||||
#
|
||||
rule reverse ( path )
|
||||
{
|
||||
if $(path) = . {
|
||||
if $(path) = .
|
||||
{
|
||||
return $(path) ;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
local tokens = [ regex.split $(path) "/" ] ;
|
||||
local tokens2 ;
|
||||
for local i in $(tokens) {
|
||||
@@ -115,27 +118,37 @@ rule reverse ( path )
|
||||
#
|
||||
rule join ( path1 path2 )
|
||||
{
|
||||
if $(path1) = . {
|
||||
if $(path1) = .
|
||||
{
|
||||
return $(path2) ;
|
||||
} else if $(path1) = / {
|
||||
}
|
||||
else if $(path1) = /
|
||||
{
|
||||
return /$(path2) ;
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
local parts = [ regex.match "((\.\./)*)(.*)" : $(path2) : 1 3 ] ;
|
||||
|
||||
if $(parts[1]) {
|
||||
|
||||
if $(parts[1])
|
||||
{
|
||||
local up_tokens = [ regex.split $(parts[1]) "/" ] ;
|
||||
for local i in $(up_tokens[1--2]) {
|
||||
for local i in $(up_tokens[1--2])
|
||||
{
|
||||
path1 = [ parent $(path1) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
if $(path1) = . {
|
||||
if $(path1) = .
|
||||
{
|
||||
return $(parts[2]) ;
|
||||
} else if $(path1) = / {
|
||||
}
|
||||
else if $(path1) = /
|
||||
{
|
||||
return /$(parts[2]) ;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return $(path1)/$(parts[2]) ;
|
||||
}
|
||||
}
|
||||
@@ -200,13 +213,17 @@ rule make-NT ( native )
|
||||
{
|
||||
local tokens = [ regex.split $(native) "[/\\]" ] ;
|
||||
local result ;
|
||||
|
||||
# Handle paths ending with slashes
|
||||
if $(tokens[-1) {
|
||||
result = [ sequence.join $(tokens) : "/" ] ;
|
||||
} else {
|
||||
result = [ sequence.join $(tokens[--2]) : "/" ] ;
|
||||
if $(tokens[-1]) = ""
|
||||
{
|
||||
tokens = $(tokens[1--2]) ; # discard the empty element
|
||||
}
|
||||
if [ regex.match "(^.:)" : $(native) ] {
|
||||
|
||||
result = [ sequence.join $(tokens) : "/" ] ;
|
||||
|
||||
if [ regex.match "(^.:)" : $(native) ]
|
||||
{
|
||||
result = /$(result) ;
|
||||
}
|
||||
return $(result) ;
|
||||
@@ -283,6 +300,7 @@ rule __test__ ( ) {
|
||||
assert.result "foo/bar/giz" : make "foo/bar/giz" ;
|
||||
assert.result "foo/bar/giz" : make "foo\\bar\\giz" ;
|
||||
assert.result "/D:/My Documents" : make "D:\\My Documents" ;
|
||||
assert.result "/c:/boost/tools/build/test/../new/project.jam" : make "c:\\boost\\tools\\build\\test\\..\\new\\project.jam" ;
|
||||
|
||||
assert.result "foo\\bar\\giz" : native "foo/bar/giz" ;
|
||||
assert.result "foo" : native "foo" ;
|
||||
|
||||
Reference in New Issue
Block a user