diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-18 23:46:51 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-18 23:46:51 -0800 |
commit | c720098b5f0eb58eef01fef4acbeccde00af2c75 (patch) | |
tree | 257c1010127a56d0641c84b4056c66e45fc70ec9 /eval.c | |
parent | 6dbb219a3fb2152ca9991a073df7e45c553eadf4 (diff) | |
download | txr-c720098b5f0eb58eef01fef4acbeccde00af2c75.tar.gz txr-c720098b5f0eb58eef01fef4acbeccde00af2c75.tar.bz2 txr-c720098b5f0eb58eef01fef4acbeccde00af2c75.zip |
* eval.c (env_hash): new function.
(eval_init): Register env and env_hash functions. Register prog_args
and prog_args_full as *args* and *full-args*.
* lib.c (timegm_hack): Invalidate env_list, after mucking with
the environment via setenv and unsetenv.
* txr.c (prog_args_full, prog_args): New global variables.
(txr_main): Command-line processing converted to use TXR's
library. Populates prog_args_full and prog_args.
* txr.h (prog_args_full, prog_args): Declared.
* txr.1: Documented *args*, *full-args*, env and env-hash.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -2548,6 +2548,19 @@ static val usleep_wrap(val usec) return retval; } +static val env_hash(void) +{ + val env_strings = env(); + val hash = make_hash(nil, nil, t); + + for (; env_strings; env_strings = cdr(env_strings)) { + cons_bind (key, val_cons, split_str(car(env_strings), lit("="))); + sethash(hash, key, car(val_cons)); + } + + return hash; +} + static void reg_fun(val sym, val fun) { sethash(top_fb, sym, cons(sym, fun)); @@ -3127,6 +3140,11 @@ void eval_init(void) reg_fun(intern(lit("exit"), user_package), func_n1(exit_wrap)); reg_fun(intern(lit("usleep"), user_package), func_n1(usleep_wrap)); + reg_fun(intern(lit("env"), user_package), func_n0(env)); + reg_fun(intern(lit("env-hash"), user_package), func_n0(env_hash)); + reg_var(intern(lit("*args*"), user_package), &prog_args); + reg_var(intern(lit("*full-args*"), user_package), &prog_args_full); + #if HAVE_DAEMON reg_fun(intern(lit("daemon"), user_package), func_n2(daemon_wrap)); #endif |