summaryrefslogtreecommitdiffstats
path: root/txr.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-05-25 19:43:09 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-05-25 19:43:09 -0700
commitf492fa9b676e95dbf317ec3b34d085909713da73 (patch)
treec532d638e009d2852f602ef3d6b65f6bb0e19811 /txr.c
parented16b6ad1030981253aa6e6575024df41318cf99 (diff)
downloadtxr-f492fa9b676e95dbf317ec3b34d085909713da73.tar.gz
txr-f492fa9b676e95dbf317ec3b34d085909713da73.tar.bz2
txr-f492fa9b676e95dbf317ec3b34d085909713da73.zip
New variable: txr-path.
* txr.c (dirname): New static function. (sysroot_init): Register txr-path variable. * txr.1: documented txr-path.
Diffstat (limited to 'txr.c')
-rw-r--r--txr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/txr.c b/txr.c
index aa1a5eaa..5243c941 100644
--- a/txr.c
+++ b/txr.c
@@ -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)