aboutsummaryrefslogtreecommitdiff
path: root/jim-file.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2014-01-11 21:13:16 +1000
committerSteve Bennett <steveb@workware.net.au>2014-01-21 16:10:19 +1000
commitfcfb8169cfa5fefe5610bcc4297500ead2dfaf42 (patch)
tree01f5b859d134e7f164a3b6935bffe9607d6fb05b /jim-file.c
parent30a78d4c698c3d47ecf2d399cd553d9e4340c788 (diff)
downloadjimtcl-fcfb8169cfa5fefe5610bcc4297500ead2dfaf42.zip
jimtcl-fcfb8169cfa5fefe5610bcc4297500ead2dfaf42.tar.gz
jimtcl-fcfb8169cfa5fefe5610bcc4297500ead2dfaf42.tar.bz2
many comment changes, some small code changes
Sweep through and clean up all (most) of the comments in the code. While there, adjust some variable and function names to be more consistent, and make a few small code changes - again, mostly for consistency. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-file.c')
-rw-r--r--jim-file.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/jim-file.c b/jim-file.c
index 23b431f..958bfad 100644
--- a/jim-file.c
+++ b/jim-file.c
@@ -351,10 +351,7 @@ static int file_cmd_join(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int file_access(Jim_Interp *interp, Jim_Obj *filename, int mode)
{
- const char *path = Jim_String(filename);
- int rc = access(path, mode);
-
- Jim_SetResultBool(interp, rc != -1);
+ Jim_SetResultBool(interp, access(Jim_String(filename), mode) != -1);
return JIM_OK;
}
@@ -374,9 +371,7 @@ static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *arg
#ifdef X_OK
return file_access(interp, argv[0], X_OK);
#else
- /* XXX: X_OK doesn't work under Windows.
- * In any case, may need to add .exe, etc. so just lie!
- */
+ /* If no X_OK, just assume true. */
Jim_SetResultBool(interp, 1);
return JIM_OK;
#endif
@@ -930,11 +925,11 @@ static int Jim_CdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int Jim_PwdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
- const int cwd_len = 2048;
- char *cwd = malloc(cwd_len);
+ char *cwd = Jim_Alloc(MAXPATHLEN);
- if (getcwd(cwd, cwd_len) == NULL) {
+ if (getcwd(cwd, MAXPATHLEN) == NULL) {
Jim_SetResultString(interp, "Failed to get pwd", -1);
+ Jim_Free(cwd);
return JIM_ERR;
}
#if defined(__MINGW32__) || defined(_MSC_VER)
@@ -949,7 +944,7 @@ static int Jim_PwdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Jim_SetResultString(interp, cwd, -1);
- free(cwd);
+ Jim_Free(cwd);
return JIM_OK;
}