Skip to content

Commit

Permalink
Use TCL_SIZE_MODIFIER when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Dec 26, 2024
1 parent 7213582 commit bf0731d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
5 changes: 4 additions & 1 deletion generic/itcl.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ ITCL_EXTERN int Itcl_SafeInit(Tcl_Interp *interp);
#define ITCL_PRIVATE 3
#define ITCL_DEFAULT_PROTECT 4

#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 7) && !defined(Tcl_Size)
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 7)
# if !defined(Tcl_Size)
# define Tcl_Size int
# endif
# define Tcl_ObjCmdProc2 Tcl_ObjCmdProc
#endif

/*
Expand Down
2 changes: 1 addition & 1 deletion generic/itclClass.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ ItclClassCreateObject(
do {
Tcl_CmdInfo dummy;

sprintf(unique,"%.200s%" ITCL_Z_MODIFIER "u", Tcl_GetString(iclsPtr->namePtr),
sprintf(unique,"%.200s%" TCL_SIZE_MODIFIER "u", Tcl_GetString(iclsPtr->namePtr),
iclsPtr->unique++);
unique[0] = tolower(UCHAR(unique[0]));

Expand Down
4 changes: 2 additions & 2 deletions generic/itclEnsemble.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ CreateEnsemble(
memset(ensData->parts, 0, ensData->maxParts*sizeof(EnsemblePart*));
Tcl_DStringInit(&buffer);
Tcl_DStringAppend(&buffer, ITCL_COMMANDS_NAMESPACE "::ensembles::", TCL_INDEX_NONE);
sprintf(buf, "%" ITCL_Z_MODIFIER "u", ensData->ensembleId);
sprintf(buf, "%" TCL_SIZE_MODIFIER "u", ensData->ensembleId);
Tcl_DStringAppend(&buffer, buf, TCL_INDEX_NONE);
ensData->nsPtr = Tcl_CreateNamespace(interp, Tcl_DStringValue(&buffer),
ensData, DeleteEnsemble);
Expand Down Expand Up @@ -837,7 +837,7 @@ CreateEnsemble(
Tcl_DStringSetLength(&buffer, 0);
Tcl_DStringAppend(&buffer, infoPtr->ensembleInfo->ensembleNsPtr->fullName, TCL_INDEX_NONE);
Tcl_DStringAppend(&buffer, "::subensembles::", TCL_INDEX_NONE);
sprintf(buf, "%" ITCL_Z_MODIFIER "u", parentEnsData->ensembleId);
sprintf(buf, "%" TCL_SIZE_MODIFIER "u", parentEnsData->ensembleId);
Tcl_DStringAppend(&buffer, buf, TCL_INDEX_NONE);
Tcl_DStringAppend(&buffer, "::", 2);
Tcl_DStringAppend(&buffer, ensName, TCL_INDEX_NONE);
Expand Down
2 changes: 1 addition & 1 deletion generic/itclHelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ ItclCreateArgList(
"\" has argument with no name", NULL);
} else {
char buf[TCL_INTEGER_SPACE];
sprintf(buf, "%" ITCL_Z_MODIFIER "d", i);
sprintf(buf, "%" TCL_SIZE_MODIFIER "d", i);
Tcl_AppendResult(interp, "argument #", buf,
" has no name", NULL);
}
Expand Down
17 changes: 13 additions & 4 deletions generic/itclInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,19 @@
# endif
#endif

#if TCL_MAJOR_VERSION == 8
# define ITCL_Z_MODIFIER ""
#else
# define ITCL_Z_MODIFIER TCL_Z_MODIFIER
#if TCL_MAJOR_VERSION == 8 && defined(TCL_MINOR_VERSION) && TCL_MINOR_VERSION < 7
# define Tcl_MethodType2 Tcl_MethodType
# define Tcl_MethodCallProc2 Tcl_MethodCallProc
# define Tcl_NewMethod2 Tcl_NewMethod
# define Tcl_CreateObjCommand2 Tcl_CreateObjCommand
# define Tcl_NRCallObjProc2 Tcl_NRCallObjProc
# define Tcl_NRCreateCommand2 Tcl_NRCreateCommand
# define objProc2 objProc
# define objClientData2 objClientData
# define Tcl_NewInstanceMethod2 Tcl_NewInstanceMethod
# define TclGetObjInterpProc2 TclGetObjInterpProc
# define TCL_OO_METHOD_VERSION_2 TCL_OO_METHOD_VERSION_CURRENT
# define TCL_SIZE_MODIFIER ""
#endif

/*
Expand Down
2 changes: 1 addition & 1 deletion generic/itclObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ ItclCreateObject(
do {
Tcl_CmdInfo dummy;

sprintf(unique,"%.200s_%" ITCL_Z_MODIFIER "u", name, iclsPtr->unique++);
sprintf(unique,"%.200s_%" TCL_SIZE_MODIFIER "u", name, iclsPtr->unique++);
unique[0] = tolower(UCHAR(unique[0]));

Tcl_DStringSetLength(&buffer, 0);
Expand Down

0 comments on commit bf0731d

Please sign in to comment.