summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-03-31 19:54:49 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-03-31 19:54:49 (GMT)
commit8d2dbe96066152901e507e44cf7dec9b00f2bee3 (patch)
tree27cd4550429711dfdbcc60e83e12d01c5f4b9b03 /generic
parentc46f74289a79498f91f6bd70d409449bc6f00b41 (diff)
downloadtk-8d2dbe96066152901e507e44cf7dec9b00f2bee3.zip
tk-8d2dbe96066152901e507e44cf7dec9b00f2bee3.tar.gz
tk-8d2dbe96066152901e507e44cf7dec9b00f2bee3.tar.bz2
Change (internal) signature of TkMenuConfigureEntryDrawOptions/TkActivateMenuEntry such that - if compiled with Tcl 9.0 headers - indexes > 2G can be used.
Also, change a lot of Tcl_NewIntObj()/Tcl_NewBooleanObj() calls to Tcl_NewWideIntObj().
Diffstat (limited to 'generic')
-rw-r--r--generic/tkMacWinMenu.c2
-rw-r--r--generic/tkMain.c4
-rw-r--r--generic/tkMenu.c70
-rw-r--r--generic/tkMenu.h10
-rw-r--r--generic/tkMenuDraw.c11
-rw-r--r--generic/tkTest.c8
-rw-r--r--generic/tkWindow.c2
-rw-r--r--generic/ttk/ttkEntry.c4
-rw-r--r--generic/ttk/ttkTreeview.c4
-rw-r--r--generic/ttk/ttkWidget.c2
10 files changed, 58 insertions, 59 deletions
diff --git a/generic/tkMacWinMenu.c b/generic/tkMacWinMenu.c
index 9449838..e6b673c 100644
--- a/generic/tkMacWinMenu.c
+++ b/generic/tkMacWinMenu.c
@@ -66,7 +66,7 @@ PreprocessMenu(
do {
finished = 1;
- for (index = 0; index < menuPtr->numEntries; index++) {
+ for (index = 0; index < (int)menuPtr->numEntries; index++) {
register TkMenuEntry *entryPtr = menuPtr->entries[index];
if ((entryPtr->type == CASCADE_ENTRY)
diff --git a/generic/tkMain.c b/generic/tkMain.c
index e50b0f4..007903c 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -298,7 +298,7 @@ Tk_MainEx(
argc--;
argv++;
- Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewWideIntObj(argc), TCL_GLOBAL_ONLY);
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
@@ -325,7 +325,7 @@ Tk_MainEx(
}
#endif
Tcl_SetVar2Ex(interp, "tcl_interactive", NULL,
- Tcl_NewIntObj(!path && (is.tty || nullStdin)), TCL_GLOBAL_ONLY);
+ Tcl_NewWideIntObj(!path && (is.tty || nullStdin)), TCL_GLOBAL_ONLY);
/*
* Invoke application-specific initialization.
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index dd29d79..89b752d 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -357,7 +357,7 @@ static int MenuAddOrInsert(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *indexPtr, int objc,
Tcl_Obj *const objv[]);
static void MenuCmdDeletedProc(ClientData clientData);
-static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, int index, int type);
+static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, TkSizeT index, int type);
static char * MenuVarProc(ClientData clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
@@ -457,7 +457,7 @@ Tk_MenuObjCmd(
menuPtr->widgetCmd = Tcl_CreateObjCommand(interp,
Tk_PathName(menuPtr->tkwin), MenuWidgetObjCmd, menuPtr,
MenuCmdDeletedProc);
- menuPtr->active = -1;
+ menuPtr->active = (TkSizeT)-1;
menuPtr->cursorPtr = NULL;
menuPtr->masterMenuPtr = menuPtr;
menuPtr->menuType = UNKNOWN_TYPE;
@@ -648,7 +648,7 @@ MenuWidgetObjCmd(
if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (menuPtr->active == index) {
+ if ((int)menuPtr->active == index) {
goto done;
}
if ((index >= 0) && ((menuPtr->entries[index]->type==SEPARATOR_ENTRY)
@@ -737,7 +737,7 @@ MenuWidgetObjCmd(
if (isdigit(UCHAR(Tcl_GetString(objv[2])[0]))
&& Tcl_GetIntFromObj(NULL, objv[2], &first) == TCL_OK) {
- if (first >= menuPtr->numEntries) {
+ if (first >= (int)menuPtr->numEntries) {
goto done;
}
} else if (TkGetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){
@@ -839,10 +839,10 @@ MenuWidgetObjCmd(
if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == -1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
}
break;
}
@@ -1489,7 +1489,7 @@ MenuWorldChanged(
ClientData instanceData) /* Information about widget. */
{
TkMenu *menuPtr = instanceData;
- int i;
+ TkSizeT i;
TkMenuConfigureDrawOptions(menuPtr);
for (i = 0; i < menuPtr->numEntries; i++) {
@@ -1630,12 +1630,11 @@ ConfigureMenu(
Tcl_EventuallyFree(menuListPtr->entries[0], (Tcl_FreeProc *) DestroyMenuEntry);
- for (i = 0; i < menuListPtr->numEntries - 1; i++) {
+ for (i = 0; i < (int)menuListPtr->numEntries - 1; i++) {
menuListPtr->entries[i] = menuListPtr->entries[i + 1];
menuListPtr->entries[i]->index = i;
}
- menuListPtr->numEntries--;
- if (menuListPtr->numEntries == 0) {
+ if (--menuListPtr->numEntries == 0) {
ckfree(menuListPtr->entries);
menuListPtr->entries = NULL;
}
@@ -1650,7 +1649,7 @@ ConfigureMenu(
* parent.
*/
- for (i = 0; i < menuListPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuListPtr->numEntries; i++) {
TkMenuEntry *mePtr;
mePtr = menuListPtr->entries[i];
@@ -2148,7 +2147,7 @@ TkGetMenuIndex(
if (isdigit(UCHAR(string[0]))) {
if (Tcl_GetInt(interp, string, &i) == TCL_OK) {
- if (i >= menuPtr->numEntries) {
+ if (i >= (int)menuPtr->numEntries) {
if (lastOK) {
i = menuPtr->numEntries;
} else {
@@ -2163,7 +2162,7 @@ TkGetMenuIndex(
Tcl_ResetResult(interp);
}
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr;
const char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr);
@@ -2246,13 +2245,13 @@ MenuCmdDeletedProc(
static TkMenuEntry *
MenuNewEntry(
TkMenu *menuPtr, /* Menu that will hold the new entry. */
- int index, /* Where in the menu the new entry is to
+ TkSizeT index, /* Where in the menu the new entry is to
* go. */
int type) /* The type of the new entry. */
{
TkMenuEntry *mePtr;
TkMenuEntry **newEntries;
- int i;
+ TkSizeT i;
ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -2392,7 +2391,7 @@ MenuAddOrInsert(
}
if (ConfigureMenuEntry(mePtr, objc - 1, objv + 1) != TCL_OK) {
TkMenu *errorMenuPtr;
- int i;
+ TkSizeT i;
for (errorMenuPtr = menuPtr->masterMenuPtr;
errorMenuPtr != NULL;
@@ -2403,8 +2402,7 @@ MenuAddOrInsert(
errorMenuPtr->entries[i] = errorMenuPtr->entries[i + 1];
errorMenuPtr->entries[i]->index = i;
}
- errorMenuPtr->numEntries--;
- if (errorMenuPtr->numEntries == 0) {
+ if (--errorMenuPtr->numEntries == 0) {
ckfree(errorMenuPtr->entries);
errorMenuPtr->entries = NULL;
}
@@ -2588,13 +2586,13 @@ MenuVarProc(
int
TkActivateMenuEntry(
register TkMenu *menuPtr, /* Menu in which to activate. */
- int index) /* Index of entry to activate, or -1 to
- * deactivate all entries. */
+ TkSizeT index) /* Index of entry to activate, or
+ * TCL_INDEX_NONE to deactivate all entries. */
{
register TkMenuEntry *mePtr;
int result = TCL_OK;
- if (menuPtr->active >= 0) {
+ if (menuPtr->active != (TkSizeT)-1) {
mePtr = menuPtr->entries[menuPtr->active];
/*
@@ -2608,7 +2606,7 @@ TkActivateMenuEntry(
TkEventuallyRedrawMenu(menuPtr, menuPtr->entries[menuPtr->active]);
}
menuPtr->active = index;
- if (index >= 0) {
+ if (index != (TkSizeT)-1) {
mePtr = menuPtr->entries[index];
mePtr->state = ENTRY_ACTIVE;
TkEventuallyRedrawMenu(menuPtr, mePtr);
@@ -2799,7 +2797,7 @@ CloneMenu(
* Clone all of the cascade menus that this menu points to.
*/
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
TkMenuReferences *cascadeRefPtr;
TkMenu *oldCascadePtr;
@@ -2870,10 +2868,10 @@ MenuDoXPosition(
return TCL_ERROR;
}
Tcl_ResetResult(interp);
- if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
+ if (index == -1) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(menuPtr->entries[index]->x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(menuPtr->entries[index]->x));
}
return TCL_OK;
}
@@ -2907,10 +2905,10 @@ MenuDoYPosition(
goto error;
}
Tcl_ResetResult(interp);
- if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
+ if (index == -1) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(menuPtr->entries[index]->y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(menuPtr->entries[index]->y));
}
return TCL_OK;
@@ -2978,7 +2976,7 @@ GetIndexFromCoords(
? Tk_Width(menuPtr->tkwin) : Tk_ReqWidth(menuPtr->tkwin);
max -= borderwidth;
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
if (menuPtr->entries[i]->entryFlags & ENTRY_LAST_COLUMN) {
x2 = max;
} else {
@@ -3021,7 +3019,7 @@ static void
RecursivelyDeleteMenu(
TkMenu *menuPtr) /* The menubar instance we are deleting. */
{
- int i;
+ TkSizeT i;
TkMenuEntry *mePtr;
/*
@@ -3108,7 +3106,7 @@ TkNewMenuName(
Tcl_AppendToObj(resultPtr, ".", -1);
}
Tcl_AppendObjToObj(resultPtr, childPtr);
- intPtr = Tcl_NewIntObj(i);
+ intPtr = Tcl_NewWideIntObj(i);
Tcl_AppendObjToObj(resultPtr, intPtr);
Tcl_DecrRefCount(intPtr);
}
@@ -3525,7 +3523,7 @@ DeleteMenuCloneEntries(
for (i = last; i >= first; i--) {
Tcl_EventuallyFree(menuListPtr->entries[i], (Tcl_FreeProc *) DestroyMenuEntry);
}
- for (i = last + 1; i < menuListPtr->numEntries; i++) {
+ for (i = last + 1; i < (int)menuListPtr->numEntries; i++) {
j = i - numDeleted;
menuListPtr->entries[j] = menuListPtr->entries[i];
menuListPtr->entries[j]->index = j;
@@ -3535,10 +3533,10 @@ DeleteMenuCloneEntries(
ckfree(menuListPtr->entries);
menuListPtr->entries = NULL;
}
- if ((menuListPtr->active >= first)
- && (menuListPtr->active <= last)) {
+ if (((int)menuListPtr->active >= first)
+ && ((int)menuListPtr->active <= last)) {
menuListPtr->active = -1;
- } else if (menuListPtr->active > last) {
+ } else if ((int)menuListPtr->active > last) {
menuListPtr->active -= numDeleted;
}
TkEventuallyRecomputeMenu(menuListPtr);
diff --git a/generic/tkMenu.h b/generic/tkMenu.h
index 8e25059..5449879 100644
--- a/generic/tkMenu.h
+++ b/generic/tkMenu.h
@@ -267,9 +267,9 @@ typedef struct TkMenu {
Tcl_Command widgetCmd; /* Token for menu's widget command. */
TkMenuEntry **entries; /* Array of pointers to all the entries in the
* menu. NULL means no entries. */
- int numEntries; /* Number of elements in entries. */
- int active; /* Index of active entry. -1 means nothing
- * active. */
+ TkSizeT numEntries; /* Number of elements in entries. */
+ TkSizeT active; /* Index of active entry. TCL_INDEX_NONE means
+ * nothing active. */
int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR. See
* below for definitions. */
Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a
@@ -482,7 +482,7 @@ typedef struct TkMenuReferences {
* the outside world:
*/
-MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, int index);
+MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, TkSizeT index);
MODULE_SCOPE void TkBindMenu(Tk_Window tkwin, TkMenu *menuPtr);
MODULE_SCOPE TkMenuReferences*TkCreateMenuReferences(Tcl_Interp *interp,
const char *name);
@@ -503,7 +503,7 @@ MODULE_SCOPE int TkInvokeMenu(Tcl_Interp *interp, TkMenu *menuPtr,
int index);
MODULE_SCOPE void TkMenuConfigureDrawOptions(TkMenu *menuPtr);
MODULE_SCOPE int TkMenuConfigureEntryDrawOptions(
- TkMenuEntry *mePtr, int index);
+ TkMenuEntry *mePtr, TkSizeT index);
MODULE_SCOPE void TkMenuFreeDrawOptions(TkMenu *menuPtr);
MODULE_SCOPE void TkMenuEntryFreeDrawOptions(TkMenuEntry *mePtr);
MODULE_SCOPE void TkMenuEventProc(ClientData clientData,
diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c
index bd00d38..e3a1ef6 100644
--- a/generic/tkMenuDraw.c
+++ b/generic/tkMenuDraw.c
@@ -298,7 +298,7 @@ TkMenuConfigureDrawOptions(
int
TkMenuConfigureEntryDrawOptions(
TkMenuEntry *mePtr,
- int index)
+ TkSizeT index)
{
XGCValues gcValues;
GC newGC, newActiveGC, newDisabledGC, newIndicatorGC;
@@ -487,7 +487,7 @@ TkEventuallyRedrawMenu(
register TkMenuEntry *mePtr)/* Entry to redraw. NULL means redraw all the
* entries in the menu. */
{
- int i;
+ TkSizeT i;
if (menuPtr->tkwin == NULL) {
return;
@@ -618,7 +618,8 @@ DisplayMenu(
register TkMenu *menuPtr = clientData;
register TkMenuEntry *mePtr;
register Tk_Window tkwin = menuPtr->tkwin;
- int index, strictMotif;
+ TkSizeT index;
+ int strictMotif;
Tk_Font tkfont;
Tk_FontMetrics menuMetrics;
int width;
@@ -911,8 +912,8 @@ TkPostSubmenu(
menuPtr->postedCascade = mePtr;
subary[0] = mePtr->namePtr;
subary[1] = Tcl_NewStringObj("post", -1);
- subary[2] = Tcl_NewIntObj(x);
- subary[3] = Tcl_NewIntObj(y);
+ subary[2] = Tcl_NewWideIntObj(x);
+ subary[3] = Tcl_NewWideIntObj(y);
Tcl_IncrRefCount(subary[1]);
Tcl_IncrRefCount(subary[2]);
Tcl_IncrRefCount(subary[3]);
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 2061893..46a1a13 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -1212,7 +1212,7 @@ TrivialConfigObjCmd(
headerPtr->optionTable, objc - 2, objv + 2,
tkwin, NULL, &mask);
if (result == TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(mask));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(mask));
}
}
break;
@@ -1222,7 +1222,7 @@ TrivialConfigObjCmd(
tkwin, &saved, &mask);
Tk_FreeSavedOptions(&saved);
if (result == TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(mask));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(mask));
}
break;
}
@@ -2167,8 +2167,8 @@ TestPhotoStringMatchCmd(
return TCL_ERROR;
}
if (TkDebugPhotoStringMatchDef(interp, objv[1], dummy, &width, &height)) {
- resultObj[0] = Tcl_NewIntObj(width);
- resultObj[1] = Tcl_NewIntObj(height);
+ resultObj[0] = Tcl_NewWideIntObj(width);
+ resultObj[1] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, resultObj));
return TCL_OK;
} else {
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 3d91927..d8c2068 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -3170,7 +3170,7 @@ Initialize(
Tcl_SetVar2Ex(interp, "argv", NULL,
Tcl_NewListObj(objc-1, rest+1), TCL_GLOBAL_ONLY);
Tcl_SetVar2Ex(interp, "argc", NULL,
- Tcl_NewIntObj(objc-1), TCL_GLOBAL_ONLY);
+ Tcl_NewWideIntObj(objc-1), TCL_GLOBAL_ONLY);
ckfree(rest);
}
Tcl_DecrRefCount(parseList);
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 49b6553..3fc0c36 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -1605,7 +1605,7 @@ static int EntrySelectionPresentCommand(
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(entryPtr->entry.selectFirst >= 0));
+ Tcl_NewWideIntObj(entryPtr->entry.selectFirst >= 0));
return TCL_OK;
}
@@ -1682,7 +1682,7 @@ static int EntryValidateCommand(
if (code == TCL_ERROR)
return code;
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(code == TCL_OK));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(code == TCL_OK));
return TCL_OK;
}
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 48656f7..cc2c9e1 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -2144,7 +2144,7 @@ static int TreeviewExistsCommand(
}
entryPtr = Tcl_FindHashEntry(&tv->tree.items, Tcl_GetString(objv[2]));
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(entryPtr != 0));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(entryPtr != 0));
return TCL_OK;
}
@@ -3114,7 +3114,7 @@ static int TreeviewTagHasCommand(
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(Ttk_TagSetContains(item->tagset, tag)));
+ Tcl_NewWideIntObj(Ttk_TagSetContains(item->tagset, tag)));
return TCL_OK;
} else {
Tcl_WrongNumArgs(interp, 3, objv, "tagName ?item?");
diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c
index c2f8d60..70243bf 100644
--- a/generic/ttk/ttkWidget.c
+++ b/generic/ttk/ttkWidget.c
@@ -738,7 +738,7 @@ int TtkWidgetInstateCommand(
if (objc == 3) {
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(Ttk_StateMatches(state,&spec)));
+ Tcl_NewWideIntObj(Ttk_StateMatches(state,&spec)));
} else if (objc == 4) {
if (Ttk_StateMatches(state,&spec)) {
status = Tcl_EvalObjEx(interp, objv[3], 0);