From d3080efe1ea6393f72f4b3a01c6cda6843b72662 Mon Sep 17 00:00:00 2001 From: oehhar Date: Mon, 16 Dec 2024 11:50:32 +0000 Subject: [PATCH 1/8] Ticket [70f3b23cad]: propose new doc wording for requirement strings --- doc/InitStubs.3 | 10 +++-- doc/package.n | 117 +++++++++++++++++++++++++----------------------- 2 files changed, 67 insertions(+), 60 deletions(-) diff --git a/doc/InitStubs.3 b/doc/InitStubs.3 index 80a21de8ab3..9ac4f24515e 100644 --- a/doc/InitStubs.3 +++ b/doc/InitStubs.3 @@ -14,21 +14,23 @@ Tcl_InitStubs \- initialize the Tcl stubs mechanism \fB#include \fR .sp const char * -\fBTcl_InitStubs\fR(\fIinterp, version, exact\fR) +\fBTcl_InitStubs\fR(\fIinterp, requirements, exact\fR) .fi .SH ARGUMENTS .AS Tcl_Interp *interp .AP Tcl_Interp *interp in Tcl interpreter handle. -.AP "const char" *version in -A version string consisting of one or more decimal numbers -separated by dots. +.AP "const char" *requirements in +The requirement string of the compatible Tcl versions. +It consists of a space separated list of requirements as described on the PACKAGE manual page in the section REQUIREMENT. .AP int exact in 1 means that only the particular version specified by \fIversion\fR is acceptable. +An exact version number must be given as \fIrequirement\fR. 0 means that versions newer than \fIversion\fR are also acceptable as long as they have the same major version number as \fIversion\fR. Other bits have no effect. +See the \fB-require\fR option of the \fBpackage require\fR command. .BE .SH INTRODUCTION .PP diff --git a/doc/package.n b/doc/package.n index d27a44a3868..9f67e9aaf61 100644 --- a/doc/package.n +++ b/doc/package.n @@ -205,62 +205,7 @@ commands. \fBpackage vsatisfies \fIversion requirement...\fR . Returns 1 if the \fIversion\fR satisfies at least one of the given -requirements, and 0 otherwise. Each \fIrequirement\fR is allowed to -have any of the forms: -.RS -.IP \fImin\fR -This form is called -.QW min-bounded . -.IP \fImin\fB\-\fR -This form is called -.QW min-unbound . -.IP \fImin\fB\-\fImax\fR -This form is called -.QW bounded . -.PP -where -.QW \fImin\fR -and -.QW \fImax\fR -are valid version numbers. The legacy syntax is -a special case of the extended syntax, keeping backward -compatibility. Regarding satisfaction the rules are: -.IP [1] -The \fIversion\fR has to pass at least one of the listed -\fIrequirement\fRs to be satisfactory. -.IP [2] -A version satisfies a -.QW bounded -requirement when -.RS -.IP [a] -For \fImin\fR equal to the \fImax\fR if, and only if the \fIversion\fR -is equal to the \fImin\fR. -.IP [b] -Otherwise if, and only if the \fIversion\fR is greater than or equal -to the \fImin\fR, and less than the \fImax\fR, where both \fImin\fR -and \fImax\fR have been padded internally with -.QW a0 . -Note that while the comparison to \fImin\fR is inclusive, the -comparison to \fImax\fR is exclusive. -.RE -.IP [3] -A -.QW min-bounded -requirement is a -.QW bounded -requirement in disguise, -with the \fImax\fR part implicitly specified as the next higher major -version number of the \fImin\fR part. A version satisfies it per the -rules above. -.IP [4] -A \fIversion\fR satisfies a -.QW min-unbound -requirement if, and only if it is greater than or equal to the -\fImin\fR, where the \fImin\fR has been padded internally with -.QW a0 . -There is no constraint to a maximum. -.RE +requirements, and 0 otherwise. \fIrequirements\fR are defined in the REQUIREMENTS section below. .\" METHOD: prefer .TP \fBpackage prefer \fR?\fBlatest\fR|\fBstable\fR? @@ -350,6 +295,66 @@ and \fBpackage provide\fR commands in scripts, and use the procedure Once you have done this, packages will be loaded automatically in response to \fBpackage require\fR commands. See the documentation for \fBpkg_mkIndex\fR for details. +.SH "REQUIREMENT" +.PP +A \fIrequirement\fR string checks, if a compatible version number of a package is present. +Most commands accept a list of requirements where the highest suitable version is matched. +.PP +Each \fIrequirement\fR is allowed to have any of the forms: +.RS +.IP \fImin\fR +This form is called +.QW min-bounded . +.IP \fImin\fB\-\fR +This form is called +.QW min-unbound . +.IP \fImin\fB\-\fImax\fR +This form is called +.QW bounded . +.PP +where +.QW \fImin\fR +and +.QW \fImax\fR +are valid version numbers. The legacy syntax is +a special case of the extended syntax, keeping backward +compatibility. Regarding satisfaction the rules are: +.IP [1] +The \fIversion\fR has to pass at least one of the listed +\fIrequirement\fRs to be satisfactory. +.IP [2] +A version satisfies a +.QW bounded +requirement when +.RS +.IP [a] +For \fImin\fR equal to the \fImax\fR if, and only if the \fIversion\fR +is equal to the \fImin\fR. +.IP [b] +Otherwise if, and only if the \fIversion\fR is greater than or equal +to the \fImin\fR, and less than the \fImax\fR, where both \fImin\fR +and \fImax\fR have been padded internally with +.QW a0 . +Note that while the comparison to \fImin\fR is inclusive, the +comparison to \fImax\fR is exclusive. +.RE +.IP [3] +A +.QW min-bounded +requirement is a +.QW bounded +requirement in disguise, +with the \fImax\fR part implicitly specified as the next higher major +version number of the \fImin\fR part. A version satisfies it per the +rules above. +.IP [4] +A \fIversion\fR satisfies a +.QW min-unbound +requirement if, and only if it is greater than or equal to the +\fImin\fR, where the \fImin\fR has been padded internally with +.QW a0 . +There is no constraint to a maximum. +.RE .SH EXAMPLES .PP To state that a Tcl script requires the Tk and http packages, put this From 4e6acfdfcd15415430f992cf3e77c0d389ed2dd1 Mon Sep 17 00:00:00 2001 From: oehhar Date: Mon, 16 Dec 2024 14:16:12 +0000 Subject: [PATCH 2/8] Add Tcl_InitStubs macro information. Update man page links. --- doc/InitStubs.3 | 14 ++++++++++---- doc/package.n | 8 ++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/doc/InitStubs.3 b/doc/InitStubs.3 index 9ac4f24515e..d6edc8797bb 100644 --- a/doc/InitStubs.3 +++ b/doc/InitStubs.3 @@ -14,15 +14,16 @@ Tcl_InitStubs \- initialize the Tcl stubs mechanism \fB#include \fR .sp const char * -\fBTcl_InitStubs\fR(\fIinterp, requirements, exact\fR) +\fBTcl_InitStubs\fR(\fIinterp, requirement, exact\fR) .fi .SH ARGUMENTS .AS Tcl_Interp *interp .AP Tcl_Interp *interp in Tcl interpreter handle. -.AP "const char" *requirements in -The requirement string of the compatible Tcl versions. -It consists of a space separated list of requirements as described on the PACKAGE manual page in the section REQUIREMENT. +.AP "const char" *requirement in +The requirement string of compatible Tcl versions. +It consists of one requirement as described for \fBpackage require\fR (\fBPACKAGE\fR manual page in the section \fBREQUIREMENT\fR). +Multiple requirement strings like with \fBpackage require\fR are not supported. .AP int exact in 1 means that only the particular version specified by \fIversion\fR is acceptable. @@ -86,7 +87,12 @@ non-zero means that only the specified \fIversion\fR is acceptable. \fBTcl_InitStubs\fR returns a string containing the actual version of Tcl satisfying the request, or NULL if the Tcl version is not acceptable, does not support stubs, or any other error condition occurred. +.PP +\fBTcl_InitStubs\fR is implemented as a macro. +If \fBUSE_TCL_STUBS\fR is not defined, it translates to a TCL version verification only. +Thus, the call may also be used if the TCL library is directly linked. .SH "SEE ALSO" Tk_InitStubs +package .SH KEYWORDS stubs diff --git a/doc/package.n b/doc/package.n index 9f67e9aaf61..ba95c316df2 100644 --- a/doc/package.n +++ b/doc/package.n @@ -123,8 +123,8 @@ loaded; otherwise it generates an error. .RS .PP A suitable version of the package is any version which satisfies at -least one of the requirements, per the rules of \fBpackage -vsatisfies\fR. If multiple versions are suitable the implementation +least one of the requirements as defined in the section \fBREQUIREMENT\fR below. +If multiple versions are suitable the implementation with the highest version is chosen. This last part is additionally influenced by the selection mode set with \fBpackage prefer\fR. .PP @@ -205,7 +205,7 @@ commands. \fBpackage vsatisfies \fIversion requirement...\fR . Returns 1 if the \fIversion\fR satisfies at least one of the given -requirements, and 0 otherwise. \fIrequirements\fR are defined in the REQUIREMENTS section below. +requirements, and 0 otherwise. \fIrequirements\fR are defined in the \fBREQUIREMENT\fR section below. .\" METHOD: prefer .TP \fBpackage prefer \fR?\fBlatest\fR|\fBstable\fR? @@ -298,7 +298,7 @@ See the documentation for \fBpkg_mkIndex\fR for details. .SH "REQUIREMENT" .PP A \fIrequirement\fR string checks, if a compatible version number of a package is present. -Most commands accept a list of requirements where the highest suitable version is matched. +Most commands accept a list of requirement strings where the highest suitable version is matched. .PP Each \fIrequirement\fR is allowed to have any of the forms: .RS From e20406d838b6c93686dc974560705e61076d2ee7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 3 Jan 2025 14:48:06 +0000 Subject: [PATCH 3/8] Document underlying Tcl_InitStubs() behavior, when circumventing the macro in tcl.h --- doc/InitStubs.3 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/InitStubs.3 b/doc/InitStubs.3 index d6edc8797bb..62b53f52982 100644 --- a/doc/InitStubs.3 +++ b/doc/InitStubs.3 @@ -83,12 +83,22 @@ and a Boolean flag indicating whether the extension requires an exact version match or not. If \fIexact\fR is 0, then the extension is indicating that newer versions of Tcl are acceptable as long as they have the same major version number as \fIversion\fR; -non-zero means that only the specified \fIversion\fR is acceptable. +1 means that only the specified \fIversion\fR is acceptable. \fBTcl_InitStubs\fR returns a string containing the actual version of Tcl satisfying the request, or NULL if the Tcl version is not acceptable, does not support stubs, or any other error condition occurred. .PP \fBTcl_InitStubs\fR is implemented as a macro. +If \fBUSE_TCL_STUBS\fR is defined, this macro calls the real \fBTcl_InitStubs\fR +function which has an additional \fBmagic\fR integer argument and uses the \fBexact\fR +parameter to know the exact Tcl major version number. If you circumvent +the macro in tcl.h, it should be called like this: +.CS + if (Tcl_InitStubs(interp, "8.6-", TCL_MAJOR_VERSION<<8, TCL_STUB_MAGIC)) == NULL) { + return TCL_ERROR; + } +} +.CE If \fBUSE_TCL_STUBS\fR is not defined, it translates to a TCL version verification only. Thus, the call may also be used if the TCL library is directly linked. .SH "SEE ALSO" From 8183691a4f59cd8825eb70046924731ff91d0425 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 6 Jan 2025 21:15:03 +0000 Subject: [PATCH 4/8] This would be my advise. Using TCL_VERSION in Tcl_InitStubs() is a bad idea (IMHO) --- doc/InitStubs.3 | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/doc/InitStubs.3 b/doc/InitStubs.3 index 62b53f52982..da659fc7eac 100644 --- a/doc/InitStubs.3 +++ b/doc/InitStubs.3 @@ -24,13 +24,33 @@ Tcl interpreter handle. The requirement string of compatible Tcl versions. It consists of one requirement as described for \fBpackage require\fR (\fBPACKAGE\fR manual page in the section \fBREQUIREMENT\fR). Multiple requirement strings like with \fBpackage require\fR are not supported. +Examples: +.CS +Tcl_InitStubs(interp, "8.5", 0); /* This extension only uses the Tcl 8.5 API. It will work with 8.6 as well */ +Tcl_InitStubs(interp, "8.6", 0); /* This extension only uses the Tcl 8.6 API. It will work with 8.6 only */ +Tcl_InitStubs(interp, "9.0", 0); /* This extension only uses the Tcl 9.0 API. It will work with 9.0 only */ +.CE +If any such extension is ported to Tcl 9.0, without additional API usage (only int -> Tcl_Size conversions, nothing more): +.CS +Tcl_InitStubs(interp, "8.5-", 0); /* This extension only uses the Tcl 8.5 API. It will work with 8.6 and (recompiled) with 9.0 as well */ +Tcl_InitStubs(interp, "8.6-", 0); /* This extension only uses the Tcl 8.6 API. It will work (recompiled) with 9.0 as well */ +.CE +If you don't know which Tcl version you are developing for, do the following: +.CS +$ tclsh +% info tclversion +9.0 +.CE +Now you know what requirement string to fill. .AP int exact in 1 means that only the particular version specified by -\fIversion\fR is acceptable. +\fIrequirement\fR is acceptable. An exact version number must be given as \fIrequirement\fR. -0 means that versions newer than \fIversion\fR are also -acceptable as long as they have the same major version number -as \fIversion\fR. Other bits have no effect. +0 means that versions newer than \fIrequirement\fR are also +acceptable. If the requirement string ends with \fB-\fR, +higher major versions are acceptable as well, otherwise +the major version must be the same as in the requirement string. +Other bits have no effect. See the \fB-require\fR option of the \fBpackage require\fR command. .BE .SH INTRODUCTION @@ -41,7 +61,7 @@ This provides two significant benefits to Tcl users: .IP 1) 5 Extensions that use the stubs mechanism can be loaded into multiple versions of Tcl without being recompiled or -relinked. +relinked, as long as the major Tcl version is the same. .IP 2) 5 Extensions that use the stubs mechanism can be dynamically loaded into statically-linked Tcl applications. @@ -81,8 +101,10 @@ and ensure that the correct version of Tcl is loaded. In addition to an interpreter handle, it accepts as arguments a version number and a Boolean flag indicating whether the extension requires an exact version match or not. If \fIexact\fR is 0, then the -extension is indicating that newer versions of Tcl are acceptable -as long as they have the same major version number as \fIversion\fR; +extension is indicating that newer versions of Tcl are acceptable. +If the requirement string ends with \fB-\fR, +higher major versions are acceptable as well, otherwise +the major version must be the same as in the requirement string. 1 means that only the specified \fIversion\fR is acceptable. \fBTcl_InitStubs\fR returns a string containing the actual version of Tcl satisfying the request, or NULL if the Tcl version is not @@ -94,9 +116,8 @@ function which has an additional \fBmagic\fR integer argument and uses the \fBex parameter to know the exact Tcl major version number. If you circumvent the macro in tcl.h, it should be called like this: .CS - if (Tcl_InitStubs(interp, "8.6-", TCL_MAJOR_VERSION<<8, TCL_STUB_MAGIC)) == NULL) { - return TCL_ERROR; - } +if (Tcl_InitStubs(interp, "9.0", TCL_MAJOR_VERSION<<8, TCL_STUB_MAGIC)) == NULL) { + return TCL_ERROR; } .CE If \fBUSE_TCL_STUBS\fR is not defined, it translates to a TCL version verification only. From bee9aff93622bd5fd3b1f15eaeb2d88b3bde0677 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 10 Jan 2025 13:59:22 +0000 Subject: [PATCH 5/8] Another attempt to make it clear, without too much bloat --- doc/InitStubs.3 | 69 ++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 50 deletions(-) diff --git a/doc/InitStubs.3 b/doc/InitStubs.3 index da659fc7eac..decea876e4f 100644 --- a/doc/InitStubs.3 +++ b/doc/InitStubs.3 @@ -14,44 +14,23 @@ Tcl_InitStubs \- initialize the Tcl stubs mechanism \fB#include \fR .sp const char * -\fBTcl_InitStubs\fR(\fIinterp, requirement, exact\fR) +\fBTcl_InitStubs\fR(\fIinterp, version, exact\fR) .fi .SH ARGUMENTS .AS Tcl_Interp *interp .AP Tcl_Interp *interp in Tcl interpreter handle. -.AP "const char" *requirement in -The requirement string of compatible Tcl versions. -It consists of one requirement as described for \fBpackage require\fR (\fBPACKAGE\fR manual page in the section \fBREQUIREMENT\fR). -Multiple requirement strings like with \fBpackage require\fR are not supported. -Examples: -.CS -Tcl_InitStubs(interp, "8.5", 0); /* This extension only uses the Tcl 8.5 API. It will work with 8.6 as well */ -Tcl_InitStubs(interp, "8.6", 0); /* This extension only uses the Tcl 8.6 API. It will work with 8.6 only */ -Tcl_InitStubs(interp, "9.0", 0); /* This extension only uses the Tcl 9.0 API. It will work with 9.0 only */ -.CE -If any such extension is ported to Tcl 9.0, without additional API usage (only int -> Tcl_Size conversions, nothing more): -.CS -Tcl_InitStubs(interp, "8.5-", 0); /* This extension only uses the Tcl 8.5 API. It will work with 8.6 and (recompiled) with 9.0 as well */ -Tcl_InitStubs(interp, "8.6-", 0); /* This extension only uses the Tcl 8.6 API. It will work (recompiled) with 9.0 as well */ -.CE -If you don't know which Tcl version you are developing for, do the following: -.CS -$ tclsh -% info tclversion -9.0 -.CE -Now you know what requirement string to fill. +.AP "const char" *version in +A version string, indicating which minimal version of Tcl is accepted. +Normally just \fB"9.0"\fR. Or \fB"8.6-"\fR if both 8.6 and 9.0 are accepted. .AP int exact in 1 means that only the particular version specified by -\fIrequirement\fR is acceptable. -An exact version number must be given as \fIrequirement\fR. -0 means that versions newer than \fIrequirement\fR are also -acceptable. If the requirement string ends with \fB-\fR, -higher major versions are acceptable as well, otherwise -the major version must be the same as in the requirement string. +\fIversion\fR is accepted. +0 means that versions newer than \fIversion\fR are also +accepted. If the\fIversion\fR ends with \fB-\fR, +higher major versions are accepted as well, otherwise +the major version must be the same as in \fIversion\fR. Other bits have no effect. -See the \fB-require\fR option of the \fBpackage require\fR command. .BE .SH INTRODUCTION .PP @@ -100,28 +79,18 @@ more information. and ensure that the correct version of Tcl is loaded. In addition to an interpreter handle, it accepts as arguments a version number and a Boolean flag indicating whether the extension requires -an exact version match or not. If \fIexact\fR is 0, then the -extension is indicating that newer versions of Tcl are acceptable. -If the requirement string ends with \fB-\fR, -higher major versions are acceptable as well, otherwise -the major version must be the same as in the requirement string. -1 means that only the specified \fIversion\fR is acceptable. +an exact version match or not. If \fIexact\fR is 0, then versions +newer than \fIversion\fR are also accepted. If the\fIversion\fR +ends with \fB-\fR, higher major versions are accepted as well, +otherwise the major version must be the same as in \fIversion\fR. +1 means that only the specified \fIversion\fR is accepted. +\fIversion\fR can be any construct as described for \fBpackage require\fR +(\fBPACKAGE\fR manual page in the section \fBREQUIREMENT\fR). +Multiple requirement strings like with \fBpackage require\fR are not supported. + \fBTcl_InitStubs\fR returns a string containing the actual version of Tcl satisfying the request, or NULL if the Tcl version is not -acceptable, does not support stubs, or any other error condition occurred. -.PP -\fBTcl_InitStubs\fR is implemented as a macro. -If \fBUSE_TCL_STUBS\fR is defined, this macro calls the real \fBTcl_InitStubs\fR -function which has an additional \fBmagic\fR integer argument and uses the \fBexact\fR -parameter to know the exact Tcl major version number. If you circumvent -the macro in tcl.h, it should be called like this: -.CS -if (Tcl_InitStubs(interp, "9.0", TCL_MAJOR_VERSION<<8, TCL_STUB_MAGIC)) == NULL) { - return TCL_ERROR; -} -.CE -If \fBUSE_TCL_STUBS\fR is not defined, it translates to a TCL version verification only. -Thus, the call may also be used if the TCL library is directly linked. +accepted, does not support stubs, or any other error condition occurred. .SH "SEE ALSO" Tk_InitStubs package From 35dfc3edbc5240707b4a9c60217115a76c63aabb Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 11 Jan 2025 21:22:45 +0000 Subject: [PATCH 6/8] Fix ifndef -> ifdef in previous commit --- generic/tclDecls.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclDecls.h b/generic/tclDecls.h index d8dffdc4da9..8f8002378e6 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -4476,7 +4476,7 @@ extern const TclStubs *tclStubsPtr; # define Tcl_UtfToUniChar Tcl_UtfToChar16 # undef Tcl_UniCharLen # define Tcl_UniCharLen Tcl_Char16Len -# ifndef TCL_NO_DEPRECATED +# ifdef TCL_NO_DEPRECATED # undef Tcl_GetUnicode # undef Tcl_GetUnicodeFromObj # undef Tcl_SetUnicodeObj From 2fd4839585c0ecc7a9119136e6e1e25728f40c45 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 12 Jan 2025 13:57:26 +0000 Subject: [PATCH 7/8] Handle TCL_NO_DEPRECATED in test code: Don't try to use deprecated API --- generic/tclTest.c | 26 +++++++++++++------------- generic/tclTestObj.c | 6 ++++++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/generic/tclTest.c b/generic/tclTest.c index 5e5c14c2152..8db9a7a3c4d 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -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. @@ -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; @@ -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; @@ -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, @@ -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 @@ -5798,7 +5798,7 @@ TestbytestringObjCmd( *---------------------------------------------------------------------- */ -#ifndef TCL_NO_DEPRECATED +#if TCL_UTF_MAX < 4 static int Testutf16stringObjCmd( TCL_UNUSED(void *), @@ -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 */ /* *---------------------------------------------------------------------- @@ -5918,7 +5918,7 @@ Testset2Cmd( *---------------------------------------------------------------------- */ -#ifndef TCL_NO_DEPRECATED +#if TCL_UTF_MAX < 4 static int TestsaveresultCmd( TCL_UNUSED(void *), @@ -6036,7 +6036,7 @@ TestsaveresultFree( { freeCount++; } -#endif /* TCL_NO_DEPRECATED */ +#endif /* TCL_UTF_MAX */ /* *---------------------------------------------------------------------- diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index 7139674c1f4..123e1e02959 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.c @@ -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) { @@ -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; @@ -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; @@ -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) { @@ -1564,6 +1568,8 @@ TeststringobjCmd( Tcl_SetObjResult(interp, varPtr[varIndex]); ckfree(unicode); break; + default: + return TCL_ERROR; } return TCL_OK; From 89e3ee4ed2f67754565d7b7411b549f965be3093 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 12 Jan 2025 17:35:02 +0000 Subject: [PATCH 8/8] In dltest/pkg*.c, prevent calling deprecate API as well --- unix/dltest/pkga.c | 3 +++ unix/dltest/pkgb.c | 3 +++ unix/dltest/pkgt.c | 3 +++ unix/dltest/pkgua.c | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/unix/dltest/pkga.c b/unix/dltest/pkga.c index f249b1d0289..f8599830cdb 100644 --- a/unix/dltest/pkga.c +++ b/unix/dltest/pkga.c @@ -11,6 +11,9 @@ */ #undef STATIC_BUILD +#ifdef TCL_NO_DEPRECATED +# define TCL_UTF_MAX 4 /* Make sure not to use the UTf-16 compatibility wrappers */ +#endif #include "tcl.h" /* diff --git a/unix/dltest/pkgb.c b/unix/dltest/pkgb.c index 3a1d3d46c5d..2b23a38d29d 100644 --- a/unix/dltest/pkgb.c +++ b/unix/dltest/pkgb.c @@ -12,6 +12,9 @@ */ #undef STATIC_BUILD +#ifdef TCL_NO_DEPRECATED +# define TCL_UTF_MAX 4 /* Make sure not to use the UTf-16 compatibility wrappers */ +#endif #include "tcl.h" #if defined(_WIN32) && defined(_MSC_VER) # define snprintf _snprintf diff --git a/unix/dltest/pkgt.c b/unix/dltest/pkgt.c index 158bd9e1791..67ab0b14a9e 100644 --- a/unix/dltest/pkgt.c +++ b/unix/dltest/pkgt.c @@ -11,6 +11,9 @@ */ #undef STATIC_BUILD +#ifdef TCL_NO_DEPRECATED +# define TCL_UTF_MAX 4 /* Make sure not to use the UTf-16 compatibility wrappers */ +#endif #include "tcl.h" static int TraceProc2 ( diff --git a/unix/dltest/pkgua.c b/unix/dltest/pkgua.c index c8a296e617f..18516b5e82d 100644 --- a/unix/dltest/pkgua.c +++ b/unix/dltest/pkgua.c @@ -11,6 +11,10 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ +#undef STATIC_BUILD +#ifdef TCL_NO_DEPRECATED +# define TCL_UTF_MAX 4 /* Make sure not to use the UTf-16 compatibility wrappers */ +#endif #include "tcl.h" /*