diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-11-20 06:10:38 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-11-20 16:17:20 -0800 |
commit | 2f8d42ce8308fa4668213e8410d5abb204b0e712 (patch) | |
tree | 7321ab58549bc4d9fe36a0403b26b7ecce373824 /txr.c | |
parent | 3c09800abda31a3f5da8157b0ef2863850f6b662 (diff) | |
download | txr-2f8d42ce8308fa4668213e8410d5abb204b0e712.tar.gz txr-2f8d42ce8308fa4668213e8410d5abb204b0e712.tar.bz2 txr-2f8d42ce8308fa4668213e8410d5abb204b0e712.zip |
TXR_COMPAT option.
* txr.c (txr_main): Implement handling of TXR_COMPAT
environment variable. Also, before entering interactive
mode, if compatibility has been set via TXR_COMPAT,
emit an informative message about this.
* txr.1: Documented TXR_COMPAT.
Diffstat (limited to 'txr.c')
-rw-r--r-- | txr.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -54,6 +54,7 @@ #include "regex.h" #include "arith.h" #include "lisplib.h" +#include "sysif.h" #include "txr.h" const wchli_t *version = wli(TXR_VER); @@ -413,10 +414,27 @@ int txr_main(int argc, char **argv) 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); list_collect_decl(arg_list, arg_tail); setvbuf(stderr, 0, _IOLBF, 0); + if (compat_val && length(compat_val) != zero) { + val value = int_str(compat_val, nil); + if (!value) { + format(std_error, + lit("~a: environment variable ~a=~a must be decimal integer\n"), + prog_string, compat_var, compat_val, nao); + return EXIT_FAILURE; + } + if (!compat(value)) { + format(std_error, lit("~a: caused by environment variable ~a=~a\n"), + prog_string, compat_var, compat_val, nao); + return EXIT_FAILURE; + } + } + if (argc <= 1) { #if HAVE_TERMIOS banner(); @@ -792,6 +810,11 @@ int txr_main(int argc, char **argv) repl: #if HAVE_TERMIOS + if (compat_val) + format(std_output, + lit("Note: operating in TXR ~a compatibility mode " + "due to environment variable.\n"), + num(opt_compat), nao); repl(bindings, std_input, std_output); #endif return 0; |