Skip to content

Commit

Permalink
Handle TCL_NO_DEPRECATED in test code: Don't try to use deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Jan 12, 2025
1 parent 35dfc3e commit 2fd4839
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
26 changes: 13 additions & 13 deletions generic/tclTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ typedef struct {
* was called for a result.
*/

#ifndef TCL_NO_DEPRECATED
#if TCL_UTF_MAX < 4
static int freeCount;
#endif /* TCL_NO_DEPRECATED */
#endif /* TCL_UTF_MAX */

/*
* Boolean flag used by the "testsetmainloop" and "testexitmainloop" commands.
Expand Down Expand Up @@ -243,9 +243,9 @@ static Tcl_ObjCmdProc TestbytestringObjCmd;
static Tcl_ObjCmdProc TestsetbytearraylengthObjCmd;
static Tcl_ObjCmdProc TestpurebytesobjObjCmd;
static Tcl_ObjCmdProc TeststringbytesObjCmd;
#ifndef TCL_NO_DEPRECATED
#if TCL_UTF_MAX < 4
static Tcl_ObjCmdProc Testutf16stringObjCmd;
#endif /* TCL_NO_DEPRECATED */
#endif /* TCL_UTF_MAX */
static Tcl_ObjCmdProc TestcmdinfoObjCmd;
static Tcl_CmdProc TestcmdtokenCmd;
static Tcl_CmdProc TestcmdtraceCmd;
Expand Down Expand Up @@ -297,10 +297,10 @@ static Tcl_ObjCmdProc TestregexpObjCmd;
static Tcl_ObjCmdProc TestreturnObjCmd;
static void TestregexpXflags(const char *string,
size_t length, int *cflagsPtr, int *eflagsPtr);
#ifndef TCL_NO_DEPRECATED
#if TCL_UTF_MAX < 4
static Tcl_ObjCmdProc TestsaveresultCmd;
static Tcl_FreeProc TestsaveresultFree;
#endif /* TCL_NO_DEPRECATED */
#endif /* TCL_UTF_MAX */
static Tcl_CmdProc TestsetassocdataCmd;
static Tcl_CmdProc TestsetCmd;
static Tcl_CmdProc Testset2Cmd;
Expand Down Expand Up @@ -590,9 +590,9 @@ Tcltest_Init(
Tcl_CreateObjCommand(interp, "testsetbytearraylength", TestsetbytearraylengthObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testbytestring", TestbytestringObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "teststringbytes", TeststringbytesObjCmd, NULL, NULL);
#ifndef TCL_NO_DEPRECATED
#if TCL_UTF_MAX < 4
Tcl_CreateObjCommand(interp, "testutf16string", Testutf16stringObjCmd, NULL, NULL);
#endif /* TCL_NO_DEPRECATED */
#endif /* TCL_UTF_MAX */
Tcl_CreateObjCommand2(interp, "testwrongnumargs", TestWrongNumArgsObjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testfilesystem", TestFilesystemObjCmd,
Expand Down Expand Up @@ -690,7 +690,7 @@ Tcltest_Init(
NULL, NULL);
Tcl_CreateObjCommand(interp, "testreturn", TestreturnObjCmd,
NULL, NULL);
#ifndef TCL_NO_DEPRECATED
#if TCL_UTF_MAX < 4
Tcl_CreateObjCommand(interp, "testsaveresult", TestsaveresultCmd,
NULL, NULL);
#endif
Expand Down Expand Up @@ -5798,7 +5798,7 @@ TestbytestringObjCmd(
*----------------------------------------------------------------------
*/

#ifndef TCL_NO_DEPRECATED
#if TCL_UTF_MAX < 4
static int
Testutf16stringObjCmd(
TCL_UNUSED(void *),
Expand All @@ -5817,7 +5817,7 @@ Testutf16stringObjCmd(
Tcl_SetObjResult(interp, Tcl_NewUnicodeObj(p, TCL_INDEX_NONE));
return TCL_OK;
}
#endif /* TCL_NO_DEPRECATED */
#endif /* TCL_UTF_MAX */

/*
*----------------------------------------------------------------------
Expand Down Expand Up @@ -5918,7 +5918,7 @@ Testset2Cmd(
*----------------------------------------------------------------------
*/

#ifndef TCL_NO_DEPRECATED
#if TCL_UTF_MAX < 4
static int
TestsaveresultCmd(
TCL_UNUSED(void *),
Expand Down Expand Up @@ -6036,7 +6036,7 @@ TestsaveresultFree(
{
freeCount++;
}
#endif /* TCL_NO_DEPRECATED */
#endif /* TCL_UTF_MAX */

/*
*----------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions generic/tclTestObj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,7 @@ TeststringobjCmd(
}
Tcl_SetWideIntObj(Tcl_GetObjResult(interp), length);
break;
#ifndef TCL_NO_DEPRECATED
case 10: { /* range */
Tcl_Size first, last;
if (objc != 5) {
Expand All @@ -1485,6 +1486,7 @@ TeststringobjCmd(
Tcl_SetObjResult(interp, Tcl_GetRange(varPtr[varIndex], first, last));
break;
}
#endif /* TCL_NO_DEPRECATED */
case 11: /* appendself */
if (objc != 4) {
goto wrongNumArgs;
Expand Down Expand Up @@ -1516,6 +1518,7 @@ TeststringobjCmd(
Tcl_AppendToObj(varPtr[varIndex], string + length, size - length);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
#ifndef TCL_NO_DEPRECATED
case 12: /* appendself2 */
if (objc != 4) {
goto wrongNumArgs;
Expand Down Expand Up @@ -1547,6 +1550,7 @@ TeststringobjCmd(
Tcl_AppendUnicodeToObj(varPtr[varIndex], unicode + length, size - length);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
#endif /* TCL_NO_DEPRECATED */
case 13: /* newunicode*/
unicode = (unsigned short *)ckalloc(((unsigned)objc - 3) * sizeof(unsigned short));
for (i = 0; i < (objc - 3); ++i) {
Expand All @@ -1564,6 +1568,8 @@ TeststringobjCmd(
Tcl_SetObjResult(interp, varPtr[varIndex]);
ckfree(unicode);
break;
default:
return TCL_ERROR;
}

return TCL_OK;
Expand Down

0 comments on commit 2fd4839

Please sign in to comment.