summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/utility.c b/utility.c
index a15ae68..a313078 100644
--- a/utility.c
+++ b/utility.c
@@ -1675,6 +1675,23 @@ char process_escape_sequence(char **ptr)
}
#endif
+#if defined BB_BASENAME || defined BB_LN
+char *get_last_path_component(char *path)
+{
+ char *s=path+strlen(path)-1;
+
+ /* strip trailing slashes */
+ while (s && *s == '/') {
+ *s-- = '\0';
+ }
+
+ /* find last component */
+ s = strrchr(path, '/');
+ if (s==NULL) return path;
+ else return s+1;
+}
+#endif
+
/* END CODE */
/*
Local Variables: