1 /* vi: set sw=4 ts=4: */
3 * bb_simplify_path implementation for busybox
5 * Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org>
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 char* FAST_FUNC
bb_simplify_abs_path_inplace(char *start
)
18 if (*s
== '/') { /* skip duplicate (or initial) slash */
22 if (s
[1] == '/' || !s
[1]) { /* remove extra '.' */
25 if ((s
[1] == '.') && (s
[2] == '/' || !s
[2])) {
28 while (*--p
!= '/') /* omit previous dir */
38 if ((p
== start
) || (*p
!= '/')) { /* not a trailing slash */
39 ++p
; /* so keep last character */
45 char* FAST_FUNC
bb_simplify_path(const char *path
)
52 p
= xrealloc_getcwd_or_warn(NULL
);
53 s
= concat_path_file(p
, path
);
57 bb_simplify_abs_path_inplace(s
);