find ./ -name .cvsignore | xargs svn rm
[oweals/busybox.git] / libbb / get_last_path_component.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * bb_get_last_path_component implementation for busybox
4  *
5  * Copyright (C) 2001  Manuel Novoa III  <mjn3@codepoet.org>
6  *
7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8  */
9
10 char *bb_get_last_path_component(char *path)
11 {
12         char *first = path;
13         char *last;
14
15         last = path - 1;
16
17         while (*path) {
18                 if ((*path != '/') && (path > ++last)) {
19                         last = first = path;
20                 }
21                 ++path;
22         }
23
24         if (*first == '/') {
25                 last = first;
26         }
27         last[1] = 0;
28
29         return first;
30 }