From 981a0d901de47d09993233f28b71cf9ff1d1e5e1 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 7 Jul 2011 13:50:29 +1000 Subject: 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 --- jim-file.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'jim-file.c') 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); -- cgit v1.1