}
if (res==0) {
- int old_fd = open(".", O_RDONLY);
-
*end = '\0';
-
- if (old_fd!=-1 &&
- chdir(start)!=-1 &&
- getcwd(buf, sizeof buf)==buf)
- start = buf;
-
- res = basename(start);
+ res = realpath(start, buf);
+ //printf("start='%s', res='%s'\n", start,res);
+ if (res==0) res = start;
- if (old_fd!=-1) {
- fchdir(old_fd);
- close(old_fd);
- }
+ res = basename(res);
}
return strdup(res);