diff options
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -1675,6 +1675,23 @@ char process_escape_sequence(char **ptr) | |||
1675 | } | 1675 | } |
1676 | #endif | 1676 | #endif |
1677 | 1677 | ||
1678 | #if defined BB_BASENAME || defined BB_LN | ||
1679 | char *get_last_path_component(char *path) | ||
1680 | { | ||
1681 | char *s=path+strlen(path)-1; | ||
1682 | |||
1683 | /* strip trailing slashes */ | ||
1684 | while (s && *s == '/') { | ||
1685 | *s-- = '\0'; | ||
1686 | } | ||
1687 | |||
1688 | /* find last component */ | ||
1689 | s = strrchr(path, '/'); | ||
1690 | if (s==NULL) return path; | ||
1691 | else return s+1; | ||
1692 | } | ||
1693 | #endif | ||
1694 | |||
1678 | /* END CODE */ | 1695 | /* END CODE */ |
1679 | /* | 1696 | /* |
1680 | Local Variables: | 1697 | Local Variables: |