diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 624c3bc4785c8fbcc62308bb9174c06c30017311..45e659cbf9d8b67e8650e552c4422bfd48e10613 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: builtin_functions.c,v 1.56 1997/11/08 01:34:36 hubbe Exp $"); +RCSID("$Id: builtin_functions.c,v 1.57 1997/11/13 22:13:28 hubbe Exp $"); #include "interpret.h" #include "svalue.h" #include "pike_macros.h" @@ -426,7 +426,7 @@ static char *combine_path(char *cwd,char *file) { if(*from == '/') { - while(from[1] == '/') from++; + while(to>ret && to[-1]=='/') to--; if(from[1] == '.') { switch(from[2]) @@ -438,17 +438,13 @@ static char *combine_path(char *cwd,char *file) while(--tmp>=ret) if(*tmp == '/') break; + tmp++; - if(tmp[1]=='.' && tmp[2]=='.' && (tmp[3]=='/' || !tmp[3])) + if(tmp[0]=='.' && tmp[1]=='.' && (tmp[2]=='/' || !tmp[2])) break; from+=3; to=tmp; - if(to<ret) - { - to++; - if(*from) from++; - } continue; } break; @@ -463,6 +459,10 @@ static char *combine_path(char *cwd,char *file) from++; to++; } + + if(*cwd && from[-1]!='/' && *ret && ret[-1]=='/') + *--to=0; + if(!*ret) { if(*cwd=='/') diff --git a/src/testsuite.in b/src/testsuite.in index 97ca99ca3e60e6ed85402426f35c808071c219f6..e80ab265a4ea3741e29ccb70d6abafe630490d8d 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,4 +1,4 @@ -test_true([["$Id: testsuite.in,v 1.60 1997/10/19 22:13:33 hubbe Exp $"]]) +test_true([["$Id: testsuite.in,v 1.61 1997/11/13 22:13:29 hubbe Exp $"]]) test_eq(1e1,10.0) test_eq(1E1,10.0) test_eq(1e+1,10.0) @@ -1512,6 +1512,7 @@ test_eq([[combine_path("/","/foo/././/bar/gazonk/../../../..")]],"/") test_eq([[combine_path("/","..")]],"/") test_eq([[combine_path("./","..")]],"..") test_eq([[combine_path("./.","..")]],"..") +test_eq([[combine_path("/","../../foo")]],"/foo") test_eq([[combine_path("./foobar/.","..")]],".") // - compile_file