From 16ea370778dcd9943fb11767992aebf6263acfd4 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 21 Jul 2021 06:55:45 -0700 Subject: 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. --- arith.h | 1 + 1 file changed, 1 insertion(+) (limited to 'arith.h') diff --git a/arith.h b/arith.h index c66e6844..f5646831 100644 --- a/arith.h +++ b/arith.h @@ -62,4 +62,5 @@ val rpoly(val x, val seq); NORETURN void do_mp_error(val self, mp_err code); void arith_init(void); +void arith_compat_fixup(int compat_ver); void arith_free_all(void); -- cgit v1.2.3