From f492fa9b676e95dbf317ec3b34d085909713da73 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 25 May 2016 19:43:09 -0700 Subject: New variable: txr-path. * txr.c (dirname): New static function. (sysroot_init): Register txr-path variable. * txr.1: documented txr-path. --- txr.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'txr.c') 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) -- cgit v1.2.3