Skip to content

Commit

Permalink
Make Tcl_SetResult usable in tclTest.c, even if TCL_NO_DEPRECATED is …
Browse files Browse the repository at this point in the history
…defined
  • Loading branch information
jan.nijtmans committed Jan 14, 2025
1 parent 74c0e69 commit 2fe2533
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion generic/tclDecls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand All @@ -4347,6 +4346,7 @@ extern const TclStubs *tclStubsPtr;
} \
} \
} while(0)
#endif /* TCL_NO_DEPRECATED */

#if defined(USE_TCL_STUBS)
# if defined(_WIN32) && defined(_WIN64)
Expand Down
22 changes: 22 additions & 0 deletions generic/tclTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@
#include "tclOO.h"
#include <math.h>

#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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2fe2533

Please sign in to comment.