diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-05-25 19:43:09 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-05-25 19:43:09 -0700 |
commit | 018b61e013dea9852c486510dd1a45985a9b8d5e (patch) | |
tree | c532d638e009d2852f602ef3d6b65f6bb0e19811 | |
parent | 8685a7c31728ad61fb21d8d1b95097e863cb70cd (diff) | |
download | txr-018b61e013dea9852c486510dd1a45985a9b8d5e.tar.gz txr-018b61e013dea9852c486510dd1a45985a9b8d5e.tar.bz2 txr-018b61e013dea9852c486510dd1a45985a9b8d5e.zip |
New variable: txr-path.
* txr.c (dirname): New static function.
(sysroot_init): Register txr-path variable.
* txr.1: documented txr-path.
-rw-r--r-- | txr.1 | 5 | ||||
-rw-r--r-- | txr.c | 7 |
2 files changed, 12 insertions, 0 deletions
@@ -41444,6 +41444,11 @@ is restored. During the processing of the profile file (see Interactive Profile File), the variable is bound to the name of that file. +.coNP Variable @ txr-path +.desc +This variable holds the absolute path name of the directory which +holds the executable file of the current process. + .SH* INTERACTIVE LISTENER .SS* Overview @@ -267,6 +267,12 @@ static val maybe_sysroot(val exepart) sysroot_path = sub_str(prog_path, 0, neg(length(exepart)))); } +static val dirname(val path) +{ + val rslash = rpos(chr('/'), path, nil, nil); + return if3(rslash, sub_str(path, zero, succ(rslash)), path); +} + static val substitute_basename(val edited_path, val source_path) { val lslash = rpos(chr('/'), edited_path, nil, nil); @@ -316,6 +322,7 @@ static void sysroot_init(void) toint(lit(TXR_VER), nil)); reg_varl(intern(lit("txr-version"), user_package), toint(lit(TXR_VER), nil)); + reg_varl(intern(lit("txr-path"), user_package), dirname(prog_path)); } static int license(void) |