From 71cc1d5902abb8cc005114f28a5cea8d766a4b05 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 7 Jul 2014 20:29:43 -0700 Subject: * 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. --- ChangeLog | 13 +++++++++++++ Makefile | 2 ++ txr.1 | 5 +++++ txr.c | 39 +++++++++++++++++++++++++++++++++++++++ unwind.h | 1 + 5 files changed, 60 insertions(+) diff --git a/ChangeLog b/ChangeLog index a6a1c27c..58abab14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2014-07-07 Kaz Kylheku + + * 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. + 2014-07-07 Kaz Kylheku * lib.c (replace_list, sel): fix use of unused variable. diff --git a/Makefile b/Makefile index 1dbc87fa..0f5b4d39 100644 --- a/Makefile +++ b/Makefile @@ -167,6 +167,8 @@ PREINSTALL := : install: $(PROG) $(PREINSTALL) $(call INSTALL,0755,txr$(EXE),$(DESTDIR)$(bindir)) + $(call INSTALL,0444,$(top_srcdir)/LICENSE,$(DESTDIR)$(datadir)) + $(call INSTALL,0444,$(top_srcdir)/METALICENSE,$(DESTDIR)$(datadir)) $(call INSTALL,0444,$(top_srcdir)/txr.1,$(DESTDIR)$(mandir)/man1) $(call INSTALL,0444,$(top_srcdir)/share/txr/stdlib/*.txr,$(DESTDIR)$(datadir)/stdlib) diff --git a/txr.1 b/txr.1 index ec6174ff..42b01bdc 100644 --- a/txr.1 +++ b/txr.1 @@ -194,6 +194,11 @@ once. .IP --help Prints usage summary on standard output, and terminates successfully. +.IP --license +Prints the software license. This depends on the software being +installed such that the LICENSE file is in the data directory. +Use of txr implies agreement with the liability disclaimer in the license. + .IP --version Prints program version standard output, and terminates successfully. 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))) { diff --git a/unwind.h b/unwind.h index ea92e9b1..4e42eecc 100644 --- a/unwind.h +++ b/unwind.h @@ -173,6 +173,7 @@ noreturn val type_mismatch(val, ...); case 2: \ EXCVAR = uw_catch.ca.exception; \ SYMVAR = uw_catch.ca.sym; \ + (void) SYMVAR; \ /* prevent looping */ \ uw_catch.ca.matches = nil; -- cgit v1.2.3