diff options
Diffstat (limited to 'generic/tkTextTag.c')
-rw-r--r-- | generic/tkTextTag.c | 84 |
1 files changed, 43 insertions, 41 deletions
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 2df950a..38a1c44 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -23,7 +23,7 @@ * a whole is not. */ -static const char *wrapStrings[] = { +static const char *const wrapStrings[] = { "char", "none", "word", "", NULL }; @@ -34,7 +34,7 @@ static const char *wrapStrings[] = { * widget as a whole is not. */ -static const char *tabStyleStrings[] = { +static const char *const tabStyleStrings[] = { "tabular", "wordprocessor", "", NULL }; @@ -87,7 +87,7 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, wrapMode), TK_OPTION_NULL_OK, (ClientData) wrapStrings, 0}, - {TK_OPTION_END} + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; /* @@ -99,7 +99,7 @@ static void ChangeTagPriority(TkText *textPtr, TkTextTag *tagPtr, static TkTextTag * FindTag(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *tagName); static void SortTags(int numTags, TkTextTag **tagArrayPtr); -static int TagSortProc(CONST VOID *first, CONST VOID *second); +static int TagSortProc(const void *first, const void *second); static void TagBindEvent(TkText *textPtr, XEvent *eventPtr, int numTags, TkTextTag **tagArrayPtr); @@ -126,11 +126,11 @@ TkTextTagCmd( register TkText *textPtr, /* Information about text widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ - Tcl_Obj *CONST objv[]) /* Argument objects. Someone else has already + Tcl_Obj *const objv[]) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "tag". */ { - static CONST char *tagOptionStrings[] = { + static const char *const tagOptionStrings[] = { "add", "bind", "cget", "configure", "delete", "lower", "names", "nextrange", "prevrange", "raise", "ranges", "remove", NULL }; @@ -144,7 +144,7 @@ TkTextTagCmd( TkTextIndex index1, index2; if (objc < 3) { - Tcl_WrongNumArgs(interp, 2, objv, "option ?arg arg ...?"); + Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?"); return TCL_ERROR; } @@ -223,7 +223,7 @@ TkTextTagCmd( if (addTag && textPtr->exportSelection && !(textPtr->flags & GOT_SELECTION)) { Tk_OwnSelection(textPtr->tkwin, XA_PRIMARY, - TkTextLostSelection, (ClientData) textPtr); + TkTextLostSelection, textPtr); textPtr->flags |= GOT_SELECTION; } textPtr->abortSelections = 1; @@ -251,7 +251,7 @@ TkTextTagCmd( if (objc == 6) { int append = 0; unsigned long mask; - char *fifth = Tcl_GetString(objv[5]); + const char *fifth = Tcl_GetString(objv[5]); if (fifth[0] == 0) { return Tk_DeleteBinding(interp, @@ -283,13 +283,13 @@ TkTextTagCmd( return TCL_ERROR; } } else if (objc == 5) { - CONST char *command; + const char *command; command = Tk_GetBinding(interp, textPtr->sharedTextPtr->bindingTable, (ClientData) tagPtr->name, Tcl_GetString(objv[4])); if (command == NULL) { - CONST char *string = Tcl_GetStringResult(interp); + const char *string = Tcl_GetStringResult(interp); /* * Ignore missing binding errors. This is a special hack that @@ -334,7 +334,7 @@ TkTextTagCmd( if (objc < 4) { Tcl_WrongNumArgs(interp, 3, objv, - "tagName ?option? ?value? ?option value ...?"); + "tagName ?-option? ?value? ?-option value ...?"); return TCL_ERROR; } tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), &newTag); @@ -351,7 +351,7 @@ TkTextTagCmd( } else { int result = TCL_OK; - if (Tk_SetOptions(interp, (char*)tagPtr, tagPtr->optionTable, + if (Tk_SetOptions(interp, (char *) tagPtr, tagPtr->optionTable, objc-4, objv+4, textPtr->tkwin, NULL, NULL) != TCL_OK) { return TCL_ERROR; } @@ -436,7 +436,7 @@ TkTextTagCmd( } } if (tagPtr->tabArrayPtr != NULL) { - ckfree((char *) tagPtr->tabArrayPtr); + ckfree(tagPtr->tabArrayPtr); tagPtr->tabArrayPtr = NULL; } if (tagPtr->tabStringPtr != NULL) { @@ -539,7 +539,7 @@ TkTextTagCmd( continue; } - tagPtr = (TkTextTag *) Tcl_GetHashValue(hPtr); + tagPtr = Tcl_GetHashValue(hPtr); if (tagPtr == textPtr->selTagPtr) { continue; } @@ -600,12 +600,12 @@ TkTextTagCmd( Tcl_HashSearch search; Tcl_HashEntry *hPtr; - arrayPtr = (TkTextTag **) ckalloc((unsigned) - (textPtr->sharedTextPtr->numTags * sizeof(TkTextTag *))); + arrayPtr = ckalloc(textPtr->sharedTextPtr->numTags + * sizeof(TkTextTag *)); for (i=0, hPtr = Tcl_FirstHashEntry( &textPtr->sharedTextPtr->tagTable, &search); hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) { - arrayPtr[i] = (TkTextTag *) Tcl_GetHashValue(hPtr); + arrayPtr[i] = Tcl_GetHashValue(hPtr); } /* @@ -634,7 +634,7 @@ TkTextTagCmd( Tcl_NewStringObj(tagPtr->name,-1)); } Tcl_SetObjResult(interp, listObj); - ckfree((char *) arrayPtr); + ckfree(arrayPtr); break; } case TAG_NEXTRANGE: { @@ -926,14 +926,14 @@ TkTextTagCmd( TkTextTag * TkTextCreateTag( TkText *textPtr, /* Widget in which tag is being used. */ - CONST char *tagName, /* Name of desired tag. */ + const char *tagName, /* Name of desired tag. */ int *newTag) /* If non-NULL, then return 1 if new, or 0 if * already exists. */ { register TkTextTag *tagPtr; Tcl_HashEntry *hPtr = NULL; int isNew; - CONST char *name; + const char *name; if (!strcmp(tagName, "sel")) { if (textPtr->selTagPtr != NULL) { @@ -953,7 +953,7 @@ TkTextCreateTag( *newTag = isNew; } if (!isNew) { - return (TkTextTag *) Tcl_GetHashValue(hPtr); + return Tcl_GetHashValue(hPtr); } name = Tcl_GetHashKey(&textPtr->sharedTextPtr->tagTable, hPtr); } @@ -963,7 +963,7 @@ TkTextCreateTag( * to it to the hash table entry. */ - tagPtr = (TkTextTag *) ckalloc(sizeof(TkTextTag)); + tagPtr = ckalloc(sizeof(TkTextTag)); tagPtr->name = name; tagPtr->textPtr = NULL; tagPtr->toggleCount = 0; @@ -1011,6 +1011,7 @@ TkTextCreateTag( tagPtr->textPtr = textPtr; textPtr->refCount++; } else { + CLANG_ASSERT(hPtr); Tcl_SetHashValue(hPtr, tagPtr); } tagPtr->optionTable = @@ -1046,7 +1047,7 @@ FindTag( { Tcl_HashEntry *hPtr; int len; - CONST char *str; + const char *str; str = Tcl_GetStringFromObj(tagName, &len); if (len == 3 && !strcmp(str,"sel")) { @@ -1055,7 +1056,7 @@ FindTag( hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable, Tcl_GetString(tagName)); if (hPtr != NULL) { - return (TkTextTag *) Tcl_GetHashValue(hPtr); + return Tcl_GetHashValue(hPtr); } if (interp != NULL) { Tcl_AppendResult(interp, "tag \"", Tcl_GetString(tagName), @@ -1166,7 +1167,7 @@ TkTextFreeTag( */ if (tagPtr->tabArrayPtr != NULL) { - ckfree((char *) tagPtr->tabArrayPtr); + ckfree(tagPtr->tabArrayPtr); } /* @@ -1195,7 +1196,7 @@ TkTextFreeTag( } textPtr->refCount--; if (textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } tagPtr->textPtr = NULL; } @@ -1204,7 +1205,7 @@ TkTextFreeTag( * Finally free the tag's memory. */ - ckfree((char *) tagPtr); + ckfree(tagPtr); } /* @@ -1277,8 +1278,8 @@ SortTags( static int TagSortProc( - CONST void *first, - CONST void *second) /* Elements to be compared. */ + const void *first, + const void *second) /* Elements to be compared. */ { TkTextTag *tagPtr1, *tagPtr2; @@ -1347,7 +1348,7 @@ ChangeTagPriority( } for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->tagTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - tagPtr2 = (TkTextTag *) Tcl_GetHashValue(hPtr); + tagPtr2 = Tcl_GetHashValue(hPtr); if ((tagPtr2->priority >= low) && (tagPtr2->priority <= high)) { tagPtr2->priority += delta; } @@ -1378,7 +1379,7 @@ TkTextBindProc( ClientData clientData, /* Pointer to canvas structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { - TkText *textPtr = (TkText *) clientData; + TkText *textPtr = clientData; int repick = 0; # define AnyButtonMask \ @@ -1458,7 +1459,7 @@ TkTextBindProc( done: if (--textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } } @@ -1590,7 +1591,7 @@ TkTextPickCurrent( SortTags(textPtr->numCurTags, textPtr->curTagArrayPtr); if (numNewTags > 0) { size = numNewTags * sizeof(TkTextTag *); - copyArrayPtr = (TkTextTag **) ckalloc((unsigned) size); + copyArrayPtr = ckalloc(size); memcpy(copyArrayPtr, newArrayPtr, (size_t) size); for (i = 0; i < textPtr->numCurTags; i++) { for (j = 0; j < numNewTags; j++) { @@ -1632,7 +1633,7 @@ TkTextPickCurrent( event.xcrossing.detail = NotifyAncestor; TagBindEvent(textPtr, &event, numOldTags, oldArrayPtr); } - ckfree((char *) oldArrayPtr); + ckfree(oldArrayPtr); } /* @@ -1654,7 +1655,7 @@ TkTextPickCurrent( event.xcrossing.detail = NotifyAncestor; TagBindEvent(textPtr, &event, numNewTags, copyArrayPtr); } - ckfree((char *) copyArrayPtr); + ckfree(copyArrayPtr); } } @@ -1684,9 +1685,9 @@ TagBindEvent( int numTags, /* Number of relevant tags. */ TkTextTag **tagArrayPtr) /* Array of relevant tags. */ { - #define NUM_BIND_TAGS 10 - CONST char *nameArray[NUM_BIND_TAGS]; - CONST char **nameArrPtr; +# define NUM_BIND_TAGS 10 + const char *nameArray[NUM_BIND_TAGS]; + const char **nameArrPtr; int i; /* @@ -1694,7 +1695,7 @@ TagBindEvent( */ if (numTags > NUM_BIND_TAGS) { - nameArrPtr = (CONST char **) ckalloc(numTags * sizeof(CONST char *)); + nameArrPtr = ckalloc(numTags * sizeof(const char *)); } else { nameArrPtr = nameArray; } @@ -1707,6 +1708,7 @@ TagBindEvent( for (i = 0; i < numTags; i++) { TkTextTag *tagPtr = tagArrayPtr[i]; + if (tagPtr != NULL) { nameArrPtr[i] = tagPtr->name; } else { @@ -1723,7 +1725,7 @@ TagBindEvent( textPtr->tkwin, numTags, (ClientData *) nameArrPtr); if (numTags > NUM_BIND_TAGS) { - ckfree((char *) nameArrPtr); + ckfree(nameArrPtr); } } |