Skip to content

Commit

Permalink
More type-casts (c++-compatibility)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Sep 13, 2023
1 parent 225ba3d commit 715e8c3
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 182 deletions.
46 changes: 23 additions & 23 deletions generic/tclCmdMZ.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Tcl_RegexpObjCmd(
"-expanded", "-line", "-linestop", "-lineanchor",
"-nocase", "-start", "--", NULL
};
enum options {
enum regexpoptions {
REGEXP_ALL, REGEXP_ABOUT, REGEXP_INDICES, REGEXP_INLINE,
REGEXP_EXPANDED,REGEXP_LINE, REGEXP_LINESTOP,REGEXP_LINEANCHOR,
REGEXP_NOCASE, REGEXP_START, REGEXP_LAST
Expand All @@ -162,7 +162,7 @@ Tcl_RegexpObjCmd(
&index) != TCL_OK) {
goto optionError;
}
switch ((enum options) index) {
switch ((enum regexpoptions) index) {
case REGEXP_ALL:
all = 1;
break;
Expand Down Expand Up @@ -1094,14 +1094,14 @@ Tcl_SplitObjCmd(

Tcl_SetHashValue(hPtr, objPtr);
} else {
objPtr = Tcl_GetHashValue(hPtr);
objPtr = (Tcl_Obj *)Tcl_GetHashValue(hPtr);
}
Tcl_ListObjAppendElement(NULL, listPtr, objPtr);
}
Tcl_DeleteHashTable(&charReuseTable);

} else if (splitCharLen == 1) {
char *p;
const char *p;

/*
* Handle the special case of splitting on a single character. This is
Expand Down Expand Up @@ -1900,7 +1900,7 @@ StringMapCmd(
* adapt this code...
*/

mapElemv = TclStackAlloc(interp, sizeof(Tcl_Obj *) * mapElemc);
mapElemv = (Tcl_Obj **)TclStackAlloc(interp, sizeof(Tcl_Obj *) * mapElemc);
Tcl_DictObjFirst(interp, objv[objc-2], &search, mapElemv+0,
mapElemv+1, &done);
for (i=2 ; i<mapElemc ; i+=2) {
Expand Down Expand Up @@ -2011,10 +2011,10 @@ StringMapCmd(
* case.
*/

mapStrings = TclStackAlloc(interp, mapElemc*2*sizeof(Tcl_UniChar *));
mapLens = TclStackAlloc(interp, mapElemc * 2 * sizeof(int));
mapStrings = (Tcl_UniChar **)TclStackAlloc(interp, mapElemc*2*sizeof(Tcl_UniChar *));
mapLens = (int *)TclStackAlloc(interp, mapElemc * 2 * sizeof(int));
if (nocase) {
u2lc = TclStackAlloc(interp, mapElemc * sizeof(Tcl_UniChar));
u2lc = (Tcl_UniChar *)TclStackAlloc(interp, mapElemc * sizeof(Tcl_UniChar));
}
for (index = 0; index < mapElemc; index++) {
mapStrings[index] = Tcl_GetUnicodeFromObj(mapElemv[index],
Expand Down Expand Up @@ -2272,7 +2272,7 @@ StringReptCmd(
* Include space for the NUL.
*/

string2 = attemptckalloc(length2 + 1);
string2 = (char *)attemptckalloc(length2 + 1);
if (string2 == NULL) {
/*
* Alloc failed. Note that in this case we try to do an error message
Expand Down Expand Up @@ -3992,7 +3992,7 @@ TclNRSwitchObjCmd(
*/

matchFound:
ctxPtr = TclStackAlloc(interp, sizeof(CmdFrame));
ctxPtr = (CmdFrame *)TclStackAlloc(interp, sizeof(CmdFrame));
*ctxPtr = *iPtr->cmdFramePtr;

if (splitObjs) {
Expand Down Expand Up @@ -4022,7 +4022,7 @@ TclNRSwitchObjCmd(
if (ctxPtr->type == TCL_LOCATION_SOURCE && ctxPtr->line[bidx] >= 0) {
int bline = ctxPtr->line[bidx];

ctxPtr->line = ckalloc(objc * sizeof(int));
ctxPtr->line = (int *)ckalloc(objc * sizeof(int));
ctxPtr->nline = objc;
TclListLines(blist, bline, objc, ctxPtr->line, objv);
} else {
Expand All @@ -4036,7 +4036,7 @@ TclNRSwitchObjCmd(

int k;

ctxPtr->line = ckalloc(objc * sizeof(int));
ctxPtr->line = (int *)ckalloc(objc * sizeof(int));
ctxPtr->nline = objc;
for (k=0; k < objc; k++) {
ctxPtr->line[k] = -1;
Expand Down Expand Up @@ -4076,9 +4076,9 @@ SwitchPostProc(
/* Unpack the preserved data */

int splitObjs = PTR2INT(data[0]);
CmdFrame *ctxPtr = data[1];
CmdFrame *ctxPtr = (CmdFrame *)data[1];
int pc = PTR2INT(data[2]);
const char *pattern = data[3];
const char *pattern = (const char *)data[3];
int patternLength = strlen(pattern);

/*
Expand Down Expand Up @@ -5052,9 +5052,9 @@ TryPostBody(
int i, dummy, code, objc;
int numHandlers = 0;

handlersObj = data[0];
finallyObj = data[1];
objv = data[2];
handlersObj = (Tcl_Obj *)data[0];
finallyObj = (Tcl_Obj *)data[1];
objv = (Tcl_Obj **)data[2];
objc = PTR2INT(data[3]);

cmdObj = objv[0];
Expand Down Expand Up @@ -5267,9 +5267,9 @@ TryPostHandler(
Tcl_Obj *finallyObj;
int finallyIndex;

objv = data[0];
options = data[1];
handlerKindObj = data[2];
objv = (Tcl_Obj **)data[0];
options = (Tcl_Obj *)data[1];
handlerKindObj = (Tcl_Obj *)data[2];
finallyIndex = PTR2INT(data[3]);

cmdObj = objv[0];
Expand Down Expand Up @@ -5351,9 +5351,9 @@ TryPostFinal(
{
Tcl_Obj *resultObj, *options, *cmdObj;

resultObj = data[0];
options = data[1];
cmdObj = data[2];
resultObj = (Tcl_Obj *)data[0];
options = (Tcl_Obj *)data[1];
cmdObj = (Tcl_Obj *)data[2];

/*
* If the result wasn't OK, we need to adjust the result options.
Expand Down
47 changes: 24 additions & 23 deletions generic/tclCompExpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ ParseExpr(

TclParseInit(interp, start, numBytes, parsePtr);

nodes = attemptckalloc(nodesAvailable * sizeof(OpNode));
nodes = (OpNode *)attemptckalloc(nodesAvailable * sizeof(OpNode));
if (nodes == NULL) {
TclNewLiteralStringObj(msg, "not enough memory to parse expression");
errCode = "NOMEM";
Expand Down Expand Up @@ -666,9 +666,10 @@ ParseExpr(
OpNode *newPtr = NULL;

do {
if (size <= UINT_MAX/sizeof(OpNode)) {
newPtr = attemptckrealloc(nodes, size * sizeof(OpNode));
}
if (size <= UINT_MAX/sizeof(OpNode)) {
newPtr = (OpNode *) attemptckrealloc(nodes,
size * sizeof(OpNode));
}
} while ((newPtr == NULL)
&& ((size -= (size - nodesUsed) / 2) > nodesUsed));
if (newPtr == NULL) {
Expand Down Expand Up @@ -911,7 +912,7 @@ ParseExpr(
break;

case SCRIPT: {
Tcl_Parse *nestedPtr =
Tcl_Parse *nestedPtr = (Tcl_Parse *)
TclStackAlloc(interp, sizeof(Tcl_Parse));

tokenPtr = parsePtr->tokenPtr + parsePtr->numTokens;
Expand Down Expand Up @@ -1830,15 +1831,15 @@ Tcl_ParseExpr(
OpNode *opTree = NULL; /* Will point to the tree of operators. */
Tcl_Obj *litList; /* List to hold the literals. */
Tcl_Obj *funcList; /* List to hold the functon names. */
Tcl_Parse *exprParsePtr = TclStackAlloc(interp, sizeof(Tcl_Parse));
Tcl_Parse *exprParsePtr = (Tcl_Parse *)TclStackAlloc(interp, sizeof(Tcl_Parse));
/* Holds the Tcl_Tokens of substitutions. */

TclNewObj(litList);
TclNewObj(funcList);
if (numBytes < 0) {
numBytes = (start ? strlen(start) : 0);
}

TclNewObj(litList);
TclNewObj(funcList);
code = ParseExpr(interp, start, numBytes, &opTree, litList, funcList,
exprParsePtr, 1 /* parseOnly */);
Tcl_DecrRefCount(funcList);
Expand Down Expand Up @@ -2119,9 +2120,9 @@ TclCompileExpr(
int optimize) /* 0 for one-off expressions. */
{
OpNode *opTree = NULL; /* Will point to the tree of operators */
Tcl_Obj *litList; /* List to hold the literals */
Tcl_Obj *funcList; /* List to hold the functon names*/
Tcl_Parse *parsePtr = TclStackAlloc(interp, sizeof(Tcl_Parse));
Tcl_Obj *litList; /* List to hold the literals */
Tcl_Obj *funcList; /* List to hold the functon names*/
Tcl_Parse *parsePtr = (Tcl_Parse *)TclStackAlloc(interp, sizeof(Tcl_Parse));
/* Holds the Tcl_Tokens of substitutions */
int code;

Expand Down Expand Up @@ -2196,7 +2197,7 @@ ExecConstantExprTree(
* bytecode, so there's no need to tend to TIP 280 issues.
*/

envPtr = TclStackAlloc(interp, sizeof(CompileEnv));
envPtr = (CompileEnv *)TclStackAlloc(interp, sizeof(CompileEnv));
TclInitCompileEnv(interp, envPtr, NULL, 0, NULL, 0);
CompileExprTree(interp, nodes, index, litObjvPtr, NULL, NULL, envPtr,
0 /* optimize */);
Expand All @@ -2205,7 +2206,7 @@ ExecConstantExprTree(
TclInitByteCodeObj(byteCodeObj, envPtr);
TclFreeCompileEnv(envPtr);
TclStackFree(interp, envPtr);
byteCodePtr = byteCodeObj->internalRep.twoPtrValue.ptr1;
byteCodePtr = (ByteCode *)byteCodeObj->internalRep.twoPtrValue.ptr1;
TclNRExecuteByteCode(interp, byteCodePtr);
code = TclNRRunCallbacks(interp, TCL_OK, rootPtr);
Tcl_DecrRefCount(byteCodeObj);
Expand Down Expand Up @@ -2293,13 +2294,13 @@ CompileExprTree(
break;
}
case QUESTION:
newJump = TclStackAlloc(interp, sizeof(JumpList));
newJump = (JumpList *)TclStackAlloc(interp, sizeof(JumpList));
newJump->next = jumpPtr;
jumpPtr = newJump;
TclEmitForwardJump(envPtr, TCL_FALSE_JUMP, &jumpPtr->jump);
break;
case COLON:
newJump = TclStackAlloc(interp, sizeof(JumpList));
newJump = (JumpList *)TclStackAlloc(interp, sizeof(JumpList));
newJump->next = jumpPtr;
jumpPtr = newJump;
TclEmitForwardJump(envPtr, TCL_UNCONDITIONAL_JUMP,
Expand All @@ -2312,7 +2313,7 @@ CompileExprTree(
break;
case AND:
case OR:
newJump = TclStackAlloc(interp, sizeof(JumpList));
newJump = (JumpList *)TclStackAlloc(interp, sizeof(JumpList));
newJump->next = jumpPtr;
jumpPtr = newJump;
TclEmitForwardJump(envPtr, (nodePtr->lexeme == AND)
Expand Down Expand Up @@ -2543,7 +2544,7 @@ TclSingleOpCmd(
int objc,
Tcl_Obj *const objv[])
{
TclOpCmdClientData *occdPtr = clientData;
TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData;
unsigned char lexeme;
OpNode nodes[2];
Tcl_Obj *const *litObjv = objv + 1;
Expand Down Expand Up @@ -2601,10 +2602,10 @@ TclSortingOpCmd(
if (objc < 3) {
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(1));
} else {
TclOpCmdClientData *occdPtr = clientData;
Tcl_Obj **litObjv = TclStackAlloc(interp,
TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData;
Tcl_Obj **litObjv = (Tcl_Obj **)TclStackAlloc(interp,
2 * (objc-2) * sizeof(Tcl_Obj *));
OpNode *nodes = TclStackAlloc(interp, 2 * (objc-2) * sizeof(OpNode));
OpNode *nodes = (OpNode *)TclStackAlloc(interp, 2 * (objc-2) * sizeof(OpNode));
unsigned char lexeme;
int i, lastAnd = 1;
Tcl_Obj *const *litObjPtrPtr = litObjv;
Expand Down Expand Up @@ -2676,7 +2677,7 @@ TclVariadicOpCmd(
int objc,
Tcl_Obj *const objv[])
{
TclOpCmdClientData *occdPtr = clientData;
TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData;
unsigned char lexeme;
int code;

Expand Down Expand Up @@ -2731,7 +2732,7 @@ TclVariadicOpCmd(
return code;
} else {
Tcl_Obj *const *litObjv = objv + 1;
OpNode *nodes = TclStackAlloc(interp, (objc-1) * sizeof(OpNode));
OpNode *nodes = (OpNode *)TclStackAlloc(interp, (objc-1) * sizeof(OpNode));
int i, lastOp = OT_LITERAL;

nodes[0].lexeme = START;
Expand Down Expand Up @@ -2795,7 +2796,7 @@ TclNoIdentOpCmd(
int objc,
Tcl_Obj *const objv[])
{
TclOpCmdClientData *occdPtr = clientData;
TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData;

if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, occdPtr->expected);
Expand Down
Loading

0 comments on commit 715e8c3

Please sign in to comment.