From 2fe25338c3cb272a550045731f0b99ce21a36106 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 14 Jan 2025 14:16:54 +0000 Subject: [PATCH] Make Tcl_SetResult usable in tclTest.c, even if TCL_NO_DEPRECATED is defined --- generic/tclDecls.h | 2 +- generic/tclTest.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/generic/tclDecls.h b/generic/tclDecls.h index dc573ec2ab2..a02a70f0784 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -4332,7 +4332,6 @@ extern const TclStubs *tclStubsPtr; #undef Tcl_RestoreResult #undef Tcl_DiscardResult #undef Tcl_MakeSafe -#endif /* TCL_NO_DEPRECATED */ #undef Tcl_SetResult #define Tcl_SetResult(interp, result, freeProc) \ do { \ @@ -4347,6 +4346,7 @@ extern const TclStubs *tclStubsPtr; } \ } \ } while(0) +#endif /* TCL_NO_DEPRECATED */ #if defined(USE_TCL_STUBS) # if defined(_WIN32) && defined(_WIN64) diff --git a/generic/tclTest.c b/generic/tclTest.c index 3cf02556473..99ae05fcd0a 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -32,6 +32,25 @@ #include "tclOO.h" #include +#if TCL_UTF_MAX > 3 +/* TCL_NO_DEPRECATED was specified, so the core doesn't have a Tcl_SetResult stub entry */ +#undef Tcl_SetResult +#define Tcl_SetResult(interp, result, freeProc) \ + do { \ + const char *__result = result; \ + Tcl_FreeProc *__freeProc = freeProc; \ + Tcl_SetObjResult(interp, Tcl_NewStringObj(__result, TCL_INDEX_NONE)); \ + if (__result != NULL && __freeProc != NULL && __freeProc != TCL_VOLATILE) { \ + if (__freeProc == TCL_DYNAMIC) { \ + ckfree(__result); \ + } else { \ + (*__freeProc)((char *)__result); \ + } \ + } \ + } while(0) +#endif /* TCL_UTF_MAX */ + + /* We want to test the UTF-32 versions of the following 3 functions */ #undef Tcl_UtfNext #undef Tcl_UtfPrev @@ -524,6 +543,9 @@ static const char version[] = TCL_PATCH_LEVEL "+" STRINGIFY(TCL_VERSION_UUID) #ifdef USE_NMAKE ".nmake" #endif +#if TCL_UTF_MAX > 3 + ".no-deprecate" +#endif #if !TCL_THREADS ".no-thread" #endif