From 3100080a509364885bb69b38ad7d75cf70b7053b Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sun, 10 May 2020 23:07:54 -0500 Subject: [PATCH] Add NO_UMASK and NO_REALPATH config options. --- CHANGELOG.md | 3 +++ src/conf/janetconf.h | 2 ++ src/core/os.c | 12 ++++++++++-- src/include/janet.h | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 526949a6..ccba0cf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All notable changes to this project will be documented in this file. +## Unreleased - ??? +- Fix compilation issue when nanboxing is disabled. + ## 1.9.0 - 2020-05-10 - Add `:ldflags` option to many jpm declare functions. - Add `errorf` to core. diff --git a/src/conf/janetconf.h b/src/conf/janetconf.h index e4893009..e21d1b2c 100644 --- a/src/conf/janetconf.h +++ b/src/conf/janetconf.h @@ -55,7 +55,9 @@ /* Other settings */ /* #define JANET_NO_PRF */ /* #define JANET_NO_UTC_MKTIME */ +/* #define JANET_NO_REALPATH */ /* #define JANET_NO_SYMLINKS */ +/* #define JANET_NO_UMASK */ /* #define JANET_OUT_OF_MEMORY do { printf("janet out of memory\n"); exit(1); } while (0) */ /* #define JANET_EXIT(msg) do { printf("C assert failed executing janet: %s\n", msg); exit(1); } while (0) */ /* #define JANET_TOP_LEVEL_SIGNAL(msg) call_my_function((msg), stderr) */ diff --git a/src/core/os.c b/src/core/os.c index 2d2db062..7714f22c 100644 --- a/src/core/os.c +++ b/src/core/os.c @@ -877,6 +877,7 @@ static Janet os_remove(int32_t argc, Janet *argv) { return janet_wrap_nil(); } +#ifndef JANET_NO_SYMLINKS static Janet os_readlink(int32_t argc, Janet *argv) { janet_fixarity(argc, 1); #ifdef JANET_WINDOWS @@ -893,6 +894,7 @@ static Janet os_readlink(int32_t argc, Janet *argv) { return janet_stringv((const uint8_t *)buffer, len); #endif } +#endif #ifdef JANET_WINDOWS @@ -1161,6 +1163,7 @@ static Janet os_chmod(int32_t argc, Janet *argv) { return janet_wrap_nil(); } +#ifndef JANET_NO_UMASK static Janet os_umask(int32_t argc, Janet *argv) { janet_fixarity(argc, 1); int mask = (int) os_getmode(argv, 0); @@ -1171,6 +1174,7 @@ static Janet os_umask(int32_t argc, Janet *argv) { #endif return janet_wrap_integer(janet_perm_to_unix(res)); } +#endif static Janet os_dir(int32_t argc, Janet *argv) { janet_arity(argc, 1, 2); @@ -1220,9 +1224,9 @@ static Janet os_rename(int32_t argc, Janet *argv) { static Janet os_realpath(int32_t argc, Janet *argv) { janet_fixarity(argc, 1); -#ifdef JANET_WINDOWS +#ifdef JANET_NO_REALPATH (void) argv; - janet_panic("os/realpath not supported on Windows"); + janet_panic("os/realpath not supported on this platform"); #else const char *src = janet_getcstring(argv, 0); char *dest = realpath(src, NULL); @@ -1339,11 +1343,13 @@ static const JanetReg os_cfuns[] = { JDOC("(os/cd path)\n\n" "Change current directory to path. Returns nil on success, errors on failure.") }, +#ifndef JANET_NO_UMASK { "os/umask", os_umask, JDOC("(os/umask mask)\n\n" "Set a new umask, returns the old umask.") }, +#endif { "os/mkdir", os_mkdir, JDOC("(os/mkdir path)\n\n" @@ -1369,6 +1375,7 @@ static const JanetReg os_cfuns[] = { "Iff symlink is falsey or not provided, " "creates a hard link. Does not work on Windows.") }, +#ifndef JANET_NO_SYMLINKS { "os/symlink", os_symlink, JDOC("(os/symlink oldpath newpath)\n\n" @@ -1379,6 +1386,7 @@ static const JanetReg os_cfuns[] = { JDOC("(os/readlink path)\n\n" "Read the contents of a symbolic link. Does not work on Windows.\n") }, +#endif #ifndef JANET_NO_PROCESSES { "os/execute", os_execute, diff --git a/src/include/janet.h b/src/include/janet.h index d15d2529..94a90a3b 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -138,6 +138,11 @@ extern "C" { #define JANET_NO_UTC_MKTIME #endif +/* Add some windows flags */ +#ifdef JANET_WINDOWS +#define JANET_NO_REALPATH +#endif + /* Define how global janet state is declared */ #ifdef JANET_SINGLE_THREADED #define JANET_THREAD_LOCAL