diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-07-12 08:16:50 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-07-12 19:17:40 +1000 |
commit | 3b317b146c492ca5176044484af7d5877799a716 (patch) | |
tree | 915b08a7fc1cbcc7042b4bacbc8a74f2a111d15e /jim-file.c | |
parent | 3c2e76f21f3bc3c154018135b4352ef5c694f113 (diff) | |
download | jimtcl-3b317b146c492ca5176044484af7d5877799a716.zip jimtcl-3b317b146c492ca5176044484af7d5877799a716.tar.gz jimtcl-3b317b146c492ca5176044484af7d5877799a716.tar.bz2 |
Fix some [file join] cases
In particular, file join / anything
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-file.c')
-rw-r--r-- | jim-file.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -285,9 +285,18 @@ static int file_cmd_join(Jim_Interp *interp, int argc, Jim_Obj *const *argv) last = newname; } #endif + else if (part[0] == '.') { + if (part[1] == '/') { + part += 2; + } + else if (part[1] == 0 && last != newname) { + /* Adding '.' to an existing path does nothing */ + continue; + } + } /* Add a slash if needed */ - if (last != newname) { + if (last != newname && last[-1] != '/') { *last++ = '/'; } @@ -302,7 +311,7 @@ static int file_cmd_join(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } /* Remove a slash if needed */ - if (last != newname && last[-1] == '/') { + if (last > newname + 1 && last[-1] == '/') { *--last = 0; } } |