pike.git / src / combine_path.h

version» Context lines:

pike.git/src/combine_path.h:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: combine_path.h,v 1.11 2002/10/11 01:39:30 nilsson Exp $ + || $Id: combine_path.h,v 1.12 2004/05/01 15:04:35 mast Exp $   */      /*    * Combine path template.    *    */      #undef IS_SEP   #undef IS_ABS   #undef IS_ROOT
pike.git/src/combine_path.h:34:   {    int c0=INDEX_PCHARP(s,0);    int c1=c0?INDEX_PCHARP(s,1):0;    if(isalpha(c0) && c1==':' && IS_SEP(INDEX_PCHARP(s,2)))    return 3;       if(IS_SEP(c0) && IS_SEP(c1))    {    int l;    for(l=2;INDEX_PCHARP(s,l) && !IS_SEP(INDEX_PCHARP(s,l));l++); -  return l; +  return INDEX_PCHARP(s,l)? l+1:l;    }       return 0;   }   #define IS_ABS(X) find_absolute((X))   #define IS_ROOT(X) ( IS_SEP( INDEX_PCHARP((X),0) )?1:0)      #define APPEND_PATH append_path_nt   #define F_COMBINE_PATH f_combine_path_nt   
pike.git/src/combine_path.h:65:    /* First, check if path is absolute,    * if so ignore anything already in 's'    */    abs=IS_ABS(MKPCHARP_STR(s->s));    if((tmp=IS_ABS(path)))    {    s->s->len=0;    s->known_shift=0;    string_builder_append(s, path, tmp);    from+=tmp; -  abs++; +  abs=tmp;    }   #ifdef IS_ROOT    else if((tmp=IS_ROOT(path)))    {    int tmp2; -  abs++; +     s->known_shift=0;    if((tmp2=IS_ABS(MKPCHARP_STR(s->s))))    {    s->s->len=tmp2; -  +  abs=tmp2;    }else{    s->s->len=0;    string_builder_append(s, path, tmp); -  +  abs=tmp;    }    from+=tmp;    }   #endif      #define LAST_PUSHED() (s->s->len ? index_shared_string(s->s,s->s->len-1) : 0)   #define PUSH(X) string_builder_putchar(s,(X))       /* Ensure s ends with a separator. */    if(s->s->len && !IS_SEP(LAST_PUSHED()))
pike.git/src/combine_path.h:135:   #endif       switch(INDEX_PCHARP(path, from+1))    {    case '.':    c3=INDEX_PCHARP(path, from+2);    if(IS_SEP(c3) || !c3)    {    /* Handle "..". */    int tmp=s->s->len-1; -  +     if (tmp) {    while(--tmp>=0)    if(IS_SEP(index_shared_string(s->s, tmp)))    break;    tmp++;    } else if (IS_SEP(index_shared_string(s->s, 0))) {    tmp++;    }    -  +  if (tmp < abs) +  tmp = abs; +  else    if ((tmp+1 < s->s->len) &&    (index_shared_string(s->s,tmp)=='.') &&    (index_shared_string(s->s,tmp+1)=='.') &&    ( (tmp+2 == s->s->len) ||    IS_SEP(index_shared_string(s->s,tmp+2))))    break;    -  -  from+=2; +  from+=(c3? 3:2);    s->s->len=tmp;    s->known_shift=0;      #if COMBINE_PATH_DEBUG > 0    s->s->str[s->s->len]=0;    fprintf(stderr,"combine_path(1), TO: %s\n",s->s->str);    fprintf(stderr,"combine_path(1), FROM (%d): %s\n",from,path.ptr+from);   #endif    continue;    }
pike.git/src/combine_path.h:181:    /* Handle ".". */    from++;    continue;    }    }    }       if(from>=len) break;    PUSH(INDEX_PCHARP(path, from++));    } -  if((s->s->len > 1) && +  if((s->s->len > 1) && (s->s->len > abs) &&    !IS_SEP(INDEX_PCHARP(path, from-1)) &&    IS_SEP(LAST_PUSHED()))    s->s->len--;       if(!s->s->len)    {    if(abs)    {    PUSH('/');    }else{    PUSH('.'); -  +  if(IS_SEP(INDEX_PCHARP(path, from-1))) +  PUSH('/');    }    }   }      void F_COMBINE_PATH(INT32 args)   {    int e;    int root=0;    struct string_builder ret;    ONERROR tmp;