summaryrefslogtreecommitdiff
path: root/libbb/simplify_path.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/simplify_path.c')
-rw-r--r--libbb/simplify_path.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libbb/simplify_path.c b/libbb/simplify_path.c
index 7e68e39..29e371d 100644
--- a/libbb/simplify_path.c
+++ b/libbb/simplify_path.c
@@ -26,13 +26,16 @@ char *bb_simplify_path(const char *path)
if (*p == '/') {
if (*s == '/') { /* skip duplicate (or initial) slash */
continue;
- } else if (*s == '.') {
- if (s[1] == '/' || s[1] == 0) { /* remove extra '.' */
+ }
+ if (*s == '.') {
+ if (s[1] == '/' || !s[1]) { /* remove extra '.' */
continue;
- } else if ((s[1] == '.') && (s[2] == '/' || s[2] == 0)) {
+ }
+ if ((s[1] == '.') && (s[2] == '/' || !s[2])) {
++s;
if (p > start) {
- while (*--p != '/'); /* omit previous dir */
+ while (*--p != '/') /* omit previous dir */
+ continue;
}
continue;
}