Fix from Matt Kraai so basename / will work as expected.
This commit is contained in:
parent
e48eea63d3
commit
69a6b2d4ae
@ -1731,14 +1731,16 @@ char *get_last_path_component(char *path)
|
|||||||
char *s=path+strlen(path)-1;
|
char *s=path+strlen(path)-1;
|
||||||
|
|
||||||
/* strip trailing slashes */
|
/* strip trailing slashes */
|
||||||
while (s && *s == '/') {
|
while (s != path && *s == '/') {
|
||||||
*s-- = '\0';
|
*s-- = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find last component */
|
/* find last component */
|
||||||
s = strrchr(path, '/');
|
s = strrchr(path, '/');
|
||||||
if (s==NULL) return path;
|
if (s == NULL || s[1] == '\0')
|
||||||
else return s+1;
|
return path;
|
||||||
|
else
|
||||||
|
return s+1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user