summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-25 12:20:04 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-25 12:20:04 (GMT)
commitb24734f447464d9b41cb0aaaf478615872427a8e (patch)
treea882a27940a7b6b85288d469aac278f99045409d /generic
parentad1ded4a7f409e06bd6e1b33da463e6c7cd844af (diff)
parentb3af1ba9a9e88b812152b32edbb39e4ea9d73b06 (diff)
downloadtk-b24734f447464d9b41cb0aaaf478615872427a8e.zip
tk-b24734f447464d9b41cb0aaaf478615872427a8e.tar.gz
tk-b24734f447464d9b41cb0aaaf478615872427a8e.tar.bz2
Use more size_t type internally, when compiling against Tcl 9.0 headers. No change when using Tcl 8.x.
Add C++ travis build for TCL_UTF_MAX=4 (compat with Tcl 8.7) and TCL_UTF_MAX=6 (compat with Tcl 9.0) making sure that C++'s strict typing stays correct.
Diffstat (limited to 'generic')
-rw-r--r--[-rwxr-xr-x]generic/nanosvg.h0
-rw-r--r--generic/tk.h25
-rw-r--r--generic/tkCanvArc.c10
-rw-r--r--generic/tkCanvBmap.c2
-rw-r--r--generic/tkCanvImg.c2
-rw-r--r--generic/tkCanvLine.c18
-rw-r--r--generic/tkCanvPoly.c2
-rw-r--r--generic/tkCanvText.c56
-rw-r--r--generic/tkCanvUtil.c16
-rw-r--r--generic/tkCanvWind.c2
-rw-r--r--generic/tkCanvas.c10
-rw-r--r--generic/tkClipboard.c50
-rw-r--r--generic/tkEntry.c80
-rw-r--r--generic/tkEntry.h10
-rw-r--r--generic/tkInt.decls24
-rw-r--r--generic/tkInt.h13
-rw-r--r--generic/tkIntDecls.h66
-rw-r--r--generic/tkListbox.c16
-rw-r--r--generic/tkPanedWindow.c14
-rw-r--r--generic/tkRectOval.c2
-rw-r--r--generic/tkSelect.c18
-rw-r--r--generic/tkSelect.h2
-rw-r--r--generic/tkStubInit.c6
-rw-r--r--generic/tkTest.c26
-rw-r--r--generic/tkText.c38
-rw-r--r--generic/tkText.h12
-rw-r--r--generic/tkTextBTree.c22
-rw-r--r--generic/tkTextDisp.c15
-rw-r--r--generic/tkTextImage.c8
-rw-r--r--generic/tkTextIndex.c39
-rw-r--r--generic/tkTextMark.c8
-rw-r--r--generic/tkTextWind.c8
-rw-r--r--generic/tkUtil.c16
-rw-r--r--generic/ttk/ttkEntry.c34
-rw-r--r--generic/ttk/ttkTagSet.c4
35 files changed, 357 insertions, 317 deletions
diff --git a/generic/nanosvg.h b/generic/nanosvg.h
index 7bb13d2..7bb13d2 100755..100644
--- a/generic/nanosvg.h
+++ b/generic/nanosvg.h
diff --git a/generic/tk.h b/generic/tk.h
index 3c75b98..1fd72fa 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -238,11 +238,19 @@ typedef struct Tk_OptionSpec {
* option config code to handle a custom option.
*/
+#if TCL_MAJOR_VERSION > 8
+typedef int (Tk_CustomOptionSetProc) (ClientData clientData,
+ Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec,
+ size_t offset, char *saveInternalPtr, int flags);
+typedef Tcl_Obj *(Tk_CustomOptionGetProc) (ClientData clientData,
+ Tk_Window tkwin, char *widgRec, size_t offset);
+#else
typedef int (Tk_CustomOptionSetProc) (ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec,
int offset, char *saveInternalPtr, int flags);
typedef Tcl_Obj *(Tk_CustomOptionGetProc) (ClientData clientData,
Tk_Window tkwin, char *widgRec, int offset);
+#endif
typedef void (Tk_CustomOptionRestoreProc) (ClientData clientData,
Tk_Window tkwin, char *internalPtr, char *saveInternalPtr);
typedef void (Tk_CustomOptionFreeProc) (ClientData clientData, Tk_Window tkwin,
@@ -346,10 +354,17 @@ typedef struct Tk_SavedOptions {
#ifndef __NO_OLD_CONFIG
+#if TCL_MAJOR_VERSION > 8
+typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, size_t offset);
+typedef const char *(Tk_OptionPrintProc) (ClientData clientData,
+ Tk_Window tkwin, char *widgRec, size_t offset, Tcl_FreeProc **freeProcPtr);
+#else
typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp,
Tk_Window tkwin, const char *value, char *widgRec, int offset);
typedef const char *(Tk_OptionPrintProc) (ClientData clientData,
Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr);
+#endif
typedef struct Tk_CustomOption {
Tk_OptionParseProc *parseProc;
@@ -1067,8 +1082,13 @@ typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
#endif /* USE_OLD_CANVAS */
typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
int index);
+#if TCL_MAJOR_VERSION > 8
+typedef size_t (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ size_t offset, char *buffer, size_t maxBytes);
+#else
typedef int (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
int offset, char *buffer, int maxBytes);
+#endif
#ifdef USE_OLD_CANVAS
typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
int beforeThis, char *string);
@@ -1579,8 +1599,13 @@ typedef int (Tk_GetSelProc) (ClientData clientData, Tcl_Interp *interp,
typedef void (Tk_LostSelProc) (ClientData clientData);
typedef Tk_RestrictAction (Tk_RestrictProc) (ClientData clientData,
XEvent *eventPtr);
+#if TCL_MAJOR_VERSION > 8
+typedef size_t (Tk_SelectionProc) (ClientData clientData, size_t offset,
+ char *buffer, size_t maxBytes);
+#else
typedef int (Tk_SelectionProc) (ClientData clientData, int offset,
char *buffer, int maxBytes);
+#endif
/*
*----------------------------------------------------------------------
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index 6952f4d..1f78c7c 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -88,9 +88,9 @@ typedef struct ArcItem {
static int StyleParseProc(ClientData clientData, Tcl_Interp *interp,
Tk_Window tkwin, const char *value,
- char *widgRec, int offset);
+ char *widgRec, TkSizeT offset);
static const char * StylePrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr);
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr);
static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
@@ -99,7 +99,7 @@ static const Tk_CustomOption styleOption = {
StyleParseProc, StylePrintProc, NULL
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption dashOption = {
TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL
@@ -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. */
- int 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. */
- int 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/tkCanvBmap.c b/generic/tkCanvBmap.c
index 3053469..b2dc012 100644
--- a/generic/tkCanvBmap.c
+++ b/generic/tkCanvBmap.c
@@ -45,7 +45,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_ConfigSpec configSpecs[] = {
diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c
index 34b52ea..53e9c25 100644
--- a/generic/tkCanvImg.c
+++ b/generic/tkCanvImg.c
@@ -47,7 +47,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_ConfigSpec configSpecs[] = {
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index 0737d76..beb8942 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -108,15 +108,15 @@ static int LineToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
static int ArrowParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *recordPtr, int offset);
+ const char *value, char *recordPtr, TkSizeT offset);
static const char * ArrowPrintProc(ClientData clientData,
- Tk_Window tkwin, char *recordPtr, int offset,
+ Tk_Window tkwin, char *recordPtr, TkSizeT offset,
Tcl_FreeProc **freeProcPtr);
static int ParseArrowShape(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *recordPtr, int offset);
+ const char *value, char *recordPtr, TkSizeT offset);
static const char * PrintArrowShape(ClientData clientData,
- Tk_Window tkwin, char *recordPtr, int offset,
+ Tk_Window tkwin, char *recordPtr, TkSizeT offset,
Tcl_FreeProc **freeProcPtr);
static void RotateLine(Tk_Canvas canvas, Tk_Item *itemPtr,
double originX, double originY, double angleRad);
@@ -145,7 +145,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption dashOption = {
TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL
@@ -1937,7 +1937,7 @@ ParseArrowShape(
const char *value, /* Textual specification of arrow shape. */
char *recordPtr, /* Pointer to item record in which to store
* arrow information. */
- int offset) /* Offset of shape information in widget
+ TkSizeT offset) /* Offset of shape information in widget
* record. */
{
LineItem *linePtr = (LineItem *) recordPtr;
@@ -2005,7 +2005,7 @@ PrintArrowShape(
Tk_Window tkwin, /* Window associated with linePtr's widget. */
char *recordPtr, /* Pointer to item record containing current
* shape information. */
- int offset, /* Offset of arrow information in record. */
+ TkSizeT offset, /* Offset of arrow information in record. */
Tcl_FreeProc **freeProcPtr) /* Store address of function to call to free
* string here. */
{
@@ -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. */
- int 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. */
- int 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 c0329d6..71e67f8 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -62,7 +62,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption dashOption = {
TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index ab7b882..3c8f364 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -32,7 +32,7 @@ typedef struct TextItem {
*/
double x, y; /* Positioning point for text. */
- int insertPos; /* Character index of character just before
+ TkSizeT insertPos; /* Character index of character just before
* which the insertion cursor is displayed. */
/*
@@ -62,8 +62,8 @@ typedef struct TextItem {
* configuration settings above.
*/
- int numChars; /* Length of text in characters. */
- int numBytes; /* Length of text in bytes. */
+ TkSizeT numChars; /* Length of text in characters. */
+ TkSizeT numBytes; /* Length of text in bytes. */
Tk_TextLayout textLayout; /* Cached text layout information. */
int actualWidth; /* Width of text as computed. Used to make
* selections of wrapped text display
@@ -87,7 +87,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption offsetOption = {
TkOffsetParseProc, TkOffsetPrintProc, INT2PTR(TK_OFFSET_RELATIVE)
@@ -146,9 +146,9 @@ static void DeleteText(Tk_Canvas canvas,
static void DisplayCanvText(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
-static int GetSelText(Tk_Canvas canvas,
- Tk_Item *itemPtr, int offset, char *buffer,
- int maxBytes);
+static TkSizeT GetSelText(Tk_Canvas canvas,
+ Tk_Item *itemPtr, TkSizeT offset, char *buffer,
+ TkSizeT maxBytes);
static int GetTextIndex(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
Tcl_Obj *obj, int *indexPtr);
@@ -510,19 +510,19 @@ ConfigureText(
textPtr->numChars = Tcl_NumUtfChars(textPtr->text, textPtr->numBytes);
if (textInfoPtr->selItemPtr == itemPtr) {
- if (textInfoPtr->selectFirst >= textPtr->numChars) {
+ if (textInfoPtr->selectFirst >= (int)textPtr->numChars) {
textInfoPtr->selItemPtr = NULL;
} else {
- if (textInfoPtr->selectLast >= textPtr->numChars) {
+ if (textInfoPtr->selectLast >= (int)textPtr->numChars) {
textInfoPtr->selectLast = textPtr->numChars - 1;
}
if ((textInfoPtr->anchorItemPtr == itemPtr)
- && (textInfoPtr->selectAnchor >= textPtr->numChars)) {
+ && (textInfoPtr->selectAnchor >= (int)textPtr->numChars)) {
textInfoPtr->selectAnchor = textPtr->numChars - 1;
}
}
}
- if (textPtr->insertPos >= textPtr->numChars) {
+ if (textPtr->insertPos + 1 >= textPtr->numChars + 1) {
textPtr->insertPos = textPtr->numChars;
}
@@ -846,7 +846,7 @@ DisplayCanvText(
if (textInfoPtr->selItemPtr == itemPtr) {
selFirstChar = textInfoPtr->selectFirst;
selLastChar = textInfoPtr->selectLast;
- if (selLastChar > textPtr->numChars) {
+ if (selLastChar > (int)textPtr->numChars) {
selLastChar = textPtr->numChars - 1;
}
if ((selFirstChar >= 0) && (selFirstChar <= selLastChar)) {
@@ -969,7 +969,7 @@ DisplayCanvText(
TkDrawAngledTextLayout(display, drawable, textPtr->selTextGC,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
selFirstChar, selLastChar + 1);
- if (selLastChar + 1 < textPtr->numChars) {
+ if (selLastChar + 1 < (int)textPtr->numChars) {
TkDrawAngledTextLayout(display, drawable, textPtr->gc,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
selLastChar + 1, textPtr->numChars);
@@ -1027,7 +1027,7 @@ TextInsert(
if (index < 0) {
index = 0;
}
- if (index > textPtr->numChars) {
+ if (index > (int)textPtr->numChars) {
index = textPtr->numChars;
}
byteIndex = Tcl_UtfAtIndex(text, index) - text;
@@ -1064,7 +1064,7 @@ TextInsert(
textInfoPtr->selectAnchor += charsAdded;
}
}
- if (textPtr->insertPos >= index) {
+ if (textPtr->insertPos + 1 >= (TkSizeT)index + 1) {
textPtr->insertPos += charsAdded;
}
ComputeTextBbox(canvas, textPtr);
@@ -1105,7 +1105,7 @@ TextDeleteChars(
if (first < 0) {
first = 0;
}
- if (last >= textPtr->numChars) {
+ if (last >= (int)textPtr->numChars) {
last = textPtr->numChars - 1;
}
if (first > last) {
@@ -1155,9 +1155,9 @@ TextDeleteChars(
}
}
}
- if (textPtr->insertPos > first) {
+ if ((int)textPtr->insertPos > first) {
textPtr->insertPos -= charsRemoved;
- if (textPtr->insertPos < first) {
+ if ((int)textPtr->insertPos < first) {
textPtr->insertPos = first;
}
}
@@ -1393,7 +1393,7 @@ GetTextIndex(
if (TCL_OK == TkGetIntForIndex(obj, textPtr->numChars - 1, 1, &idx)) {
if (idx == TCL_INDEX_NONE) {
idx = 0;
- } else if (idx > (TkSizeT)textPtr->numChars) {
+ } else if (idx > textPtr->numChars) {
idx = textPtr->numChars;
}
*indexPtr = (int)idx;
@@ -1489,7 +1489,7 @@ SetTextCursor(
if (index < 0) {
textPtr->insertPos = 0;
- } else if (index > textPtr->numChars) {
+ } else if (index > (int)textPtr->numChars) {
textPtr->insertPos = textPtr->numChars;
} else {
textPtr->insertPos = index;
@@ -1516,25 +1516,25 @@ SetTextCursor(
*--------------------------------------------------------------
*/
-static int
+static TkSizeT
GetSelText(
Tk_Canvas canvas, /* Canvas containing selection. */
Tk_Item *itemPtr, /* Text item containing selection. */
- int 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. */
- int maxBytes) /* Maximum number of bytes to place at buffer,
+ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- int byteCount;
+ TkSizeT byteCount;
char *text;
const char *selStart, *selEnd;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
(void)canvas;
- if ((textInfoPtr->selectFirst < 0) ||
+ if ((textInfoPtr->selectFirst == -1) ||
(textInfoPtr->selectFirst > textInfoPtr->selectLast)) {
return 0;
}
@@ -1542,13 +1542,13 @@ GetSelText(
selStart = Tcl_UtfAtIndex(text, textInfoPtr->selectFirst);
selEnd = Tcl_UtfAtIndex(selStart,
textInfoPtr->selectLast + 1 - textInfoPtr->selectFirst);
+ if (selEnd <= selStart + offset) {
+ return 0;
+ }
byteCount = selEnd - selStart - offset;
if (byteCount > maxBytes) {
byteCount = maxBytes;
}
- if (byteCount <= 0) {
- return 0;
- }
memcpy(buffer, selStart + offset, byteCount);
buffer[byteCount] = '\0';
return byteCount;
diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c
index 1d6a394..eee1ad2 100644
--- a/generic/tkCanvUtil.c
+++ b/generic/tkCanvUtil.c
@@ -402,13 +402,13 @@ Tk_CanvasGetTextInfo(
*/
int
-Tk_CanvasTagsParseProc(
+TkCanvasTagsParseProc(
ClientData dummy, /* Not used.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option (list of tag names). */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item (ignored). */
+ TkSizeT offset) /* Offset into item (ignored). */
{
Tk_Item *itemPtr = (Tk_Item *) widgRec;
int argc, i;
@@ -472,11 +472,11 @@ Tk_CanvasTagsParseProc(
*/
const char *
-Tk_CanvasTagsPrintProc(
+TkCanvasTagsPrintProc(
ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Ignored. */
+ TkSizeT offset, /* Ignored. */
Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
@@ -523,7 +523,7 @@ TkCanvasDashParseProc(
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ TkSizeT offset) /* Offset into item. */
{
(void)dummy;
(void)tkwin;
@@ -558,7 +558,7 @@ TkCanvasDashPrintProc(
ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int 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. */
- int offset) /* Offset into item. */
+ TkSizeT offset) /* Offset into item. */
{
const Tk_SmoothMethod **smoothPtr =
(const Tk_SmoothMethod **) (widgRec + offset);
@@ -839,7 +839,7 @@ TkSmoothPrintProc(
ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int 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/tkCanvWind.c b/generic/tkCanvWind.c
index 22729d6..8028c14 100644
--- a/generic/tkCanvWind.c
+++ b/generic/tkCanvWind.c
@@ -41,7 +41,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_ConfigSpec configSpecs[] = {
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index d3868d5..54087e6 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -223,8 +223,8 @@ static void CanvasCmdDeletedProc(ClientData clientData);
static void CanvasDoEvent(TkCanvas *canvasPtr, XEvent *eventPtr);
static void CanvasEventProc(ClientData clientData,
XEvent *eventPtr);
-static int CanvasFetchSelection(ClientData clientData, int offset,
- char *buffer, int maxBytes);
+static TkSizeT CanvasFetchSelection(ClientData clientData, TkSizeT offset,
+ char *buffer, TkSizeT maxBytes);
static Tk_Item * CanvasFindClosest(TkCanvas *canvasPtr,
double coords[2]);
static void CanvasFocusProc(TkCanvas *canvasPtr, int gotFocus);
@@ -5689,13 +5689,13 @@ CanvasSelectTo(
*--------------------------------------------------------------
*/
-static int
+static TkSizeT
CanvasFetchSelection(
ClientData clientData, /* Information about canvas widget. */
- int 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. */
- int 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/tkClipboard.c b/generic/tkClipboard.c
index f09958e..308be14 100644
--- a/generic/tkClipboard.c
+++ b/generic/tkClipboard.c
@@ -19,12 +19,12 @@
* Prototypes for functions used only in this file:
*/
-static int ClipboardAppHandler(ClientData clientData,
- int offset, char *buffer, int maxBytes);
-static int ClipboardHandler(ClientData clientData,
- int offset, char *buffer, int maxBytes);
-static int ClipboardWindowHandler(ClientData clientData,
- int offset, char *buffer, int maxBytes);
+static TkSizeT ClipboardAppHandler(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
+static TkSizeT ClipboardHandler(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
+static TkSizeT ClipboardWindowHandler(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
static void ClipboardLostSel(ClientData clientData);
static int ClipboardGetProc(ClientData clientData,
Tcl_Interp *interp, const char *portion);
@@ -48,20 +48,20 @@ static int ClipboardGetProc(ClientData clientData,
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
ClipboardHandler(
ClientData clientData, /* Information about data to fetch. */
- int offset, /* Return selection bytes starting at this
+ TkSizeT offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */
{
TkClipboardTarget *targetPtr = (TkClipboardTarget *)clientData;
TkClipboardBuffer *cbPtr;
char *srcPtr, *destPtr;
- size_t count = 0;
- size_t scanned = 0;
- size_t length, freeCount;
+ TkSizeT count = 0;
+ TkSizeT scanned = 0;
+ TkSizeT length, freeCount;
/*
* Skip to buffer containing offset byte
@@ -71,7 +71,7 @@ ClipboardHandler(
if (cbPtr == NULL) {
return 0;
}
- if (scanned + cbPtr->length > (size_t)offset) {
+ if (scanned + cbPtr->length > offset) {
break;
}
scanned += cbPtr->length;
@@ -102,7 +102,7 @@ ClipboardHandler(
srcPtr = cbPtr->buffer;
length = cbPtr->length;
}
- return (int)count;
+ return count;
}
/*
@@ -126,30 +126,30 @@ ClipboardHandler(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
ClipboardAppHandler(
ClientData clientData, /* Pointer to TkDisplay structure. */
- int offset, /* Return selection bytes starting at this
+ TkSizeT offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */
{
TkDisplay *dispPtr = (TkDisplay *)clientData;
- size_t length;
+ TkSizeT length;
const char *p;
p = dispPtr->clipboardAppPtr->winPtr->nameUid;
length = strlen(p);
- length -= offset;
- if (length <= 0) {
+ if (length <= offset) {
return 0;
}
- if (length > (size_t) maxBytes) {
+ length -= offset;
+ if (length > maxBytes) {
length = maxBytes;
}
memcpy(buffer, p, length);
buffer[length] = 0;
- return (int)length;
+ return length;
}
/*
@@ -171,13 +171,13 @@ ClipboardAppHandler(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
ClipboardWindowHandler(
ClientData dummy, /* Not used. */
- int offset, /* Return selection bytes starting at this
+ TkSizeT offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int 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 bffe8b8..e331dcb 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -412,8 +412,8 @@ static void EntryComputeGeometry(Entry *entryPtr);
static void EntryEventProc(ClientData clientData,
XEvent *eventPtr);
static void EntryFocusProc(Entry *entryPtr, int gotFocus);
-static int EntryFetchSelection(ClientData clientData, int offset,
- char *buffer, int maxBytes);
+static TkSizeT EntryFetchSelection(ClientData clientData, TkSizeT offset,
+ char *buffer, TkSizeT maxBytes);
static void EntryLostSelection(ClientData clientData);
static void EventuallyRedraw(Entry *entryPtr);
static void EntryScanTo(Entry *entryPtr, int y);
@@ -637,7 +637,7 @@ EntryWidgetObjCmd(
&index) != TCL_OK) {
goto error;
}
- if ((index == entryPtr->numChars) && (index > 0)) {
+ if ((index == (int)entryPtr->numChars) && (index > 0)) {
index--;
}
Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height);
@@ -989,7 +989,7 @@ EntryWidgetObjCmd(
break;
}
}
- if (index >= entryPtr->numChars) {
+ if (index >= (int)entryPtr->numChars) {
index = entryPtr->numChars - 1;
}
if (index < 0) {
@@ -1706,8 +1706,8 @@ DisplayEntry(
0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
if (showSelection && (entryPtr->state != STATE_DISABLED)
- && (entryPtr->selectLast > entryPtr->leftIndex)) {
- if (entryPtr->selectFirst <= entryPtr->leftIndex) {
+ && (entryPtr->selectLast > (int)entryPtr->leftIndex)) {
+ if (entryPtr->selectFirst <= (int)entryPtr->leftIndex) {
selStartX = entryPtr->leftX;
} else {
Tk_CharBbox(entryPtr->textLayout, entryPtr->selectFirst,
@@ -1749,7 +1749,7 @@ DisplayEntry(
cursorX -= (entryPtr->insertWidth == 1) ? 1 : (entryPtr->insertWidth)/2;
Tk_SetCaretPos(entryPtr->tkwin, cursorX, baseY - fm.ascent,
fm.ascent + fm.descent);
- if (entryPtr->insertPos >= entryPtr->leftIndex && cursorX < xBound) {
+ if ((entryPtr->insertPos >= (int)entryPtr->leftIndex) && cursorX < xBound) {
if (entryPtr->flags & CURSOR_ON) {
Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->insertBorder,
cursorX, baseY - fm.ascent, entryPtr->insertWidth,
@@ -1783,7 +1783,7 @@ DisplayEntry(
&& (entryPtr->selectFirst < entryPtr->selectLast)) {
int selFirst;
- if (entryPtr->selectFirst < entryPtr->leftIndex) {
+ if (entryPtr->selectFirst < (int)entryPtr->leftIndex) {
selFirst = entryPtr->leftIndex;
} else {
selFirst = entryPtr->selectFirst;
@@ -1982,7 +1982,7 @@ EntryComputeGeometry(
p = (char *)ckalloc(entryPtr->numDisplayBytes + 1);
entryPtr->displayString = p;
- for (i = entryPtr->numChars; --i >= 0; ) {
+ for (i = entryPtr->numChars; i-- > 0; ) {
memcpy(p, buf, size);
p += size;
}
@@ -2083,7 +2083,7 @@ EntryComputeGeometry(
if (rightX < overflow) {
maxOffScreen++;
}
- if (entryPtr->leftIndex > maxOffScreen) {
+ if (entryPtr->leftIndex + 1 > (TkSizeT)maxOffScreen + 1) {
entryPtr->leftIndex = maxOffScreen;
}
Tk_CharBbox(entryPtr->textLayout, entryPtr->leftIndex, &rightX,
@@ -2200,7 +2200,7 @@ InsertChars(
if ((entryPtr->selectAnchor > index) || (entryPtr->selectFirst >= index)) {
entryPtr->selectAnchor += charsAdded;
}
- if (entryPtr->leftIndex > index) {
+ if (entryPtr->leftIndex + 1 > (TkSizeT)index + 1) {
entryPtr->leftIndex += charsAdded;
}
if (entryPtr->insertPos >= index) {
@@ -2237,7 +2237,7 @@ DeleteChars(
const char *string;
char *newStr, *toDelete;
- if ((index + count) > entryPtr->numChars) {
+ if ((index + count) > (int)entryPtr->numChars) {
count = entryPtr->numChars - index;
}
if (count <= 0) {
@@ -2308,8 +2308,8 @@ DeleteChars(
entryPtr->selectAnchor = index;
}
}
- if (entryPtr->leftIndex > index) {
- if (entryPtr->leftIndex >= (index + count)) {
+ if (entryPtr->leftIndex + 1 > (TkSizeT)index + 1) {
+ if (entryPtr->leftIndex + 1 >= (TkSizeT)index + count + 1) {
entryPtr->leftIndex -= count;
} else {
entryPtr->leftIndex = index;
@@ -2482,21 +2482,21 @@ EntrySetValue(
}
if (entryPtr->selectFirst >= 0) {
- if (entryPtr->selectFirst >= entryPtr->numChars) {
+ if (entryPtr->selectFirst >= (int)entryPtr->numChars) {
entryPtr->selectFirst = -1;
entryPtr->selectLast = -1;
- } else if (entryPtr->selectLast > entryPtr->numChars) {
+ } else if (entryPtr->selectLast > (int)entryPtr->numChars) {
entryPtr->selectLast = entryPtr->numChars;
}
}
- if (entryPtr->leftIndex >= entryPtr->numChars) {
- if (entryPtr->numChars > 0) {
+ if (entryPtr->leftIndex + 1 >= entryPtr->numChars + 1) {
+ if (entryPtr->numChars + 1 > 1) {
entryPtr->leftIndex = entryPtr->numChars - 1;
} else {
entryPtr->leftIndex = 0;
}
}
- if (entryPtr->insertPos > entryPtr->numChars) {
+ if (entryPtr->insertPos > (int)entryPtr->numChars) {
entryPtr->insertPos = entryPtr->numChars;
}
@@ -2657,8 +2657,8 @@ GetEntryIndex(
if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->numChars - 1, 1, &idx)) {
if (idx == TCL_INDEX_NONE) {
idx = 0;
- } else if (idx > (TkSizeT)entryPtr->numChars) {
- idx = (TkSizeT)entryPtr->numChars;
+ } else if (idx > entryPtr->numChars) {
+ idx = entryPtr->numChars;
}
*indexPtr = (int)idx;
return TCL_OK;
@@ -2680,7 +2680,7 @@ GetEntryIndex(
*indexPtr = entryPtr->insertPos;
break;
case 's':
- if (entryPtr->selectFirst < 0) {
+ if (entryPtr->selectFirst == -1) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"selection isn't in widget %s",
@@ -2727,7 +2727,7 @@ GetEntryIndex(
* be selected, for example.
*/
- if (roundUp && (*indexPtr < entryPtr->numChars)) {
+ if (roundUp && (*indexPtr < (int)entryPtr->numChars)) {
*indexPtr += 1;
}
break;
@@ -2781,7 +2781,7 @@ EntryScanTo(
newLeftIndex = entryPtr->scanMarkIndex
- (10 * (x - entryPtr->scanMarkX)) / entryPtr->avgWidth;
- if (newLeftIndex >= entryPtr->numChars) {
+ if (newLeftIndex >= (int)entryPtr->numChars) {
newLeftIndex = entryPtr->scanMarkIndex = entryPtr->numChars - 1;
entryPtr->scanMarkX = x;
}
@@ -2790,11 +2790,11 @@ EntryScanTo(
entryPtr->scanMarkX = x;
}
- if (newLeftIndex != entryPtr->leftIndex) {
+ if ((TkSizeT)newLeftIndex != entryPtr->leftIndex) {
entryPtr->leftIndex = newLeftIndex;
entryPtr->flags |= UPDATE_SCROLLBAR;
EntryComputeGeometry(entryPtr);
- if (newLeftIndex != entryPtr->leftIndex) {
+ if ((TkSizeT)newLeftIndex != entryPtr->leftIndex) {
entryPtr->scanMarkIndex = entryPtr->leftIndex;
entryPtr->scanMarkX = x;
}
@@ -2842,8 +2842,8 @@ EntrySelectTo(
* Pick new starting and ending points for the selection.
*/
- if (entryPtr->selectAnchor > entryPtr->numChars) {
- entryPtr->selectAnchor = entryPtr->numChars;
+ if (entryPtr->selectAnchor > (int)entryPtr->numChars) {
+ entryPtr->selectAnchor = (int)entryPtr->numChars;
}
if (entryPtr->selectAnchor <= index) {
newFirst = entryPtr->selectAnchor;
@@ -2885,21 +2885,21 @@ EntrySelectTo(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
EntryFetchSelection(
ClientData clientData, /* Information about entry widget. */
- int 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. */
- int 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;
- int byteCount;
+ TkSizeT byteCount;
const char *string;
const char *selStart, *selEnd;
- if ((entryPtr->selectFirst < 0) || (!entryPtr->exportSelection)
+ if ((entryPtr->selectFirst == -1) || (!entryPtr->exportSelection)
|| Tcl_IsSafe(entryPtr->interp)) {
return -1;
}
@@ -2907,14 +2907,14 @@ EntryFetchSelection(
selStart = Tcl_UtfAtIndex(string, entryPtr->selectFirst);
selEnd = Tcl_UtfAtIndex(selStart,
entryPtr->selectLast - entryPtr->selectFirst);
+ if (selEnd <= selStart + offset) {
+ return 0;
+ }
byteCount = selEnd - selStart - offset;
if (byteCount > maxBytes) {
byteCount = maxBytes;
}
- if (byteCount <= 0) {
- return 0;
- }
- memcpy(buffer, selStart + offset, (size_t) byteCount);
+ memcpy(buffer, selStart + offset, byteCount);
buffer[byteCount] = '\0';
return byteCount;
}
@@ -3035,7 +3035,7 @@ EntryVisibleRange(
charsInWindow = Tk_PointToChar(entryPtr->textLayout,
Tk_Width(entryPtr->tkwin) - entryPtr->inset
- entryPtr->xWidth - entryPtr->layoutX - 1, 0);
- if (charsInWindow < entryPtr->numChars) {
+ if (charsInWindow < (int)entryPtr->numChars) {
charsInWindow++;
}
charsInWindow -= entryPtr->leftIndex;
@@ -3845,7 +3845,7 @@ SpinboxWidgetObjCmd(
&index) != TCL_OK) {
goto error;
}
- if ((index == entryPtr->numChars) && (index > 0)) {
+ if ((index == (int)entryPtr->numChars) && (index > 0)) {
index--;
}
Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height);
@@ -4275,7 +4275,7 @@ SpinboxWidgetObjCmd(
break;
}
}
- if (index >= entryPtr->numChars) {
+ if (index >= (int)entryPtr->numChars) {
index = entryPtr->numChars - 1;
}
if (index < 0) {
diff --git a/generic/tkEntry.h b/generic/tkEntry.h
index c81563c..f251185 100644
--- a/generic/tkEntry.h
+++ b/generic/tkEntry.h
@@ -134,7 +134,7 @@ typedef struct {
Tk_TextLayout placeholderLayout;/* Cached placeholder text layout information. */
char *placeholderString; /* String value of placeholder. */
- int placeholderChars; /* Number of chars in placeholder. */
+ TkSizeT placeholderChars; /* Number of chars in placeholder. */
XColor *placeholderColorPtr;/* Color value of placeholder foreground. */
GC placeholderGC; /* For drawing placeholder text. */
int placeholderX; /* Origin for layout. */
@@ -151,13 +151,13 @@ typedef struct {
* malloced memory with the same character
* length as string but whose characters are
* all equal to showChar. */
- int numBytes; /* Length of string in bytes. */
- int numChars; /* Length of string in characters. Both string
+ TkSizeT numBytes; /* Length of string in bytes. */
+ TkSizeT numChars; /* Length of string in characters. Both string
* and displayString have the same character
* length, but may have different byte lengths
* due to being made from different UTF-8
* characters. */
- int numDisplayBytes; /* Length of displayString in bytes. */
+ TkSizeT numDisplayBytes; /* Length of displayString in bytes. */
int inset; /* Number of pixels on the left and right
* sides that are taken up by XPAD,
* borderWidth (if any), and highlightWidth
@@ -166,7 +166,7 @@ typedef struct {
int layoutX, layoutY; /* Origin for layout. */
int leftX; /* X position at which character at leftIndex
* is drawn (varies depending on justify). */
- int leftIndex; /* Character index of left-most character
+ TkSizeT leftIndex; /* Character index of left-most character
* visible in window. */
Tcl_TimerToken insertBlinkHandler;
/* Timer handler used to blink cursor on and
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index dd493e9..4ac3bab 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -567,51 +567,51 @@ declare 168 {
# Next group of functions exposed due to [Bug 2768945].
declare 169 {
int TkStateParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 170 {
const char *TkStatePrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 171 {
int TkCanvasDashParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 172 {
const char *TkCanvasDashPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 173 {
int TkOffsetParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 174 {
const char *TkOffsetPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 175 {
int TkPixelParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 176 {
const char *TkPixelPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 177 {
int TkOrientParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 178 {
const char *TkOrientPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 179 {
int TkSmoothParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 180 {
const char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
# Angled text API, exposed for Emiliano Gavilán's RBC work.
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 6ebf8eb..ab06435 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1283,6 +1283,15 @@ MODULE_SCOPE int TkGetDoublePixels(Tcl_Interp *interp, Tk_Window tkwin,
MODULE_SCOPE int TkPostscriptImage(Tcl_Interp *interp, Tk_Window tkwin,
Tk_PostscriptInfo psInfo, XImage *ximage,
int x, int y, int width, int height);
+#if TCL_MAJOR_VERSION > 8
+MODULE_SCOPE int TkCanvasTagsParseProc(ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, size_t offset);
+MODULE_SCOPE const char *TkCanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, size_t offset, Tcl_FreeProc **freeProcPtr);
+#else
+#define TkCanvasTagsParseProc Tk_CanvasTagsParseProc
+#define TkCanvasTagsPrintProc Tk_CanvasTagsPrintProc
+#endif
MODULE_SCOPE void TkMapTopFrame(Tk_Window tkwin);
MODULE_SCOPE XEvent * TkpGetBindingXEvent(Tcl_Interp *interp);
MODULE_SCOPE void TkCreateExitHandler(Tcl_ExitProc *proc,
@@ -1390,8 +1399,8 @@ MODULE_SCOPE void TkUnixSetXftClipRegion(Region clipRegion);
#endif
#if TCL_UTF_MAX > 4
-# define TkUtfToUniChar (size_t)Tcl_UtfToUniChar
-# define TkUniCharToUtf (size_t)Tcl_UniCharToUtf
+# define TkUtfToUniChar(src, ch) (size_t)(((int (*)(const char *, int *))Tcl_UtfToUniChar)(src, ch))
+# define TkUniCharToUtf(ch, src) (size_t)(((int (*)(int, char *))Tcl_UniCharToUtf)(ch, src))
# define TkUtfPrev Tcl_UtfPrev
#else
MODULE_SCOPE size_t TkUtfToUniChar(const char *, int *);
diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h
index 0b3a3cc..f241b75 100644
--- a/generic/tkIntDecls.h
+++ b/generic/tkIntDecls.h
@@ -488,51 +488,57 @@ EXTERN void TkTextInsertDisplayProc(struct TkText *textPtr,
/* 169 */
EXTERN int TkStateParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 170 */
EXTERN const char * TkStatePrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 171 */
EXTERN int TkCanvasDashParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 172 */
EXTERN const char * TkCanvasDashPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 173 */
EXTERN int TkOffsetParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 174 */
EXTERN const char * TkOffsetPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 175 */
EXTERN int TkPixelParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 176 */
EXTERN const char * TkPixelPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 177 */
EXTERN int TkOrientParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 178 */
EXTERN const char * TkOrientPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 179 */
EXTERN int TkSmoothParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 180 */
EXTERN const char * TkSmoothPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 181 */
EXTERN void TkDrawAngledTextLayout(Display *display,
Drawable drawable, GC gc,
@@ -757,18 +763,18 @@ typedef struct TkIntStubs {
void (*tkTextChanged) (struct TkSharedText *sharedTextPtr, struct TkText *textPtr, const struct TkTextIndex *index1Ptr, const struct TkTextIndex *index2Ptr); /* 166 */
int (*tkBTreeNumLines) (TkTextBTree tree, const struct TkText *textPtr); /* 167 */
void (*tkTextInsertDisplayProc) (struct TkText *textPtr, struct TkTextDispChunk *chunkPtr, int x, int y, int height, int baseline, Display *display, Drawable dst, int screenY); /* 168 */
- int (*tkStateParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 169 */
- const char * (*tkStatePrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 170 */
- int (*tkCanvasDashParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 171 */
- const char * (*tkCanvasDashPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 172 */
- int (*tkOffsetParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 173 */
- const char * (*tkOffsetPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 174 */
- int (*tkPixelParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 175 */
- const char * (*tkPixelPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 176 */
- int (*tkOrientParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 177 */
- const char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 178 */
- int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 179 */
- const char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 180 */
+ int (*tkStateParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 169 */
+ const char * (*tkStatePrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 170 */
+ int (*tkCanvasDashParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 171 */
+ const char * (*tkCanvasDashPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 172 */
+ int (*tkOffsetParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 173 */
+ const char * (*tkOffsetPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 174 */
+ int (*tkPixelParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 175 */
+ const char * (*tkPixelPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 176 */
+ int (*tkOrientParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 177 */
+ const char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 178 */
+ int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 179 */
+ const char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 180 */
void (*tkDrawAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int firstChar, int lastChar); /* 181 */
void (*tkUnderlineAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int underline); /* 182 */
int (*tkIntersectAngledTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height, double angle); /* 183 */
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index ce5f350..6ea80ff 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -409,8 +409,8 @@ static void ListboxComputeGeometry(Listbox *listPtr,
int fontChanged, int maxIsStale, int updateGrid);
static void ListboxEventProc(ClientData clientData,
XEvent *eventPtr);
-static int ListboxFetchSelection(ClientData clientData,
- int offset, char *buffer, int maxBytes);
+static TkSizeT ListboxFetchSelection(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
static void ListboxLostSelection(ClientData clientData);
static void GenerateListboxSelectEvent(Listbox *listPtr);
static void EventuallyRedrawRange(Listbox *listPtr,
@@ -3112,13 +3112,13 @@ ListboxSelect(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
ListboxFetchSelection(
ClientData clientData, /* Information about listbox widget. */
- int 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. */
- int maxBytes) /* Maximum number of bytes to place at buffer,
+ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
@@ -3163,12 +3163,12 @@ ListboxFetchSelection(
* Copy the requested portion of the selection to the buffer.
*/
- if (length <= (TkSizeT)offset) {
+ if (length <= offset) {
count = 0;
} else {
count = length - offset;
- if (count > maxBytes) {
- count = maxBytes;
+ if (count > (int)maxBytes) {
+ count = (int)maxBytes;
}
memcpy(buffer, Tcl_DStringValue(&selection) + offset, count);
}
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index 297b335..5972f69 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -225,10 +225,10 @@ static void DestroyOptionTables(ClientData clientData,
Tcl_Interp *interp);
static int SetSticky(ClientData clientData, Tcl_Interp *interp,
Tk_Window tkwin, Tcl_Obj **value, char *recordPtr,
- int internalOffset, char *oldInternalPtr,
+ TkSizeT internalOffset, char *oldInternalPtr,
int flags);
static Tcl_Obj * GetSticky(ClientData clientData, Tk_Window tkwin,
- char *recordPtr, int internalOffset);
+ char *recordPtr, TkSizeT internalOffset);
static void RestoreSticky(ClientData clientData, Tk_Window tkwin,
char *internalPtr, char *oldInternalPtr);
static void AdjustForSticky(int sticky, int cavityWidth,
@@ -236,7 +236,7 @@ static void AdjustForSticky(int sticky, int cavityWidth,
int *slaveWidthPtr, int *slaveHeightPtr);
static void MoveSash(PanedWindow *pwPtr, int sash, int diff);
static int ObjectIsEmpty(Tcl_Obj *objPtr);
-static void * ComputeSlotAddress(void *recordPtr, size_t offset);
+static void * ComputeSlotAddress(void *recordPtr, TkSizeT offset);
static int PanedWindowIdentifyCoords(PanedWindow *pwPtr,
Tcl_Interp *interp, int x, int y);
@@ -2402,7 +2402,7 @@ GetSticky(
ClientData dummy,
Tk_Window tkwin,
char *recordPtr, /* Pointer to widget record. */
- int internalOffset) /* Offset within *recordPtr containing the
+ TkSizeT internalOffset) /* Offset within *recordPtr containing the
* sticky value. */
{
int sticky = *(int *)(recordPtr + internalOffset);
@@ -2456,7 +2456,7 @@ SetSticky(
* We use a pointer to the pointer because we
* may need to return a value (NULL). */
char *recordPtr, /* Pointer to storage for the widget record. */
- int internalOffset, /* Offset within *recordPtr at which the
+ TkSizeT internalOffset, /* Offset within *recordPtr at which the
* internal value is to be stored. */
char *oldInternalPtr, /* Pointer to storage for the old value. */
int flags) /* Flags for the option, set Tk_SetOptions. */
@@ -3035,9 +3035,9 @@ ObjectIsEmpty(
static void *
ComputeSlotAddress(
void *recordPtr, /* Pointer to the start of a record. */
- size_t offset) /* Offset of a slot within that record; may be -1. */
+ TkSizeT offset) /* Offset of a slot within that record; may be TCL_INDEX_NONE. */
{
- if (offset != (size_t)-1) {
+ if (offset != TCL_INDEX_NONE) {
return (char *)recordPtr + offset;
} else {
return NULL;
diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c
index a820411..76bf03b 100644
--- a/generic/tkRectOval.c
+++ b/generic/tkRectOval.c
@@ -47,7 +47,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption dashOption = {
TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index a6548b6..3ad2820 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -59,8 +59,8 @@ static Tcl_ThreadDataKey dataKey;
* Forward declarations for functions defined in this file:
*/
-static int HandleTclCommand(ClientData clientData,
- int offset, char *buffer, int maxBytes);
+static TkSizeT HandleTclCommand(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
static void LostSelection(ClientData clientData);
static int SelGetProc(ClientData clientData,
Tcl_Interp *interp, const char *portion);
@@ -1319,13 +1319,13 @@ SelGetProc(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
HandleTclCommand(
ClientData clientData, /* Information about command to execute. */
- int offset, /* Return selection bytes starting at this
+ TkSizeT offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */
{
CommandInfo *cmdInfoPtr = (CommandInfo *)clientData;
int length;
@@ -1349,7 +1349,7 @@ HandleTclCommand(
* character.
*/
- if (offset == cmdInfoPtr->byteOffset) {
+ if ((int)offset == cmdInfoPtr->byteOffset) {
charOffset = cmdInfoPtr->charOffset;
extraBytes = strlen(cmdInfoPtr->buffer);
if (extraBytes > 0) {
@@ -1370,7 +1370,7 @@ HandleTclCommand(
*/
command = Tcl_ObjPrintf("%s %d %d",
- cmdInfoPtr->command, charOffset, maxBytes);
+ cmdInfoPtr->command, charOffset, (int)maxBytes);
Tcl_IncrRefCount(command);
/*
@@ -1387,7 +1387,7 @@ HandleTclCommand(
*/
string = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &length);
- count = (length > maxBytes) ? maxBytes : length;
+ count = (length > (int)maxBytes) ? (int)maxBytes : length;
memcpy(buffer, string, count);
buffer[count] = '\0';
@@ -1397,7 +1397,7 @@ HandleTclCommand(
*/
if (cmdInfoPtr->interp != NULL) {
- if (length <= maxBytes) {
+ if (length <= (int)maxBytes) {
cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1);
cmdInfoPtr->buffer[0] = '\0';
} else {
diff --git a/generic/tkSelect.h b/generic/tkSelect.h
index 405cbea..c2d153b 100644
--- a/generic/tkSelect.h
+++ b/generic/tkSelect.h
@@ -107,7 +107,7 @@ typedef struct TkSelRetrievalInfo {
typedef struct TkClipboardBuffer {
char *buffer; /* Null terminated data buffer. */
- size_t length; /* Length of string in buffer. */
+ TkSizeT length; /* Length of string in buffer. */
struct TkClipboardBuffer *nextPtr;
/* Next in list of buffers. NULL means end of
* list . */
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index 1942173..8b98928 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -100,6 +100,12 @@ static Tk_Style Tk_GetStyleFromObj(Tcl_Obj *obj)
#define TkMacOSXInitAppleEvents_ TkMacOSXInitAppleEvents
#define TkGenWMConfigureEvent_ TkGenWMConfigureEvent
#define TkGenerateActivateEvents_ TkGenerateActivateEvents
+#define Tk_CanvasTagsParseProc \
+ (int (*) (void *, Tcl_Interp *,Tk_Window, const char *, char *, \
+ int offset))(void *)TkCanvasTagsParseProc
+#define Tk_CanvasTagsPrintProc \
+ (const char *(*) (void *,Tk_Window, char *, int, \
+ Tcl_FreeProc **))(void *)TkCanvasTagsPrintProc
#ifdef _WIN32
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 97b33fc..1f76fe2 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -186,19 +186,10 @@ static int TestmetricsObjCmd(ClientData dummy,
static int TestobjconfigObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj * const objv[]);
-static int CustomOptionSet(ClientData clientData,
- Tcl_Interp *interp, Tk_Window tkwin,
- Tcl_Obj **value, char *recordPtr,
- int internalOffset, char *saveInternalPtr,
- int flags);
-static Tcl_Obj * CustomOptionGet(ClientData clientData,
- Tk_Window tkwin, char *recordPtr,
- int internalOffset);
-static void CustomOptionRestore(ClientData clientData,
- Tk_Window tkwin, char *internalPtr,
- char *saveInternalPtr);
-static void CustomOptionFree(ClientData clientData,
- Tk_Window tkwin, char *internalPtr);
+static Tk_CustomOptionSetProc CustomOptionSet;
+static Tk_CustomOptionGetProc CustomOptionGet;
+static Tk_CustomOptionRestoreProc CustomOptionRestore;
+static Tk_CustomOptionFreeProc CustomOptionFree;
static int TestpropObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj * const objv[]);
@@ -2047,8 +2038,7 @@ TestwrapperObjCmd(
* CustomOptionSet Sets option value to new setting.
* CustomOptionGet Creates a new Tcl_Obj.
* CustomOptionRestore Resets option value to original value.
- * CustomOptionFree Free storage for internal rep of
- * option.
+ * CustomOptionFree Free storage for internal rep of option.
*
*----------------------------------------------------------------------
*/
@@ -2060,7 +2050,7 @@ CustomOptionSet(
Tk_Window tkwin,
Tcl_Obj **value,
char *recordPtr,
- int internalOffset,
+ TkSizeT internalOffset,
char *saveInternalPtr,
int flags)
{
@@ -2071,7 +2061,7 @@ CustomOptionSet(
objEmpty = 0;
- if (internalOffset != -1) {
+ if (internalOffset != TCL_INDEX_NONE) {
internalPtr = recordPtr + internalOffset;
} else {
internalPtr = NULL;
@@ -2121,7 +2111,7 @@ CustomOptionGet(
ClientData dummy,
Tk_Window tkwin,
char *recordPtr,
- int internalOffset)
+ TkSizeT internalOffset)
{
(void)dummy;
(void)tkwin;
diff --git a/generic/tkText.c b/generic/tkText.c
index 882225f..36b5ae2 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -96,11 +96,11 @@ static const char *const insertUnfocussedStrings[] = {
static int SetLineStartEnd(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
Tcl_Obj **value, char *recordPtr,
- int internalOffset, char *oldInternalPtr,
+ TkSizeT internalOffset, char *oldInternalPtr,
int flags);
static Tcl_Obj * GetLineStartEnd(ClientData clientData,
Tk_Window tkwin, char *recordPtr,
- int internalOffset);
+ TkSizeT internalOffset);
static void RestoreLineStartEnd(ClientData clientData,
Tk_Window tkwin, char *internalPtr,
char *oldInternalPtr);
@@ -365,8 +365,8 @@ static int CreateWidget(TkSharedText *sharedPtr, Tk_Window tkwin,
int objc, Tcl_Obj *const objv[]);
static void TextEventProc(ClientData clientData,
XEvent *eventPtr);
-static int TextFetchSelection(ClientData clientData, int offset,
- char *buffer, int maxBytes);
+static TkSizeT TextFetchSelection(ClientData clientData, TkSizeT offset,
+ char *buffer, TkSizeT maxBytes);
static int TextIndexSortProc(const void *first,
const void *second);
static int TextInsertCmd(TkSharedText *sharedTextPtr,
@@ -3413,13 +3413,13 @@ DeleteIndexRange(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
TextFetchSelection(
ClientData clientData, /* Information about text widget. */
- int 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. */
- int maxBytes) /* Maximum number of bytes to place at buffer,
+ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
@@ -3484,13 +3484,15 @@ TextFetchSelection(
*/
while (1) {
+ TkSizeT offsetInSeg1;
if (maxBytes == 0) {
goto fetchDone;
}
- segPtr = TkTextIndexToSeg(&textPtr->selIndex, &offsetInSeg);
+ segPtr = TkTextIndexToSeg(&textPtr->selIndex, &offsetInSeg1);
+ offsetInSeg = offsetInSeg1;
chunkSize = segPtr->size - offsetInSeg;
- if (chunkSize > maxBytes) {
- chunkSize = maxBytes;
+ if (chunkSize > (int)maxBytes) {
+ chunkSize = (int)maxBytes;
}
if (textPtr->selIndex.linePtr == search.curIndex.linePtr) {
int leftInRange;
@@ -4095,14 +4097,14 @@ TextSearchIndexInLine(
if ((segPtr->typePtr == &tkTextCharType) &&
(searchSpecPtr->searchElide
|| !TkTextIsElided(textPtr, &curIndex, NULL))) {
- if (leftToScan < segPtr->size) {
+ if (leftToScan < (int)segPtr->size) {
if (searchSpecPtr->exact) {
index += leftToScan;
} else {
index += Tcl_NumUtfChars(segPtr->body.chars, leftToScan);
}
} else if (searchSpecPtr->exact) {
- index += segPtr->size;
+ index += (int)segPtr->size;
} else {
index += Tcl_NumUtfChars(segPtr->body.chars, -1);
}
@@ -4362,7 +4364,7 @@ TextSearchFoundMatch(
}
} else {
if (searchSpecPtr->exact) {
- leftToScan -= segPtr->size;
+ leftToScan -= (int)segPtr->size;
} else {
leftToScan -= Tcl_NumUtfChars(segPtr->body.chars, -1);
}
@@ -5433,7 +5435,7 @@ TextGetText(
if (TkTextIndexCmp(indexPtr1, indexPtr2) < 0) {
while (1) {
- int offset;
+ TkSizeT offset;
TkTextSegment *segPtr = TkTextIndexToSeg(&tmpIndex, &offset);
int last = segPtr->size, last2;
@@ -6778,14 +6780,14 @@ GetLineStartEnd(
ClientData dummy,
Tk_Window tkwin,
char *recordPtr, /* Pointer to widget record. */
- int internalOffset) /* Offset within *recordPtr containing the
+ TkSizeT internalOffset) /* Offset within *recordPtr containing the
* line value. */
{
TkTextLine *linePtr = *(TkTextLine **)(recordPtr + internalOffset);
(void)dummy;
(void)tkwin;
- if (linePtr == NULL) {
+ if ((internalOffset == TCL_INDEX_NONE) || (recordPtr == NULL)) {
return Tcl_NewObj();
}
return Tcl_NewWideIntObj(1 + TkBTreeLinesTo(NULL, linePtr));
@@ -6819,7 +6821,7 @@ SetLineStartEnd(
* We use a pointer to the pointer because we
* may need to return a value (NULL). */
char *recordPtr, /* Pointer to storage for the widget record. */
- int internalOffset, /* Offset within *recordPtr at which the
+ TkSizeT internalOffset, /* Offset within *recordPtr at which the
* internal value is to be stored. */
char *oldInternalPtr, /* Pointer to storage for the old value. */
int flags) /* Flags for the option, set Tk_SetOptions. */
@@ -6830,7 +6832,7 @@ SetLineStartEnd(
(void)dummy;
(void)tkwin;
- if (internalOffset >= 0) {
+ if (internalOffset != TCL_INDEX_NONE) {
internalPtr = (char *)recordPtr + internalOffset;
} else {
internalPtr = NULL;
diff --git a/generic/tkText.h b/generic/tkText.h
index 8fb4134..52abc8c 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -165,7 +165,7 @@ typedef struct TkTextSegment {
struct TkTextSegment *nextPtr;
/* Next in list of segments for this line, or
* NULL for end of list. */
- int size; /* Size of this segment (# of bytes of index
+ TkSizeT size; /* Size of this segment (# of bytes of index
* space it occupies). */
union {
char chars[2]; /* Characters that make up character info.
@@ -847,7 +847,7 @@ typedef struct TkText {
*/
typedef TkTextSegment * Tk_SegSplitProc(struct TkTextSegment *segPtr,
- int index);
+ TkSizeT index);
typedef int Tk_SegDeleteProc(struct TkTextSegment *segPtr,
TkTextLine *linePtr, int treeGone);
typedef TkTextSegment * Tk_SegCleanupProc(struct TkTextSegment *segPtr,
@@ -856,8 +856,8 @@ typedef void Tk_SegLineChangeProc(struct TkTextSegment *segPtr,
TkTextLine *linePtr);
typedef int Tk_SegLayoutProc(struct TkText *textPtr,
struct TkTextIndex *indexPtr,
- TkTextSegment *segPtr, int offset, int maxX,
- int maxChars, int noCharsYet, TkWrapMode wrapMode,
+ TkTextSegment *segPtr, TkSizeT offset, int maxX,
+ TkSizeT maxChars, int noCharsYet, TkWrapMode wrapMode,
struct TkTextDispChunk *chunkPtr);
typedef void Tk_SegCheckProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
@@ -1060,7 +1060,7 @@ MODULE_SCOPE int TkTextIndexBbox(TkText *textPtr,
int *widthPtr, int *heightPtr, int *charWidthPtr);
MODULE_SCOPE int TkTextCharLayoutProc(TkText *textPtr,
TkTextIndex *indexPtr, TkTextSegment *segPtr,
- int offset, int maxX, int maxChars, int noBreakYet,
+ TkSizeT offset, int maxX, TkSizeT maxChars, int noBreakYet,
TkWrapMode wrapMode, TkTextDispChunk *chunkPtr);
MODULE_SCOPE void TkTextCreateDInfo(TkText *textPtr);
MODULE_SCOPE int TkTextDLineInfo(TkText *textPtr,
@@ -1106,7 +1106,7 @@ MODULE_SCOPE void TkTextIndexOfX(TkText *textPtr, int x,
MODULE_SCOPE int TkTextIndexYPixels(TkText *textPtr,
const TkTextIndex *indexPtr);
MODULE_SCOPE TkTextSegment *TkTextIndexToSeg(const TkTextIndex *indexPtr,
- int *offsetPtr);
+ TkSizeT *offsetPtr);
MODULE_SCOPE void TkTextLostSelection(ClientData clientData);
MODULE_SCOPE TkTextIndex *TkTextMakeCharIndex(TkTextBTree tree, TkText *textPtr,
int lineIndex, int charIndex,
diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c
index 071ae59..5ce7a99 100644
--- a/generic/tkTextBTree.c
+++ b/generic/tkTextBTree.c
@@ -161,7 +161,7 @@ static int CharDeleteProc(TkTextSegment *segPtr,
TkTextLine *linePtr, int treeGone);
static TkTextSegment * CharCleanupProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
-static TkTextSegment * CharSplitProc(TkTextSegment *segPtr, int index);
+static TkTextSegment * CharSplitProc(TkTextSegment *segPtr, TkSizeT index);
static void CheckNodeConsistency(Node *nodePtr, int references);
static void CleanupLine(TkTextLine *linePtr);
static void DeleteSummaries(Summary *tagPtr);
@@ -1197,7 +1197,7 @@ SplitSeg(
segPtr = linePtr->segPtr;
while (segPtr != NULL) {
- if (segPtr->size > count) {
+ if (segPtr->size > (TkSizeT)count) {
if (count == 0) {
return prevPtr;
}
@@ -2654,7 +2654,7 @@ TkBTreeStartSearch(
/* Where to store information about search's
* progress. */
{
- int offset;
+ TkSizeT offset;
TkTextIndex index0; /* First index of the tag. */
TkTextSegment *seg0Ptr; /* First segment of the tag. */
@@ -2750,7 +2750,7 @@ TkBTreeStartSearchBack(
/* Where to store information about search's
* progress. */
{
- int offset;
+ TkSizeT offset;
TkTextIndex index0; /* Last index of the tag. */
TkTextIndex backOne; /* One character before starting index. */
TkTextSegment *seg0Ptr; /* Last segment of the tag. */
@@ -3244,7 +3244,7 @@ TkBTreeCharTagged(
toggleSegPtr = NULL;
for (index = 0, segPtr = indexPtr->linePtr->segPtr;
- (index + segPtr->size) <= indexPtr->byteIndex;
+ (index + (int)segPtr->size) <= indexPtr->byteIndex;
index += segPtr->size, segPtr = segPtr->nextPtr) {
if (((segPtr->typePtr == &tkTextToggleOnType)
|| (segPtr->typePtr == &tkTextToggleOffType))
@@ -3364,7 +3364,7 @@ TkBTreeGetTags(
linePtr = indexPtr->linePtr;
index = 0;
segPtr = linePtr->segPtr;
- while ((index + segPtr->size) <= indexPtr->byteIndex) {
+ while ((index + (int)segPtr->size) <= indexPtr->byteIndex) {
if ((segPtr->typePtr == &tkTextToggleOnType)
|| (segPtr->typePtr == &tkTextToggleOffType)) {
IncCount(segPtr->body.toggle.tagPtr, 1, &tagInfo);
@@ -3528,7 +3528,7 @@ TkTextIsElided(
index = 0;
linePtr = indexPtr->linePtr;
segPtr = linePtr->segPtr;
- while ((index + segPtr->size) <= indexPtr->byteIndex) {
+ while ((index + (int)segPtr->size) <= indexPtr->byteIndex) {
if ((segPtr->typePtr == &tkTextToggleOnType)
|| (segPtr->typePtr == &tkTextToggleOffType)) {
tagPtr = segPtr->body.toggle.tagPtr;
@@ -3865,7 +3865,7 @@ TkBTreeCheck(
}
if (segPtr->size != 1) {
Tcl_Panic("TkBTreeCheck: last line has wrong # characters: %d",
- segPtr->size);
+ (int)segPtr->size);
}
if ((segPtr->body.chars[0] != '\n') || (segPtr->body.chars[1] != 0)) {
Tcl_Panic("TkBTreeCheck: last line had bad value: %s",
@@ -4549,7 +4549,7 @@ TkBTreeNumPixels(
static TkTextSegment *
CharSplitProc(
TkTextSegment *segPtr, /* Pointer to segment to split. */
- int index) /* Position within segment at which to
+ TkSizeT index) /* Position within segment at which to
* split. */
{
TkTextSegment *newPtr1, *newPtr2;
@@ -4675,10 +4675,10 @@ CharCheckProc(
* to each other: they should be merged together.
*/
- if (segPtr->size <= 0) {
+ if (segPtr->size + 1 <= 1) {
Tcl_Panic("CharCheckProc: segment has size <= 0");
}
- if (strlen(segPtr->body.chars) != (size_t) segPtr->size) {
+ if (strlen(segPtr->body.chars) != (size_t)segPtr->size) {
Tcl_Panic("CharCheckProc: segment has wrong size");
}
if (segPtr->nextPtr == NULL) {
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 2dfe964..6917292 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -1173,7 +1173,8 @@ LayoutDLine(
/* Pointer to last chunk in display lines with
* numBytes > 0. Used to drop 0-sized chunks
* from the end of the line. */
- int byteOffset, ascent, descent, code, elide, elidesize;
+ TkSizeT byteOffset;
+ int ascent, descent, code, elide, elidesize;
StyleValues *sValuePtr;
TkTextElideInfo info; /* Keep track of elide state. */
@@ -1213,7 +1214,7 @@ LayoutDLine(
if (elide && indexPtr->byteIndex == 0) {
maxBytes = 0;
for (segPtr = info.segPtr; segPtr != NULL; segPtr = segPtr->nextPtr) {
- if (segPtr->size > 0) {
+ if (segPtr->size + 1 > 1) {
if (elide == 0) {
/*
* We toggled a tag and the elide state changed to
@@ -1334,7 +1335,7 @@ LayoutDLine(
connectNextLogicalLine:
byteOffset = curIndex.byteIndex;
segPtr = curIndex.linePtr->segPtr;
- while ((byteOffset > 0) && (byteOffset >= segPtr->size)) {
+ while ((byteOffset + 1 > 1) && (byteOffset + 1 >= segPtr->size + 1)) {
byteOffset -= segPtr->size;
segPtr = segPtr->nextPtr;
@@ -1374,7 +1375,7 @@ LayoutDLine(
if (elide && (lastChunkPtr != NULL)
&& (lastChunkPtr->displayProc == NULL /*ElideDisplayProc*/)) {
elidesize = segPtr->size - byteOffset;
- if (elidesize > 0) {
+ if (segPtr->size + 1 > byteOffset + 1) {
curIndex.byteIndex += elidesize;
lastChunkPtr->numBytes += elidesize;
breakByteOffset = lastChunkPtr->breakIndex
@@ -7603,11 +7604,11 @@ TkTextCharLayoutProc(
TkTextIndex *indexPtr, /* Index of first character to lay out
* (corresponds to segPtr and offset). */
TkTextSegment *segPtr, /* Segment being layed out. */
- int byteOffset, /* Byte offset within segment of first
+ TkSizeT byteOffset, /* Byte offset within segment of first
* character to consider. */
int maxX, /* Chunk must not occupy pixels at this
* position or higher. */
- int 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. */
@@ -7684,7 +7685,7 @@ TkTextCharLayoutProc(
chunkPtr->x, maxX, TK_ISOLATE_END, &nextX);
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
- if (bytesThatFit < maxBytes) {
+ if ((TkSizeT)bytesThatFit + 1 <= maxBytes) {
if ((bytesThatFit == 0) && noCharsYet) {
int ch;
int chLen = TkUtfToUniChar(p, &ch);
diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c
index ccdfda6..ef79376 100644
--- a/generic/tkTextImage.c
+++ b/generic/tkTextImage.c
@@ -43,7 +43,7 @@ static void EmbImageDisplayProc(TkText *textPtr,
Drawable dst, int screenY);
static int EmbImageLayoutProc(TkText *textPtr,
TkTextIndex *indexPtr, TkTextSegment *segPtr,
- int offset, int maxX, int maxChars,
+ TkSizeT offset, int maxX, TkSizeT maxChars,
int noCharsYet, TkWrapMode wrapMode,
TkTextDispChunk *chunkPtr);
static void EmbImageProc(ClientData clientData, int x, int y,
@@ -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. */
- int 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. */
- int 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. */
@@ -631,7 +631,7 @@ EmbImageCheckProc(
}
if (eiPtr->size != 1) {
Tcl_Panic("EmbImageCheckProc: embedded image has size %d",
- eiPtr->size);
+ (int)eiPtr->size);
}
}
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index 70a53ae..4a80844 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -425,7 +425,7 @@ TkTextMakeByteIndex(
indexPtr->byteIndex = index - sizeof(char);
break;
}
- if (index + segPtr->size > byteIndex) {
+ if (index + (int)segPtr->size > byteIndex) {
indexPtr->byteIndex = byteIndex;
if ((byteIndex > index) && (segPtr->typePtr == &tkTextCharType)) {
/*
@@ -531,7 +531,7 @@ TkTextMakeCharIndex(
index += offset;
}
} else {
- if (charIndex < segPtr->size) {
+ if (charIndex < (int)segPtr->size) {
indexPtr->byteIndex = index;
break;
}
@@ -565,11 +565,11 @@ TkTextMakeCharIndex(
TkTextSegment *
TkTextIndexToSeg(
const TkTextIndex *indexPtr,/* Text index. */
- int *offsetPtr) /* Where to store offset within segment, or
+ TkSizeT *offsetPtr) /* Where to store offset within segment, or
* NULL if offset isn't wanted. */
{
TkTextSegment *segPtr;
- int offset;
+ TkSizeT offset;
for (offset = indexPtr->byteIndex, segPtr = indexPtr->linePtr->segPtr;
offset >= segPtr->size;
@@ -1049,7 +1049,7 @@ TkTextPrintIndex(
linePtr = TkBTreeNextLine(NULL, linePtr);
segPtr = linePtr->segPtr;
}
- if (numBytes <= segPtr->size) {
+ if (numBytes <= (int)segPtr->size) {
break;
}
if (segPtr->typePtr == &tkTextCharType) {
@@ -1488,7 +1488,7 @@ TkTextIndexForwChars(
TkTextLine *linePtr;
TkTextSegment *segPtr;
TkTextElideInfo *infoPtr = NULL;
- int byteOffset;
+ TkSizeT byteOffset;
char *start, *end, *p;
int ch;
int elide = 0;
@@ -1597,7 +1597,7 @@ TkTextIndexForwChars(
charCount--;
}
} else if (type & COUNT_INDICES) {
- if (charCount < segPtr->size - byteOffset) {
+ if (charCount + byteOffset < segPtr->size) {
dstPtr->byteIndex += charCount;
goto forwardCharDone;
}
@@ -1676,7 +1676,7 @@ IndexCountBytesOrdered(
/* Index describing location of last character
* at which to stop the count. */
{
- int byteCount, offset;
+ TkSizeT byteCount, offset;
TkTextSegment *segPtr, *segPtr1;
TkTextLine *linePtr;
@@ -1753,7 +1753,8 @@ TkTextIndexCount(
TkTextLine *linePtr1;
TkTextSegment *segPtr, *seg2Ptr = NULL;
TkTextElideInfo *infoPtr = NULL;
- int byteOffset, maxBytes, count = 0, elide = 0;
+ TkSizeT byteOffset, maxBytes, count = 0;
+ int elide = 0;
int checkElided = (type & COUNT_DISPLAY);
/*
@@ -1843,13 +1844,13 @@ TkTextIndexCount(
}
if (segPtr->typePtr == &tkTextCharType) {
- int byteLen = segPtr->size - byteOffset;
+ TkSizeT byteLen = segPtr->size - byteOffset;
unsigned char *str = (unsigned char *)
segPtr->body.chars + byteOffset;
- int i;
+ TkSizeT i;
if (segPtr == seg2Ptr) {
- if (byteLen > (maxBytes - byteOffset)) {
+ if (byteLen + byteOffset > maxBytes) {
byteLen = maxBytes - byteOffset;
}
}
@@ -1876,10 +1877,10 @@ TkTextIndexCount(
}
} else {
if (type & COUNT_INDICES) {
- int byteLen = segPtr->size - byteOffset;
+ TkSizeT byteLen = segPtr->size - byteOffset;
if (segPtr == seg2Ptr) {
- if (byteLen > (maxBytes - byteOffset)) {
+ if (byteLen + byteOffset > maxBytes) {
byteLen = maxBytes - byteOffset;
}
}
@@ -2055,7 +2056,7 @@ TkTextIndexBackChars(
linePtr = TkBTreeNextLine(NULL, linePtr);
segPtr = linePtr->segPtr;
}
- if (segSize <= segPtr->size) {
+ if (segSize <= (int)segPtr->size) {
break;
}
segSize -= segPtr->size;
@@ -2296,7 +2297,7 @@ StartEnd(
} else if ((*string == 'w') && (strncmp(string, "wordend", length) == 0)
&& (length >= 5)) {
int firstChar = 1;
- int offset;
+ TkSizeT offset;
/*
* If the current character isn't part of a word then just move
@@ -2339,7 +2340,7 @@ StartEnd(
} else if ((*string == 'w') && (strncmp(string, "wordstart", length) == 0)
&& (length >= 5)) {
int firstChar = 1;
- int offset;
+ TkSizeT offset;
if (modifier == TKINDEX_DISPLAY) {
TkTextIndexForwChars(textPtr, indexPtr, 0, indexPtr,
@@ -2364,7 +2365,7 @@ StartEnd(
if (!Tcl_UniCharIsWordChar(ch)) {
break;
}
- if (offset > 0) {
+ if (offset + 1 > 1) {
chSize = (segPtr->body.chars + offset
- TkUtfPrev(segPtr->body.chars + offset,
segPtr->body.chars));
@@ -2383,7 +2384,7 @@ StartEnd(
indexPtr->byteIndex -= chSize;
}
offset -= chSize;
- if (offset < 0) {
+ if ((int)offset < 0) {
if (indexPtr->byteIndex == 0) {
goto done;
}
diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c
index 11acf37..8eceda9 100644
--- a/generic/tkTextMark.c
+++ b/generic/tkTextMark.c
@@ -36,8 +36,8 @@ static TkTextSegment * MarkCleanupProc(TkTextSegment *segPtr,
static void MarkCheckProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
static int MarkLayoutProc(TkText *textPtr, TkTextIndex *indexPtr,
- TkTextSegment *segPtr, int offset, int maxX,
- int maxChars, int noCharsYet, TkWrapMode wrapMode,
+ TkTextSegment *segPtr, TkSizeT offset, int maxX,
+ TkSizeT maxChars, int noCharsYet, TkWrapMode wrapMode,
TkTextDispChunk *chunkPtr);
static int MarkFindNext(Tcl_Interp *interp,
TkText *textPtr, Tcl_Obj *markName);
@@ -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. */
- int 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. */
- int 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 d9c77d1..b046076 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.c
@@ -57,7 +57,7 @@ static int EmbWinDeleteProc(TkTextSegment *segPtr,
TkTextLine *linePtr, int treeGone);
static int EmbWinLayoutProc(TkText *textPtr,
TkTextIndex *indexPtr, TkTextSegment *segPtr,
- int offset, int maxX, int maxChars,int noCharsYet,
+ TkSizeT offset, int maxX, TkSizeT maxChars,int noCharsYet,
TkWrapMode wrapMode, TkTextDispChunk *chunkPtr);
static void EmbWinStructureProc(ClientData clientData,
XEvent *eventPtr);
@@ -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. */
- int 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. */
- int 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. */
@@ -1063,7 +1063,7 @@ EmbWinCheckProc(
Tcl_Panic("EmbWinCheckProc: embedded window is last segment in line");
}
if (ewPtr->size != 1) {
- Tcl_Panic("EmbWinCheckProc: embedded window has size %d", ewPtr->size);
+ Tcl_Panic("EmbWinCheckProc: embedded window has size %d", (int)ewPtr->size);
}
}
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index 01155c9..5a970c0 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. */
- int offset) /* Offset into item. */
+ TkSizeT offset) /* Offset into item. */
{
int c;
int flags = PTR2INT(clientData);
@@ -128,7 +128,7 @@ TkStatePrintProc(
TCL_UNUSED(void *), /* Ignored. */
TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
+ TkSizeT offset, /* Offset into item. */
TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
@@ -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. */
- int offset) /* Offset into item. */
+ TkSizeT offset) /* Offset into item. */
{
int c;
size_t length;
@@ -230,7 +230,7 @@ TkOrientPrintProc(
TCL_UNUSED(void *), /* Ignored. */
TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
+ TkSizeT offset, /* Offset into item. */
TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
@@ -262,7 +262,7 @@ TkOffsetParseProc(
Tk_Window tkwin, /* Window on same display as tile */
const char *value, /* Name of image */
char *widgRec, /* Widget structure record */
- int offset) /* Offset of tile in record */
+ TkSizeT offset) /* Offset of tile in record */
{
Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset);
Tk_TSOffset tsoffset;
@@ -412,7 +412,7 @@ TkOffsetPrintProc(
TCL_UNUSED(void *), /* not used */
TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
- int 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 */
- int offset) /* Offset of tile in record */
+ TkSizeT offset) /* Offset of tile in record */
{
double *doublePtr = (double *) (widgRec + offset);
int result;
@@ -513,7 +513,7 @@ TkPixelPrintProc(
TCL_UNUSED(void *), /* not used */
TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
- int offset, /* Offset of tile in record */
+ TkSizeT offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
{
double *doublePtr = (double *) (widgRec + offset);
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index fe7f6ff..9e5b63a 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -84,8 +84,8 @@ typedef struct {
* Internal state:
*/
char *string; /* Storage for string (malloced) */
- int numBytes; /* Length of string in bytes. */
- int numChars; /* Length of string in characters. */
+ TkSizeT numBytes; /* Length of string in bytes. */
+ TkSizeT numChars; /* Length of string in characters. */
int insertPos; /* Insert index */
int selectFirst; /* Index of start of selection, or -1 */
@@ -350,32 +350,32 @@ EntryEditable(Entry *entryPtr)
/* EntryFetchSelection --
* Selection handler for entry widgets.
*/
-static int
+static TkSizeT
EntryFetchSelection(
- ClientData clientData, int offset, char *buffer, int maxBytes)
+ ClientData clientData, TkSizeT offset, char *buffer, TkSizeT maxBytes)
{
Entry *entryPtr = (Entry *)clientData;
- int byteCount;
+ TkSizeT byteCount;
const char *string;
const char *selStart, *selEnd;
- if (entryPtr->entry.selectFirst < 0 || (!entryPtr->entry.exportSelection)
+ if (entryPtr->entry.selectFirst == -1 || (!entryPtr->entry.exportSelection)
|| Tcl_IsSafe(entryPtr->core.interp)) {
- return -1;
+ return TCL_INDEX_NONE;
}
string = entryPtr->entry.displayString;
selStart = Tcl_UtfAtIndex(string, entryPtr->entry.selectFirst);
selEnd = Tcl_UtfAtIndex(selStart,
entryPtr->entry.selectLast - entryPtr->entry.selectFirst);
+ if (selEnd <= selStart + offset) {
+ return 0;
+ }
byteCount = selEnd - selStart - offset;
if (byteCount > maxBytes) {
/* @@@POSSIBLE BUG: Can transfer partial UTF-8 sequences. Is this OK? */
byteCount = maxBytes;
}
- if (byteCount <= 0) {
- return 0;
- }
memcpy(buffer, selStart + offset, byteCount);
buffer[byteCount] = '\0';
return byteCount;
@@ -734,7 +734,7 @@ static void
EntryStoreValue(Entry *entryPtr, const char *value)
{
size_t numBytes = strlen(value);
- int numChars = Tcl_NumUtfChars(value, numBytes);
+ TkSizeT numChars = Tcl_NumUtfChars(value, numBytes);
if (entryPtr->core.flags & VALIDATING)
entryPtr->core.flags |= VALIDATION_SET_VALUE;
@@ -886,7 +886,7 @@ DeleteChars(
if (index < 0) {
index = 0;
}
- if (count > entryPtr->entry.numChars - index) {
+ if (count + index > (int)entryPtr->entry.numChars) {
count = entryPtr->entry.numChars - index;
}
if (count <= 0) {
@@ -1373,8 +1373,8 @@ EntryIndex(
const char *string;
if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->entry.numChars - 1, 1, &idx)) {
- if (idx + 1 > (TkSizeT)entryPtr->entry.numChars + 1) {
- idx = (TkSizeT)entryPtr->entry.numChars;
+ if (idx + 1 > entryPtr->entry.numChars + 1) {
+ idx = entryPtr->entry.numChars;
}
*indexPtr = (int)idx;
return TCL_OK;
@@ -1389,7 +1389,7 @@ EntryIndex(
} else if (strncmp(string, "right", length) == 0) { /* for debugging */
*indexPtr = entryPtr->entry.xscroll.last;
} else if (strncmp(string, "sel.", 4) == 0) {
- if (entryPtr->entry.selectFirst < 0) {
+ if (entryPtr->entry.selectFirst == -1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"selection isn't in widget %s",
Tk_PathName(entryPtr->core.tkwin)));
@@ -1430,7 +1430,7 @@ EntryIndex(
* last character to be selected, for example.
*/
- if (roundUp && (*indexPtr < entryPtr->entry.numChars)) {
+ if (roundUp && (*indexPtr < (int)entryPtr->entry.numChars)) {
*indexPtr += 1;
}
} else {
@@ -1463,7 +1463,7 @@ EntryBBoxCommand(
if (EntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) {
return TCL_ERROR;
}
- if ((index == entryPtr->entry.numChars) && (index > 0)) {
+ if ((index == (int)entryPtr->entry.numChars) && (index > 0)) {
index--;
}
Tk_CharBbox(entryPtr->entry.textLayout, index,
diff --git a/generic/ttk/ttkTagSet.c b/generic/ttk/ttkTagSet.c
index 96e6c4e..33d06bc 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;
- int offset = optionSpec->objOffset;
+ size_t 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) {
- int offset = optionSpec->objOffset;
+ size_t offset = optionSpec->objOffset;
const char *optionName = optionSpec->optionName;
Tcl_Obj *val = Ttk_StyleMap(style, optionName, state);
if (val) {