version 1.20, 2003/07/28 18:35:36 |
version 1.21, 2003/07/28 19:05:26 |
|
|
fetchname(const char *at, int strip_leading, int assume_exists) |
fetchname(const char *at, int strip_leading, int assume_exists) |
{ |
{ |
char *fullname, *name, *t, tmpbuf[200]; |
char *fullname, *name, *t, tmpbuf[200]; |
int sleading = strip_leading; |
|
struct stat filestat; |
struct stat filestat; |
|
|
if (at == NULL || *at == '\0') |
if (at == NULL || *at == '\0') |
|
|
return NULL; /* against /dev/null. */ |
return NULL; /* against /dev/null. */ |
name = fullname = t = savestr(at); |
name = fullname = t = savestr(at); |
|
|
/* Strip off up to `sleading' leading slashes and null terminate. */ |
/* Strip off up to `strip_leading' path components and NUL terminate. */ |
for (; *t && !isspace(*t); t++) |
for (; *t != '\0' && !isspace(*t); t++) { |
if (*t == '/') |
if (t[0] == '/' && t[1] != '/' && t[1] != '\0') |
if (--sleading >= 0) |
if (--strip_leading >= 0) |
name = t + 1; |
name = t + 1; |
|
} |
*t = '\0'; |
*t = '\0'; |
|
|
/* |
/* |