summaryrefslogtreecommitdiffstats
path: root/txr.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-07-07 20:29:43 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-07-07 20:29:43 -0700
commit71cc1d5902abb8cc005114f28a5cea8d766a4b05 (patch)
tree49242d1f03974045036d21772dae553738301e18 /txr.c
parent46b7f60f9fa32fd2a8c2162cf108dc89d3d95196 (diff)
downloadtxr-71cc1d5902abb8cc005114f28a5cea8d766a4b05.tar.gz
txr-71cc1d5902abb8cc005114f28a5cea8d766a4b05.tar.bz2
txr-71cc1d5902abb8cc005114f28a5cea8d766a4b05.zip
* Makefile: install the LICENSE and METALICENSE files into the data
directory. * txr.c (help): Help text updated to document --license option. (license): New function. (txr_main): Implement --license option. * unwind.h (uw_catch): Add cast to suppress warning about unused symbol. * txr.1: Document --license option.
Diffstat (limited to 'txr.c')
-rw-r--r--txr.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/txr.c b/txr.c
index aa3ab885..4d666635 100644
--- a/txr.c
+++ b/txr.c
@@ -121,6 +121,9 @@ static void help(void)
" to the utility.\n"
"--help You already know!\n"
"--version Display program version\n"
+"--license Display software license\n"
+" Use of txr implies agreement with the disclaimer\n"
+" section at the bottom of the license.\n"
"--lisp-bindings Synonym for -l\n"
"--debugger Synonym for -d\n"
"\n"
@@ -240,6 +243,39 @@ static void sysroot_init(void)
toint(lit(TXR_VER), nil));
}
+static int license(void)
+{
+ int retval = EXIT_SUCCESS;
+
+ uw_catch_begin(cons(error_s, nil), esym, eobj);
+
+ {
+ val path = sysroot(lit("share/txr/LICENSE"));
+ val lic = open_file(path, lit("r"));
+ val line;
+
+ put_char(chr('\n'), std_output);
+
+ while ((line = get_line(lic)))
+ put_line(line, std_output);
+
+ put_char(chr('\n'), std_output);
+
+ close_stream(lic, nil);
+ }
+
+ uw_catch (esym, eobj) {
+ format(std_output, lit("~a:\nThis TXR installation might be unlicensed.\n"), eobj, nao);
+ retval = EXIT_FAILURE;
+ }
+
+ uw_unwind { }
+
+ uw_catch_end;
+
+ return retval;
+}
+
int txr_main(int argc, char **argv);
int main(int argc, char **argv)
@@ -331,6 +367,9 @@ int txr_main(int argc, char **argv)
return 0;
}
+ if (equal(arg, lit("--license")))
+ return license();
+
if (memqual(arg, list(lit("-a"), lit("-c"), lit("-f"),
lit("-e"), lit("-p"), nao)))
{