aboutsummaryrefslogtreecommitdiff
path: root/jim-file.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-07-12 08:16:50 +1000
committerSteve Bennett <steveb@workware.net.au>2011-07-12 19:17:40 +1000
commit3b317b146c492ca5176044484af7d5877799a716 (patch)
tree915b08a7fc1cbcc7042b4bacbc8a74f2a111d15e /jim-file.c
parent3c2e76f21f3bc3c154018135b4352ef5c694f113 (diff)
downloadjimtcl-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.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/jim-file.c b/jim-file.c
index 111e926..8e3d9d6 100644
--- a/jim-file.c
+++ b/jim-file.c
@@ -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;
}
}