Skip to content

Commit

Permalink
Never use TCL_SIZE_MODIFIER "u", because Tcl_Size can be negative
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Dec 26, 2023
2 parents 1c2e801 + e32ce30 commit 8ccfc03
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions generic/tkCanvArc.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ ArcCoords(
return TCL_ERROR;
} else if (objc != 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 4, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 4, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC",
NULL);
return TCL_ERROR;
Expand Down Expand Up @@ -404,7 +404,7 @@ ArcCoords(
ComputeArcBbox(canvas, arcPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 4, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 0 or 4, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", NULL);
return TCL_ERROR;
}
Expand Down
4 changes: 2 additions & 2 deletions generic/tkCanvBmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ BitmapCoords(
return TCL_ERROR;
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP",
NULL);
return TCL_ERROR;
Expand All @@ -278,7 +278,7 @@ BitmapCoords(
ComputeBitmapBbox(canvas, bmapPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP", NULL);
return TCL_ERROR;
}
Expand Down
4 changes: 2 additions & 2 deletions generic/tkCanvImg.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ ImageCoords(
return TCL_ERROR;
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE",
NULL);
return TCL_ERROR;
Expand All @@ -262,7 +262,7 @@ ImageCoords(
ComputeImageBbox(canvas, imgPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE", NULL);
return TCL_ERROR;
}
Expand Down
4 changes: 2 additions & 2 deletions generic/tkCanvLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,13 @@ LineCoords(
}
if (objc & 1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected an even number, got %" TCL_SIZE_MODIFIER "u",
"wrong # coordinates: expected an even number, got %" TCL_SIZE_MODIFIER "d",
objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL);
return TCL_ERROR;
} else if (objc < 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected at least 4, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected at least 4, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL);
return TCL_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion generic/tkCanvPoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ PolygonCoords(
}
if (objc & 1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected an even number, got %" TCL_SIZE_MODIFIER "u",
"wrong # coordinates: expected an even number, got %" TCL_SIZE_MODIFIER "d",
objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "POLYGON", NULL);
return TCL_ERROR;
Expand Down
4 changes: 2 additions & 2 deletions generic/tkCanvText.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ TextCoords(
return TCL_OK;
} else if (objc > 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", NULL);
return TCL_ERROR;
}
Expand All @@ -438,7 +438,7 @@ TextCoords(
return TCL_ERROR;
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", NULL);
return TCL_ERROR;
}
Expand Down
4 changes: 2 additions & 2 deletions generic/tkCanvWind.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ WinItemCoords(
return TCL_ERROR;
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW",
NULL);
return TCL_ERROR;
Expand All @@ -275,7 +275,7 @@ WinItemCoords(
ComputeWindowBbox(canvas, winItemPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW", NULL);
return TCL_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion generic/tkImgListFormat.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ StringMatchDef(
colCount = curColCount;
} else if (curColCount != colCount) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid row # %" TCL_SIZE_MODIFIER "u: "
Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid row # %" TCL_SIZE_MODIFIER "d: "
"all rows must have the same number of elements", y));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
"INVALID_DATA", NULL);
Expand Down
2 changes: 1 addition & 1 deletion generic/tkRectOval.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ RectOvalCoords(

if (objc != 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 4, got %" TCL_SIZE_MODIFIER "u", objc));
"wrong # coordinates: expected 0 or 4, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS",
(rectOvalPtr->header.typePtr == &tkRectangleType
? "RECTANGLE" : "OVAL"), NULL);
Expand Down
2 changes: 1 addition & 1 deletion generic/tkSelect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ HandleTclCommand(
* the offset and maximum # of bytes.
*/

command = Tcl_ObjPrintf("%s %" TCL_SIZE_MODIFIER "u %" TCL_SIZE_MODIFIER "u",
command = Tcl_ObjPrintf("%s %" TCL_SIZE_MODIFIER "d %" TCL_SIZE_MODIFIER "d",
cmdInfoPtr->command, charOffset, maxBytes);
Tcl_IncrRefCount(command);

Expand Down
2 changes: 1 addition & 1 deletion generic/tkText.c
Original file line number Diff line number Diff line change
Expand Up @@ -2841,7 +2841,7 @@ TextPushUndoAction(
Tcl_NewStringObj("set", 3));
markSetRUndoMarkCmdObj = Tcl_DuplicateObj(markSetLUndoMarkCmdObj);
textPtr->sharedTextPtr->undoMarkId++;
snprintf(stringUndoMarkId, TCL_INTEGER_SPACE, "%" TCL_SIZE_MODIFIER "u", textPtr->sharedTextPtr->undoMarkId);
snprintf(stringUndoMarkId, TCL_INTEGER_SPACE, "%" TCL_SIZE_MODIFIER "d", textPtr->sharedTextPtr->undoMarkId);
strcat(lMarkName, stringUndoMarkId);
strcat(rMarkName, stringUndoMarkId);
Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
Expand Down
4 changes: 2 additions & 2 deletions generic/ttk/ttkEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ ExpandPercents(
string = numStorage;
break;
case 'i': /* index of insert/delete */
snprintf(numStorage, sizeof(numStorage), "%d", (int)index);
snprintf(numStorage, sizeof(numStorage), "%" TCL_SIZE_MODIFIER "d", index);
string = numStorage;
break;
case 'P': /* 'Peeked' new value of the string */
Expand Down Expand Up @@ -587,7 +587,7 @@ static int EntryNeedsValidation(VMODE vmode, VREASON reason)
* Returns:
* TCL_OK if the change is accepted
* TCL_BREAK if the change is rejected
* TCL_ERROR if any errors occurred
* TCL_ERROR if any errors occurred
*
* The change will be rejected if -validatecommand returns 0,
* or if -validatecommand or -invalidcommand modifies the value.
Expand Down
6 changes: 3 additions & 3 deletions generic/ttk/ttkTreeview.c
Original file line number Diff line number Diff line change
Expand Up @@ -2775,7 +2775,7 @@ static int TreeviewHorribleIdentify(
if (dColumnNumber < 0) {
goto done;
}
snprintf(dcolbuf, sizeof(dcolbuf), "#%" TCL_SIZE_MODIFIER "u", dColumnNumber);
snprintf(dcolbuf, sizeof(dcolbuf), "#%" TCL_SIZE_MODIFIER "d", dColumnNumber);

if (Ttk_BoxContains(tv->tree.headingArea,x,y)) {
if (-HALO <= x1 - x && x1 - x <= HALO) {
Expand Down Expand Up @@ -2882,15 +2882,15 @@ static int TreeviewIdentifyCommand(

case I_COLUMN :
if (colno >= 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%" TCL_SIZE_MODIFIER "u", colno));
Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%" TCL_SIZE_MODIFIER "d", colno));
}
break;

case I_CELL :
if (item && colno >= 0) {
Tcl_Obj *elem[2];
elem[0] = ItemID(tv, item);
elem[1] = Tcl_ObjPrintf("#%" TCL_SIZE_MODIFIER "u", colno);
elem[1] = Tcl_ObjPrintf("#%" TCL_SIZE_MODIFIER "d", colno);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, elem));
}
break;
Expand Down

0 comments on commit 8ccfc03

Please sign in to comment.