| * bb_simplify_path implementation for busybox |
| * Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org> |
| * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| char* FAST_FUNC bb_simplify_abs_path_inplace(char *start) |
| if (*s == '/') { /* skip duplicate (or initial) slash */ |
| if (s[1] == '/' || !s[1]) { /* remove extra '.' */ |
| if ((s[1] == '.') && (s[2] == '/' || !s[2])) { |
| while (*--p != '/') /* omit previous dir */ |
| if ((p == start) || (*p != '/')) { /* not a trailing slash */ |
| ++p; /* so keep last character */ |
| char* FAST_FUNC bb_simplify_path(const char *path) |
| p = xrealloc_getcwd_or_warn(NULL); |
| s = concat_path_file(p, path); |
| bb_simplify_abs_path_inplace(s); |