diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-25 15:08:53 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-25 15:08:53 (GMT) |
commit | 8e4c7b8f2f43e49559dba9709768e1c737e6b3b1 (patch) | |
tree | 9e4d8b272990338f713721e12686c38f1fb34ee6 | |
parent | b3af1ba9a9e88b812152b32edbb39e4ea9d73b06 (diff) | |
parent | b24734f447464d9b41cb0aaaf478615872427a8e (diff) | |
download | tk-8e4c7b8f2f43e49559dba9709768e1c737e6b3b1.zip tk-8e4c7b8f2f43e49559dba9709768e1c737e6b3b1.tar.gz tk-8e4c7b8f2f43e49559dba9709768e1c737e6b3b1.tar.bz2 |
Formatting and even more size_t usage.
31 files changed, 134 insertions, 116 deletions
diff --git a/generic/tk.h b/generic/tk.h index 1fd72fa..c6c682f 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -983,8 +983,12 @@ typedef struct Tk_SmoothMethod { #define TK_TAG_SPACE 3 typedef struct Tk_Item { - int id; /* Unique identifier for this item (also +#if TCL_MAJOR_VERSION > 8 + size_t id; /* Unique identifier for this item (also * serves as first tag for item). */ +#else + int id; +#endif struct Tk_Item *nextPtr; /* Next in display list of all items in this * canvas. Later items in list are drawn on * top of earlier ones. */ @@ -993,10 +997,14 @@ typedef struct Tk_Item { Tk_Uid *tagPtr; /* Pointer to array of tags. Usually points to * staticTagSpace, but may point to malloc-ed * space if there are lots of tags. */ - int tagSpace; /* Total amount of tag space available at +#if TCL_MAJOR_VERSION > 8 + size_t tagSpace; /* Total amount of tag space available at * tagPtr. */ - int numTags; /* Number of tag slots actually used at + size_t numTags; /* Number of tag slots actually used at * *tagPtr. */ +#else + int tagSpace, numTags; +#endif struct Tk_ItemType *typePtr;/* Table of procedures that implement this * type of item. */ int x1, y1, x2, y2; /* Bounding box for item, in integer canvas @@ -1080,12 +1088,14 @@ typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr); #endif /* USE_OLD_CANVAS */ -typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - int index); #if TCL_MAJOR_VERSION > 8 +typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr, + size_t index); typedef size_t (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr, size_t offset, char *buffer, size_t maxBytes); #else +typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr, + int index); typedef int (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr, int offset, char *buffer, int maxBytes); #endif @@ -1191,17 +1201,25 @@ typedef struct Tk_CanvasTextInfo { Tk_Item *selItemPtr; /* Pointer to selected item. NULL means * selection isn't in this canvas. Writable by * items. */ - int selectFirst; /* Character index of first selected +#if TCL__MAJOR_VERSION > 8 + size_t selectFirst; /* Character index of first selected * character. Writable by items. */ - int selectLast; /* Character index of last selected character. + size_t selectLast; /* Character index of last selected character. * Writable by items. */ +#else + int selectFirst, selectLast; +#endif Tk_Item *anchorItemPtr; /* Item corresponding to "selectAnchor": not * necessarily selItemPtr. Read-only to * items. */ - int selectAnchor; /* Character index of fixed end of selection +#if TCL__MAJOR_VERSION > 8 + size_t selectAnchor; /* Character index of fixed end of selection * (i.e. "select to" operation will use this * as one end of the selection). Writable by * items. */ +#else + int selectAnchor; +#endif Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion * cursor. Read-only to items. */ int insertWidth; /* Total width of insertion cursor. Read-only diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index 1f78c7c..c711f1d 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -2202,7 +2202,7 @@ StyleParseProc( Tk_Window tkwin, /* Window containing canvas widget. */ const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ - TkSizeT offset) /* Offset into item. */ + TkSizeT offset) /* Offset into item. */ { int c; size_t length; @@ -2265,7 +2265,7 @@ StylePrintProc( ClientData dummy, /* Ignored. */ Tk_Window tkwin, /* Ignored. */ char *widgRec, /* Pointer to record for item. */ - TkSizeT offset, /* Offset into item. */ + TkSizeT offset, /* Offset into item. */ Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index beb8942..3394e13 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -2046,7 +2046,7 @@ ArrowParseProc( Tk_Window tkwin, /* Window containing canvas widget. */ const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ - TkSizeT offset) /* Offset into item. */ + TkSizeT offset) /* Offset into item. */ { int c; size_t length; @@ -2113,7 +2113,7 @@ ArrowPrintProc( ClientData dummy, /* Ignored. */ Tk_Window tkwin, /* Window containing canvas widget. */ char *widgRec, /* Pointer to record for item. */ - TkSizeT offset, /* Offset into item. */ + TkSizeT offset, /* Offset into item. */ Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 71e67f8..6a36bdf 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -1680,7 +1680,7 @@ GetPolygonIndex( TkSizeT length, idx; PolygonItem *polyPtr = (PolygonItem *) itemPtr; const char *string; - TkSizeT count = 2*(polyPtr->numPoints - polyPtr->autoClosed); + TkSizeT count = 2*(polyPtr->numPoints - polyPtr->autoClosed); if (TCL_OK == TkGetIntForIndex(obj, (INT_MAX - 1) - ((INT_MAX) % count), 1, &idx)) { if (idx == TCL_INDEX_NONE) { diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c index 77cff1f..7b51122 100644 --- a/generic/tkCanvPs.c +++ b/generic/tkCanvPs.c @@ -576,7 +576,7 @@ TkCanvPostscriptCmd( if (result != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (generating Postscript for item %d)", - itemPtr->id)); + (int)itemPtr->id)); goto cleanup; } diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 3c8f364..6210e6a 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -510,14 +510,14 @@ ConfigureText( textPtr->numChars = Tcl_NumUtfChars(textPtr->text, textPtr->numBytes); if (textInfoPtr->selItemPtr == itemPtr) { - if (textInfoPtr->selectFirst >= (int)textPtr->numChars) { + if (textInfoPtr->selectFirst + 1 >= textPtr->numChars + 1) { textInfoPtr->selItemPtr = NULL; } else { - if (textInfoPtr->selectLast >= (int)textPtr->numChars) { + if (textInfoPtr->selectLast + 1 >= textPtr->numChars + 1) { textInfoPtr->selectLast = textPtr->numChars - 1; } if ((textInfoPtr->anchorItemPtr == itemPtr) - && (textInfoPtr->selectAnchor >= (int)textPtr->numChars)) { + && (textInfoPtr->selectAnchor + 1 >= textPtr->numChars + 1)) { textInfoPtr->selectAnchor = textPtr->numChars - 1; } } @@ -1053,14 +1053,14 @@ TextInsert( */ if (textInfoPtr->selItemPtr == itemPtr) { - if (textInfoPtr->selectFirst >= index) { + if (textInfoPtr->selectFirst + 1 >= (TkSizeT)index + 1) { textInfoPtr->selectFirst += charsAdded; } - if (textInfoPtr->selectLast >= index) { + if (textInfoPtr->selectLast + 1 >= (TkSizeT)index + 1) { textInfoPtr->selectLast += charsAdded; } if ((textInfoPtr->anchorItemPtr == itemPtr) - && (textInfoPtr->selectAnchor >= index)) { + && (textInfoPtr->selectAnchor + 1 >= (TkSizeT)index + 1)) { textInfoPtr->selectAnchor += charsAdded; } } @@ -1132,32 +1132,32 @@ TextDeleteChars( */ if (textInfoPtr->selItemPtr == itemPtr) { - if (textInfoPtr->selectFirst > first) { + if (textInfoPtr->selectFirst + 1 > (TkSizeT)first + 1) { textInfoPtr->selectFirst -= charsRemoved; - if (textInfoPtr->selectFirst < first) { + if (textInfoPtr->selectFirst + 1 < (TkSizeT)first + 1) { textInfoPtr->selectFirst = first; } } - if (textInfoPtr->selectLast >= first) { + if (textInfoPtr->selectLast + 1 >= (TkSizeT)first + 1) { textInfoPtr->selectLast -= charsRemoved; - if (textInfoPtr->selectLast < first - 1) { + if (textInfoPtr->selectLast + 1 < (TkSizeT)first) { textInfoPtr->selectLast = first - 1; } } - if (textInfoPtr->selectFirst > textInfoPtr->selectLast) { + if (textInfoPtr->selectFirst + 1 > textInfoPtr->selectLast + 1) { textInfoPtr->selItemPtr = NULL; } if ((textInfoPtr->anchorItemPtr == itemPtr) - && (textInfoPtr->selectAnchor > first)) { + && (textInfoPtr->selectAnchor + 1 > (TkSizeT)first + 1)) { textInfoPtr->selectAnchor -= charsRemoved; - if (textInfoPtr->selectAnchor < first) { + if (textInfoPtr->selectAnchor + 1 < (TkSizeT)first + 1) { textInfoPtr->selectAnchor = first; } } } - if ((int)textPtr->insertPos > first) { + if (textPtr->insertPos + 1 > (TkSizeT)first + 1) { textPtr->insertPos -= charsRemoved; - if ((int)textPtr->insertPos < first) { + if (textPtr->insertPos + 1 < (TkSizeT)first + 1) { textPtr->insertPos = first; } } @@ -1520,10 +1520,10 @@ static TkSizeT GetSelText( Tk_Canvas canvas, /* Canvas containing selection. */ Tk_Item *itemPtr, /* Text item containing selection. */ - TkSizeT offset, /* Byte offset within selection of first + TkSizeT offset, /* Byte offset within selection of first * character to be returned. */ char *buffer, /* Location in which to place selection. */ - TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, + TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ { @@ -1534,8 +1534,8 @@ GetSelText( Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; (void)canvas; - if ((textInfoPtr->selectFirst == -1) || - (textInfoPtr->selectFirst > textInfoPtr->selectLast)) { + if ((textInfoPtr->selectFirst == TCL_INDEX_NONE) || + (textInfoPtr->selectFirst + 1 > textInfoPtr->selectLast + 1)) { return 0; } text = textPtr->text; diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index eee1ad2..a1fe265 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -430,9 +430,9 @@ TkCanvasTagsParseProc( * Make sure that there's enough space in the item to hold the tag names. */ - if (itemPtr->tagSpace < argc) { + if ((int)itemPtr->tagSpace < argc) { newPtr = (Tk_Uid *)ckalloc(argc * sizeof(Tk_Uid)); - for (i = itemPtr->numTags-1; i >= 0; i--) { + for (i = (int)itemPtr->numTags - 1; i >= 0; i--) { newPtr[i] = itemPtr->tagPtr[i]; } if (itemPtr->tagPtr != itemPtr->staticTagSpace) { @@ -558,7 +558,7 @@ TkCanvasDashPrintProc( ClientData dummy, /* Ignored. */ Tk_Window tkwin, /* Window containing canvas widget. */ char *widgRec, /* Pointer to record for item. */ - TkSizeT offset, /* Offset in record for item. */ + TkSizeT offset, /* Offset in record for item. */ Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ @@ -747,7 +747,7 @@ TkSmoothParseProc( Tk_Window tkwin, /* Window containing canvas widget. */ const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ - TkSizeT offset) /* Offset into item. */ + TkSizeT offset) /* Offset into item. */ { const Tk_SmoothMethod **smoothPtr = (const Tk_SmoothMethod **) (widgRec + offset); diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 54087e6..288949d 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -52,7 +52,7 @@ typedef struct TagSearch { int searchOver; /* Non-zero means NextItem should always * return NULL. */ int type; /* Search type (see #defs below) */ - int id; /* Item id for searches by id */ + TkSizeT id; /* Item id for searches by id */ const char *string; /* Tag expression string */ int stringIndex; /* Current position in string scan */ int stringLength; /* Length of tag expression string */ @@ -732,8 +732,8 @@ Tk_CanvasObjCmd( canvasPtr->textInfo.selBorderWidth = 0; canvasPtr->textInfo.selFgColorPtr = NULL; canvasPtr->textInfo.selItemPtr = NULL; - canvasPtr->textInfo.selectFirst = -1; - canvasPtr->textInfo.selectLast = -1; + canvasPtr->textInfo.selectFirst = TCL_INDEX_NONE; + canvasPtr->textInfo.selectLast = TCL_INDEX_NONE; canvasPtr->textInfo.anchorItemPtr = NULL; canvasPtr->textInfo.selectAnchor = 0; canvasPtr->textInfo.insertBorder = NULL; @@ -1306,8 +1306,7 @@ CanvasWidgetCmd( typePtr = matchPtr; itemPtr = (Tk_Item *)ckalloc(typePtr->itemSize); - itemPtr->id = canvasPtr->nextId; - canvasPtr->nextId++; + itemPtr->id = canvasPtr->nextId++; itemPtr->tagPtr = itemPtr->staticTagSpace; itemPtr->tagSpace = TK_TAG_SPACE; itemPtr->numTags = 0; @@ -1457,7 +1456,7 @@ CanvasWidgetCmd( tag = Tk_GetUid(Tcl_GetString(objv[2])); } FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) { - for (i = itemPtr->numTags-1; i >= 0; i--) { + for (i = (int)itemPtr->numTags-1; i >= 0; i--) { if (itemPtr->tagPtr[i] == tag) { /* @@ -1531,7 +1530,7 @@ CanvasWidgetCmd( int i; Tcl_Obj *resultObj = Tcl_NewObj(); - for (i = 0; i < itemPtr->numTags; i++) { + for (i = 0; i < (int)itemPtr->numTags; i++) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(itemPtr->tagPtr[i], -1)); } @@ -2012,8 +2011,8 @@ CanvasWidgetCmd( goto done; } if (canvasPtr->textInfo.selItemPtr == itemPtr) { - if (index < (canvasPtr->textInfo.selectFirst - + canvasPtr->textInfo.selectLast)/2) { + if (index < (int)((canvasPtr->textInfo.selectFirst + + canvasPtr->textInfo.selectLast)/2)) { canvasPtr->textInfo.selectAnchor = canvasPtr->textInfo.selectLast + 1; } else { @@ -4223,7 +4222,7 @@ TagSearchEvalExpr( * set result 1 if tag is found in item's tags */ - for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags; + for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags; count > 0; tagPtr++, count--) { if (*tagPtr == uid) { result = 1; @@ -4243,7 +4242,7 @@ TagSearchEvalExpr( * set result 1 if tag is found in item's tags. */ - for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags; + for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags; count > 0; tagPtr++, count--) { if (*tagPtr == uid) { result = 1; @@ -4409,7 +4408,7 @@ TagSearchFirst( uid = searchPtr->expr->uid; for (lastPtr = NULL, itemPtr = searchPtr->canvasPtr->firstItemPtr; itemPtr != NULL; lastPtr=itemPtr, itemPtr=itemPtr->nextPtr) { - for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags; + for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags; count > 0; tagPtr++, count--) { if (*tagPtr == uid) { searchPtr->lastPtr = lastPtr; @@ -4511,7 +4510,7 @@ TagSearchNext( uid = searchPtr->expr->uid; for (; itemPtr != NULL; lastPtr = itemPtr, itemPtr = itemPtr->nextPtr) { - for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags; + for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags; count > 0; tagPtr++, count--) { if (*tagPtr == uid) { searchPtr->lastPtr = lastPtr; @@ -4581,7 +4580,7 @@ DoItem( return; } - for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags; + for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags; count > 0; tagPtr++, count--) { if (tag == *tagPtr) { return; @@ -5301,7 +5300,7 @@ PickCurrentItem( */ if ((itemPtr == canvasPtr->currentItemPtr) && !buttonDown) { - for (i = itemPtr->numTags-1; i >= 0; i--) { + for (i = (int)itemPtr->numTags-1; i >= 0; i--) { if (itemPtr->tagPtr[i] == searchUids->currentUid) /* then */ { memmove((void *)(itemPtr->tagPtr + i), @@ -5489,10 +5488,10 @@ CanvasDoEvent( objectPtr = (void **)ckalloc(numObjects * sizeof(void *)); } objectPtr[0] = (char *)searchUids->allUid; - for (i = itemPtr->numTags-1; i >= 0; i--) { + for (i = (int)itemPtr->numTags - 1; i >= 0; i--) { objectPtr[i+1] = (char *)itemPtr->tagPtr[i]; } - objectPtr[itemPtr->numTags+1] = itemPtr; + objectPtr[itemPtr->numTags + 1] = itemPtr; /* * Copy uids of matching expressions into object array @@ -5654,15 +5653,15 @@ CanvasSelectTo( canvasPtr->textInfo.anchorItemPtr = itemPtr; canvasPtr->textInfo.selectAnchor = index; } - if (canvasPtr->textInfo.selectAnchor <= index) { + if (canvasPtr->textInfo.selectAnchor + 1 <= (TkSizeT)index + 1) { canvasPtr->textInfo.selectFirst = canvasPtr->textInfo.selectAnchor; canvasPtr->textInfo.selectLast = index; } else { canvasPtr->textInfo.selectFirst = index; canvasPtr->textInfo.selectLast = canvasPtr->textInfo.selectAnchor - 1; } - if ((canvasPtr->textInfo.selectFirst != oldFirst) - || (canvasPtr->textInfo.selectLast != oldLast) + if ((canvasPtr->textInfo.selectFirst != (TkSizeT)oldFirst) + || (canvasPtr->textInfo.selectLast != (TkSizeT)oldLast) || (itemPtr != oldSelPtr)) { EventuallyRedrawItem(canvasPtr, itemPtr); } @@ -5692,10 +5691,10 @@ CanvasSelectTo( static TkSizeT CanvasFetchSelection( ClientData clientData, /* Information about canvas widget. */ - TkSizeT offset, /* Offset within selection of first character + TkSizeT offset, /* Offset within selection of first character * to be returned. */ char *buffer, /* Location in which to place selection. */ - TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, + TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ { diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index fc0ac7a..f1adbc4 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -214,7 +214,7 @@ typedef struct TkCanvas { * when converting coordinates. */ int flags; /* Various flags; see below for * definitions. */ - int nextId; /* Number to use as id for next item created + TkSizeT nextId; /* Number to use as id for next item created * in widget. */ Tk_PostscriptInfo psInfo; /* Pointer to information used for generating * Postscript for the canvas. NULL means no diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c index 308be14..8a7ffee 100644 --- a/generic/tkClipboard.c +++ b/generic/tkClipboard.c @@ -129,10 +129,10 @@ ClipboardHandler( static TkSizeT ClipboardAppHandler( ClientData clientData, /* Pointer to TkDisplay structure. */ - TkSizeT offset, /* Return selection bytes starting at this + TkSizeT offset, /* Return selection bytes starting at this * offset. */ char *buffer, /* Place to store converted selection. */ - TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */ + TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */ { TkDisplay *dispPtr = (TkDisplay *)clientData; TkSizeT length; @@ -174,10 +174,10 @@ ClipboardAppHandler( static TkSizeT ClipboardWindowHandler( ClientData dummy, /* Not used. */ - TkSizeT offset, /* Return selection bytes starting at this + TkSizeT offset, /* Return selection bytes starting at this * offset. */ char *buffer, /* Place to store converted selection. */ - TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */ + TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */ { (void)dummy; (void)offset; diff --git a/generic/tkEntry.c b/generic/tkEntry.c index e331dcb..6729ae5 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -2888,10 +2888,10 @@ EntrySelectTo( static TkSizeT EntryFetchSelection( ClientData clientData, /* Information about entry widget. */ - TkSizeT offset, /* Byte offset within selection of first + TkSizeT offset, /* Byte offset within selection of first * character to be returned. */ char *buffer, /* Location in which to place selection. */ - TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, + TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, * not including terminating NUL character. */ { Entry *entryPtr = (Entry *)clientData; diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 4ac3bab..b5e4d3c 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -538,7 +538,7 @@ declare 162 { int byteIndex, struct TkTextIndex *indexPtr) } declare 163 { - int TkTextPrintIndex(const struct TkText *textPtr, + TkSizeT TkTextPrintIndex(const struct TkText *textPtr, const struct TkTextIndex *indexPtr, char *string) } declare 164 { diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index f241b75..619e3cf 100755..100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -461,7 +461,7 @@ EXTERN struct TkTextIndex * TkTextMakeByteIndex(TkTextBTree tree, const struct TkText *textPtr, int lineIndex, int byteIndex, struct TkTextIndex *indexPtr); /* 163 */ -EXTERN int TkTextPrintIndex(const struct TkText *textPtr, +EXTERN TkSizeT TkTextPrintIndex(const struct TkText *textPtr, const struct TkTextIndex *indexPtr, char *string); /* 164 */ @@ -757,7 +757,7 @@ typedef struct TkIntStubs { int (*tkTextIndexBackBytes) (const struct TkText *textPtr, const struct TkTextIndex *srcPtr, int count, struct TkTextIndex *dstPtr); /* 160 */ int (*tkTextIndexForwBytes) (const struct TkText *textPtr, const struct TkTextIndex *srcPtr, int count, struct TkTextIndex *dstPtr); /* 161 */ struct TkTextIndex * (*tkTextMakeByteIndex) (TkTextBTree tree, const struct TkText *textPtr, int lineIndex, int byteIndex, struct TkTextIndex *indexPtr); /* 162 */ - int (*tkTextPrintIndex) (const struct TkText *textPtr, const struct TkTextIndex *indexPtr, char *string); /* 163 */ + TkSizeT (*tkTextPrintIndex) (const struct TkText *textPtr, const struct TkTextIndex *indexPtr, char *string); /* 163 */ struct TkTextSegment * (*tkTextSetMark) (struct TkText *textPtr, const char *name, struct TkTextIndex *indexPtr); /* 164 */ int (*tkTextXviewCmd) (struct TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 165 */ void (*tkTextChanged) (struct TkSharedText *sharedTextPtr, struct TkText *textPtr, const struct TkTextIndex *index1Ptr, const struct TkTextIndex *index2Ptr); /* 166 */ diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 6ea80ff..d190adc 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -3115,10 +3115,10 @@ ListboxSelect( static TkSizeT ListboxFetchSelection( ClientData clientData, /* Information about listbox widget. */ - TkSizeT offset, /* Offset within selection of first byte to be + TkSizeT offset, /* Offset within selection of first byte to be * returned. */ char *buffer, /* Location in which to place selection. */ - TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, + TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ { diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 5972f69..f25726e 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -3035,7 +3035,7 @@ ObjectIsEmpty( static void * ComputeSlotAddress( void *recordPtr, /* Pointer to the start of a record. */ - TkSizeT offset) /* Offset of a slot within that record; may be TCL_INDEX_NONE. */ + TkSizeT offset) /* Offset of a slot within that record; may be TCL_INDEX_NONE. */ { if (offset != TCL_INDEX_NONE) { return (char *)recordPtr + offset; diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 3ad2820..58c54f5 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -1322,10 +1322,10 @@ SelGetProc( static TkSizeT HandleTclCommand( ClientData clientData, /* Information about command to execute. */ - TkSizeT offset, /* Return selection bytes starting at this + TkSizeT offset, /* Return selection bytes starting at this * offset. */ char *buffer, /* Place to store converted selection. */ - TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */ + TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */ { CommandInfo *cmdInfoPtr = (CommandInfo *)clientData; int length; diff --git a/generic/tkTest.c b/generic/tkTest.c index 1f76fe2..ae67f11 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -2050,7 +2050,7 @@ CustomOptionSet( Tk_Window tkwin, Tcl_Obj **value, char *recordPtr, - TkSizeT internalOffset, + TkSizeT internalOffset, char *saveInternalPtr, int flags) { @@ -2111,7 +2111,7 @@ CustomOptionGet( ClientData dummy, Tk_Window tkwin, char *recordPtr, - TkSizeT internalOffset) + TkSizeT internalOffset) { (void)dummy; (void)tkwin; diff --git a/generic/tkText.c b/generic/tkText.c index 36b5ae2..0c4d74c 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -3416,10 +3416,10 @@ DeleteIndexRange( static TkSizeT TextFetchSelection( ClientData clientData, /* Information about text widget. */ - TkSizeT offset, /* Offset within selection of first character + TkSizeT offset, /* Offset within selection of first character * to be returned. */ char *buffer, /* Location in which to place selection. */ - TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, + TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ { diff --git a/generic/tkText.h b/generic/tkText.h index 52abc8c..75cab59 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -857,7 +857,7 @@ typedef void Tk_SegLineChangeProc(struct TkTextSegment *segPtr, typedef int Tk_SegLayoutProc(struct TkText *textPtr, struct TkTextIndex *indexPtr, TkTextSegment *segPtr, TkSizeT offset, int maxX, - TkSizeT maxChars, int noCharsYet, TkWrapMode wrapMode, + TkSizeT maxChars, int noCharsYet, TkWrapMode wrapMode, struct TkTextDispChunk *chunkPtr); typedef void Tk_SegCheckProc(TkTextSegment *segPtr, TkTextLine *linePtr); diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 5ce7a99..f471044 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -2750,7 +2750,7 @@ TkBTreeStartSearchBack( /* Where to store information about search's * progress. */ { - TkSizeT offset; + TkSizeT offset; TkTextIndex index0; /* Last index of the tag. */ TkTextIndex backOne; /* One character before starting index. */ TkTextSegment *seg0Ptr; /* Last segment of the tag. */ diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6917292..df032a2 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7608,7 +7608,7 @@ TkTextCharLayoutProc( * character to consider. */ int maxX, /* Chunk must not occupy pixels at this * position or higher. */ - TkSizeT maxBytes, /* Chunk must not include more than this many + TkSizeT maxBytes, /* Chunk must not include more than this many * characters. */ int noCharsYet, /* Non-zero means no characters have been * assigned to this display line yet. */ diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index ef79376..9370b92 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -533,11 +533,11 @@ EmbImageLayoutProc( TkText *textPtr, /* Text widget being layed out. */ TkTextIndex *indexPtr, /* Identifies first character in chunk. */ TkTextSegment *eiPtr, /* Segment corresponding to indexPtr. */ - TkSizeT offset, /* Offset within segPtr corresponding to + TkSizeT offset, /* Offset within segPtr corresponding to * indexPtr (always 0). */ int maxX, /* Chunk must not occupy pixels at this * position or higher. */ - TkSizeT maxChars, /* Chunk must not include more than this many + TkSizeT maxChars, /* Chunk must not include more than this many * characters. */ int noCharsYet, /* Non-zero means no characters have been * assigned to this line yet. */ diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 4a80844..87816f4 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -1024,7 +1024,7 @@ GetIndex( *--------------------------------------------------------------------------- */ -int +TkSizeT TkTextPrintIndex( const TkText *textPtr, const TkTextIndex *indexPtr,/* Pointer to index. */ diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c index 8eceda9..fe5a892 100644 --- a/generic/tkTextMark.c +++ b/generic/tkTextMark.c @@ -564,11 +564,11 @@ MarkLayoutProc( TkText *textPtr, /* Text widget being layed out. */ TkTextIndex *indexPtr, /* Identifies first character in chunk. */ TkTextSegment *segPtr, /* Segment corresponding to indexPtr. */ - TkSizeT offset, /* Offset within segPtr corresponding to + TkSizeT offset, /* Offset within segPtr corresponding to * indexPtr (always 0). */ int maxX, /* Chunk must not occupy pixels at this * position or higher. */ - TkSizeT maxChars, /* Chunk must not include more than this many + TkSizeT maxChars, /* Chunk must not include more than this many * characters. */ int noCharsYet, /* Non-zero means no characters have been * assigned to this line yet. */ diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index b046076..5b33a84 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -822,11 +822,11 @@ EmbWinLayoutProc( TkText *textPtr, /* Text widget being layed out. */ TkTextIndex *indexPtr, /* Identifies first character in chunk. */ TkTextSegment *ewPtr, /* Segment corresponding to indexPtr. */ - TkSizeT offset, /* Offset within segPtr corresponding to + TkSizeT offset, /* Offset within segPtr corresponding to * indexPtr (always 0). */ int maxX, /* Chunk must not occupy pixels at this * position or higher. */ - TkSizeT maxChars, /* Chunk must not include more than this many + TkSizeT maxChars, /* Chunk must not include more than this many * characters. */ int noCharsYet, /* Non-zero means no characters have been * assigned to this line yet. */ diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 5a970c0..f7b839a 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -51,7 +51,7 @@ TkStateParseProc( TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */ const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ - TkSizeT offset) /* Offset into item. */ + TkSizeT offset) /* Offset into item. */ { int c; int flags = PTR2INT(clientData); @@ -174,7 +174,7 @@ TkOrientParseProc( TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */ const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ - TkSizeT offset) /* Offset into item. */ + TkSizeT offset) /* Offset into item. */ { int c; size_t length; @@ -412,7 +412,7 @@ TkOffsetPrintProc( TCL_UNUSED(void *), /* not used */ TCL_UNUSED(Tk_Window), /* not used */ char *widgRec, /* Widget structure record */ - TkSizeT offset, /* Offset of tile in record */ + TkSizeT offset, /* Offset of tile in record */ Tcl_FreeProc **freeProcPtr) /* not used */ { Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset); @@ -479,7 +479,7 @@ TkPixelParseProc( Tk_Window tkwin, /* Window on same display as tile */ const char *value, /* Name of image */ char *widgRec, /* Widget structure record */ - TkSizeT offset) /* Offset of tile in record */ + TkSizeT offset) /* Offset of tile in record */ { double *doublePtr = (double *) (widgRec + offset); int result; diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 9e5b63a..2b4cec1 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1088,7 +1088,7 @@ static int EntryPostConfigure(Tcl_Interp *dummy, void *recordPtr, int mask) * Precondition: textLayout and layoutX up-to-date. */ static int -EntryCharPosition(Entry *entryPtr, int index) +EntryCharPosition(Entry *entryPtr, TkSizeT index) { int xPos; Tk_CharBbox(entryPtr->entry.textLayout, index, &xPos, NULL, NULL, NULL); diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c index b1e6cfd..d93bc1a 100644 --- a/generic/ttk/ttkManager.c +++ b/generic/ttk/ttkManager.c @@ -61,7 +61,7 @@ struct TtkManager_ void *managerData; Tk_Window masterWindow; unsigned flags; - int nSlaves; + TkSizeT nSlaves; Ttk_Slave **slaves; }; @@ -142,7 +142,7 @@ static const int ManagerEventMask = StructureNotifyMask; static void ManagerEventHandler(ClientData clientData, XEvent *eventPtr) { Ttk_Manager *mgr = (Ttk_Manager *)clientData; - int i; + TkSizeT i; switch (eventPtr->type) { @@ -248,9 +248,9 @@ void Ttk_DeleteManager(Ttk_Manager *mgr) /* ++ InsertSlave -- * Adds slave to the list of managed windows. */ -static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, int index) +static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, TkSizeT index) { - int endIndex = mgr->nSlaves++; + TkSizeT endIndex = mgr->nSlaves++; mgr->slaves = (Ttk_Slave **)ckrealloc(mgr->slaves, mgr->nSlaves * sizeof(Ttk_Slave *)); while (endIndex > index) { @@ -277,10 +277,10 @@ static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, int index) * [1] It's safe to call Tk_UnmapWindow / Tk_UnmaintainGeometry even if this * routine is called from the slave's DestroyNotify event handler. */ -static void RemoveSlave(Ttk_Manager *mgr, int index) +static void RemoveSlave(Ttk_Manager *mgr, TkSizeT index) { Ttk_Slave *slave = mgr->slaves[index]; - int i; + TkSizeT i; /* Notify manager: */ @@ -427,7 +427,7 @@ Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, TkSizeT slaveIndex) */ TkSizeT Ttk_SlaveIndex(Ttk_Manager *mgr, Tk_Window slaveWindow) { - int index; + TkSizeT index; for (index = 0; index < mgr->nSlaves; ++index) if (mgr->slaves[index]->slaveWindow == slaveWindow) return index; @@ -447,7 +447,7 @@ int Ttk_GetSlaveIndexFromObj( Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, int *indexPtr) { const char *string = Tcl_GetString(objPtr); - int slaveIndex = 0; + TkSizeT slaveIndex = 0; TkSizeT idx; Tk_Window tkwin; @@ -455,7 +455,7 @@ int Ttk_GetSlaveIndexFromObj( */ if (TkGetIntForIndex(objPtr, mgr->nSlaves - 1, 1, &idx) == TCL_OK) { slaveIndex = idx; - if (slaveIndex < 0 || slaveIndex > mgr->nSlaves) { + if (slaveIndex + 1 > mgr->nSlaves + 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Slave index %d out of bounds", slaveIndex)); Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL); @@ -470,7 +470,7 @@ int Ttk_GetSlaveIndexFromObj( if ((*string == '.') && (tkwin = Tk_NameToWindow(interp, string, mgr->masterWindow))) { slaveIndex = Ttk_SlaveIndex(mgr, tkwin); - if (slaveIndex < 0) { + if (slaveIndex == TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s is not managed by %s", string, Tk_PathName(mgr->masterWindow))); diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index ee10a71..17c3662 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -940,7 +940,7 @@ static int NotebookInsertCommand( { Notebook *nb = (Notebook *)recordPtr; int current = nb->notebook.currentIndex; - int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); + TkSizeT nSlaves1 = Ttk_NumberSlaves(nb->notebook.mgr); int srcIndex, destIndex; if (objc < 4) { @@ -964,14 +964,14 @@ static int NotebookInsertCommand( } srcIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow); - if (srcIndex < 0) { /* New slave */ + if (srcIndex == -1) { /* New slave */ return AddTab(interp, nb, destIndex, slaveWindow, objc-4,objv+4); } } else if (Ttk_GetSlaveIndexFromObj( interp, nb->notebook.mgr, objv[3], &srcIndex) != TCL_OK) { return TCL_ERROR; - } else if (srcIndex >= (int)Ttk_NumberSlaves(nb->notebook.mgr)) { + } else if ((TkSizeT)srcIndex + 1 >= Ttk_NumberSlaves(nb->notebook.mgr) + 1) { srcIndex = Ttk_NumberSlaves(nb->notebook.mgr) - 1; } @@ -985,8 +985,8 @@ static int NotebookInsertCommand( return TCL_ERROR; } - if (destIndex >= nSlaves) { - destIndex = nSlaves - 1; + if (destIndex >= (int)nSlaves1) { + destIndex = nSlaves1 - 1; } Ttk_ReorderSlave(nb->notebook.mgr, srcIndex, destIndex); diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index d06c863..2786223 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -647,8 +647,9 @@ static int PanedInsertCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = (Paned *)recordPtr; - int nSlaves = Ttk_NumberSlaves(pw->paned.mgr); - int srcIndex, destIndex; + TkSizeT nSlaves = Ttk_NumberSlaves(pw->paned.mgr); + TkSizeT srcIndex; + int destIndex; Tk_Window slaveWindow; if (objc < 4) { @@ -669,11 +670,11 @@ static int PanedInsertCommand( } srcIndex = Ttk_SlaveIndex(pw->paned.mgr, slaveWindow); - if (srcIndex < 0) { /* New slave: */ + if (srcIndex == TCL_INDEX_NONE) { /* New slave: */ return AddPane(interp, pw, destIndex, slaveWindow, objc-4, objv+4); } /* else -- move existing slave: */ - if (destIndex >= nSlaves) + if ((TkSizeT) destIndex + 1 >= nSlaves + 1) destIndex = nSlaves - 1; Ttk_ReorderSlave(pw->paned.mgr, srcIndex, destIndex); @@ -701,7 +702,7 @@ static int PanedForgetCommand( interp, pw->paned.mgr, objv[2], &paneIndex)) { return TCL_ERROR; - } else if (paneIndex >= (int)Ttk_NumberSlaves(pw->paned.mgr)) { + } else if ((TkSizeT)paneIndex + 1 >= Ttk_NumberSlaves(pw->paned.mgr) + 1) { paneIndex = Ttk_NumberSlaves(pw->paned.mgr) - 1; } Ttk_ForgetSlave(pw->paned.mgr, paneIndex); @@ -783,7 +784,7 @@ static int PanedPaneCommand( interp,pw->paned.mgr,objv[2],&paneIndex)) { return TCL_ERROR; - } else if (paneIndex >= (int)Ttk_NumberSlaves(pw->paned.mgr)) { + } else if ((TkSizeT)paneIndex + 1 >= Ttk_NumberSlaves(pw->paned.mgr) + 1) { paneIndex = Ttk_NumberSlaves(pw->paned.mgr) - 1; } diff --git a/generic/ttk/ttkTagSet.c b/generic/ttk/ttkTagSet.c index 33d06bc..e99c76f 100644 --- a/generic/ttk/ttkTagSet.c +++ b/generic/ttk/ttkTagSet.c @@ -281,7 +281,7 @@ void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record) for (i = 0; tagTable->optionSpecs[i].type != TK_OPTION_END; ++i) { const Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i; - size_t offset = optionSpec->objOffset; + TkSizeT offset = optionSpec->objOffset; int prio = LOWEST_PRIORITY; for (j = 0; j < tagSet->nTags; ++j) { @@ -300,7 +300,7 @@ void Ttk_TagSetApplyStyle( const Tk_OptionSpec *optionSpec = tagTable->optionSpecs; while (optionSpec->type != TK_OPTION_END) { - size_t offset = optionSpec->objOffset; + TkSizeT offset = optionSpec->objOffset; const char *optionName = optionSpec->optionName; Tcl_Obj *val = Ttk_StyleMap(style, optionName, state); if (val) { |