pike.git / src / combine_path.h

version» Context lines:

pike.git/src/combine_path.h:173: Inside #if defined(AMIGAOS_COMBINE_PATH)
   /* Handle "//" */    int tmp=s->s->len-2;    while(tmp>0 && !IS_ANY_SEP(index_shared_string(s->s,tmp-1)))    --tmp;    s->s->len=tmp;    s->known_shift=0;    from++;    continue;    }   #else /* !AMIGAOS_COMBINE_PATH */ +  do { +  /* Remove sequences of ending slashes and single dots +  * from the result path. +  */    while(s->s->len && IS_SEP(LAST_PUSHED()))    s->s->len--; -  +  if (LAST_PUSHED() == '.') { +  if (s->s->len == 1) { +  /* Result path started with "./". */ +  s->s->len = 0; +  break; +  } else if (IS_SEP(index_shared_string(s->s, s->s->len-2))) { +  /* Result path ended with "/./". */ +  s->s->len -= 2; +  continue; +  } +  } +  /* Restore a single slash as directory separator. */    PUSH('/'); -  +  break; +  } while (1);    if(from<len && INDEX_PCHARP(path, from) == '.')    {    int c3;   #if COMBINE_PATH_DEBUG > 0    /* s->s->str[s->s->len]=0; */    fprintf(stderr, "combine_path(0), TO: \"%s\"[%d]\n",    s->s->str, s->s->len);    fprintf(stderr, "combine_path(0), FROM (%d): \"%s\"[%d]\n",    from, path.ptr+from, len - from);   #endif       switch(INDEX_PCHARP(path, from+1))    {    case '.':    c3=INDEX_PCHARP(path, from+2); -  if(IS_SEP(c3) || !c3) +  if(s->s->len && (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++;
pike.git/src/combine_path.h:213:       if (tmp < abs)    tmp = abs;    else {    if (index_shared_string(s->s,tmp)=='.') {    if ((tmp+1 < s->s->len) &&    (index_shared_string(s->s,tmp+1)=='.') &&    ( (tmp+2 == s->s->len) ||    IS_SEP(index_shared_string(s->s,tmp+2)))) {    break; -  } else if ((tmp+1 == s->s->len) || -  IS_SEP(index_shared_string(s->s,tmp+1))) { -  /* Previous is "." or "./". -  * Replace it with "..". -  */ -  if (tmp+1 != s->s->len) { -  /* Remove the separator. */ -  s->s->len--; +     } -  PUSH('.'); -  from += 2; -  if (c3) { -  PUSH('/'); -  from++; +     } - #if COMBINE_PATH_DEBUG > 0 -  /* s->s->str[s->s->len]=0; */ -  fprintf(stderr,"combine_path(2), TO: %s[%d]\n", -  s->s->str, s->s->len); -  fprintf(stderr,"combine_path(2), FROM (%d): %s[%d]\n", -  from, path.ptr+from, len-from); - #endif -  continue; +     } -  } -  } +        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[%d]\n",    s->s->str, s->s->len);    fprintf(stderr,"combine_path(1), FROM (%d): %s[%d]\n",