From 0e5885d7fab885a2ef6ee3d709a6745b0bf585fb Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Sep 2020 08:56:18 +0000 Subject: More use of TCL_UNUSED() and C++-safe typecasts. Use Tk_Offset() in stead of sizeof() when using flexible arrays --- generic/tkFont.c | 59 +++++++++++---------- generic/tkSelect.c | 65 ++++++++++++------------ generic/tkText.c | 141 ++++++++++++++++++++++++--------------------------- generic/tkTextDisp.c | 126 ++++++++++++++++++++++----------------------- unix/tkUnixWm.c | 2 +- win/tkWinWm.c | 2 +- 6 files changed, 193 insertions(+), 202 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 0b858fc..ab431a0 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -380,7 +380,7 @@ void TkFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { - TkFontInfo *fiPtr = ckalloc(sizeof(TkFontInfo)); + TkFontInfo *fiPtr = (TkFontInfo *)ckalloc(sizeof(TkFontInfo)); Tcl_InitHashTable(&fiPtr->fontCache, TCL_STRING_KEYS); Tcl_InitHashTable(&fiPtr->namedTable, TCL_STRING_KEYS); @@ -473,7 +473,7 @@ Tk_FontObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { int index; - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; TkFontInfo *fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; static const char *const optionStrings[] = { "actual", "configure", "create", "delete", @@ -617,9 +617,9 @@ Tk_FontObjCmd( } string = Tcl_GetString(objv[2]); namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string); - nfPtr = NULL; /* lint. */ + nfPtr = NULL; if (namedHashPtr != NULL) { - nfPtr = Tcl_GetHashValue(namedHashPtr); + nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); } if ((namedHashPtr == NULL) || nfPtr->deletePending) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -797,10 +797,10 @@ Tk_FontObjCmd( resultPtr = Tcl_NewObj(); namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); while (namedHashPtr != NULL) { - NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr); + NamedFont *nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); if (!nfPtr->deletePending) { - char *string = Tcl_GetHashKey(&fiPtr->namedTable, + char *string = (char *)Tcl_GetHashKey(&fiPtr->namedTable, namedHashPtr); Tcl_ListObjAppendElement(NULL, resultPtr, @@ -843,7 +843,7 @@ UpdateDependentFonts( Tcl_HashEntry *cacheHashPtr; Tcl_HashSearch search; TkFont *fontPtr; - NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr); + NamedFont *nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); if (nfPtr->refCount == 0) { /* @@ -856,7 +856,7 @@ UpdateDependentFonts( cacheHashPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search); while (cacheHashPtr != NULL) { - for (fontPtr = Tcl_GetHashValue(cacheHashPtr); + for (fontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr); fontPtr != NULL; fontPtr = fontPtr->nextPtr) { if (fontPtr->namedHashPtr == namedHashPtr) { TkpGetFontFromAttributes(fontPtr, tkwin, &nfPtr->fa); @@ -874,7 +874,7 @@ static void TheWorldHasChanged( ClientData clientData) /* Info about application's fonts. */ { - TkFontInfo *fiPtr = clientData; + TkFontInfo *fiPtr = (TkFontInfo *)clientData; /* * On macOS it is catastrophic to recompute all widgets while the @@ -964,7 +964,7 @@ TkCreateNamedFont( namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &isNew); if (!isNew) { - nfPtr = Tcl_GetHashValue(namedHashPtr); + nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); if (!nfPtr->deletePending) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -986,7 +986,7 @@ TkCreateNamedFont( return TCL_OK; } - nfPtr = ckalloc(sizeof(NamedFont)); + nfPtr = (NamedFont *)ckalloc(sizeof(NamedFont)); nfPtr->deletePending = 0; Tcl_SetHashValue(namedHashPtr, nfPtr); nfPtr->fa = *faPtr; @@ -1025,7 +1025,7 @@ TkDeleteNamedFont( } return TCL_ERROR; } - nfPtr = Tcl_GetHashValue(namedHashPtr); + nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); if (nfPtr->refCount != 0) { nfPtr->deletePending = 1; } else { @@ -1114,7 +1114,7 @@ Tk_AllocFontFromObj( SetFontFromAny(interp, objPtr); } - oldFontPtr = objPtr->internalRep.twoPtrValue.ptr1; + oldFontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1; if (oldFontPtr != NULL) { if (oldFontPtr->resourceRefCount == 0) { /* @@ -1143,7 +1143,7 @@ Tk_AllocFontFromObj( cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr), &isNew); } - firstFontPtr = Tcl_GetHashValue(cacheHashPtr); + firstFontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr); for (fontPtr = firstFontPtr; (fontPtr != NULL); fontPtr = fontPtr->nextPtr) { if (Tk_Screen(tkwin) == fontPtr->screen) { @@ -1166,7 +1166,7 @@ Tk_AllocFontFromObj( * Construct a font based on a named font. */ - nfPtr = Tcl_GetHashValue(namedHashPtr); + nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); nfPtr->refCount++; fontPtr = TkpGetFontFromAttributes(NULL, tkwin, &nfPtr->fa); @@ -1299,7 +1299,7 @@ Tk_GetFontFromObj( SetFontFromAny(NULL, objPtr); } - fontPtr = objPtr->internalRep.twoPtrValue.ptr1; + fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1; if (fontPtr != NULL) { if (fontPtr->resourceRefCount == 0) { /* @@ -1326,7 +1326,7 @@ Tk_GetFontFromObj( hashPtr = Tcl_FindHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr)); } if (hashPtr != NULL) { - for (fontPtr = Tcl_GetHashValue(hashPtr); fontPtr != NULL; + for (fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr); fontPtr != NULL; fontPtr = fontPtr->nextPtr) { if (Tk_Screen(tkwin) == fontPtr->screen) { fontPtr->objRefCount++; @@ -1361,7 +1361,7 @@ Tk_GetFontFromObj( static int SetFontFromAny( - Tcl_Interp *interp, /* Used for error reporting if not NULL. */ + TCL_UNUSED(Tcl_Interp *), /* Used for error reporting if not NULL. */ Tcl_Obj *objPtr) /* The object to convert. */ { const Tcl_ObjType *typePtr; @@ -1437,8 +1437,7 @@ Tk_FreeFont( if (fontPtr == NULL) { return; } - fontPtr->resourceRefCount--; - if (fontPtr->resourceRefCount > 0) { + if (fontPtr->resourceRefCount-- > 1) { return; } if (fontPtr->namedHashPtr != NULL) { @@ -1447,7 +1446,7 @@ Tk_FreeFont( * the named font and free it if no-one else is using it. */ - nfPtr = Tcl_GetHashValue(fontPtr->namedHashPtr); + nfPtr = (NamedFont *)Tcl_GetHashValue(fontPtr->namedHashPtr); nfPtr->refCount--; if ((nfPtr->refCount == 0) && nfPtr->deletePending) { Tcl_DeleteHashEntry(fontPtr->namedHashPtr); @@ -1455,7 +1454,7 @@ Tk_FreeFont( } } - prevPtr = Tcl_GetHashValue(fontPtr->cacheHashPtr); + prevPtr = (TkFont *)Tcl_GetHashValue(fontPtr->cacheHashPtr); if (prevPtr == fontPtr) { if (fontPtr->nextPtr == NULL) { Tcl_DeleteHashEntry(fontPtr->cacheHashPtr); @@ -1533,7 +1532,7 @@ static void FreeFontObj( Tcl_Obj *objPtr) /* The object we are releasing. */ { - TkFont *fontPtr = objPtr->internalRep.twoPtrValue.ptr1; + TkFont *fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1; if (fontPtr != NULL) { fontPtr->objRefCount--; @@ -1568,7 +1567,7 @@ DupFontObjProc( Tcl_Obj *srcObjPtr, /* The object we are copying from. */ Tcl_Obj *dupObjPtr) /* The object we are copying to. */ { - TkFont *fontPtr = srcObjPtr->internalRep.twoPtrValue.ptr1; + TkFont *fontPtr = (TkFont *)srcObjPtr->internalRep.twoPtrValue.ptr1; dupObjPtr->typePtr = srcObjPtr->typePtr; dupObjPtr->internalRep.twoPtrValue.ptr1 = fontPtr; @@ -2007,8 +2006,8 @@ Tk_ComputeTextLayout( maxChunks = 1; - layoutPtr = ckalloc(sizeof(TextLayout) - + (maxChunks-1) * sizeof(LayoutChunk)); + layoutPtr = (TextLayout *)ckalloc(Tk_Offset(TextLayout, chunks) + + maxChunks * sizeof(LayoutChunk)); layoutPtr->tkfont = tkfont; layoutPtr->string = string; layoutPtr->numChunks = 0; @@ -3405,7 +3404,7 @@ noMapping: ; static int ConfigAttributesObj( Tcl_Interp *interp, /* Interp for error return. */ - Tk_Window tkwin, /* For display on which font will be used. */ + TCL_UNUSED(Tk_Window), /* For display on which font will be used. */ int objc, /* Number of elements in argv. */ Tcl_Obj *const objv[], /* Command line options. */ TkFontAttributes *faPtr) /* Font attributes structure whose fields are @@ -3780,7 +3779,7 @@ NewChunk( maxChunks = *maxPtr; if (layoutPtr->numChunks == maxChunks) { maxChunks *= 2; - s = sizeof(TextLayout) + ((maxChunks - 1) * sizeof(LayoutChunk)); + s = Tk_Offset(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk)); layoutPtr = ckrealloc(layoutPtr, s); *layoutPtrPtr = layoutPtr; @@ -4244,7 +4243,7 @@ TkDebugFont( hashPtr = Tcl_FindHashEntry( &((TkWindow *) tkwin)->mainPtr->fontInfoPtr->fontCache, name); if (hashPtr != NULL) { - fontPtr = Tcl_GetHashValue(hashPtr); + fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr); if (fontPtr == NULL) { Tcl_Panic("TkDebugFont found empty hash table entry"); } @@ -4297,7 +4296,7 @@ TkFontGetFirstTextLayout( } chunkPtr = layoutPtr->chunks; numBytesInChunk = chunkPtr->numBytes; - strncpy(dst, chunkPtr->start, (size_t) numBytesInChunk); + strncpy(dst, chunkPtr->start, numBytesInChunk); *font = layoutPtr->tkfont; return numBytesInChunk; } diff --git a/generic/tkSelect.c b/generic/tkSelect.c index ef16ff5..91f0836 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -125,7 +125,7 @@ Tk_CreateSelHandler( * listed in the ICCCM will be tolerated * (blech). */ { - register TkSelHandler *selPtr; + TkSelHandler *selPtr; TkWindow *winPtr = (TkWindow *) tkwin; if (winPtr->dispPtr->multipleAtom == None) { @@ -139,7 +139,7 @@ Tk_CreateSelHandler( for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) { if (selPtr == NULL) { - selPtr = ckalloc(sizeof(TkSelHandler)); + selPtr = (TkSelHandler *)ckalloc(sizeof(TkSelHandler)); selPtr->nextPtr = winPtr->selHandlerList; winPtr->selHandlerList = selPtr; break; @@ -177,7 +177,7 @@ Tk_CreateSelHandler( target = winPtr->dispPtr->utf8Atom; for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) { if (selPtr == NULL) { - selPtr = ckalloc(sizeof(TkSelHandler)); + selPtr = (TkSelHandler *)ckalloc(sizeof(TkSelHandler)); selPtr->nextPtr = winPtr->selHandlerList; winPtr->selHandlerList = selPtr; selPtr->selection = selection; @@ -239,9 +239,9 @@ Tk_DeleteSelHandler( * removed. */ { TkWindow *winPtr = (TkWindow *) tkwin; - register TkSelHandler *selPtr, *prevPtr; - register TkSelInProgress *ipPtr; - ThreadSpecificData *tsdPtr = + TkSelHandler *selPtr, *prevPtr; + TkSelInProgress *ipPtr; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -353,7 +353,7 @@ Tk_OwnSelection( ClientData clientData) /* Arbitrary one-word argument to pass to * proc. */ { - register TkWindow *winPtr = (TkWindow *) tkwin; + TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; Tk_LostSelProc *clearProc = NULL; @@ -382,7 +382,7 @@ Tk_OwnSelection( } } if (infoPtr == NULL) { - infoPtr = ckalloc(sizeof(TkSelectionInfo)); + infoPtr = (TkSelectionInfo *)ckalloc(sizeof(TkSelectionInfo)); infoPtr->selection = selection; infoPtr->nextPtr = dispPtr->selectionInfoPtr; dispPtr->selectionInfoPtr = infoPtr; @@ -460,7 +460,7 @@ Tk_ClearSelection( Tk_Window tkwin, /* Window that selects a display. */ Atom selection) /* Selection to be cancelled. */ { - register TkWindow *winPtr = (TkWindow *) tkwin; + TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; TkSelectionInfo *prevPtr; @@ -556,7 +556,7 @@ Tk_GetSelection( TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (dispPtr->multipleAtom == None) { @@ -577,7 +577,7 @@ Tk_GetSelection( } } if (infoPtr != NULL) { - register TkSelHandler *selPtr; + TkSelHandler *selPtr; int offset, result, count; char buffer[TK_SEL_BYTES_AT_ONCE+1]; TkSelInProgress ip; @@ -670,7 +670,7 @@ Tk_SelectionObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; const char *path = NULL; Atom selection; const char *selName = NULL; @@ -830,7 +830,7 @@ Tk_SelectionObjCmd( Atom target, format; const char *targetName = NULL; const char *formatName = NULL; - register CommandInfo *cmdInfoPtr; + CommandInfo *cmdInfoPtr; int cmdLength; static const char *const handleOptionStrings[] = { "-format", "-selection", "-type", NULL @@ -904,7 +904,7 @@ Tk_SelectionObjCmd( if (cmdLength == 0) { Tk_DeleteSelHandler(tkwin, selection, target); } else { - cmdInfoPtr = ckalloc(Tk_Offset(CommandInfo, command) + cmdInfoPtr = (CommandInfo *)ckalloc(Tk_Offset(CommandInfo, command) + 1 + cmdLength); cmdInfoPtr->interp = interp; cmdInfoPtr->charOffset = 0; @@ -919,7 +919,7 @@ Tk_SelectionObjCmd( } case SELECTION_OWN: { - register LostCommand *lostPtr; + LostCommand *lostPtr; Tcl_Obj *commandObj = NULL; static const char *const ownOptionStrings[] = { "-command", "-displayof", "-selection", NULL @@ -1008,7 +1008,7 @@ Tk_SelectionObjCmd( Tk_OwnSelection(tkwin, selection, NULL, NULL); return TCL_OK; } - lostPtr = ckalloc(sizeof(LostCommand)); + lostPtr = (LostCommand *)ckalloc(sizeof(LostCommand)); lostPtr->interp = interp; lostPtr->cmdObj = commandObj; Tcl_IncrRefCount(commandObj); @@ -1040,7 +1040,7 @@ Tk_SelectionObjCmd( TkSelInProgress * TkSelGetInProgress(void) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); return tsdPtr->pendingPtr; @@ -1067,7 +1067,7 @@ void TkSelSetInProgress( TkSelInProgress *pendingPtr) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); tsdPtr->pendingPtr = pendingPtr; @@ -1092,12 +1092,12 @@ TkSelSetInProgress( void TkSelDeadWindow( - register TkWindow *winPtr) /* Window that's being deleted. */ + TkWindow *winPtr) /* Window that's being deleted. */ { - register TkSelHandler *selPtr; - register TkSelInProgress *ipPtr; + TkSelHandler *selPtr; + TkSelInProgress *ipPtr; TkSelectionInfo *infoPtr, *prevPtr, *nextPtr; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -1170,7 +1170,7 @@ TkSelInit( Tk_Window tkwin) /* Window token (used to find display to * initialize). */ { - register TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; /* * Fetch commonly-used atoms. @@ -1221,9 +1221,9 @@ TkSelInit( void TkSelClearSelection( Tk_Window tkwin, /* Window for which event was targeted. */ - register XEvent *eventPtr) /* X SelectionClear event. */ + XEvent *eventPtr) /* X SelectionClear event. */ { - register TkWindow *winPtr = (TkWindow *) tkwin; + TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; TkSelectionInfo *prevPtr; @@ -1285,16 +1285,15 @@ TkSelClearSelection( *-------------------------------------------------------------- */ - /* ARGSUSED */ static int SelGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ - Tcl_Interp *interp, /* Interpreter used for error reporting (not + TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not * used). */ const char *portion) /* New information to be appended. */ { - Tcl_DStringAppend(clientData, portion, -1); + Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1); return TCL_OK; } @@ -1411,7 +1410,7 @@ HandleTclCommand( cmdInfoPtr->charOffset += numChars; length = p - string; if (length > 0) { - strncpy(cmdInfoPtr->buffer, string, (size_t) length); + strncpy(cmdInfoPtr->buffer, string, length); } cmdInfoPtr->buffer[length] = '\0'; } @@ -1470,7 +1469,7 @@ TkSelDefaultSelection( Atom *typePtr) /* Store here the type of the selection, for * use in converting to proper X format. */ { - register TkWindow *winPtr = (TkWindow *) infoPtr->owner; + TkWindow *winPtr = (TkWindow *) infoPtr->owner; TkDisplay *dispPtr = winPtr->dispPtr; if (target == dispPtr->timestampAtom) { @@ -1483,7 +1482,7 @@ TkSelDefaultSelection( } if (target == dispPtr->targetsAtom) { - register TkSelHandler *selPtr; + TkSelHandler *selPtr; int length; Tcl_DString ds; @@ -1509,7 +1508,7 @@ TkSelDefaultSelection( Tcl_DStringFree(&ds); return -1; } - memcpy(buffer, Tcl_DStringValue(&ds), (unsigned) (1+length)); + memcpy(buffer, Tcl_DStringValue(&ds), length + 1); Tcl_DStringFree(&ds); *typePtr = XA_ATOM; return length; @@ -1566,7 +1565,7 @@ static void LostSelection( ClientData clientData) /* Pointer to LostCommand structure. */ { - LostCommand *lostPtr = clientData; + LostCommand *lostPtr = (LostCommand *)clientData; Tcl_Interp *interp = lostPtr->interp; Tcl_InterpState savedState; int code; diff --git a/generic/tkText.c b/generic/tkText.c index 2ddfea1..5996688 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -14,9 +14,9 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include "default.h" #include "tkInt.h" #include "tkUndo.h" +#include "default.h" #if defined(MAC_OSX_TK) #define Style TkStyle @@ -461,7 +461,7 @@ Tk_TextObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); @@ -502,7 +502,7 @@ CreateWidget( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register TkText *textPtr; + TkText *textPtr; Tk_OptionTable optionTable; TkTextIndex startIndex; Tk_Window newWin; @@ -523,7 +523,7 @@ CreateWidget( * and 'insert', 'current' mark pointers are all NULL to start. */ - textPtr = ckalloc(sizeof(TkText)); + textPtr = (TkText *)ckalloc(sizeof(TkText)); memset(textPtr, 0, sizeof(TkText)); textPtr->tkwin = newWin; @@ -534,7 +534,7 @@ CreateWidget( textPtr, TextCmdDeletedProc); if (sharedPtr == NULL) { - sharedPtr = ckalloc(sizeof(TkSharedText)); + sharedPtr = (TkSharedText *)ckalloc(sizeof(TkSharedText)); memset(sharedPtr, 0, sizeof(TkSharedText)); sharedPtr->refCount = 0; @@ -632,7 +632,7 @@ CreateWidget( */ textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel", NULL); - textPtr->selTagPtr->reliefString = + textPtr->selTagPtr->reliefString = (char *) ckalloc(sizeof(DEF_TEXT_SELECT_RELIEF)); strcpy(textPtr->selTagPtr->reliefString, DEF_TEXT_SELECT_RELIEF); Tk_GetRelief(interp, DEF_TEXT_SELECT_RELIEF, &textPtr->selTagPtr->relief); @@ -699,7 +699,7 @@ TextWidgetObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; int result = TCL_OK; int index; @@ -864,11 +864,10 @@ TextWidgetObjCmd( for (i = 2; i < objc-2; i++) { int value; - size_t length; - const char *option = Tcl_GetString(objv[i]); + int length; + const char *option = Tcl_GetStringFromObj(objv[i], &length); char c; - length = objv[i]->length; if (length < 2 || option[0] != '-') { goto badOption; } @@ -1126,7 +1125,7 @@ TextWidgetObjCmd( objc -= 2; objv += 2; - indices = ckalloc((objc + 1) * sizeof(TkTextIndex)); + indices = (TkTextIndex *)ckalloc((objc + 1) * sizeof(TkTextIndex)); /* * First pass verifies that all indices are valid. @@ -1154,8 +1153,8 @@ TextWidgetObjCmd( COUNT_INDICES); objc++; } - useIdx = ckalloc(objc); - memset(useIdx, 0, (size_t) objc); + useIdx = (char *)ckalloc(objc); + memset(useIdx, 0, objc); /* * Do a decreasing order sort so that we delete the end ranges @@ -1260,7 +1259,7 @@ TextWidgetObjCmd( Tcl_Obj *objPtr = NULL; int i, found = 0, visible = 0; const char *name; - size_t length; + int length; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, @@ -1276,14 +1275,12 @@ TextWidgetObjCmd( i = 2; if (objc > 3) { - name = Tcl_GetString(objv[i]); - length = objv[i]->length; + name = Tcl_GetStringFromObj(objv[i], &length); if (length > 1 && name[0] == '-') { if (strncmp("-displaychars", name, length) == 0) { i++; visible = 1; - name = Tcl_GetString(objv[i]); - length = objv[i]->length; + name = Tcl_GetStringFromObj(objv[i], &length); } if ((i < objc-1) && (length == 2) && !strcmp("--", name)) { i++; @@ -1610,7 +1607,7 @@ SharedTextObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register TkSharedText *sharedPtr = clientData; + TkSharedText *sharedPtr = (TkSharedText *)clientData; int result = TCL_OK; int index; @@ -1980,7 +1977,7 @@ DestroyText( for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->windowTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { TkTextEmbWindowClient *loop; - TkTextSegment *ewPtr = Tcl_GetHashValue(hPtr); + TkTextSegment *ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr); loop = ewPtr->body.ew.clients; if (loop->textPtr == textPtr) { @@ -2012,7 +2009,7 @@ DestroyText( for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - tagPtr = Tcl_GetHashValue(hPtr); + tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr); /* * No need to use 'TkTextDeleteTag' since we've already removed @@ -2078,7 +2075,7 @@ DestroyText( static int ConfigureText( Tcl_Interp *interp, /* Used for error reporting. */ - register TkText *textPtr, /* Information about widget; may or may not + TkText *textPtr, /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2381,7 +2378,7 @@ static void TextWorldChangedCallback( ClientData instanceData) /* Information about widget. */ { - TkText *textPtr = instanceData; + TkText *textPtr = (TkText *)instanceData; TextWorldChanged(textPtr, TK_TEXT_LINE_GEOMETRY); } @@ -2470,9 +2467,9 @@ TextWorldChanged( static void TextEventProc( ClientData clientData, /* Information about window. */ - register XEvent *eventPtr) /* Information about event. */ + XEvent *eventPtr) /* Information about event. */ { - register TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; TkTextIndex index, index2; if (eventPtr->type == Expose) { @@ -2581,7 +2578,7 @@ static void TextCmdDeletedProc( ClientData clientData) /* Pointer to widget record for widget. */ { - TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; Tk_Window tkwin = textPtr->tkwin; /* @@ -2634,14 +2631,13 @@ InsertChars( int viewUpdate) /* Update the view if set. */ { int lineIndex; - size_t length; + int length; TkText *tPtr; int *lineAndByteIndex; int resetViewCount; int pixels[2*PIXEL_CLIENTS]; - const char *string = Tcl_GetString(stringPtr); + const char *string = Tcl_GetStringFromObj(stringPtr, &length); - length = stringPtr->length; if (sharedTextPtr == NULL) { sharedTextPtr = textPtr->sharedTextPtr; } @@ -2667,7 +2663,7 @@ InsertChars( resetViewCount = 0; if (sharedTextPtr->refCount > PIXEL_CLIENTS) { - lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); + lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); } else { lineAndByteIndex = pixels; } @@ -2916,7 +2912,7 @@ TextUndoRedoCallback( Tcl_Obj *objPtr) /* Arguments of a command to be handled by the * shared text data structure. */ { - TkSharedText *sharedPtr = clientData; + TkSharedText *sharedPtr = (TkSharedText *)clientData; int res, objc; Tcl_Obj **objv; TkText *textPtr; @@ -3155,9 +3151,7 @@ DeleteIndexRange( for (i=0, hPtr=Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search); hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) { - TkTextTag *tagPtr = Tcl_GetHashValue(hPtr); - - TkBTreeTag(&index1, &index2, tagPtr, 0); + TkBTreeTag(&index1, &index2, (TkTextTag *)Tcl_GetHashValue(hPtr), 0); } /* @@ -3191,7 +3185,7 @@ DeleteIndexRange( resetViewCount = 0; if (sharedTextPtr->refCount > PIXEL_CLIENTS) { - lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); + lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); } else { lineAndByteIndex = pixels; } @@ -3380,7 +3374,7 @@ TextFetchSelection( * not including terminating NULL * character. */ { - register TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; TkTextIndex eof; int count, chunkSize, offsetInSeg; TkTextSearch search; @@ -3464,7 +3458,7 @@ TextFetchSelection( if ((segPtr->typePtr == &tkTextCharType) && !TkTextIsElided(textPtr, &textPtr->selIndex, NULL)) { memcpy(buffer, segPtr->body.chars + offsetInSeg, - (size_t) chunkSize); + chunkSize); buffer += chunkSize; maxBytes -= chunkSize; count += chunkSize; @@ -3511,7 +3505,7 @@ void TkTextLostSelection( ClientData clientData) /* Information about text widget. */ { - register TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; if (TkpAlwaysShowSelection(textPtr->tkwin)) { TkTextIndex start, end; @@ -3596,7 +3590,7 @@ static void TextBlinkProc( ClientData clientData) /* Pointer to record describing text. */ { - register TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; TkTextIndex index; int x, y, w, h, charWidth; @@ -3976,7 +3970,7 @@ TextSearchGetLineIndex( { const TkTextIndex *indexPtr; int line; - TkText *textPtr = searchSpecPtr->clientData; + TkText *textPtr = (TkText *)searchSpecPtr->clientData; indexPtr = TkTextGetIndexFromObj(interp, textPtr, objPtr); if (indexPtr == NULL) { @@ -4041,7 +4035,7 @@ TextSearchIndexInLine( TkTextSegment *segPtr; TkTextIndex curIndex; int index, leftToScan; - TkText *textPtr = searchSpecPtr->clientData; + TkText *textPtr = (TkText *)searchSpecPtr->clientData; index = 0; curIndex.tree = textPtr->sharedTextPtr->tree; @@ -4111,7 +4105,7 @@ TextSearchAddNextLine( TkTextLine *linePtr, *thisLinePtr; TkTextIndex curIndex; TkTextSegment *segPtr; - TkText *textPtr = searchSpecPtr->clientData; + TkText *textPtr = (TkText *)searchSpecPtr->clientData; int nothingYet = 1; /* @@ -4233,7 +4227,7 @@ TextSearchFoundMatch( TkTextIndex curIndex, foundIndex; TkTextSegment *segPtr; TkTextLine *linePtr; - TkText *textPtr = searchSpecPtr->clientData; + TkText *textPtr = (TkText *)searchSpecPtr->clientData; if (lineNum == searchSpecPtr->stopLine) { /* @@ -4284,7 +4278,7 @@ TextSearchFoundMatch( * reached the end of the match or we have reached the end of the line. */ - linePtr = clientData; + linePtr = (TkTextLine *)clientData; if (linePtr == NULL) { linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, lineNum); @@ -4494,8 +4488,8 @@ TkTextGetTabs( * Parse the elements of the list one at a time to fill in the array. */ - tabArrayPtr = ckalloc(sizeof(TkTextTabArray) - + (count - 1) * sizeof(TkTextTab)); + tabArrayPtr = (TkTextTabArray *)ckalloc(Tk_Offset(TkTextTabArray, tabs) + + count * sizeof(TkTextTab)); tabArrayPtr->numTabs = 0; prevStop = 0.0; lastStop = 0.0; @@ -4621,7 +4615,7 @@ TkTextGetTabs( static int TextDumpCmd( - register TkText *textPtr, /* Information about text widget. */ + 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 @@ -4708,14 +4702,13 @@ TextDumpCmd( if (objc == arg) { TkTextIndexForwChars(NULL, &index1, 1, &index2, COUNT_INDICES); } else { - size_t length; + int length; const char *str; if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) { return TCL_ERROR; } - str = Tcl_GetString(objv[arg]); - length = objv[arg]->length; + str = Tcl_GetStringFromObj(objv[arg], &length); if (strncmp(str, "end", length) == 0) { atEnd = 1; } @@ -4859,7 +4852,7 @@ DumpLine( */ int length = last - first; - char *range = ckalloc(length + 1); + char *range = (char *)ckalloc(length + 1); memcpy(range, segPtr->body.chars + first, length); range[length] = '\0'; @@ -4890,7 +4883,7 @@ DumpLine( name = NULL; lineChanged = 0; } else { - name = Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, + name = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, markPtr->hPtr); } if (name != NULL) { @@ -5016,7 +5009,7 @@ DumpSegment( const char *value, /* Segment value. */ Tcl_Obj *command, /* Script callback. */ const TkTextIndex *index, /* index with line/byte position info. */ - int what) /* Look for TK_DUMP_INDEX bit. */ + TCL_UNUSED(int)) /* Look for TK_DUMP_INDEX bit. */ { char buffer[TK_POS_CHARS]; Tcl_Obj *values[3], *tuple; @@ -5518,7 +5511,7 @@ void TkTextRunAfterSyncCmd( ClientData clientData) /* Information about text widget. */ { - register TkText *textPtr = (TkText *) clientData; + TkText *textPtr = (TkText *)clientData; int code; if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { @@ -5592,7 +5585,7 @@ SearchPerform( if (toPtr != NULL) { const TkTextIndex *indexToPtr, *indexFromPtr; - TkText *textPtr = searchSpecPtr->clientData; + TkText *textPtr = (TkText *)searchSpecPtr->clientData; indexToPtr = TkTextGetIndexFromObj(interp, textPtr, toPtr); if (indexToPtr == NULL) { @@ -5673,7 +5666,8 @@ SearchCore( * they are Unicode char offsets. */ - int firstOffset, lastOffset, matchOffset, matchLength; + int firstOffset, lastOffset; + int matchOffset, matchLength; int passes; int lineNum = searchSpecPtr->startLine; int code = TCL_OK; @@ -5746,8 +5740,7 @@ SearchCore( * it has dual purpose. */ - pattern = Tcl_GetString(patObj); - matchLength = patObj->length; + pattern = Tcl_GetStringFromObj(patObj, &matchLength); nl = strchr(pattern, '\n'); /* @@ -5916,7 +5909,7 @@ SearchCore( } while (p >= startOfLine + firstOffset) { if (matchLength == 0 || (p[0] == c && !strncmp( - p, pattern, (size_t) matchLength))) { + p, pattern, matchLength))) { goto backwardsMatch; } p--; @@ -5945,7 +5938,7 @@ SearchCore( */ p = startOfLine + lastOffset - firstNewLine - 1; - if (strncmp(p, pattern, (unsigned) firstNewLine + 1)) { + if (strncmp(p, pattern, firstNewLine + 1)) { /* * No match. */ @@ -6011,7 +6004,7 @@ SearchCore( * result. */ - if (strncmp(p,pattern,(size_t)matchLength)) { + if (strncmp(p, pattern, matchLength)) { p = NULL; } break; @@ -6259,8 +6252,8 @@ SearchCore( */ if ((match && - firstOffset+info.matches[0].end != lastTotal && - firstOffset+info.matches[0].end < prevFullLine) + firstOffset + info.matches[0].end != lastTotal && + firstOffset + info.matches[0].end < prevFullLine) || info.extendStart < 0) { break; } @@ -6329,8 +6322,8 @@ SearchCore( * Possible overlap or enclosure. */ - if (thisOffset-lastNonOverlap >= - lastBackwardsMatchOffset+matchLength){ + if (thisOffset - lastNonOverlap >= + lastBackwardsMatchOffset + matchLength){ /* * Totally encloses previous match, so * forget the previous match. @@ -6434,7 +6427,7 @@ SearchCore( * matches on the heap. */ - int *newArray = + int *newArray = (int *) ckalloc(4 * matchNum * sizeof(int)); memcpy(newArray, storeMatch, matchNum*sizeof(int)); memcpy(newArray + 2*matchNum, storeLength, @@ -6695,8 +6688,8 @@ SearchCore( static Tcl_Obj * GetLineStartEnd( - ClientData clientData, - Tk_Window tkwin, + TCL_UNUSED(void *), + TCL_UNUSED(Tk_Window), char *recordPtr, /* Pointer to widget record. */ int internalOffset) /* Offset within *recordPtr containing the * line value. */ @@ -6730,9 +6723,9 @@ GetLineStartEnd( static int SetLineStartEnd( - ClientData clientData, + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interp; may be used for errors. */ - Tk_Window tkwin, /* Window for which option is being set. */ + TCL_UNUSED(Tk_Window), /* Window for which option is being set. */ Tcl_Obj **value, /* Pointer to the pointer to the value object. * We use a pointer to the pointer because we * may need to return a value (NULL). */ @@ -6789,8 +6782,8 @@ SetLineStartEnd( static void RestoreLineStartEnd( - ClientData clientData, - Tk_Window tkwin, + TCL_UNUSED(void *), + TCL_UNUSED(Tk_Window), char *internalPtr, /* Pointer to storage for value. */ char *oldInternalPtr) /* Pointer to old value. */ { @@ -6848,7 +6841,7 @@ ObjectIsEmpty( int TkpTesttextCmd( - ClientData clientData, /* Main window for application. */ + TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ @@ -6867,7 +6860,7 @@ TkpTesttextCmd( if (Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) == 0) { return TCL_ERROR; } - textPtr = info.objClientData; + textPtr = (TkText *)info.objClientData; len = strlen(Tcl_GetString(objv[2])); if (strncmp(Tcl_GetString(objv[2]), "byteindex", len) == 0) { if (objc != 5) { diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6d680f6..6ab8508 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -444,8 +444,8 @@ typedef struct TextDInfo { typedef struct CharInfo { int numBytes; /* Number of bytes to display. */ - char chars[1]; /* UTF characters to display. Actual size will - * be numBytes, not 1. THIS MUST BE THE LAST + char chars[1]; /* UTF characters to display. + * Allocated as large as necessary. THIS MUST BE THE LAST * FIELD IN THE STRUCTURE. */ } CharInfo; @@ -658,10 +658,10 @@ void TkTextCreateDInfo( TkText *textPtr) /* Overall information for text widget. */ { - register TextDInfo *dInfoPtr; + TextDInfo *dInfoPtr; XGCValues gcValues; - dInfoPtr = ckalloc(sizeof(TextDInfo)); + dInfoPtr = (TextDInfo *)ckalloc(sizeof(TextDInfo)); Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int)); dInfoPtr->dLinePtr = NULL; dInfoPtr->copyGC = NULL; @@ -717,7 +717,7 @@ void TkTextFreeDInfo( TkText *textPtr) /* Overall information for text widget. */ { - register TextDInfo *dInfoPtr = textPtr->dInfoPtr; + TextDInfo *dInfoPtr = textPtr->dInfoPtr; /* * Be careful to free up styleTable *after* freeing up all the DLines, so @@ -773,7 +773,7 @@ GetStyle( * information is wanted. */ { TkTextTag **tagPtrs; - register TkTextTag *tagPtr; + TkTextTag *tagPtr; StyleValues styleValues; TextStyle *stylePtr; Tcl_HashEntry *hPtr; @@ -1002,7 +1002,7 @@ GetStyle( hPtr = Tcl_CreateHashEntry(&textPtr->dInfoPtr->styleTable, (char *) &styleValues, &isNew); if (!isNew) { - stylePtr = Tcl_GetHashValue(hPtr); + stylePtr = (TextStyle *)Tcl_GetHashValue(hPtr); stylePtr->refCount++; return stylePtr; } @@ -1011,7 +1011,7 @@ GetStyle( * No existing style matched. Make a new one. */ - stylePtr = ckalloc(sizeof(TextStyle)); + stylePtr = (TextStyle *)ckalloc(sizeof(TextStyle)); stylePtr->refCount = 1; if (styleValues.border != NULL) { gcValues.foreground = Tk_3DBorderColor(styleValues.border)->pixel; @@ -1069,7 +1069,7 @@ GetStyle( static void FreeStyle( TkText *textPtr, /* Information about overall widget. */ - register TextStyle *stylePtr) + TextStyle *stylePtr) /* Information about style to free. */ { stylePtr->refCount--; @@ -1132,7 +1132,7 @@ LayoutDLine( * necessarily point to a character * segment. */ { - register DLine *dlPtr; /* New display line. */ + DLine *dlPtr; /* New display line. */ TkTextSegment *segPtr; /* Current segment in text. */ TkTextDispChunk *lastChunkPtr; /* Last chunk allocated so far for line. */ @@ -1186,7 +1186,7 @@ LayoutDLine( * Create and initialize a new DLine structure. */ - dlPtr = ckalloc(sizeof(DLine)); + dlPtr = (DLine *)ckalloc(sizeof(DLine)); dlPtr->index = *indexPtr; dlPtr->byteCount = 0; dlPtr->y = 0; @@ -1435,7 +1435,7 @@ LayoutDLine( continue; } if (chunkPtr == NULL) { - chunkPtr = ckalloc(sizeof(TkTextDispChunk)); + chunkPtr = (TkTextDispChunk *)ckalloc(sizeof(TkTextDispChunk)); chunkPtr->nextPtr = NULL; chunkPtr->clientData = NULL; } @@ -1833,8 +1833,8 @@ static void UpdateDisplayInfo( TkText *textPtr) /* Text widget to update. */ { - register TextDInfo *dInfoPtr = textPtr->dInfoPtr; - register DLine *dlPtr, *prevPtr; + TextDInfo *dInfoPtr = textPtr->dInfoPtr; + DLine *dlPtr, *prevPtr; TkTextIndex index; TkTextLine *lastLinePtr; int y, maxY, xPixelOffset, maxOffset, lineHeight; @@ -1871,7 +1871,7 @@ UpdateDisplayInfo( y = dInfoPtr->y - dInfoPtr->newTopPixelOffset; maxY = dInfoPtr->maxY; while (1) { - register DLine *newPtr; + DLine *newPtr; if (index.linePtr == lastLinePtr) { break; @@ -1982,7 +1982,7 @@ UpdateDisplayInfo( */ if (index.linePtr != prevPtr->index.linePtr) { - register DLine *nextPtr; + DLine *nextPtr; nextPtr = dlPtr; while ((nextPtr != NULL) @@ -2351,7 +2351,7 @@ UpdateDisplayInfo( static void FreeDLines( TkText *textPtr, /* Information about overall text widget. */ - register DLine *firstPtr, /* Pointer to first DLine to free up. */ + DLine *firstPtr, /* Pointer to first DLine to free up. */ DLine *lastPtr, /* Pointer to DLine just after last one to * free (NULL means everything starting with * firstPtr). */ @@ -2364,8 +2364,8 @@ FreeDLines( * we shouldn't invalidate anything for the * overall widget. */ { - register TkTextDispChunk *chunkPtr, *nextChunkPtr; - register DLine *nextDLinePtr; + TkTextDispChunk *chunkPtr, *nextChunkPtr; + DLine *nextDLinePtr; if (action == DLINE_FREE_TEMP) { lineHeightsRecalculated++; @@ -2384,7 +2384,7 @@ FreeDLines( if (textPtr->dInfoPtr->dLinePtr == firstPtr) { textPtr->dInfoPtr->dLinePtr = lastPtr; } else { - register DLine *prevPtr; + DLine *prevPtr; for (prevPtr = textPtr->dInfoPtr->dLinePtr; prevPtr->nextPtr != firstPtr; prevPtr = prevPtr->nextPtr) { @@ -2432,14 +2432,14 @@ FreeDLines( static void DisplayDLine( TkText *textPtr, /* Text widget in which to draw line. */ - register DLine *dlPtr, /* Information about line to draw. */ + DLine *dlPtr, /* Information about line to draw. */ DLine *prevPtr, /* Line just before one to draw, or NULL if * dlPtr is the top line. */ Pixmap pixmap) /* Pixmap to use for double-buffering. Caller * must make sure it's large enough to hold * line. */ { - register TkTextDispChunk *chunkPtr; + TkTextDispChunk *chunkPtr; TextDInfo *dInfoPtr = textPtr->dInfoPtr; Display *display; int height, y_off; @@ -2611,7 +2611,7 @@ DisplayDLine( static void DisplayLineBackground( TkText *textPtr, /* Text widget containing line. */ - register DLine *dlPtr, /* Information about line to draw. */ + DLine *dlPtr, /* Information about line to draw. */ DLine *prevPtr, /* Line just above dlPtr, or NULL if dlPtr is * the top-most line in the window. */ Pixmap pixmap) /* Pixmap to use for double-buffering. Caller @@ -3007,7 +3007,7 @@ static void AsyncUpdateLineMetrics( ClientData clientData) /* Information about widget. */ { - register TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; TextDInfo *dInfoPtr = textPtr->dInfoPtr; int lineNum; @@ -4164,9 +4164,9 @@ static void DisplayText( ClientData clientData) /* Information about widget. */ { - register TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; TextDInfo *dInfoPtr = textPtr->dInfoPtr; - register DLine *dlPtr; + DLine *dlPtr; DLine *prevPtr; Pixmap pixmap; int maxHeight, borders; @@ -4254,7 +4254,7 @@ DisplayText( */ for (dlPtr = dInfoPtr->dLinePtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { - register DLine *dlPtr2; + DLine *dlPtr2; int offset, height, y, oldY; TkRegion damageRgn; @@ -4552,7 +4552,7 @@ DisplayText( * proc of embedded windows only. */ #endif - register TkTextDispChunk *chunkPtr; + TkTextDispChunk *chunkPtr; for (chunkPtr = dlPtr->chunkPtr; (chunkPtr != NULL); chunkPtr = chunkPtr->nextPtr) { @@ -4754,7 +4754,7 @@ TextInvalidateRegion( TkText *textPtr, /* Widget record for text widget. */ TkRegion region) /* Region of area to redraw. */ { - register DLine *dlPtr; + DLine *dlPtr; TextDInfo *dInfoPtr = textPtr->dInfoPtr; int maxY, inset; XRectangle rect; @@ -5012,7 +5012,7 @@ TextRedrawTag( int withTag) /* 1 means redraw characters that have the * tag, 0 means redraw those without. */ { - register DLine *dlPtr; + DLine *dlPtr; DLine *endPtr; int tagOn; TkTextSearch search; @@ -5352,7 +5352,7 @@ TkTextSetYView( * are to be off the top of the screen. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - register DLine *dlPtr; + DLine *dlPtr; int bottomY, close, lineIndex; TkTextIndex tmpIndex, rounded; int lineHeight; @@ -6180,7 +6180,7 @@ TkTextYviewCmd( pickPlace = 0; if (Tcl_GetString(objv[2])[0] == '-') { - register const char *switchStr = + const char *switchStr = Tcl_GetStringFromObj(objv[2], &switchLength); if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace", @@ -6358,7 +6358,7 @@ TkTextPendingsync( int TkTextScanCmd( - register TkText *textPtr, /* Information about text widget. */ + 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 @@ -6844,7 +6844,7 @@ static void AsyncUpdateYScrollbar( ClientData clientData) /* Information about widget. */ { - register TkText *textPtr = clientData; + TkText *textPtr = (TkText *)clientData; textPtr->dInfoPtr->scrollbarTimer = NULL; @@ -6879,7 +6879,7 @@ AsyncUpdateYScrollbar( static DLine * FindDLine( TkText *textPtr, /* Widget record for text widget. */ - register DLine *dlPtr, /* Pointer to first in list of DLines to + DLine *dlPtr, /* Pointer to first in list of DLines to * search. */ const TkTextIndex *indexPtr)/* Index of desired character. */ { @@ -7049,7 +7049,7 @@ TkTextPixelIndex( * border of the widget). */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - register DLine *dlPtr, *validDlPtr; + DLine *dlPtr, *validDlPtr; int nearby = 0; /* @@ -7151,7 +7151,7 @@ DlineIndexOfX( * the character nearest to x. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - register TkTextDispChunk *chunkPtr; + TkTextDispChunk *chunkPtr; /* * Scan through the line's chunks to find the one that contains the @@ -7279,7 +7279,7 @@ DlineXOfIndex( int byteIndex) /* The byte index for which we want the * coordinate. */ { - register TkTextDispChunk *chunkPtr = dlPtr->chunkPtr; + TkTextDispChunk *chunkPtr = dlPtr->chunkPtr; int x = 0; if (byteIndex == 0 || chunkPtr == NULL) { @@ -7349,7 +7349,7 @@ TkTextIndexBbox( { TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr; - register TkTextDispChunk *chunkPtr; + TkTextDispChunk *chunkPtr; int byteCount; /* @@ -7541,14 +7541,14 @@ TkTextDLineInfo( static void ElideBboxProc( - TkText *textPtr, + TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ - int index, /* Index of desired character within the + TCL_UNUSED(int), /* Index of desired character within the * chunk. */ int y, /* Topmost pixel in area allocated for this * line. */ - int lineHeight, /* Height of line, in pixels. */ - int baseline, /* Location of line's baseline, in pixels + TCL_UNUSED(int), /* Height of line, in pixels. */ + TCL_UNUSED(int), /* Location of line's baseline, in pixels * measured down from y. */ int *xPtr, int *yPtr, /* Gets filled in with coords of character's * upper-left pixel. X-coord is in same @@ -7569,8 +7569,8 @@ ElideBboxProc( static int ElideMeasureProc( - TkTextDispChunk *chunkPtr, /* Chunk containing desired coord. */ - int x) /* X-coordinate, in same coordinate system as + TCL_UNUSED(TkTextDispChunk *), /* Chunk containing desired coord. */ + TCL_UNUSED(int)) /* X-coordinate, in same coordinate system as * chunkPtr->x. */ { return 0 /*chunkPtr->numBytes - 1*/; @@ -7599,8 +7599,8 @@ ElideMeasureProc( int TkTextCharLayoutProc( - TkText *textPtr, /* Text widget being layed out. */ - TkTextIndex *indexPtr, /* Index of first character to lay out + TCL_UNUSED(TkText *), /* Text widget being layed out. */ + TCL_UNUSED(TkTextIndex *), /* Index of first character to lay out * (corresponds to segPtr and offset). */ TkTextSegment *segPtr, /* Segment being layed out. */ int byteOffset, /* Byte offset within segment of first @@ -7614,7 +7614,7 @@ TkTextCharLayoutProc( TkWrapMode wrapMode, /* How to handle line wrapping: * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or * TEXT_WRAPMODE_WORD. */ - register TkTextDispChunk *chunkPtr) + TkTextDispChunk *chunkPtr) /* Structure to fill in with information about * this chunk. The x field has already been * set by the caller. */ @@ -7765,9 +7765,9 @@ TkTextCharLayoutProc( chunkPtr->breakIndex = -1; #if !TK_LAYOUT_WITH_BASE_CHUNKS - ciPtr = ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit); + ciPtr = (CharInfo *)ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit); chunkPtr->clientData = ciPtr; - memcpy(ciPtr->chars, p, (unsigned) bytesThatFit); + memcpy(ciPtr->chars, p, bytesThatFit); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ ciPtr->numBytes = bytesThatFit; @@ -7878,7 +7878,7 @@ CharChunkMeasureChars( * here. */ { Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; - CharInfo *ciPtr = chunkPtr->clientData; + CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; #if !TK_LAYOUT_WITH_BASE_CHUNKS if (chars == NULL) { @@ -7953,21 +7953,21 @@ CharChunkMeasureChars( static void CharDisplayProc( - TkText *textPtr, + TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk that is to be drawn. */ int x, /* X-position in dst at which to draw this * chunk (may differ from the x-position in * the chunk because of scrolling). */ int y, /* Y-position at which to draw this chunk in * dst. */ - int height, /* Total height of line. */ + TCL_UNUSED(int), /* Total height of line. */ int baseline, /* Offset of baseline from y. */ Display *display, /* Display to use for drawing. */ Drawable dst, /* Pixmap or window in which to draw chunk. */ - int screenY) /* Y-coordinate in text window that + TCL_UNUSED(int)) /* Y-coordinate in text window that * corresponds to y. */ { - CharInfo *ciPtr = chunkPtr->clientData; + CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; const char *string; TextStyle *stylePtr; StyleValues *sValuePtr; @@ -8115,10 +8115,10 @@ CharDisplayProc( static void CharUndisplayProc( - TkText *textPtr, /* Overall information about text widget. */ + TCL_UNUSED(TkText *), /* Overall information about text widget. */ TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */ { - CharInfo *ciPtr = chunkPtr->clientData; + CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; if (ciPtr) { #if TK_LAYOUT_WITH_BASE_CHUNKS @@ -8204,13 +8204,13 @@ CharMeasureProc( static void CharBboxProc( - TkText *textPtr, + TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ int byteIndex, /* Byte offset of desired character within the * chunk. */ int y, /* Topmost pixel in area allocated for this * line. */ - int lineHeight, /* Height of line, in pixels. */ + TCL_UNUSED(int), /* Height of line, in pixels. */ int baseline, /* Location of line's baseline, in pixels * measured down from y. */ int *xPtr, int *yPtr, /* Gets filled in with coords of character's @@ -8221,7 +8221,7 @@ CharBboxProc( int *heightPtr) /* Gets filled in with height of character, in * pixels. */ { - CharInfo *ciPtr = chunkPtr->clientData; + CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; int maxX; maxX = chunkPtr->width + chunkPtr->x; @@ -8384,7 +8384,7 @@ AdjustForTab( if (chunkPtr2->displayProc != CharDisplayProc) { continue; } - ciPtr = chunkPtr2->clientData; + ciPtr = (CharInfo *)chunkPtr2->clientData; for (p = ciPtr->chars, i = 0; i < ciPtr->numBytes; p++, i++) { if (isdigit(UCHAR(*p))) { gotDigit = 1; @@ -8405,7 +8405,7 @@ AdjustForTab( if (decimalChunkPtr != NULL) { int curX; - ciPtr = decimalChunkPtr->clientData; + ciPtr = (CharInfo *)decimalChunkPtr->clientData; CharChunkMeasureChars(decimalChunkPtr, NULL, 0, 0, decimal, decimalChunkPtr->x, -1, 0, &curX); desired = tabX - (curX - x); @@ -8676,7 +8676,7 @@ MeasureChars( int curX, width, ch; const char *special, *end, *start; - ch = 0; /* lint. */ + ch = 0; curX = startX; start = source + rangeStart; end = start + rangeLength; diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 00893f2..029f3aa 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -27,7 +27,7 @@ typedef struct ProtocolHandler { /* Next in list of protocol handlers for the * same top-level window, or NULL for end of * list. */ - Tcl_Interp *interp; /* Interpreter in which to invoke command. */ + Tcl_Interp *interp; /* Interpreter in which to invoke command. */ char command[1]; /* Tcl command to invoke when a client message * for this protocol arrives. The actual size * of the structure varies to accommodate the diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 923a58f..ff3f07f 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -57,7 +57,7 @@ typedef struct ProtocolHandler { /* Next in list of protocol handlers for the * same top-level window, or NULL for end of * list. */ - Tcl_Interp *interp; /* Interpreter in which to invoke command. */ + Tcl_Interp *interp; /* Interpreter in which to invoke command. */ char command[1]; /* Tcl command to invoke when a client message * for this protocol arrives. The actual size * of the structure varies to accommodate the -- cgit v0.12