diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-12-12 23:13:54 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-12-12 23:13:54 +0000 |
commit | 69a6b2d4aef2028a963751a2105d55a305d046ba (patch) | |
tree | 5c7c91363ab9f4bfbd29b7d4e2fb4d05e9e74ed5 | |
parent | e48eea63d3c826afe78f75bbd24971887e6e932b (diff) | |
download | busybox-w32-69a6b2d4aef2028a963751a2105d55a305d046ba.tar.gz busybox-w32-69a6b2d4aef2028a963751a2105d55a305d046ba.tar.bz2 busybox-w32-69a6b2d4aef2028a963751a2105d55a305d046ba.zip |
Fix from Matt Kraai so basename / will work as expected.
-rw-r--r-- | utility.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1731,14 +1731,16 @@ char *get_last_path_component(char *path) | |||
1731 | char *s=path+strlen(path)-1; | 1731 | char *s=path+strlen(path)-1; |
1732 | 1732 | ||
1733 | /* strip trailing slashes */ | 1733 | /* strip trailing slashes */ |
1734 | while (s && *s == '/') { | 1734 | while (s != path && *s == '/') { |
1735 | *s-- = '\0'; | 1735 | *s-- = '\0'; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | /* find last component */ | 1738 | /* find last component */ |
1739 | s = strrchr(path, '/'); | 1739 | s = strrchr(path, '/'); |
1740 | if (s==NULL) return path; | 1740 | if (s == NULL || s[1] == '\0') |
1741 | else return s+1; | 1741 | return path; |
1742 | else | ||
1743 | return s+1; | ||
1742 | } | 1744 | } |
1743 | #endif | 1745 | #endif |
1744 | 1746 | ||