From f81e7f815a6f36ff328f1b75319362166ae2e576 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Tue, 7 Apr 2020 10:21:45 +0300 Subject: [PATCH] Add os-executable-file builtin --- c/env.c | 9 +++++++++ c/libraries.c | 1 + c/scheme.h | 1 + 3 files changed, 11 insertions(+) diff --git a/c/env.c b/c/env.c index 8a964ba..b6ad0f3 100644 --- a/c/env.c +++ b/c/env.c @@ -277,3 +277,12 @@ value_t builtin_version_alist(value_t *args, uint32_t nargs) argcount("version-alist", nargs, 0); return get_version_alist(); } + +value_t builtin_os_executable_file(value_t *args, uint32_t nargs) +{ + (void)args; + argcount("os-executable-file", nargs, 0); + char buf[512]; + char *exe = get_exename(buf, sizeof(buf)); + return exe ? string_from_cstr(exe) : FL_F; +} diff --git a/c/libraries.c b/c/libraries.c index fa207c7..c02ab39 100644 --- a/c/libraries.c +++ b/c/libraries.c @@ -63,6 +63,7 @@ static struct builtin_procedure builtin_procedures[] = { { "features", builtin_features, R7RS_BASE | UP_2019 }, { "version-alist", builtin_version_alist, SRFI_176 | UP_2019 }, + { "os-executable-file", builtin_os_executable_file, UP_2019 }, { "string?", fl_stringp, SRFI_13 | R7RS_BASE | UP_2019 }, { "string-reverse", fl_string_reverse, SRFI_13 | UP_2019 }, diff --git a/c/scheme.h b/c/scheme.h index 23901e5..d5ac53e 100644 --- a/c/scheme.h +++ b/c/scheme.h @@ -1010,6 +1010,7 @@ value_t envst_language_c(void); value_t get_version_alist(void); value_t builtin_features(value_t *args, uint32_t nargs); value_t builtin_version_alist(value_t *args, uint32_t nargs); +value_t builtin_os_executable_file(value_t *args, uint32_t nargs); // env_*.c