aboutsummaryrefslogtreecommitdiff
path: root/jim-file.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-07-07 13:50:29 +1000
committerSteve Bennett <steveb@workware.net.au>2011-07-07 21:16:07 +1000
commit981a0d901de47d09993233f28b71cf9ff1d1e5e1 (patch)
tree4609f18de548a833cda46e7156b7aa96609939f6 /jim-file.c
parentf828399b2034b8dfb03d48a8cbff33a1924e1ed7 (diff)
downloadjimtcl-981a0d901de47d09993233f28b71cf9ff1d1e5e1.zip
jimtcl-981a0d901de47d09993233f28b71cf9ff1d1e5e1.tar.gz
jimtcl-981a0d901de47d09993233f28b71cf9ff1d1e5e1.tar.bz2
Do just enough to make Jim useable with msys/mingw
Convert some paths from backslashes to forward slashes Handle splitting/joining paths which look like z:/abc/def Identify the platform as mingw Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-file.c')
-rw-r--r--jim-file.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/jim-file.c b/jim-file.c
index 4b65aa8..ea69b5a 100644
--- a/jim-file.c
+++ b/jim-file.c
@@ -188,6 +188,12 @@ static int file_cmd_dirname(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
else if (p == path) {
Jim_SetResultString(interp, "/", -1);
}
+#if defined(__MINGW32__)
+ else if (p[-1] == ':') {
+ /* z:/dir => z:/ */
+ Jim_SetResultString(interp, path, p - path + 1);
+ }
+#endif
else {
Jim_SetResultString(interp, path, p - path);
}
@@ -273,6 +279,12 @@ static int file_cmd_join(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
/* Absolute component, so go back to the start */
last = newname;
}
+#if defined(__MINGW32__)
+ else if (strchr(part, ':')) {
+ /* Absolute compontent on mingw, so go back to the start */
+ last = newname;
+ }
+#endif
/* Add a slash if needed */
if (last != newname) {
@@ -847,6 +859,15 @@ static int Jim_PwdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Jim_SetResultString(interp, "Failed to get pwd", -1);
return JIM_ERR;
}
+#if defined(__MINGW32__)
+ {
+ /* Try to keep backlashes out of paths */
+ char *p = cwd;
+ while ((p = strchr(p, '\\')) != NULL) {
+ *p++ = '/';
+ }
+ }
+#endif
Jim_SetResultString(interp, cwd, -1);