diff options
author | Eric Andersen | 2000-12-12 23:13:54 +0000 |
---|---|---|
committer | Eric Andersen | 2000-12-12 23:13:54 +0000 |
commit | 69a6b2d4aef2028a963751a2105d55a305d046ba (patch) | |
tree | 5c7c91363ab9f4bfbd29b7d4e2fb4d05e9e74ed5 /utility.c | |
parent | e48eea63d3c826afe78f75bbd24971887e6e932b (diff) | |
download | busybox-69a6b2d4aef2028a963751a2105d55a305d046ba.zip busybox-69a6b2d4aef2028a963751a2105d55a305d046ba.tar.gz |
Fix from Matt Kraai so basename / will work as expected.
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1731,14 +1731,16 @@ char *get_last_path_component(char *path) char *s=path+strlen(path)-1; /* strip trailing slashes */ - while (s && *s == '/') { + while (s != path && *s == '/') { *s-- = '\0'; } /* find last component */ s = strrchr(path, '/'); - if (s==NULL) return path; - else return s+1; + if (s == NULL || s[1] == '\0') + return path; + else + return s+1; } #endif |