diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-27 19:58:33 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-27 19:58:33 -0700 |
commit | 80623a3c5ab1e1c645cdaafa2e1716cb0dcb3b60 (patch) | |
tree | 91f96a16eb91330c520f4837ebf1f0203615c1e7 /txr.c | |
parent | e6eb95aaecce20c3a8883022de6e300ac15cdd4f (diff) | |
download | txr-80623a3c5ab1e1c645cdaafa2e1716cb0dcb3b60.tar.gz txr-80623a3c5ab1e1c645cdaafa2e1716cb0dcb3b60.tar.bz2 txr-80623a3c5ab1e1c645cdaafa2e1716cb0dcb3b60.zip |
command line: set self-path for --compile.
I noticed that when compiling a TXR Lisp program which
refers to self-path using the --compile option, the
compiler complained about self-path being unbound.
* txr.c (self_path_s): New global variable.
(do_compile_opt): Prior to running compile-update-file,
bind self-path to the source path.
(txr_main): Don't define local self_path_s, but initialize
the global one. Replace redundant re-intering of self-path
with a reference to self_path_s.
* txr.1: self-path documentation updated.
Diffstat (limited to 'txr.c')
-rw-r--r-- | txr.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -82,6 +82,7 @@ int opt_compat; int opt_dbg_expansion; int opt_free_all; val stdlib_path; +val self_path_s; #if HAVE_FORK_STUFF #define IF_HAVE_FORK_STUFF(THEN, ELSE) THEN @@ -455,6 +456,8 @@ static void do_compile_opt(val arg) source = sub_str(source, zero, col_pos); } + reg_varl(self_path_s, source); + funcall2(compile_update_file, source, target); } @@ -572,7 +575,6 @@ int txr_main(int argc, char **argv) val txr_lisp_p = nil; val enter_repl = nil; val args_s = intern(lit("*args*"), user_package); - val self_path_s = intern(lit("self-path"), user_package); val compat_var = lit("TXR_COMPAT"); val compat_val = getenv_wrap(compat_var); val orig_args = nil, ref_arg_list = nil; @@ -582,6 +584,8 @@ int txr_main(int argc, char **argv) static char alt_args_buf[128 + 7] = "@(txr):", *alt_args = alt_args_buf + 7; + self_path_s = intern(lit("self-path"), user_package); + if (ends_with(lit("lisp" EXE_SUFF), prog_path, nil, nil)) txr_lisp_p = t; else if (ends_with(lit("vm" EXE_SUFF), prog_path, nil, nil)) @@ -1269,7 +1273,7 @@ repl: "due to environment variable.\n"), num(opt_compat), nao); reg_var(args_s, or2(orig_args, arg_list)); - reg_varl(intern(lit("self-path"), user_package), lit("listener")); + reg_varl(self_path_s, lit("listener")); env_vbind(dyn_env, package_s, opt_compat && opt_compat <= 190 ? user_package : public_package); env_vbind(dyn_env, load_recursive_s, nil); |