summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-02-13 09:57:07 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-02-13 09:57:07 (GMT)
commit4a1828d3e7f328cce5d6b770ffbb6ea5a5373d0c (patch)
treeee4d9a63fa953072901b6d76880e60f81266dd78
parent58dee83cb742162ddda8b91eb7a8132aebaa68b4 (diff)
downloadtk-4a1828d3e7f328cce5d6b770ffbb6ea5a5373d0c.zip
tk-4a1828d3e7f328cce5d6b770ffbb6ea5a5373d0c.tar.gz
tk-4a1828d3e7f328cce5d6b770ffbb6ea5a5373d0c.tar.bz2
Make tk.h work unchanged with Tcl 9.0 (novem), account for possible missing TCL_STORAGE_CLASS definition. More internal use of size_t in stead of int.
-rw-r--r--generic/tk.h4
-rw-r--r--generic/tkCmds.c7
-rw-r--r--generic/tkGC.c5
-rw-r--r--generic/tkImgBmap.c5
-rw-r--r--generic/tkVisual.c13
-rw-r--r--unix/tkUnixWm.c28
6 files changed, 29 insertions, 33 deletions
diff --git a/generic/tk.h b/generic/tk.h
index 1d070d3..1cb10e2 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -105,6 +105,10 @@ extern "C" {
#ifdef BUILD_tk
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
+#else
+# ifndef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLIMPORT
+# endif
#endif
/*
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index 6196b17..93c1fb0 100644
--- a/generic/tkCmds.c
+++ b/generic/tkCmds.c
@@ -2068,14 +2068,13 @@ TkGetDisplayOf(
* present. */
{
const char *string;
- int length;
if (objc < 1) {
return 0;
}
- string = Tcl_GetStringFromObj(objv[0], &length);
- if ((length >= 2) &&
- (strncmp(string, "-displayof", (unsigned) length) == 0)) {
+ string = Tcl_GetString(objv[0]);
+ if ((objv[0]->length >= 2) &&
+ (strncmp(string, "-displayof", objv[0]->length) == 0)) {
if (objc < 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"value for \"-displayof\" missing", -1));
diff --git a/generic/tkGC.c b/generic/tkGC.c
index c424e30..55e5774 100644
--- a/generic/tkGC.c
+++ b/generic/tkGC.c
@@ -23,7 +23,7 @@
typedef struct {
GC gc; /* Graphics context. */
Display *display; /* Display to which gc belongs. */
- int refCount; /* Number of active uses of gc. */
+ size_t refCount; /* Number of active uses of gc. */
Tcl_HashEntry *valueHashPtr;/* Entry in valueTable (needed when deleting
* this structure). */
} TkGC;
@@ -312,8 +312,7 @@ Tk_FreeGC(
Tcl_Panic("Tk_FreeGC received unknown gc argument");
}
gcPtr = Tcl_GetHashValue(idHashPtr);
- gcPtr->refCount--;
- if (gcPtr->refCount == 0) {
+ if (gcPtr->refCount-- <= 1) {
XFreeGC(gcPtr->display, gcPtr->gc);
Tcl_DeleteHashEntry(gcPtr->valueHashPtr);
Tcl_DeleteHashEntry(idHashPtr);
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c
index 0906673..1a9a86e 100644
--- a/generic/tkImgBmap.c
+++ b/generic/tkImgBmap.c
@@ -49,7 +49,7 @@ typedef struct BitmapMaster {
*/
typedef struct BitmapInstance {
- int refCount; /* Number of instances that share this data
+ size_t refCount; /* Number of instances that share this data
* structure. */
BitmapMaster *masterPtr; /* Pointer to master for image. */
Tk_Window tkwin; /* Window in which the instances will be
@@ -951,8 +951,7 @@ ImgBmapFree(
BitmapInstance *instancePtr = clientData;
BitmapInstance *prevPtr;
- instancePtr->refCount--;
- if (instancePtr->refCount > 0) {
+ if (instancePtr->refCount-- > 1) {
return;
}
diff --git a/generic/tkVisual.c b/generic/tkVisual.c
index 8b0c155..6f6816d 100644
--- a/generic/tkVisual.c
+++ b/generic/tkVisual.c
@@ -46,7 +46,7 @@ static const VisualDictionary visualNames[] = {
struct TkColormap {
Colormap colormap; /* X's identifier for the colormap. */
Visual *visual; /* Visual for which colormap was allocated. */
- int refCount; /* How many uses of the colormap are still
+ size_t refCount; /* How many uses of the colormap are still
* outstanding (calls to Tk_GetColormap minus
* calls to Tk_FreeColormap). */
int shareable; /* 0 means this colormap was allocated by a
@@ -137,7 +137,7 @@ Tk_GetVisual(
for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL;
cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->colormap == *colormapPtr) {
- cmapPtr->refCount += 1;
+ cmapPtr->refCount++;
break;
}
}
@@ -324,7 +324,7 @@ Tk_GetVisual(
cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->shareable && (cmapPtr->visual == visual)) {
*colormapPtr = cmapPtr->colormap;
- cmapPtr->refCount += 1;
+ cmapPtr->refCount++;
goto done;
}
}
@@ -427,7 +427,7 @@ Tk_GetColormap(
for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL;
cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->colormap == colormap) {
- cmapPtr->refCount += 1;
+ cmapPtr->refCount++;
}
}
return colormap;
@@ -476,8 +476,7 @@ Tk_FreeColormap(
for (prevPtr = NULL, cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL;
prevPtr = cmapPtr, cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->colormap == colormap) {
- cmapPtr->refCount -= 1;
- if (cmapPtr->refCount == 0) {
+ if (cmapPtr->refCount-- <= 1) {
XFreeColormap(display, colormap);
if (prevPtr == NULL) {
dispPtr->cmapPtr = cmapPtr->nextPtr;
@@ -534,7 +533,7 @@ Tk_PreserveColormap(
for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL;
cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->colormap == colormap) {
- cmapPtr->refCount += 1;
+ cmapPtr->refCount++;
return;
}
}
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index 19ac86c..68ab6d6 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -1033,7 +1033,7 @@ Tk_WmObjCmd(
WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM,
WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM, WMOPT_STACKORDER,
WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT, WMOPT_WITHDRAW };
- int index, length;
+ int index;
const char *argv1;
TkWindow *winPtr;
Tk_Window targetWin;
@@ -1045,9 +1045,9 @@ Tk_WmObjCmd(
return TCL_ERROR;
}
- argv1 = Tcl_GetStringFromObj(objv[1], &length);
- if ((argv1[0] == 't') && (strncmp(argv1, "tracing", (size_t) length) == 0)
- && (length >= 3)) {
+ argv1 = Tcl_GetString(objv[1]);
+ if ((argv1[0] == 't') && (strncmp(argv1, "tracing", objv[1]->length) == 0)
+ && (objv[1]->length >= 3)) {
int wmTracing;
if ((objc != 2) && (objc != 3)) {
@@ -1457,7 +1457,6 @@ WmClientCmd(
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- int length;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?name?");
@@ -1470,7 +1469,7 @@ WmClientCmd(
}
return TCL_OK;
}
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
+ argv3 = Tcl_GetString(objv[3]);
if (argv3[0] == 0) {
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
@@ -1486,7 +1485,7 @@ WmClientCmd(
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
}
- wmPtr->clientMachine = ckalloc(length + 1);
+ wmPtr->clientMachine = ckalloc(objv[3]->length + 1);
strcpy(wmPtr->clientMachine, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XTextProperty textProp;
@@ -2072,7 +2071,6 @@ WmGroupCmd(
Tk_Window tkwin2;
WmInfo *wmPtr2;
const char *argv3;
- int length;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?");
@@ -2084,7 +2082,7 @@ WmGroupCmd(
}
return TCL_OK;
}
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
+ argv3 = Tcl_GetString(objv[3]);
if (*argv3 == '\0') {
wmPtr->hints.flags &= ~WindowGroupHint;
if (wmPtr->leaderName != NULL) {
@@ -2112,7 +2110,7 @@ WmGroupCmd(
}
wmPtr->hints.window_group = Tk_WindowId(wmPtr2->wrapperPtr);
wmPtr->hints.flags |= WindowGroupHint;
- wmPtr->leaderName = ckalloc(length + 1);
+ wmPtr->leaderName = ckalloc(objv[3]->length + 1);
strcpy(wmPtr->leaderName, argv3);
}
UpdateHints(winPtr);
@@ -2334,7 +2332,6 @@ WmIconnameCmd(
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- int length;
if (objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?");
@@ -2349,8 +2346,8 @@ WmIconnameCmd(
if (wmPtr->iconName != NULL) {
ckfree(wmPtr->iconName);
}
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->iconName = ckalloc(length + 1);
+ argv3 = Tcl_GetString(objv[3]);
+ wmPtr->iconName = ckalloc(objv[3]->length + 1);
strcpy(wmPtr->iconName, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
UpdateTitle(winPtr);
@@ -3471,7 +3468,6 @@ WmTitleCmd(
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- int length;
if (objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?");
@@ -3487,8 +3483,8 @@ WmTitleCmd(
if (wmPtr->title != NULL) {
ckfree(wmPtr->title);
}
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->title = ckalloc(length + 1);
+ argv3 = Tcl_GetString(objv[3]);
+ wmPtr->title = ckalloc(objv[3]->length + 1);
strcpy(wmPtr->title, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {