summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-09-02 22:18:38 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-09-02 22:18:38 -0700
commitacc53f437c82ed43f0211521659c7e01e1b371c9 (patch)
tree661f89b5a1b558b33882d53f07482ea5b3b24391
parent1572c93478c55ff14738a4b6f1b38dc41878a816 (diff)
downloadtxr-acc53f437c82ed43f0211521659c7e01e1b371c9.tar.gz
txr-acc53f437c82ed43f0211521659c7e01e1b371c9.tar.bz2
txr-acc53f437c82ed43f0211521659c7e01e1b371c9.zip
* txr.1: Document -C option.
* txr.c (opt_compat): New global variable. (help): Describe -C option. (txr_main): Process -C, and set opt_compat. Ensure -C does not clump. * txr.h (opt_compat): Declared.
-rw-r--r--ChangeLog11
-rw-r--r--txr.111
-rw-r--r--txr.c20
-rw-r--r--txr.h1
4 files changed, 40 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c572feaf..a0be3ea0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2014-09-02 Kaz Kylheku <kaz@kylheku.com>
+ * txr.1: Document -C option.
+
+ * txr.c (opt_compat): New global variable.
+ (help): Describe -C option.
+ (txr_main): Process -C, and set opt_compat.
+ Ensure -C does not clump.
+
+ * txr.h (opt_compat): Declared.
+
+2014-09-02 Kaz Kylheku <kaz@kylheku.com>
+
* eval.c (eval_init): Update registration of lisp-parse and read
to account for new parameter.
diff --git a/txr.1 b/txr.1
index 736dc5d8..daf9a3a2 100644
--- a/txr.1
+++ b/txr.1
@@ -191,6 +191,17 @@ Evaluates a TXR Lisp expression and prints its value. Can be specified more
than once. The query-file argument becomes optional if -p is used at least
once.
+.IP "-C number"
+Requests TXR to behave in a manner that is compatible with the specified
+version of TXR. This makes a difference in situations when a release of
+TXR breaks backward compatibility. If some version N+1 deliberately introduces
+a change which is backward incompatible, then -C N can be used to request
+the old behavior. The requested value of N can be too low, in which case TXR
+will complain and exit with an unsuccessful termination status. This indicates
+that TXR refuses to be compatible with such an old version. Users requiring
+the behavior of that version will have to install an older version of TXR which
+supports that behavior, or even that exact version.
+
.IP --help
Prints usage summary on standard output, and terminates successfully.
diff --git a/txr.c b/txr.c
index 9963fd30..16a2cbe7 100644
--- a/txr.c
+++ b/txr.c
@@ -59,6 +59,7 @@ const wchli_t *version = wli(TXR_VER);
const wchar_t *progname = L"txr";
static const char *progname_u8;
static val progpath = nil;
+int opt_compat;
/*
* Can implement an emergency allocator here from a fixed storage
@@ -119,6 +120,8 @@ static void help(void)
" option, instead of the query-file argument.\n"
" This allows #! scripts to pass options through\n"
" to the utility.\n"
+"-C number Request backward-compatible behavior to the\n"
+" specified version of TXR.\n"
"--help You already know!\n"
"--version Display program version\n"
"--license Display software license\n"
@@ -368,7 +371,7 @@ int txr_main(int argc, char **argv)
return license();
if (memqual(arg, list(lit("-a"), lit("-c"), lit("-f"),
- lit("-e"), lit("-p"), nao)))
+ lit("-e"), lit("-p"), lit("-C"), nao)))
{
val opt = chr_str(arg, one);
@@ -383,6 +386,7 @@ int txr_main(int argc, char **argv)
switch (c_chr(opt)) {
case 'a':
+ case 'C':
{
val optval = int_str(arg, nil);
@@ -393,8 +397,17 @@ int txr_main(int argc, char **argv)
return EXIT_FAILURE;
}
- opt_arraydims = c_num(optval);
- opt_print_bindings = 1;
+ if (opt == chr('a')) {
+ opt_arraydims = c_num(optval);
+ opt_print_bindings = 1;
+ } else {
+ if ((opt_compat = c_num(optval)) < 97) {
+ format(std_error, lit("~a: compatibility with versions "
+ "lower than 97 not supported by version ~a\n"),
+ prog_string, auto_str(version), nao);
+ return EXIT_FAILURE;
+ }
+ }
}
break;
case 'c':
@@ -489,6 +502,7 @@ int txr_main(int argc, char **argv)
case 'e':
case 'p':
case 'f':
+ case 'C':
case 'D':
format(std_error, lit("~a: option -~a does not clump\n"),
prog_string, opch, nao);
diff --git a/txr.h b/txr.h
index bfc01b04..201bd385 100644
--- a/txr.h
+++ b/txr.h
@@ -33,5 +33,6 @@ extern int opt_gc_debug;
extern int opt_vg_debug;
#endif
extern int opt_derivative_regex;
+extern int opt_compat;
extern const wchli_t *version;
extern const wchar_t *progname;