2
0
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:
Dave Abrahams
2002-05-02 16:30:38 +00:00
parent 0f7b53fd2f
commit a387e51771
2 changed files with 72 additions and 36 deletions

View File

@@ -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" ;

View File

@@ -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" ;