diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-06-27 11:28:59 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-06-27 11:33:35 -0700 |
commit | 6d390f413981c29c15e6ce8a6faf59cae77246f9 (patch) | |
tree | 422b037d0c9028232308fdf3c336158465f65507 /txr.c | |
parent | 9a9fe075f5c1f79dde574bae585431b717a83e18 (diff) | |
download | txr-6d390f413981c29c15e6ce8a6faf59cae77246f9.tar.gz txr-6d390f413981c29c15e6ce8a6faf59cae77246f9.tar.bz2 txr-6d390f413981c29c15e6ce8a6faf59cae77246f9.zip |
Preparations for bundling Cygwin library.
* LICENSE-CYG: New file.
* METALICENSE: Include a note about the use of Cygwin
in accordance with LGPL.
* txr.c (license): Use glob to iterate over all files in the txr
share directory which match the LICENSE* pattern.
Diffstat (limited to 'txr.c')
-rw-r--r-- | txr.c | 36 |
1 files changed, 25 insertions, 11 deletions
@@ -53,6 +53,9 @@ #include "regex.h" #include "arith.h" #include "sysif.h" +#if HAVE_GLOB +#include "glob.h" +#endif #include "txr.h" const wchli_t *version = wli(TXR_VER); @@ -337,25 +340,36 @@ static int license(void) { int retval = EXIT_SUCCESS; - uw_catch_begin(cons(error_s, nil), esym, eobj); + uw_catch_begin(cons(error_s, nil), esym, eargs); { - val path = sysroot(lit("share/txr/LICENSE")); - val lic = open_file(path, lit("r")); - val line; - - put_char(chr('\n'), std_output); + val iter; +#if HAVE_GLOB + val glob_pattern = sysroot(lit("share/txr/LICENSE*")); + val path_list = glob_wrap(glob_pattern, zero, nil); +#else + val glob_pattern = sysroot(lit("share/txr/LICENSE")); + val path_list = cons(glob_pattern, nil); +#endif - while ((line = get_line(lic))) - put_line(line, std_output); + if (!path_list) + uw_throwf(error_s, lit("Error: pattern ~a didn't match any files."), + glob_pattern, nao); put_char(chr('\n'), std_output); - close_stream(lic, nil); + for (iter = path_list; iter; iter = cdr(iter)) { + val lic = open_file(car(iter), lit("r")); + + put_lines(lazy_stream_cons(lic), std_output); + put_char(chr('\n'), std_output); + } } - uw_catch (esym, eobj) { - format(std_output, lit("~a:\nThis TXR installation might be unlicensed.\n"), eobj, nao); + uw_catch (esym, eargs) { + format(std_output, + lit("~a\nThis TXR installation might be unlicensed.\n"), + car(eargs), nao); retval = EXIT_FAILURE; } |