diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-22 00:47:18 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-22 00:47:18 +0200 |
| commit | fbb12ddc6a53ad97ff6bcc7ed9b253c09001ad2f (patch) | |
| tree | 94c82f9eac30c86a1ec4f4d06f6c17b72b47cf3e /libbb | |
| parent | b6bca7703bbe6aacec0bda964c82fad389a02b69 (diff) | |
| download | busybox-w32-1_14_2.tar.gz busybox-w32-1_14_2.tar.bz2 busybox-w32-1_14_2.zip | |
post 1.14.1 fixes; bump version to 1.14.21_14_2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
| -rw-r--r-- | libbb/simplify_path.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/libbb/simplify_path.c b/libbb/simplify_path.c index 367f1f04d..f80e3e8a5 100644 --- a/libbb/simplify_path.c +++ b/libbb/simplify_path.c | |||
| @@ -6,22 +6,13 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | char* FAST_FUNC bb_simplify_path(const char *path) | 11 | char* FAST_FUNC bb_simplify_abs_path_inplace(char *start) |
| 13 | { | 12 | { |
| 14 | char *s, *start, *p; | 13 | char *s, *p; |
| 15 | 14 | ||
| 16 | if (path[0] == '/') | ||
| 17 | start = xstrdup(path); | ||
| 18 | else { | ||
| 19 | s = xrealloc_getcwd_or_warn(NULL); | ||
| 20 | start = concat_path_file(s, path); | ||
| 21 | free(s); | ||
| 22 | } | ||
| 23 | p = s = start; | 15 | p = s = start; |
| 24 | |||
| 25 | do { | 16 | do { |
| 26 | if (*p == '/') { | 17 | if (*p == '/') { |
| 27 | if (*s == '/') { /* skip duplicate (or initial) slash */ | 18 | if (*s == '/') { /* skip duplicate (or initial) slash */ |
| @@ -47,7 +38,22 @@ char* FAST_FUNC bb_simplify_path(const char *path) | |||
| 47 | if ((p == start) || (*p != '/')) { /* not a trailing slash */ | 38 | if ((p == start) || (*p != '/')) { /* not a trailing slash */ |
| 48 | ++p; /* so keep last character */ | 39 | ++p; /* so keep last character */ |
| 49 | } | 40 | } |
| 50 | *p = 0; | 41 | *p = '\0'; |
| 42 | return p; | ||
| 43 | } | ||
| 44 | |||
| 45 | char* FAST_FUNC bb_simplify_path(const char *path) | ||
| 46 | { | ||
| 47 | char *s, *p; | ||
| 48 | |||
| 49 | if (path[0] == '/') | ||
| 50 | s = xstrdup(path); | ||
| 51 | else { | ||
| 52 | p = xrealloc_getcwd_or_warn(NULL); | ||
| 53 | s = concat_path_file(p, path); | ||
| 54 | free(p); | ||
| 55 | } | ||
| 51 | 56 | ||
| 52 | return start; | 57 | bb_simplify_abs_path_inplace(s); |
| 58 | return s; | ||
| 53 | } | 59 | } |
