diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-10-16 21:26:09 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-10-16 21:26:09 (GMT) |
commit | b3d0333c9f6dfac63a960f8a2d0b1ca836e46136 (patch) | |
tree | e7cceb20401dbebec2a9f916cd5a3ebe559f2c38 /generic | |
parent | 9dd1ecf775ca98d0b14666163def8d3571c4e71c (diff) | |
download | tk-b3d0333c9f6dfac63a960f8a2d0b1ca836e46136.zip tk-b3d0333c9f6dfac63a960f8a2d0b1ca836e46136.tar.gz tk-b3d0333c9f6dfac63a960f8a2d0b1ca836e46136.tar.bz2 |
Another round of (internal) int|long -> size_t replacements, at least when compiling against Tcl 9.0 headers.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkInt.h | 6 | ||||
-rw-r--r-- | generic/tkObj.c | 6 | ||||
-rw-r--r-- | generic/tkText.c | 2 | ||||
-rw-r--r-- | generic/tkText.h | 14 | ||||
-rw-r--r-- | generic/tkTextBTree.c | 4 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 13 | ||||
-rw-r--r-- | generic/tkTextIndex.c | 6 |
7 files changed, 32 insertions, 19 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h index 849781f..c5231ea 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -597,7 +597,11 @@ typedef struct TkMainInfo { Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow * structs for all windows related to this * main window. Managed by tkWindow.c. */ - long deletionEpoch; /* Incremented by window deletions. */ +#if TCL_MAJOR_VERSION > 8 + size_t deletionEpoch; /* Incremented by window deletions. */ +#else + long deletionEpoch; +#endif Tk_BindingTable bindingTable; /* Used in conjunction with "bind" command to * bind events to Tcl commands. */ diff --git a/generic/tkObj.c b/generic/tkObj.c index 1355aad..b857d98 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -73,8 +73,12 @@ typedef struct MMRep { typedef struct WindowRep { Tk_Window tkwin; /* Cached window; NULL if not found. */ TkMainInfo *mainPtr; /* MainWindow associated with tkwin. */ - long epoch; /* Value of mainPtr->deletionEpoch at last +#if TCL_MAJOR_VERSION > 8 + size_t epoch; /* Value of mainPtr->deletionEpoch at last * successful lookup. */ +#else + long epoch; +#endif } WindowRep; /* diff --git a/generic/tkText.c b/generic/tkText.c index 81551f6..8225e3d 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5076,7 +5076,7 @@ DumpSegment( Tcl_DecrRefCount(tuple); return 0; } else { - int oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree); + TkSizeT oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree); Tcl_DString buf; int code; diff --git a/generic/tkText.h b/generic/tkText.h index 430c96b..44e2ad9 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -532,8 +532,14 @@ typedef enum { * that are peers. */ +#if TCL_MAJOR_VERSION > 8 +#define TkSizeT size_t +#else +#define TkSizeT int +#endif + typedef struct TkSharedText { - int refCount; /* Reference count this shared object. */ + TkSizeT refCount; /* Reference count this shared object. */ TkTextBTree tree; /* B-tree representation of text and tags for * widget. */ Tcl_HashTable tagTable; /* Hash table that maps from tag names to @@ -562,7 +568,7 @@ typedef struct TkSharedText { * exist, so the table hasn't been created. * Each "object" used for this table is the * name of a tag. */ - int stateEpoch; /* This is incremented each time the B-tree's + TkSizeT stateEpoch; /* This is incremented each time the B-tree's * contents change structurally, or when the * start/end limits change, and means that any * cached TkTextIndex objects are no longer @@ -783,7 +789,7 @@ typedef struct TkText { * definitions. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ - int refCount; /* Number of cached TkTextIndex objects + TkSizeT refCount; /* Number of cached TkTextIndex objects * refering to us. */ int insertCursorType; /* 0 = standard insertion cursor, 1 = block * cursor. */ @@ -1009,7 +1015,7 @@ MODULE_SCOPE void TkBTreeRemoveClient(TkTextBTree tree, MODULE_SCOPE void TkBTreeDestroy(TkTextBTree tree); MODULE_SCOPE void TkBTreeDeleteIndexRange(TkTextBTree tree, TkTextIndex *index1Ptr, TkTextIndex *index2Ptr); -MODULE_SCOPE int TkBTreeEpoch(TkTextBTree tree); +MODULE_SCOPE TkSizeT TkBTreeEpoch(TkTextBTree tree); MODULE_SCOPE TkTextLine *TkBTreeFindLine(TkTextBTree tree, const TkText *textPtr, int line); MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree, diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 1ae04ea..66fa140 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -105,7 +105,7 @@ typedef struct BTree { int clients; /* Number of clients of this B-tree. */ int pixelReferences; /* Number of clients of this B-tree which care * about pixel heights. */ - int stateEpoch; /* Updated each time any aspect of the B-tree + TkSizeT stateEpoch; /* Updated each time any aspect of the B-tree * changes. */ TkSharedText *sharedTextPtr;/* Used to find tagTable in consistency * checking code, and to access list of all @@ -501,7 +501,7 @@ TkBTreeDestroy( *---------------------------------------------------------------------- */ -int +TkSizeT TkBTreeEpoch( TkTextBTree tree) /* Tree to get epoch for. */ { diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 965f1a4..9f0d7e0 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -162,7 +162,7 @@ typedef struct StyleValues { */ typedef struct TextStyle { - int refCount; /* Number of times this structure is + TkSizeT refCount; /* Number of times this structure is * referenced in Chunks. */ GC bgGC; /* Graphics context for background. None means * use widget background. */ @@ -400,7 +400,7 @@ typedef struct TextDInfo { * to so far... */ int metricPixelHeight; /* ...and this is for the height calculation * so far...*/ - int metricEpoch; /* ...and this for the epoch of the partial + TkSizeT metricEpoch; /* ...and this for the epoch of the partial * calculation so it can be cancelled if * things change once more. This field will be * -1 if there is no long-line calculation in @@ -1052,8 +1052,7 @@ FreeStyle( register TextStyle *stylePtr) /* Information about style to free. */ { - stylePtr->refCount--; - if (stylePtr->refCount == 0) { + if (stylePtr->refCount-- <= 1) { if (stylePtr->bgGC != None) { Tk_FreeGC(textPtr->display, stylePtr->bgGC); } @@ -3044,7 +3043,7 @@ AsyncUpdateLineMetrics( * and we've reached the last line, then we're done. */ - if (dInfoPtr->metricEpoch == -1 + if (dInfoPtr->metricEpoch == TCL_AUTO_LENGTH && lineNum == dInfoPtr->lastMetricUpdateLine) { /* * We have looped over all lines, so we're done. We must release our @@ -3194,7 +3193,7 @@ TkTextUpdateLineMetrics( * then we can't be done. */ - if (textPtr->dInfoPtr->metricEpoch == -1 && lineNum == endLine) { + if (textPtr->dInfoPtr->metricEpoch == TCL_AUTO_LENGTH && lineNum == endLine) { /* * We have looped over all lines, so we're done. */ @@ -6258,7 +6257,7 @@ TkTextPendingsync( TextDInfo *dInfoPtr = textPtr->dInfoPtr; return ( - ((dInfoPtr->metricEpoch == -1) && + ((dInfoPtr->metricEpoch == TCL_AUTO_LENGTH) && (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ? 0 : 1); } diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index bfef403..2870c07 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -64,7 +64,7 @@ static void UpdateStringOfTextIndex(Tcl_Obj *objPtr); #define SET_TEXTINDEX(objPtr, indexPtr) \ ((objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (indexPtr)) #define SET_INDEXEPOCH(objPtr, epoch) \ - ((objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(epoch)) + ((objPtr)->internalRep.twoPtrValue.ptr2 = (void *) (size_t) (epoch)) /* * Define the 'textindex' object type, which Tk uses to represent indices in @@ -104,7 +104,7 @@ DupTextIndexInternalRep( Tcl_Obj *srcPtr, /* TextIndex obj with internal rep to copy. */ Tcl_Obj *copyPtr) /* TextIndex obj with internal rep to set. */ { - int epoch; + TkSizeT epoch; TkTextIndex *dupIndexPtr, *indexPtr; dupIndexPtr = ckalloc(sizeof(TkTextIndex)); @@ -206,7 +206,7 @@ TkTextGetIndexFromObj( int cache; if (objPtr->typePtr == &tkTextIndexType) { - int epoch; + TkSizeT epoch; indexPtr = GET_TEXTINDEX(objPtr); epoch = GET_INDEXEPOCH(objPtr); |