summaryrefslogtreecommitdiffstats
path: root/generic/tkTextBTree.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkTextBTree.c')
-rw-r--r--generic/tkTextBTree.c309
1 files changed, 151 insertions, 158 deletions
diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c
index 81e31dc..fba26b9 100644
--- a/generic/tkTextBTree.c
+++ b/generic/tkTextBTree.c
@@ -140,9 +140,9 @@ int tkBTreeDebug = 0;
* Macros that determine how much space to allocate for new segments:
*/
-#define CSEG_SIZE(chars) ((unsigned) (Tk_Offset(TkTextSegment, body) \
+#define CSEG_SIZE(chars) ((unsigned)(Tk_Offset(TkTextSegment, body) \
+ 1 + (chars)))
-#define TSEG_SIZE ((unsigned) (Tk_Offset(TkTextSegment, body) \
+#define TSEG_SIZE ((unsigned)(Tk_Offset(TkTextSegment, body) \
+ sizeof(TkTextToggle)))
/*
@@ -261,10 +261,10 @@ TkTextBTree
TkBTreeCreate(
TkSharedText *sharedTextPtr)
{
- register BTree *treePtr;
- register Node *rootPtr;
- register TkTextLine *linePtr, *linePtr2;
- register TkTextSegment *segPtr;
+ BTree *treePtr;
+ Node *rootPtr;
+ TkTextLine *linePtr, *linePtr2;
+ TkTextSegment *segPtr;
/*
* The tree will initially have two empty lines. The second line isn't
@@ -273,9 +273,9 @@ TkBTreeCreate(
* of the tree.
*/
- rootPtr = ckalloc(sizeof(Node));
- linePtr = ckalloc(sizeof(TkTextLine));
- linePtr2 = ckalloc(sizeof(TkTextLine));
+ rootPtr = (Node *)ckalloc(sizeof(Node));
+ linePtr = (TkTextLine *)ckalloc(sizeof(TkTextLine));
+ linePtr2 = (TkTextLine *)ckalloc(sizeof(TkTextLine));
rootPtr->parentPtr = NULL;
rootPtr->nextPtr = NULL;
@@ -296,7 +296,7 @@ TkBTreeCreate(
linePtr->parentPtr = rootPtr;
linePtr->nextPtr = linePtr2;
- segPtr = ckalloc(CSEG_SIZE(1));
+ segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(1));
linePtr->segPtr = segPtr;
segPtr->typePtr = &tkTextCharType;
segPtr->nextPtr = NULL;
@@ -306,7 +306,7 @@ TkBTreeCreate(
linePtr2->parentPtr = rootPtr;
linePtr2->nextPtr = NULL;
- segPtr = ckalloc(CSEG_SIZE(1));
+ segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(1));
linePtr2->segPtr = segPtr;
segPtr->typePtr = &tkTextCharType;
segPtr->nextPtr = NULL;
@@ -314,7 +314,7 @@ TkBTreeCreate(
segPtr->body.chars[0] = '\n';
segPtr->body.chars[1] = 0;
- treePtr = ckalloc(sizeof(BTree));
+ treePtr = (BTree *)ckalloc(sizeof(BTree));
treePtr->sharedTextPtr = sharedTextPtr;
treePtr->rootPtr = rootPtr;
treePtr->clients = 0;
@@ -366,7 +366,7 @@ TkBTreeAddClient(
int defaultHeight) /* Default line height for the new client, or
* -1 if no pixel heights are to be kept. */
{
- register BTree *treePtr = (BTree *) tree;
+ BTree *treePtr = (BTree *) tree;
if (treePtr == NULL) {
Tcl_Panic("NULL treePtr in TkBTreeAddClient");
@@ -632,9 +632,9 @@ AdjustStartEndRefs(
i++;
}
treePtr->startEndCount = count;
- treePtr->startEnd = ckrealloc(treePtr->startEnd,
+ treePtr->startEnd = (TkTextLine **)ckrealloc(treePtr->startEnd,
sizeof(TkTextLine *) * count);
- treePtr->startEndRef = ckrealloc(treePtr->startEndRef,
+ treePtr->startEndRef = (TkText **)ckrealloc(treePtr->startEndRef,
sizeof(TkText *) * count);
}
if ((action & TEXT_ADD_REFS)
@@ -650,9 +650,9 @@ AdjustStartEndRefs(
count = treePtr->startEndCount;
- treePtr->startEnd = ckrealloc(treePtr->startEnd,
+ treePtr->startEnd = (TkTextLine **)ckrealloc(treePtr->startEnd,
sizeof(TkTextLine *) * count);
- treePtr->startEndRef = ckrealloc(treePtr->startEndRef,
+ treePtr->startEndRef = (TkText **)ckrealloc(treePtr->startEndRef,
sizeof(TkText *) * count);
if (textPtr->start != NULL) {
@@ -725,7 +725,7 @@ AdjustPixelClient(
loopPtr = loopPtr->nextPtr;
}
} else {
- register TkTextLine *linePtr = nodePtr->children.linePtr;
+ TkTextLine *linePtr = nodePtr->children.linePtr;
while (linePtr != NULL) {
if (!*counting && (linePtr == start)) {
@@ -735,7 +735,7 @@ AdjustPixelClient(
*counting = 0;
}
if (newPixelReferences != treePtr->pixelReferences) {
- linePtr->pixels = ckrealloc(linePtr->pixels,
+ linePtr->pixels = (int *)ckrealloc(linePtr->pixels,
sizeof(int) * 2 * newPixelReferences);
}
@@ -752,7 +752,7 @@ AdjustPixelClient(
}
}
if (newPixelReferences != treePtr->pixelReferences) {
- nodePtr->numPixels = ckrealloc(nodePtr->numPixels,
+ nodePtr->numPixels = (int *)ckrealloc(nodePtr->numPixels,
sizeof(int) * newPixelReferences);
}
nodePtr->numPixels[useReference] = pixelCount;
@@ -802,7 +802,7 @@ RemovePixelClient(
ckfree(nodePtr->numPixels);
nodePtr->numPixels = NULL;
} else {
- nodePtr->numPixels = ckrealloc(nodePtr->numPixels,
+ nodePtr->numPixels = (int *)ckrealloc(nodePtr->numPixels,
sizeof(int) * (treePtr->pixelReferences - 1));
}
if (nodePtr->level != 0) {
@@ -812,7 +812,7 @@ RemovePixelClient(
nodePtr = nodePtr->nextPtr;
}
} else {
- register TkTextLine *linePtr = nodePtr->children.linePtr;
+ TkTextLine *linePtr = nodePtr->children.linePtr;
while (linePtr != NULL) {
if (overwriteWithLast != -1) {
linePtr->pixels[2*overwriteWithLast] =
@@ -823,7 +823,7 @@ RemovePixelClient(
if (treePtr->pixelReferences == 1) {
linePtr->pixels = NULL;
} else {
- linePtr->pixels = ckrealloc(linePtr->pixels,
+ linePtr->pixels = (int *)ckrealloc(linePtr->pixels,
sizeof(int) * 2 * (treePtr->pixelReferences-1));
}
linePtr = linePtr->nextPtr;
@@ -850,7 +850,7 @@ RemovePixelClient(
static void
DestroyNode(
- register Node *nodePtr) /* Destroy from this node downwards. */
+ Node *nodePtr) /* Destroy from this node downwards. */
{
if (nodePtr->level == 0) {
TkTextLine *linePtr;
@@ -868,7 +868,7 @@ DestroyNode(
ckfree(linePtr);
}
} else {
- register Node *childPtr;
+ Node *childPtr;
while (nodePtr->children.nodePtr != NULL) {
childPtr = nodePtr->children.nodePtr;
@@ -900,10 +900,10 @@ DestroyNode(
static void
DeleteSummaries(
- register Summary *summaryPtr)
+ Summary *summaryPtr)
/* First in list of node's tag summaries. */
{
- register Summary *nextPtr;
+ Summary *nextPtr;
while (summaryPtr != NULL) {
nextPtr = summaryPtr->nextPtr;
@@ -932,7 +932,7 @@ DeleteSummaries(
int
TkBTreeAdjustPixelHeight(
const TkText *textPtr, /* Client of the B-tree. */
- register TkTextLine *linePtr,
+ TkTextLine *linePtr,
/* The logical line to update. */
int newPixelHeight, /* The line's known height in pixels. */
int mergedLogicalLines) /* The number of extra logical lines which
@@ -942,7 +942,7 @@ TkBTreeAdjustPixelHeight(
* height associated with the given
* linePtr. */
{
- register Node *nodePtr;
+ Node *nodePtr;
int changeToPixelCount; /* Counts change to total number of pixels in
* file. */
int pixelReference = textPtr->pixelReference;
@@ -1001,7 +1001,7 @@ TkBTreeAdjustPixelHeight(
void
TkBTreeInsertChars(
TkTextBTree tree, /* Tree to insert into. */
- register TkTextIndex *indexPtr,
+ TkTextIndex *indexPtr,
/* Indicates where to insert text. When the
* function returns, this index is no longer
* valid because of changes to the segment
@@ -1009,8 +1009,8 @@ TkBTreeInsertChars(
const char *string) /* Pointer to bytes to insert (may contain
* newlines, must be null-terminated). */
{
- register Node *nodePtr;
- register TkTextSegment *prevPtr;
+ Node *nodePtr;
+ TkTextSegment *prevPtr;
/* The segment just before the first new
* segment (NULL means new segment is at
* beginning of line). */
@@ -1019,10 +1019,10 @@ TkBTreeInsertChars(
* insert at beginning of line. */
TkTextLine *linePtr; /* Current line (new segments are added to
* this line). */
- register TkTextSegment *segPtr;
+ TkTextSegment *segPtr;
TkTextLine *newLinePtr;
int chunkSize; /* # characters in current chunk. */
- register const char *eol; /* Pointer to character just after last one in
+ const char *eol; /* Pointer to character just after last one in
* current chunk. */
int changeToLineCount; /* Counts change to total number of lines in
* file. */
@@ -1044,7 +1044,7 @@ TkBTreeInsertChars(
changeToLineCount = 0;
if (treePtr->pixelReferences > PIXEL_CLIENTS) {
- changeToPixelCount = ckalloc(sizeof(int) * treePtr->pixelReferences);
+ changeToPixelCount = (int *)ckalloc(sizeof(int) * treePtr->pixelReferences);
} else {
changeToPixelCount = pixels;
}
@@ -1060,7 +1060,7 @@ TkBTreeInsertChars(
}
}
chunkSize = eol-string;
- segPtr = ckalloc(CSEG_SIZE(chunkSize));
+ segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(chunkSize));
segPtr->typePtr = &tkTextCharType;
if (curPtr == NULL) {
segPtr->nextPtr = linePtr->segPtr;
@@ -1070,7 +1070,7 @@ TkBTreeInsertChars(
curPtr->nextPtr = segPtr;
}
segPtr->size = chunkSize;
- memcpy(segPtr->body.chars, string, (size_t) chunkSize);
+ memcpy(segPtr->body.chars, string, (size_t)chunkSize);
segPtr->body.chars[chunkSize] = 0;
if (eol[-1] != '\n') {
@@ -1082,8 +1082,8 @@ TkBTreeInsertChars(
* the remainder of the old line to it.
*/
- newLinePtr = ckalloc(sizeof(TkTextLine));
- newLinePtr->pixels =
+ newLinePtr = (TkTextLine *)ckalloc(sizeof(TkTextLine));
+ newLinePtr->pixels = (int *)
ckalloc(sizeof(int) * 2 * treePtr->pixelReferences);
newLinePtr->parentPtr = linePtr->parentPtr;
@@ -1312,10 +1312,10 @@ CleanupLine(
void
TkBTreeDeleteIndexRange(
TkTextBTree tree, /* Tree to delete from. */
- register TkTextIndex *index1Ptr,
+ TkTextIndex *index1Ptr,
/* Indicates first character that is to be
* deleted. */
- register TkTextIndex *index2Ptr)
+ TkTextIndex *index2Ptr)
/* Indicates character just after the last one
* that is to be deleted. */
{
@@ -1596,8 +1596,8 @@ TkBTreeFindLine(
int line) /* Index of desired line. */
{
BTree *treePtr = (BTree *) tree;
- register Node *nodePtr;
- register TkTextLine *linePtr;
+ Node *nodePtr;
+ TkTextLine *linePtr;
if (treePtr == NULL) {
treePtr = (BTree *) textPtr->sharedTextPtr->tree;
@@ -1686,8 +1686,8 @@ TkBTreeFindPixelLine(
int *pixelOffset) /* Used to return offset. */
{
BTree *treePtr = (BTree *) tree;
- register Node *nodePtr;
- register TkTextLine *linePtr;
+ Node *nodePtr;
+ TkTextLine *linePtr;
int pixelReference = textPtr->pixelReference;
nodePtr = treePtr->rootPtr;
@@ -1755,10 +1755,10 @@ TkBTreeFindPixelLine(
TkTextLine *
TkBTreeNextLine(
const TkText *textPtr, /* Next line in the context of this client. */
- register TkTextLine *linePtr)
+ TkTextLine *linePtr)
/* Pointer to existing line in B-tree. */
{
- register Node *nodePtr;
+ Node *nodePtr;
if (linePtr->nextPtr != NULL) {
if (textPtr != NULL && (linePtr == textPtr->end)) {
@@ -1811,12 +1811,12 @@ TkBTreeNextLine(
TkTextLine *
TkBTreePreviousLine(
TkText *textPtr, /* Relative to this client of the B-tree. */
- register TkTextLine *linePtr)
+ TkTextLine *linePtr)
/* Pointer to existing line in B-tree. */
{
- register Node *nodePtr;
- register Node *node2Ptr;
- register TkTextLine *prevPtr;
+ Node *nodePtr;
+ Node *node2Ptr;
+ TkTextLine *prevPtr;
if (textPtr != NULL && textPtr->start == linePtr) {
return NULL;
@@ -1895,8 +1895,8 @@ TkBTreePixelsTo(
const TkText *textPtr, /* Relative to this client of the B-tree. */
TkTextLine *linePtr) /* Pointer to existing line in B-tree. */
{
- register TkTextLine *linePtr2;
- register Node *nodePtr, *parentPtr;
+ TkTextLine *linePtr2;
+ Node *nodePtr, *parentPtr;
int index;
int pixelReference = textPtr->pixelReference;
@@ -1921,7 +1921,7 @@ TkBTreePixelsTo(
for (parentPtr = nodePtr->parentPtr ; parentPtr != NULL;
nodePtr = parentPtr, parentPtr = parentPtr->parentPtr) {
- register Node *nodePtr2;
+ Node *nodePtr2;
for (nodePtr2 = parentPtr->children.nodePtr; nodePtr2 != nodePtr;
nodePtr2 = nodePtr2->nextPtr) {
@@ -1957,8 +1957,8 @@ TkBTreeLinesTo(
const TkText *textPtr, /* Relative to this client of the B-tree. */
TkTextLine *linePtr) /* Pointer to existing line in B-tree. */
{
- register TkTextLine *linePtr2;
- register Node *nodePtr, *parentPtr, *nodePtr2;
+ TkTextLine *linePtr2;
+ Node *nodePtr, *parentPtr, *nodePtr2;
int index;
/*
@@ -2037,7 +2037,6 @@ TkBTreeLinesTo(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
void
TkBTreeLinkSegment(
TkTextSegment *segPtr, /* Pointer to new segment to be added to
@@ -2046,7 +2045,7 @@ TkBTreeLinkSegment(
TkTextIndex *indexPtr) /* Where to add segment: it gets linked in
* just before the segment indicated here. */
{
- register TkTextSegment *prevPtr;
+ TkTextSegment *prevPtr;
prevPtr = SplitSeg(indexPtr);
if (prevPtr == NULL) {
@@ -2080,13 +2079,12 @@ TkBTreeLinkSegment(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
void
TkBTreeUnlinkSegment(
TkTextSegment *segPtr, /* Segment to be unlinked. */
TkTextLine *linePtr) /* Line that currently contains segment. */
{
- register TkTextSegment *prevPtr;
+ TkTextSegment *prevPtr;
if (linePtr->segPtr == segPtr) {
linePtr->segPtr = segPtr->nextPtr;
@@ -2135,9 +2133,9 @@ TkBTreeUnlinkSegment(
int
TkBTreeTag(
- register TkTextIndex *index1Ptr,
+ TkTextIndex *index1Ptr,
/* Indicates first character in range. */
- register TkTextIndex *index2Ptr,
+ TkTextIndex *index2Ptr,
/* Indicates character just after the last one
* in range. */
TkTextTag *tagPtr, /* Tag to add or remove. */
@@ -2157,7 +2155,7 @@ TkBTreeTag(
oldState = TkBTreeCharTagged(index1Ptr, tagPtr);
if ((add != 0) ^ oldState) {
- segPtr = ckalloc(TSEG_SIZE);
+ segPtr = (TkTextSegment *)ckalloc(TSEG_SIZE);
segPtr->typePtr = (add) ? &tkTextToggleOnType : &tkTextToggleOffType;
prevPtr = SplitSeg(index1Ptr);
if (prevPtr == NULL) {
@@ -2228,7 +2226,7 @@ TkBTreeTag(
}
}
if ((add != 0) ^ oldState) {
- segPtr = ckalloc(TSEG_SIZE);
+ segPtr = (TkTextSegment *)ckalloc(TSEG_SIZE);
segPtr->typePtr = (add) ? &tkTextToggleOffType : &tkTextToggleOnType;
prevPtr = SplitSeg(index2Ptr);
if (prevPtr == NULL) {
@@ -2285,14 +2283,14 @@ TkBTreeTag(
static void
ChangeNodeToggleCount(
- register Node *nodePtr, /* Node whose toggle count for a tag must be
+ Node *nodePtr, /* Node whose toggle count for a tag must be
* changed. */
TkTextTag *tagPtr, /* Information about tag. */
int delta) /* Amount to add to current toggle count for
* tag (may be negative). */
{
- register Summary *summaryPtr, *prevPtr;
- register Node *node2Ptr;
+ Summary *summaryPtr, *prevPtr;
+ Node *node2Ptr;
int rootLevel; /* Level of original tag root. */
tagPtr->toggleCount += delta;
@@ -2372,7 +2370,7 @@ ChangeNodeToggleCount(
Node *rootNodePtr = tagPtr->tagRootPtr;
- summaryPtr = ckalloc(sizeof(Summary));
+ summaryPtr = (Summary *)ckalloc(sizeof(Summary));
summaryPtr->tagPtr = tagPtr;
summaryPtr->toggleCount = tagPtr->toggleCount - delta;
summaryPtr->nextPtr = rootNodePtr->summaryPtr;
@@ -2381,7 +2379,7 @@ ChangeNodeToggleCount(
rootLevel = rootNodePtr->level;
tagPtr->tagRootPtr = rootNodePtr;
}
- summaryPtr = ckalloc(sizeof(Summary));
+ summaryPtr = (Summary *)ckalloc(sizeof(Summary));
summaryPtr->tagPtr = tagPtr;
summaryPtr->toggleCount = delta;
summaryPtr->nextPtr = nodePtr->summaryPtr;
@@ -2471,10 +2469,10 @@ FindTagStart(
TkTextTag *tagPtr, /* Tag to search for. */
TkTextIndex *indexPtr) /* Return - index information. */
{
- register Node *nodePtr;
- register TkTextLine *linePtr;
- register TkTextSegment *segPtr;
- register Summary *summaryPtr;
+ Node *nodePtr;
+ TkTextLine *linePtr;
+ TkTextSegment *segPtr;
+ Summary *summaryPtr;
int offset;
nodePtr = tagPtr->tagRootPtr;
@@ -2556,10 +2554,10 @@ FindTagEnd(
TkTextTag *tagPtr, /* Tag to search for. */
TkTextIndex *indexPtr) /* Return - index information. */
{
- register Node *nodePtr, *lastNodePtr;
- register TkTextLine *linePtr ,*lastLinePtr;
- register TkTextSegment *segPtr, *lastSegPtr, *last2SegPtr;
- register Summary *summaryPtr;
+ Node *nodePtr, *lastNodePtr;
+ TkTextLine *linePtr ,*lastLinePtr;
+ TkTextSegment *segPtr, *lastSegPtr, *last2SegPtr;
+ Summary *summaryPtr;
int lastoffset, lastoffset2, offset;
nodePtr = tagPtr->tagRootPtr;
@@ -2652,7 +2650,7 @@ TkBTreeStartSearch(
* position *will* be returned. */
TkTextTag *tagPtr, /* Tag to search for. NULL means search for
* any tag. */
- register TkTextSearch *searchPtr)
+ TkTextSearch *searchPtr)
/* Where to store information about search's
* progress. */
{
@@ -2748,7 +2746,7 @@ TkBTreeStartSearchBack(
* position *will* be returned. */
TkTextTag *tagPtr, /* Tag to search for. NULL means search for
* any tag. */
- register TkTextSearch *searchPtr)
+ TkTextSearch *searchPtr)
/* Where to store information about search's
* progress. */
{
@@ -2849,14 +2847,14 @@ TkBTreeStartSearchBack(
int
TkBTreeNextTag(
- register TkTextSearch *searchPtr)
+ TkTextSearch *searchPtr)
/* Information about search in progress; must
* have been set up by call to
* TkBTreeStartSearch. */
{
- register TkTextSegment *segPtr;
- register Node *nodePtr;
- register Summary *summaryPtr;
+ TkTextSegment *segPtr;
+ Node *nodePtr;
+ Summary *summaryPtr;
if (searchPtr->linesLeft <= 0) {
goto searchOver;
@@ -3014,15 +3012,15 @@ TkBTreeNextTag(
int
TkBTreePrevTag(
- register TkTextSearch *searchPtr)
+ TkTextSearch *searchPtr)
/* Information about search in progress; must
* have been set up by call to
* TkBTreeStartSearch. */
{
- register TkTextSegment *segPtr, *prevPtr;
- register TkTextLine *linePtr, *prevLinePtr;
- register Node *nodePtr, *node2Ptr, *prevNodePtr;
- register Summary *summaryPtr;
+ TkTextSegment *segPtr, *prevPtr;
+ TkTextLine *linePtr, *prevLinePtr;
+ Node *nodePtr, *node2Ptr, *prevNodePtr;
+ Summary *summaryPtr;
int byteIndex, linesSkipped;
int pastLast; /* Saw last marker during scan. */
@@ -3232,9 +3230,9 @@ TkBTreeCharTagged(
* check for a tag. */
TkTextTag *tagPtr) /* Tag of interest. */
{
- register Node *nodePtr;
- register TkTextLine *siblingLinePtr;
- register TkTextSegment *segPtr;
+ Node *nodePtr;
+ TkTextLine *siblingLinePtr;
+ TkTextSegment *segPtr;
TkTextSegment *toggleSegPtr;
int toggles, index;
@@ -3288,8 +3286,8 @@ TkBTreeCharTagged(
toggles = 0;
for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
nodePtr = nodePtr->parentPtr) {
- register Node *siblingPtr;
- register Summary *summaryPtr;
+ Node *siblingPtr;
+ Summary *summaryPtr;
for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
@@ -3336,7 +3334,6 @@ TkBTreeCharTagged(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
TkTextTag **
TkBTreeGetTags(
const TkTextIndex *indexPtr,/* Indicates a particular position in the
@@ -3347,9 +3344,9 @@ TkBTreeGetTags(
int *numTagsPtr) /* Store number of tags found at this
* location. */
{
- register Node *nodePtr;
- register TkTextLine *siblingLinePtr;
- register TkTextSegment *segPtr;
+ Node *nodePtr;
+ TkTextLine *siblingLinePtr;
+ TkTextSegment *segPtr;
TkTextLine *linePtr;
int src, dst, index;
TagInfo tagInfo;
@@ -3357,8 +3354,8 @@ TkBTreeGetTags(
tagInfo.numTags = 0;
tagInfo.arraySize = NUM_TAG_INFOS;
- tagInfo.tagPtrs = ckalloc(NUM_TAG_INFOS * sizeof(TkTextTag *));
- tagInfo.counts = ckalloc(NUM_TAG_INFOS * sizeof(int));
+ tagInfo.tagPtrs = (TkTextTag **)ckalloc(NUM_TAG_INFOS * sizeof(TkTextTag *));
+ tagInfo.counts = (int *)ckalloc(NUM_TAG_INFOS * sizeof(int));
/*
* Record tag toggles within the line of indexPtr but preceding indexPtr.
@@ -3410,8 +3407,8 @@ TkBTreeGetTags(
for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
nodePtr = nodePtr->parentPtr) {
- register Node *siblingPtr;
- register Summary *summaryPtr;
+ Node *siblingPtr;
+ Summary *summaryPtr;
for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
@@ -3482,7 +3479,6 @@ TkBTreeGetTags(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkTextIsElided(
const TkText *textPtr, /* Overall information about text widget. */
@@ -3492,17 +3488,17 @@ TkTextIsElided(
* indexPtr's elide state will be stored and
* returned. */
{
- register Node *nodePtr;
- register TkTextLine *siblingLinePtr;
- register TkTextSegment *segPtr;
- register TkTextTag *tagPtr = NULL;
- register int i, index;
- register TkTextElideInfo *infoPtr;
+ Node *nodePtr;
+ TkTextLine *siblingLinePtr;
+ TkTextSegment *segPtr;
+ TkTextTag *tagPtr = NULL;
+ int i, index;
+ TkTextElideInfo *infoPtr;
TkTextLine *linePtr;
int elide;
if (elideInfo == NULL) {
- infoPtr = ckalloc(sizeof(TkTextElideInfo));
+ infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
} else {
infoPtr = elideInfo;
}
@@ -3517,8 +3513,8 @@ TkTextIsElided(
*/
if (LOTSA_TAGS < infoPtr->numTags) {
- infoPtr->tagCnts = ckalloc(sizeof(int) * infoPtr->numTags);
- infoPtr->tagPtrs = ckalloc(sizeof(TkTextTag *) * infoPtr->numTags);
+ infoPtr->tagCnts = (int *)ckalloc(sizeof(int) * infoPtr->numTags);
+ infoPtr->tagPtrs = (TkTextTag **)ckalloc(sizeof(TkTextTag *) * infoPtr->numTags);
}
for (i=0; i<infoPtr->numTags; i++) {
@@ -3591,8 +3587,8 @@ TkTextIsElided(
for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
nodePtr = nodePtr->parentPtr) {
- register Node *siblingPtr;
- register Summary *summaryPtr;
+ Node *siblingPtr;
+ Summary *summaryPtr;
for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
@@ -3697,7 +3693,7 @@ IncCount(
TagInfo *tagInfoPtr) /* Holds cumulative information about tags;
* increment count here. */
{
- register TkTextTag **tagPtrPtr;
+ TkTextTag **tagPtrPtr;
int count;
for (tagPtrPtr = tagInfoPtr->tagPtrs, count = tagInfoPtr->numTags;
@@ -3718,12 +3714,12 @@ IncCount(
int *newCounts, newSize;
newSize = 2 * tagInfoPtr->arraySize;
- newTags = ckalloc(newSize * sizeof(TkTextTag *));
+ newTags = (TkTextTag **)ckalloc(newSize * sizeof(TkTextTag *));
memcpy(newTags, tagInfoPtr->tagPtrs,
tagInfoPtr->arraySize * sizeof(TkTextTag *));
ckfree(tagInfoPtr->tagPtrs);
tagInfoPtr->tagPtrs = newTags;
- newCounts = ckalloc(newSize * sizeof(int));
+ newCounts = (int *)ckalloc(newSize * sizeof(int));
memcpy(newCounts, tagInfoPtr->counts,
tagInfoPtr->arraySize * sizeof(int));
ckfree(tagInfoPtr->counts);
@@ -3759,11 +3755,11 @@ TkBTreeCheck(
TkTextBTree tree) /* Tree to check. */
{
BTree *treePtr = (BTree *) tree;
- register Summary *summaryPtr;
- register Node *nodePtr;
- register TkTextLine *linePtr;
- register TkTextSegment *segPtr;
- register TkTextTag *tagPtr;
+ Summary *summaryPtr;
+ Node *nodePtr;
+ TkTextLine *linePtr;
+ TkTextSegment *segPtr;
+ TkTextTag *tagPtr;
Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
int count;
@@ -3774,7 +3770,7 @@ TkBTreeCheck(
for (entryPtr=Tcl_FirstHashEntry(&treePtr->sharedTextPtr->tagTable,&search);
entryPtr != NULL ; entryPtr = Tcl_NextHashEntry(&search)) {
- tagPtr = Tcl_GetHashValue(entryPtr);
+ tagPtr = (TkTextTag *)Tcl_GetHashValue(entryPtr);
nodePtr = tagPtr->tagRootPtr;
if (nodePtr == NULL) {
if (tagPtr->toggleCount != 0) {
@@ -3898,14 +3894,14 @@ TkBTreeCheck(
static void
CheckNodeConsistency(
- register Node *nodePtr, /* Node whose subtree should be checked. */
+ Node *nodePtr, /* Node whose subtree should be checked. */
int references) /* Number of referring widgets which have
* pixel counts. */
{
- register Node *childNodePtr;
- register Summary *summaryPtr, *summaryPtr2;
- register TkTextLine *linePtr;
- register TkTextSegment *segPtr;
+ Node *childNodePtr;
+ Summary *summaryPtr, *summaryPtr2;
+ TkTextLine *linePtr;
+ TkTextSegment *segPtr;
int numChildren, numLines, toggleCount, minChildren, i;
int *numPixels;
int pixels[PIXEL_CLIENTS];
@@ -3926,7 +3922,7 @@ CheckNodeConsistency(
numChildren = 0;
numLines = 0;
if (references > PIXEL_CLIENTS) {
- numPixels = ckalloc(sizeof(int) * references);
+ numPixels = (int *)ckalloc(sizeof(int) * references);
} else {
numPixels = pixels;
}
@@ -4087,7 +4083,7 @@ CheckNodeConsistency(
static void
Rebalance(
BTree *treePtr, /* Tree that is being rebalanced. */
- register Node *nodePtr) /* Node that may be out of balance. */
+ Node *nodePtr) /* Node that may be out of balance. */
{
/*
* Loop over the entire ancestral chain of the node, working up through
@@ -4095,8 +4091,8 @@ Rebalance(
*/
for ( ; nodePtr != NULL; nodePtr = nodePtr->parentPtr) {
- register Node *newPtr, *childPtr;
- register TkTextLine *linePtr;
+ Node *newPtr, *childPtr;
+ TkTextLine *linePtr;
int i;
/*
@@ -4114,7 +4110,7 @@ Rebalance(
*/
if (nodePtr->parentPtr == NULL) {
- newPtr = ckalloc(sizeof(Node));
+ newPtr = (Node *)ckalloc(sizeof(Node));
newPtr->parentPtr = NULL;
newPtr->nextPtr = NULL;
newPtr->summaryPtr = NULL;
@@ -4122,7 +4118,7 @@ Rebalance(
newPtr->children.nodePtr = nodePtr;
newPtr->numChildren = 1;
newPtr->numLines = nodePtr->numLines;
- newPtr->numPixels =
+ newPtr->numPixels = (int *)
ckalloc(sizeof(int) * treePtr->pixelReferences);
for (i=0; i<treePtr->pixelReferences; i++) {
newPtr->numPixels[i] = nodePtr->numPixels[i];
@@ -4130,8 +4126,8 @@ Rebalance(
RecomputeNodeCounts(treePtr, newPtr);
treePtr->rootPtr = newPtr;
}
- newPtr = ckalloc(sizeof(Node));
- newPtr->numPixels =
+ newPtr = (Node *)ckalloc(sizeof(Node));
+ newPtr->numPixels = (int *)
ckalloc(sizeof(int) * treePtr->pixelReferences);
for (i=0; i<treePtr->pixelReferences; i++) {
newPtr->numPixels[i] = 0;
@@ -4170,7 +4166,7 @@ Rebalance(
}
while (nodePtr->numChildren < MIN_CHILDREN) {
- register Node *otherPtr;
+ Node *otherPtr;
Node *halfwayNodePtr = NULL; /* Initialization needed only */
TkTextLine *halfwayLinePtr = NULL; /* to prevent cc warnings. */
int totalChildren, firstChildren, i;
@@ -4234,7 +4230,7 @@ Rebalance(
otherPtr->children.linePtr = NULL;
}
if (nodePtr->level == 0) {
- register TkTextLine *linePtr;
+ TkTextLine *linePtr;
for (linePtr = nodePtr->children.linePtr, i = 1;
linePtr->nextPtr != NULL;
@@ -4250,7 +4246,7 @@ Rebalance(
i++;
}
} else {
- register Node *childPtr;
+ Node *childPtr;
for (childPtr = nodePtr->children.nodePtr, i = 1;
childPtr->nextPtr != NULL;
@@ -4326,14 +4322,14 @@ Rebalance(
static void
RecomputeNodeCounts(
- register BTree *treePtr, /* The whole B-tree. */
- register Node *nodePtr) /* Node whose tag summary information must be
+ BTree *treePtr, /* The whole B-tree. */
+ Node *nodePtr) /* Node whose tag summary information must be
* recomputed. */
{
- register Summary *summaryPtr, *summaryPtr2;
- register Node *childPtr;
- register TkTextLine *linePtr;
- register TkTextSegment *segPtr;
+ Summary *summaryPtr, *summaryPtr2;
+ Node *childPtr;
+ TkTextLine *linePtr;
+ TkTextSegment *segPtr;
TkTextTag *tagPtr;
int ref;
@@ -4377,7 +4373,7 @@ RecomputeNodeCounts(
for (summaryPtr = nodePtr->summaryPtr; ;
summaryPtr = summaryPtr->nextPtr) {
if (summaryPtr == NULL) {
- summaryPtr = ckalloc(sizeof(Summary));
+ summaryPtr = (Summary *)ckalloc(sizeof(Summary));
summaryPtr->tagPtr = tagPtr;
summaryPtr->toggleCount = 1;
summaryPtr->nextPtr = nodePtr->summaryPtr;
@@ -4405,7 +4401,7 @@ RecomputeNodeCounts(
for (summaryPtr = nodePtr->summaryPtr; ;
summaryPtr = summaryPtr->nextPtr) {
if (summaryPtr == NULL) {
- summaryPtr = ckalloc(sizeof(Summary));
+ summaryPtr = (Summary *)ckalloc(sizeof(Summary));
summaryPtr->tagPtr = summaryPtr2->tagPtr;
summaryPtr->toggleCount = summaryPtr2->toggleCount;
summaryPtr->nextPtr = nodePtr->summaryPtr;
@@ -4558,12 +4554,12 @@ CharSplitProc(
{
TkTextSegment *newPtr1, *newPtr2;
- newPtr1 = ckalloc(CSEG_SIZE(index));
- newPtr2 = ckalloc(CSEG_SIZE(segPtr->size - index));
+ newPtr1 = (TkTextSegment *)ckalloc(CSEG_SIZE(index));
+ newPtr2 = (TkTextSegment *)ckalloc(CSEG_SIZE(segPtr->size - index));
newPtr1->typePtr = &tkTextCharType;
newPtr1->nextPtr = newPtr2;
newPtr1->size = index;
- memcpy(newPtr1->body.chars, segPtr->body.chars, (size_t) index);
+ memcpy(newPtr1->body.chars, segPtr->body.chars, (size_t)index);
newPtr1->body.chars[index] = 0;
newPtr2->typePtr = &tkTextCharType;
newPtr2->nextPtr = segPtr->nextPtr;
@@ -4592,12 +4588,11 @@ CharSplitProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static TkTextSegment *
CharCleanupProc(
TkTextSegment *segPtr, /* Pointer to first of two adjacent segments
* to join. */
- TkTextLine *linePtr) /* Line containing segments (not used). */
+ TCL_UNUSED(TkTextLine *)) /* Line containing segments (not used). */
{
TkTextSegment *segPtr2, *newPtr;
@@ -4605,7 +4600,7 @@ CharCleanupProc(
if ((segPtr2 == NULL) || (segPtr2->typePtr != &tkTextCharType)) {
return segPtr;
}
- newPtr = ckalloc(CSEG_SIZE(segPtr->size + segPtr2->size));
+ newPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(segPtr->size + segPtr2->size));
newPtr->typePtr = &tkTextCharType;
newPtr->nextPtr = segPtr2->nextPtr;
newPtr->size = segPtr->size + segPtr2->size;
@@ -4633,12 +4628,11 @@ CharCleanupProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
CharDeleteProc(
TkTextSegment *segPtr, /* Segment to delete. */
- TkTextLine *linePtr, /* Line containing segment. */
- int treeGone) /* Non-zero means the entire tree is being
+ TCL_UNUSED(TkTextLine *), /* Line containing segment. */
+ TCL_UNUSED(int)) /* Non-zero means the entire tree is being
* deleted, so everything must get cleaned
* up. */
{
@@ -4663,7 +4657,6 @@ CharDeleteProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
CharCheckProc(
TkTextSegment *segPtr, /* Segment to check. */
@@ -4679,7 +4672,7 @@ CharCheckProc(
if (segPtr->size <= 0) {
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) {
@@ -4858,7 +4851,7 @@ ToggleCheckProc(
TkTextSegment *segPtr, /* Segment to check. */
TkTextLine *linePtr) /* Line containing segment. */
{
- register Summary *summaryPtr;
+ Summary *summaryPtr;
int needSummary;
if (segPtr->size != 0) {