Branch: Tag:

1997-08-27

1997-08-27 02:39:18 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

combine_path() now handles relative paths

Rev: src/builtin_functions.c:1.40
Rev: src/testsuite.in:1.47

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.39 1997/08/26 23:24:45 grubba Exp $"); + RCSID("$Id: builtin_functions.c,v 1.40 1997/08/27 02:39:17 hubbe Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"
411:       from=to=ret;    +  /* Skip all leading "./" */ +  while(from[0]=='.' && from[1]=='/') from+=2; +     while(( *to = *from ))    {    if(*from == '/')
423:    case '.':    if(from[3] == '/' || from[3] == 0)    { +  char *tmp=to; +  while(--tmp>=ret) +  if(*tmp == '/') +  break; +  +  if(tmp[1]=='.' && tmp[2]=='.' && (tmp[3]=='/' || !tmp[3])) +  break; +     from+=3; -  if(to != ret) +  to=tmp; +  if(to<ret)    { -  for(--to;*to!='/' && to>ret;to--); +  to++; +  if(*from) from++;    } -  if(!*from && to==ret && *to=='/') to++; +     continue;    }    break;       case 0: -  if (to == ret) { -  /* Special case, so we don't get an empty string */ -  to++; -  } -  /* FALL_THROUGH */ +     case '/':    from+=2;    continue;
448:    from++;    to++;    } +  if(!*ret) +  { +  if(*cwd=='/') +  { +  ret[0]='/'; +  ret[1]=0; +  }else{ +  ret[0]='.'; +  ret[1]=0; +  } +  }       if(my_cwd) free(my_cwd);    return ret;