diff options
Diffstat (limited to 'libbb/dirname.c')
-rw-r--r-- | libbb/dirname.c | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/libbb/dirname.c b/libbb/dirname.c deleted file mode 100644 index 81298730b..000000000 --- a/libbb/dirname.c +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * dirname implementation for busybox (for libc's missing one) | ||
4 | * | ||
5 | * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | /* Note: The previous busybox implementation did not handle NULL path | ||
24 | * and also moved a pointer before path, which is not portable in C. | ||
25 | * So I replaced it with my uClibc version. | ||
26 | */ | ||
27 | |||
28 | #include <string.h> | ||
29 | #include "libbb.h" | ||
30 | |||
31 | #if __GNU_LIBRARY__ < 5 | ||
32 | |||
33 | extern | ||
34 | char *dirname(char *path) | ||
35 | { | ||
36 | static const char null_or_empty_or_noslash[] = "."; | ||
37 | register char *s; | ||
38 | register char *last; | ||
39 | char *first; | ||
40 | |||
41 | last = s = path; | ||
42 | |||
43 | if (s != NULL) { | ||
44 | |||
45 | LOOP: | ||
46 | while (*s && (*s != '/')) ++s; | ||
47 | first = s; | ||
48 | while (*s == '/') ++s; | ||
49 | if (*s) { | ||
50 | last = first; | ||
51 | goto LOOP; | ||
52 | } | ||
53 | |||
54 | if (last == path) { | ||
55 | if (*last != '/') { | ||
56 | goto DOT; | ||
57 | } | ||
58 | if ((*++last == '/') && (last[1] == 0)) { | ||
59 | ++last; | ||
60 | } | ||
61 | } | ||
62 | *last = 0; | ||
63 | return path; | ||
64 | } | ||
65 | DOT: | ||
66 | return (char *) null_or_empty_or_noslash; | ||
67 | } | ||
68 | |||
69 | #endif | ||