Add os-executable-file builtin

This commit is contained in:
Lassi Kortela 2020-04-07 10:21:45 +03:00
parent 8cb5cff824
commit f81e7f815a
3 changed files with 11 additions and 0 deletions

View File

@ -277,3 +277,12 @@ value_t builtin_version_alist(value_t *args, uint32_t nargs)
argcount("version-alist", nargs, 0); argcount("version-alist", nargs, 0);
return get_version_alist(); 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;
}

View File

@ -63,6 +63,7 @@ static struct builtin_procedure builtin_procedures[] = {
{ "features", builtin_features, R7RS_BASE | UP_2019 }, { "features", builtin_features, R7RS_BASE | UP_2019 },
{ "version-alist", builtin_version_alist, SRFI_176 | 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?", fl_stringp, SRFI_13 | R7RS_BASE | UP_2019 },
{ "string-reverse", fl_string_reverse, SRFI_13 | UP_2019 }, { "string-reverse", fl_string_reverse, SRFI_13 | UP_2019 },

View File

@ -1010,6 +1010,7 @@ value_t envst_language_c(void);
value_t get_version_alist(void); value_t get_version_alist(void);
value_t builtin_features(value_t *args, uint32_t nargs); value_t builtin_features(value_t *args, uint32_t nargs);
value_t builtin_version_alist(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 // env_*.c