- s = start;
- /* remove . and .. */
- while(*s) {
- if(*s++ == '/' && (*s == '/' || *s == 0)) {
- /* remove duplicate and trailing slashes */
- s = strcpy_overlap(s-1, s);
- }
- else if(*(s-1) == '.' && *(s-2)=='/') {
- if(*s == '/' || *s == 0) {
- /* remove . */
- s = strcpy_overlap(s-1, s); /* maybe set // */
- s--;
- } else if(*s == '.') {
- next = s+1; /* set after ".." */
- if(*next == '/' || *next == 0) { /* "../" */
- if((s-=2) > start)
- /* skip previous dir */
- do s--; while(*s != '/');
- /* remove previous dir */
- strcpy_overlap(s, next);
- }