From 0402075f2b4a088bc6a76f514a3120901799d0f6 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 13 Jun 2017 20:06:49 -0600 Subject: [PATCH] rktio: repairs to file & directory operations --- racket/src/racket/src/file.c | 9 ++++++--- racket/src/rktio/rktio_fs.c | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/racket/src/racket/src/file.c b/racket/src/racket/src/file.c index 08e8f26f44..47a5f8b293 100644 --- a/racket/src/racket/src/file.c +++ b/racket/src/racket/src/file.c @@ -2041,6 +2041,8 @@ Scheme_Object *scheme_get_fd_identity(Scheme_Object *port, intptr_t fd, char *pa args[1] = scheme_make_integer(ident->c_bits + ident->b_bits); a = scheme_bitwise_shift(2, args); + free(ident); + return scheme_bin_plus(scheme_bin_plus(a, b), c); } @@ -3423,7 +3425,7 @@ static Scheme_Object *delete_file(int argc, Scheme_Object **argv) filename_for_error(argv[0])); } - return NULL; + return scheme_void; } static Scheme_Object *rename_file(int argc, Scheme_Object **argv) @@ -3661,7 +3663,7 @@ static Scheme_Object *do_resolve_path(int argc, Scheme_Object *argv[], int guard if (content) { Scheme_Object *r; - r = scheme_make_sized_path(content, len, 1); + r = scheme_make_sized_path(content, -1, 1); free(content); return r; } @@ -4913,6 +4915,7 @@ static Scheme_Object *file_or_dir_permissions(int argc, Scheme_Object *argv[]) l = scheme_make_pair(write_symbol, l); if (r & RKTIO_PERMISSION_EXEC) l = scheme_make_pair(execute_symbol, l); + return l; } } } else { @@ -5368,7 +5371,7 @@ find_system_path(int argc, Scheme_Object **argv) s = rktio_system_path(scheme_rktio, which); - p = scheme_make_sized_offset_path(s, 1, -1, 1); + p = scheme_make_sized_offset_path(s, 0, -1, 1); if (!scheme_is_complete_path(SCHEME_PATH_VAL(p), SCHEME_PATH_LEN(p), SCHEME_PLATFORM_PATH_KIND)) { p = scheme_path_to_complete_path(p, original_pwd); diff --git a/racket/src/rktio/rktio_fs.c b/racket/src/rktio/rktio_fs.c index 3f8d1523e2..40884e3064 100644 --- a/racket/src/rktio/rktio_fs.c +++ b/racket/src/rktio/rktio_fs.c @@ -661,7 +661,7 @@ static rktio_identity_t *get_identity(rktio_t *rktio, rktio_fd_t *fd, char *path uintptr_t devi = 0, inoi = 0, inoi2 = 0; uintptr_t devi_bits = 0, inoi_bits = 0, inoi2_bits = 0; -#ifdef FILES_HAVE_FDS +#ifdef RKTIO_SYSTEM_UNIX int errid = 0; struct MSC_IZE(stat) buf; @@ -689,7 +689,7 @@ static rktio_identity_t *get_identity(rktio_t *rktio, rktio_fd_t *fd, char *path inoi_bits = sizeof(buf.st_ino) << 3; } #endif -#ifdef WINDOWS_FILE_HANDLES +#ifdef RKTIO_SYSTEM_WINDOWS BY_HANDLE_FILE_INFORMATION info; HANDLE fdh; @@ -1767,7 +1767,7 @@ static char *append_paths(char *a, char *b, int free_a, int free_b) int sep_len = 0; char *s; - if (!IS_A_SEP(a[alen])) + if (alen && !IS_A_SEP(a[alen-1])) sep_len = 1; s = malloc(alen + sep_len + blen + 1); @@ -1776,7 +1776,7 @@ static char *append_paths(char *a, char *b, int free_a, int free_b) if (sep_len) s[alen] = A_PATH_SEP; memcpy(s+alen+sep_len, b, blen); - s[alen + blen] = 0; + s[alen + sep_len + blen] = 0; if (free_a) free(a); if (free_b) free(b);