diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-07-21 06:55:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-07-21 06:55:45 -0700 |
commit | 16ea370778dcd9943fb11767992aebf6263acfd4 (patch) | |
tree | 02f66ea406e46eb7571a27ab6a4b3510d24fe05f /ffi.c | |
parent | 5613a3b0d42a89d061df18cd9ae4e1008696572c (diff) | |
download | txr-16ea370778dcd9943fb11767992aebf6263acfd4.tar.gz txr-16ea370778dcd9943fb11767992aebf6263acfd4.tar.bz2 txr-16ea370778dcd9943fb11767992aebf6263acfd4.zip |
compat: fix glaringly broken init-time handling.
We are doing numerous compat_ver checks in various init
functions, to enact alternative symbol registrations. Only
problem is, compat_ver is always zero during initialization;
it is not set until the -C option is processed in txr_main.
Registrations must be fixed up after initialization;
that's what the compat_fixup mechanism is for.
This is an long-standing problem which affects compatibility
operation going back over 150 versions.
* arith.c (arith_init): Move compat logic to
arith_compat_fixup.
(arith_compat_fixup): New function.
* arith.h (arith_compat_fixup): Declared.
* eval.c (eval_init): Move compat logic to eval_compat_fixup.
* ffi.c (ffi_init): Move compat logic to ffi_compat_fixup.
(ffi_compat_fixup): New function.
* ffi.h (ffi_compat_fixup): Declared.
* regex.c (regex_init): Move compat logic to
regex_compat_fixup.
(regex_compat_fixup): New function.
* regex.h (regex_compat_fixup): Declared.
* stream.c (stream_init): Move compat logic to
stream_compat_fixup.
(stream_compat_fixup): New function.
* stream.h (stream_compat_fixup): Declared.
* struct.c (struct_init): Move compat logic to
struct_compat_fixup.
(struct_compat_fixup): New function.
* struct.h (stream_compat_fixup): Declared.
* lib.c (compat_fixup): Call arith_compat_fixup,
ffi_compat_fixup, regex_compat_fixup, stream_compat_fixup and
struct_compat_fixup.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -6464,13 +6464,6 @@ void ffi_init(void) reg_fun(intern(lit("carray-int"), user_package), ca_int); reg_fun(intern(lit("uint-carray"), user_package), uint_ca); reg_fun(intern(lit("int-carray"), user_package), int_ca); - - if (opt_compat && opt_compat <= 227) { - reg_fun(intern(lit("carray-unum"), user_package), ca_uint); - reg_fun(intern(lit("carray-num"), user_package), ca_int); - reg_fun(intern(lit("unum-carray"), user_package), uint_ca); - reg_fun(intern(lit("num-carray"), user_package), int_ca); - } } reg_fun(intern(lit("put-carray"), user_package), func_n3o(put_carray, 1)); reg_fun(intern(lit("fill-carray"), user_package), func_n3o(fill_carray, 1)); @@ -6493,3 +6486,18 @@ void ffi_init(void) ffi_init_types(); ffi_init_extra_types(); } + +void ffi_compat_fixup(int compat_ver) +{ + if (compat_ver <= 227) { + val ca_uint = func_n2o(carray_uint, 1); + val ca_int = func_n2o(carray_int, 1); + val uint_ca = func_n1(uint_carray); + val int_ca = func_n1(int_carray); + + reg_fun(intern(lit("carray-unum"), user_package), ca_uint); + reg_fun(intern(lit("carray-num"), user_package), ca_int); + reg_fun(intern(lit("unum-carray"), user_package), uint_ca); + reg_fun(intern(lit("num-carray"), user_package), int_ca); + } +} |