summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-09-10 20:23:27 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-09-10 20:23:27 -0700
commit75c9240632d0f69d25390814b835523a23ebfb19 (patch)
tree07a7ad0289ae2632b94e199e56c46bc3358e27e1
parent063b5a8c138e68237e11bcdac2f5763243b9bfc7 (diff)
downloadtxr-75c9240632d0f69d25390814b835523a23ebfb19.tar.gz
txr-75c9240632d0f69d25390814b835523a23ebfb19.tar.bz2
txr-75c9240632d0f69d25390814b835523a23ebfb19.zip
* lib.c (compat_fixup): void return changed to int.
Returns minimum supported emulation. * lib.h (compat_fixup): Declaration fixed. * txr.c (compat): Replace hard-coded min version by return value of compat_fixup.
-rw-r--r--ChangeLog10
-rw-r--r--lib.c9
-rw-r--r--lib.h2
-rw-r--r--txr.12
-rw-r--r--txr.c12
5 files changed, 28 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 2604b623..fc940d6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-09-10 Kaz Kylheku <kaz@kylheku.com>
+
+ * lib.c (compat_fixup): void return changed to int.
+ Returns minimum supported emulation.
+
+ * lib.h (compat_fixup): Declaration fixed.
+
+ * txr.c (compat): Replace hard-coded min version
+ by return value of compat_fixup.
+
2014-09-09 Kaz Kylheku <kaz@kylheku.com>
* txr.c (help): List new --compat option.
diff --git a/lib.c b/lib.c
index cb779d8d..c8298468 100644
--- a/lib.c
+++ b/lib.c
@@ -6778,9 +6778,12 @@ void init(const wchar_t *pn, mem_t *(*oom)(mem_t *, size_t),
gc_state(gc_save);
}
-void compat_fixup(int compat_ver)
+int compat_fixup(int compat_ver)
{
- if (compat_ver <= 97) {
+ if (compat_ver < 97)
+ return 97;
+
+ if (compat_ver == 97) {
symbol_setname(type_error_s, lit("type_error"));
symbol_setname(internal_error_s, lit("internal_error"));
symbol_setname(numeric_error_s, lit("numeric_error"));
@@ -6789,6 +6792,8 @@ void compat_fixup(int compat_ver)
symbol_setname(file_error_s, lit("file_error"));
symbol_setname(process_error_s, lit("process_error"));
}
+
+ return 0;
}
void dump(val obj, val out)
diff --git a/lib.h b/lib.h
index 77b5a342..5198feac 100644
--- a/lib.h
+++ b/lib.h
@@ -797,7 +797,7 @@ val make_time_utc(val year, val month, val day,
void init(const wchar_t *progname, mem_t *(*oom_realloc)(mem_t *, size_t),
val *stack_bottom);
-void compat_fixup(int compat_ver);
+int compat_fixup(int compat_ver);
void dump(val obj, val stream);
void d(val obj);
void breakpt(void);
diff --git a/txr.1 b/txr.1
index d2c04fd3..f31c9c23 100644
--- a/txr.1
+++ b/txr.1
@@ -208,6 +208,8 @@ 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.
+If the option is specified more than once, the behavior is not specified.
+
For more information, see the COMPATIBILITY section.
.IP "--gc-delta=number"
diff --git a/txr.c b/txr.c
index 65880002..b9c11e5f 100644
--- a/txr.c
+++ b/txr.c
@@ -328,13 +328,17 @@ static int do_fixnum_opt(int (*opt_func)(val), val opt, val arg)
static int compat(val optval)
{
- if ((opt_compat = c_num(optval)) < 97) {
+ int compat = c_num(optval);
+ int min = compat_fixup(compat);
+
+ if (min) {
format(std_error, lit("~a: compatibility with versions "
- "lower than 97 not supported by version ~a\n"),
- prog_string, auto_str(version), nao);
+ "lower than ~a not supported by version ~a\n"),
+ prog_string, num(min), auto_str(version), nao);
return 0;
}
- compat_fixup(opt_compat);
+
+ opt_compat = compat;
return 1;
}