From e80eb01a0079da5a6ad2d524d67b8c8bdfb4fb7e Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 17 Nov 2005 16:21:55 +0000 Subject: ANSIfy and reduce casting of NULL to promote readability --- generic/tkClipboard.c | 8 +- generic/tkConfig.c | 47 +- generic/tkGrid.c | 83 +-- generic/tkImage.c | 13 +- generic/tkImgGIF.c | 391 +++++------ generic/tkImgPPM.c | 104 +-- generic/tkImgPhoto.c | 596 ++++++++-------- generic/tkListbox.c | 113 +-- generic/tkMenu.c | 1849 ++++++++++++++++++++++++------------------------- generic/tkObj.c | 12 +- generic/tkOldConfig.c | 29 +- generic/tkScale.c | 33 +- generic/tkSelect.c | 25 +- generic/tkStubInit.c | 16 +- generic/tkTest.c | 6 +- generic/tkText.c | 66 +- generic/tkText.h | 1432 ++++++++++++++++++-------------------- generic/tkTextBTree.c | 42 +- generic/tkTextIndex.c | 6 +- generic/tkTrig.c | 180 ++--- generic/tkUndo.c | 5 +- generic/tkWindow.c | 75 +- 22 files changed, 2488 insertions(+), 2643 deletions(-) diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c index b580499..bf4876d 100644 --- a/generic/tkClipboard.c +++ b/generic/tkClipboard.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkClipboard.c,v 1.14 2005/10/17 22:14:32 dkf Exp $ + * RCS: @(#) $Id: tkClipboard.c,v 1.15 2005/11/17 16:21:55 dkf Exp $ */ #include "tkInt.h" @@ -373,7 +373,7 @@ Tk_ClipboardAppend( Tcl_AppendResult(interp, "format \"", Tk_GetAtomName(tkwin, format), "\" does not match current format \"", Tk_GetAtomName(tkwin, targetPtr->format),"\" for ", - Tk_GetAtomName(tkwin, type), (char *) NULL); + Tk_GetAtomName(tkwin, type), NULL); return TCL_ERROR; } @@ -478,7 +478,7 @@ Tk_ClipboardObjCmd( i++; if (i >= objc) { Tcl_AppendResult(interp, "value for \"", string, - "\" missing", (char *) NULL); + "\" missing", NULL); return TCL_ERROR; } switch ((enum appendOptions) subIndex) { @@ -567,7 +567,7 @@ Tk_ClipboardObjCmd( i++; if (i >= objc) { Tcl_AppendResult(interp, "value for \"", string, - "\" missing", (char *) NULL); + "\" missing", NULL); return TCL_ERROR; } switch ((enum getOptions) subIndex) { diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 87ad572..ec6aa23 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkConfig.c,v 1.21 2005/10/10 21:21:00 hobbs Exp $ + * RCS: @(#) $Id: tkConfig.c,v 1.22 2005/11/17 16:21:55 dkf Exp $ */ /* @@ -139,11 +139,11 @@ static int SetOptionFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); */ Tcl_ObjType tkOptionObjType = { - "option", /* name */ - (Tcl_FreeInternalRepProc *) NULL, /* freeIntRepProc */ - (Tcl_DupInternalRepProc *) NULL, /* dupIntRepProc */ - (Tcl_UpdateStringProc *) NULL, /* updateStringProc */ - SetOptionFromAny /* setFromAnyProc */ + "option", /* name */ + NULL, /* freeIntRepProc */ + NULL, /* dupIntRepProc */ + NULL, /* updateStringProc */ + SetOptionFromAny /* setFromAnyProc */ }; /* @@ -553,7 +553,7 @@ Tk_InitOptions(interp, recordPtr, optionTable, tkwin) Tcl_IncrRefCount(valuePtr); if (DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, - (Tk_SavedOption *) NULL) != TCL_OK) { + NULL) != TCL_OK) { if (interp != NULL) { char msg[200]; @@ -1158,7 +1158,7 @@ GetOptionFromObj(interp, objPtr, tablePtr) error: if (interp != NULL) { - Tcl_AppendResult(interp, "unknown option \"",name,"\"", (char *) NULL); + Tcl_AppendResult(interp, "unknown option \"", name, "\"", NULL); } return NULL; } @@ -1311,7 +1311,7 @@ Tk_SetOptions(interp, recordPtr, optionTable, objc, objv, tkwin, savePtr, if (interp != NULL) { Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "value for \"", Tcl_GetStringFromObj(*objv, NULL), - "\" missing", (char *) NULL); + "\" missing", NULL); goto error; } } @@ -1332,7 +1332,7 @@ Tk_SetOptions(interp, recordPtr, optionTable, objc, objv, tkwin, savePtr, } if (DoObjConfig(interp, recordPtr, optionPtr, objv[1], tkwin, (savePtr != NULL) ? &lastSavePtr->items[lastSavePtr->numItems] - : (Tk_SavedOption *) NULL) != TCL_OK) { + : NULL) != TCL_OK) { char msg[100]; sprintf(msg, "\n (processing \"%.40s\" option)", @@ -1795,7 +1795,7 @@ Tk_GetOptionInfo(interp, recordPtr, optionTable, namePtr, tkwin) if (namePtr != NULL) { optionPtr = GetOptionFromObj(interp, namePtr, tablePtr); if (optionPtr == NULL) { - return (Tcl_Obj *) NULL; + return NULL; } if (optionPtr->specPtr->type == TK_OPTION_SYNONYM) { optionPtr = optionPtr->extra.synonymPtr; @@ -1808,7 +1808,7 @@ Tk_GetOptionInfo(interp, recordPtr, optionTable, namePtr, tkwin) * information. */ - resultPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); + resultPtr = Tcl_NewListObj(0, NULL); for (; tablePtr != NULL; tablePtr = tablePtr->nextPtr) { for (optionPtr = tablePtr->options, count = tablePtr->numOptions; count > 0; optionPtr++, count--) { @@ -1847,28 +1847,28 @@ GetConfigList(recordPtr, optionPtr, tkwin) { Tcl_Obj *listPtr, *elementPtr; - listPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, listPtr, + listPtr = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewStringObj(optionPtr->specPtr->optionName, -1)); if (optionPtr->specPtr->type == TK_OPTION_SYNONYM) { elementPtr = Tcl_NewStringObj( optionPtr->extra.synonymPtr->specPtr->optionName, -1); - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, listPtr, elementPtr); + Tcl_ListObjAppendElement(NULL, listPtr, elementPtr); } else { if (optionPtr->dbNameUID == NULL) { elementPtr = Tcl_NewObj(); } else { elementPtr = Tcl_NewStringObj(optionPtr->dbNameUID, -1); } - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, listPtr, elementPtr); + Tcl_ListObjAppendElement(NULL, listPtr, elementPtr); if (optionPtr->dbClassUID == NULL) { elementPtr = Tcl_NewObj(); } else { elementPtr = Tcl_NewStringObj(optionPtr->dbClassUID, -1); } - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, listPtr, elementPtr); + Tcl_ListObjAppendElement(NULL, listPtr, elementPtr); if ((tkwin != NULL) && ((optionPtr->specPtr->type == TK_OPTION_COLOR) || (optionPtr->specPtr->type == TK_OPTION_BORDER)) @@ -1880,7 +1880,7 @@ GetConfigList(recordPtr, optionPtr, tkwin) } else { elementPtr = Tcl_NewObj(); } - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, listPtr, elementPtr); + Tcl_ListObjAppendElement(NULL, listPtr, elementPtr); if (optionPtr->specPtr->objOffset >= 0) { elementPtr = *((Tcl_Obj **) (recordPtr @@ -1891,7 +1891,7 @@ GetConfigList(recordPtr, optionPtr, tkwin) } else { elementPtr = GetObjectForOption(recordPtr, optionPtr, tkwin); } - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, listPtr, elementPtr); + Tcl_ListObjAppendElement(NULL, listPtr, elementPtr); } return listPtr; } @@ -2148,13 +2148,12 @@ TkDebugConfig(interp, table) hashEntryPtr = Tcl_NextHashEntry(&search)) { if (tablePtr == (OptionTable *) Tcl_GetHashValue(hashEntryPtr)) { for ( ; tablePtr != NULL; tablePtr = tablePtr->nextPtr) { - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, objPtr, + Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(tablePtr->refCount)); - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, objPtr, + Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(tablePtr->numOptions)); - Tcl_ListObjAppendElement((Tcl_Interp *) NULL, objPtr, - Tcl_NewStringObj( - tablePtr->options[0].specPtr->optionName, -1)); + Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj( + tablePtr->options[0].specPtr->optionName, -1)); } break; } diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 0caf89f..e9dfce1 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkGrid.c,v 1.40 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkGrid.c,v 1.41 2005/11/17 16:21:55 dkf Exp $ */ #include "tkInt.h" @@ -333,7 +333,7 @@ Tk_GridObjCmd(clientData, interp, objc, objv) static CONST char *optionStrings[] = { "anchor", "bbox", "columnconfigure", "configure", "forget", "info", "location", "propagate", "remove", - "rowconfigure", "size", "slaves", (char *) NULL + "rowconfigure", "size", "slaves", NULL }; enum options { GRID_ANCHOR, GRID_BBOX, GRID_COLUMNCONFIGURE, GRID_CONFIGURE, @@ -655,8 +655,7 @@ GridForgetRemoveCommand(tkwin, interp, objc, objv) slavePtr->flags = 0; slavePtr->sticky = 0; } - Tk_ManageGeometry(slave, (Tk_GeomMgr *) NULL, - (ClientData) NULL); + Tk_ManageGeometry(slave, NULL, (ClientData) NULL); if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); @@ -714,13 +713,13 @@ GridInfoCommand(tkwin, interp, objc, objv) sprintf(buffer, " -column %d -row %d -columnspan %d -rowspan %d", slavePtr->column, slavePtr->row, slavePtr->numCols, slavePtr->numRows); - Tcl_AppendResult(interp, buffer, (char *) NULL); + Tcl_AppendResult(interp, buffer, NULL); TkPrintPadAmount(interp, "ipadx", slavePtr->iPadX/2, slavePtr->iPadX); TkPrintPadAmount(interp, "ipady", slavePtr->iPadY/2, slavePtr->iPadY); TkPrintPadAmount(interp, "padx", slavePtr->padLeft, slavePtr->padX); TkPrintPadAmount(interp, "pady", slavePtr->padTop, slavePtr->padY); StickyToString(slavePtr->sticky, buffer); - Tcl_AppendResult(interp, " -sticky ", buffer, (char *) NULL); + Tcl_AppendResult(interp, " -sticky ", buffer, NULL); return TCL_OK; } @@ -928,7 +927,7 @@ GridRowColumnConfigureCommand(tkwin, interp, objc, objv) int i, j, first, last; char *string; static CONST char *optionStrings[] = { - "-minsize", "-pad", "-uniform", "-weight", (char *) NULL + "-minsize", "-pad", "-uniform", "-weight", NULL }; enum options { ROWCOL_MINSIZE, ROWCOL_PAD, ROWCOL_UNIFORM, ROWCOL_WEIGHT }; int index; @@ -955,13 +954,13 @@ GridRowColumnConfigureCommand(tkwin, interp, objc, objv) if ((objc == 4) || (objc == 5)) { if (lObjc != 1) { Tcl_AppendResult(interp, Tcl_GetString(objv[3]), - " must be a single element.", (char *) NULL); + " must be a single element.", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, lObjv[0], &slot) != TCL_OK) { Tcl_AppendResult(interp, " (when retreiving options only integer indices are allowed)", - (char *) NULL); + NULL); return TCL_ERROR; } ok = CheckSlotData(masterPtr, slot, slotType, /* checkOnly */ 1); @@ -1055,16 +1054,15 @@ GridRowColumnConfigureCommand(tkwin, interp, objc, objv) Tcl_ResetResult(interp); Tcl_AppendResult(interp, Tcl_GetString(objv[0]), " ", Tcl_GetString(objv[1]), ": the window \"", - Tcl_GetString(lObjv[j]), - "\" is not managed by \"", Tcl_GetString(objv[2]), - "\"", (char *) NULL); + Tcl_GetString(lObjv[j]), "\" is not managed by \"", + Tcl_GetString(objv[2]), "\"", NULL); return TCL_ERROR; } } else { Tcl_ResetResult(interp); Tcl_AppendResult(interp, Tcl_GetString(objv[0]), " ", Tcl_GetString(objv[1]), ": illegal index \"", - Tcl_GetString(lObjv[j]), "\"", (char *) NULL); + Tcl_GetString(lObjv[j]), "\"", NULL); return TCL_ERROR; } @@ -1086,7 +1084,7 @@ GridRowColumnConfigureCommand(tkwin, interp, objc, objv) Tcl_AppendResult(interp, Tcl_GetString(objv[0]), " ", Tcl_GetString(objv[1]), ": \"", Tcl_GetString(lObjv[j]), - "\" is out of range", (char *) NULL); + "\" is out of range", NULL); return TCL_ERROR; } slotPtr = (slotType == COLUMN) ? @@ -1117,7 +1115,7 @@ GridRowColumnConfigureCommand(tkwin, interp, objc, objv) } else if (wt < 0) { Tcl_AppendResult(interp, "invalid arg \"", Tcl_GetString(objv[i]), - "\": should be non-negative", (char *) NULL); + "\": should be non-negative", NULL); return TCL_ERROR; } else { slotPtr[slot].weight = wt; @@ -1136,7 +1134,7 @@ GridRowColumnConfigureCommand(tkwin, interp, objc, objv) } else if (size < 0) { Tcl_AppendResult(interp, "invalid arg \"", Tcl_GetString(objv[i]), - "\": should be non-negative", (char *) NULL); + "\": should be non-negative", NULL); return TCL_ERROR; } else { slotPtr[slot].pad = size; @@ -1264,7 +1262,7 @@ GridSlavesCommand(tkwin, interp, objc, objv) int i, value; int row = -1, column = -1; static CONST char *optionStrings[] = { - "-column", "-row", (char *) NULL + "-column", "-row", NULL }; enum options { SLAVES_COLUMN, SLAVES_ROW }; int index; @@ -1285,8 +1283,7 @@ GridSlavesCommand(tkwin, interp, objc, objv) } if (value < 0) { Tcl_AppendResult(interp, Tcl_GetString(objv[i]), - " is an invalid value: should NOT be < 0", - (char *) NULL); + " is an invalid value: should NOT be < 0", NULL); return TCL_ERROR; } if (index == SLAVES_COLUMN) { @@ -2766,7 +2763,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) int numSkip; /* Number of 'x' found */ static CONST char *optionStrings[] = { "-column", "-columnspan", "-in", "-ipadx", "-ipady", - "-padx", "-pady", "-row", "-rowspan", "-sticky", (char *) NULL + "-padx", "-pady", "-row", "-rowspan", "-sticky", NULL }; enum options { CONF_COLUMN, CONF_COLUMNSPAN, CONF_IN, CONF_IPADX, CONF_IPADY, @@ -2809,7 +2806,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) } if (length > 1 && i == 0) { Tcl_AppendResult(interp, "bad argument \"", string, - "\": must be name of window", (char *) NULL); + "\": must be name of window", NULL); return TCL_ERROR; } if (length > 1 && firstChar == '-') { @@ -2818,15 +2815,14 @@ ConfigureSlaves(interp, tkwin, objc, objv) if (length > 1) { Tcl_AppendResult(interp, "unexpected parameter, \"", string, "\", in configure list. ", - "Should be window name or option", (char *) NULL); + "Should be window name or option", NULL); return TCL_ERROR; } if ((firstChar == REL_HORIZ) && ((numWindows == 0) || (prevChar == REL_SKIP) || (prevChar == REL_VERT))) { Tcl_AppendResult(interp, - "Must specify window before shortcut '-'.", - (char *) NULL); + "Must specify window before shortcut '-'.", NULL); return TCL_ERROR; } @@ -2836,14 +2832,13 @@ ConfigureSlaves(interp, tkwin, objc, objv) } Tcl_AppendResult(interp, "invalid window shortcut, \"", - string, "\" should be '-', 'x', or '^'", (char *) NULL); + string, "\" should be '-', 'x', or '^'", NULL); return TCL_ERROR; } numWindows = i; if ((objc - numWindows) & 1) { - Tcl_AppendResult(interp, "extra option or", - " option with no value", (char *) NULL); + Tcl_AppendResult(interp, "extra option or option with no value", NULL); return TCL_ERROR; } @@ -2872,7 +2867,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) Tcl_ResetResult(interp); Tcl_AppendResult(interp, "bad row value \"", Tcl_GetString(objv[i+1]), - "\": must be a non-negative integer", (char *) NULL); + "\": must be a non-negative integer", NULL); return TCL_ERROR; } defaultRow = tmp; @@ -2934,7 +2929,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) if (Tk_TopWinHierarchy(slave)) { Tcl_AppendResult(interp, "can't manage \"", Tcl_GetString(objv[j]), - "\": it's a top-level window", (char *) NULL); + "\": it's a top-level window", NULL); return TCL_ERROR; } slavePtr = GetGrid(slave); @@ -2963,7 +2958,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) || tmp < 0) { Tcl_AppendResult(interp, "bad column value \"", Tcl_GetString(objv[i+1]), - "\": must be a non-negative integer", (char *)NULL); + "\": must be a non-negative integer", NULL); return TCL_ERROR; } slavePtr->column = tmp; @@ -2973,7 +2968,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) || tmp <= 0) { Tcl_AppendResult(interp, "bad columnspan value \"", Tcl_GetString(objv[i+1]), - "\": must be a positive integer", (char *)NULL); + "\": must be a positive integer", NULL); return TCL_ERROR; } slavePtr->numCols = tmp; @@ -2999,7 +2994,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) Tcl_AppendResult(interp, "bad stickyness value \"", Tcl_GetString(objv[i+1]), "\": must be a string containing n, e, s, and/or w", - (char *)NULL); + NULL); return TCL_ERROR; } slavePtr->sticky = sticky; @@ -3010,8 +3005,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) &tmp) != TCL_OK) || (tmp < 0)) { Tcl_AppendResult(interp, "bad ipadx value \"", Tcl_GetString(objv[i+1]), - "\": must be positive screen distance", - (char *) NULL); + "\": must be positive screen distance", NULL); return TCL_ERROR; } slavePtr->iPadX = tmp*2; @@ -3021,8 +3015,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) &tmp) != TCL_OK) || (tmp < 0)) { Tcl_AppendResult(interp, "bad ipady value \"", Tcl_GetString(objv[i+1]), - "\": must be positive screen distance", - (char *) NULL); + "\": must be positive screen distance", NULL); return TCL_ERROR; } slavePtr->iPadY = tmp*2; @@ -3044,8 +3037,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) || tmp < 0) { Tcl_AppendResult(interp, "bad row value \"", Tcl_GetString(objv[i+1]), - "\": must be a non-negative integer", - (char *) NULL); + "\": must be a non-negative integer", NULL); return TCL_ERROR; } slavePtr->row = tmp; @@ -3055,7 +3047,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) || tmp <= 0) { Tcl_AppendResult(interp, "bad rowspan value \"", Tcl_GetString(objv[i+1]), - "\": must be a positive integer", (char *) NULL); + "\": must be a positive integer", NULL); return TCL_ERROR; } slavePtr->numRows = tmp; @@ -3118,8 +3110,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) } if (Tk_TopWinHierarchy(ancestor)) { Tcl_AppendResult(interp, "can't put ", Tcl_GetString(objv[j]), - " inside ", Tk_PathName(masterPtr->tkwin), - (char *) NULL); + " inside ", Tk_PathName(masterPtr->tkwin), NULL); Unlink(slavePtr); return TCL_ERROR; } @@ -3132,7 +3123,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) if (masterPtr->masterPtr == slavePtr) { Tcl_AppendResult(interp, "can't put ", Tcl_GetString(objv[j]), " inside ", Tk_PathName(masterPtr->tkwin), - ", would cause management loop.", (char *) NULL); + ", would cause management loop.", NULL); Unlink(slavePtr); return TCL_ERROR; } @@ -3193,8 +3184,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) } if (masterPtr == NULL) { - Tcl_AppendResult(interp, "can't use '^', cant find master", - (char *) NULL); + Tcl_AppendResult(interp, "can't use '^', cant find master", NULL); return TCL_ERROR; } @@ -3244,14 +3234,13 @@ ConfigureSlaves(interp, tkwin, objc, objv) } if (!match) { Tcl_AppendResult(interp, "can't find slave to extend with \"^\".", - (char *) NULL); + NULL); return TCL_ERROR; } } if (masterPtr == NULL) { - Tcl_AppendResult(interp, "can't determine master window", - (char *) NULL); + Tcl_AppendResult(interp, "can't determine master window", NULL); return TCL_ERROR; } SetGridSize(masterPtr); diff --git a/generic/tkImage.c b/generic/tkImage.c index 58a60de..0ae7046 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkImage.c,v 1.26 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkImage.c,v 1.27 2005/11/17 16:21:55 dkf Exp $ */ #include "tkInt.h" @@ -159,7 +159,7 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) { static CONST char *imageOptions[] = { "create", "delete", "height", "inuse", "names", "type", "types", - "width", (char *) NULL + "width", NULL }; enum options { IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_INUSE, IMAGE_NAMES, @@ -220,7 +220,7 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) } if (typePtr == NULL) { Tcl_AppendResult(interp, "image type \"", arg, "\" doesn't exist", - (char *) NULL); + NULL); return TCL_ERROR; } @@ -252,7 +252,7 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) topWin = (TkWindow *) TkToplevelWindowForCommand(interp, name); if (topWin != NULL && winPtr->mainPtr->winPtr == topWin) { Tcl_AppendResult(interp, "images may not be named the ", - "same as the main window", (char *) NULL); + "same as the main window", NULL); return TCL_ERROR; } } @@ -436,7 +436,7 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) return TCL_OK; alreadyDeleted: - Tcl_AppendResult(interp, "image \"",arg,"\" doesn't exist", (char *) NULL); + Tcl_AppendResult(interp, "image \"", arg, "\" doesn't exist", NULL); return TCL_ERROR; } @@ -574,8 +574,7 @@ Tk_GetImage(interp, tkwin, name, changeProc, clientData) return (Tk_Image) imagePtr; noSuchImage: - Tcl_AppendResult(interp, "image \"", name, "\" doesn't exist", - (char *) NULL); + Tcl_AppendResult(interp, "image \"", name, "\" doesn't exist", NULL); return NULL; } diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 1c58769..e1b35a6 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -32,7 +32,7 @@ * This file also contains code from miGIF. See lower down in file for the * applicable copyright notice for that portion. * - * RCS: @(#) $Id: tkImgGIF.c,v 1.29 2005/08/10 22:02:22 dkf Exp $ + * RCS: @(#) $Id: tkImgGIF.c,v 1.30 2005/11/17 16:21:55 dkf Exp $ */ /* @@ -204,13 +204,14 @@ static void mInit(unsigned char *string, MFile *handle, */ static int -FileMatchGIF(chan, fileName, format, widthPtr, heightPtr, interp) - Tcl_Channel chan; /* The image file, open for reading. */ - CONST char *fileName; /* The name of the image file. */ - Tcl_Obj *format; /* User-specified format object, or NULL. */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned +FileMatchGIF( + Tcl_Channel chan, /* The image file, open for reading. */ + CONST char *fileName, /* The name of the image file. */ + Tcl_Obj *format, /* User-specified format object, or NULL. */ + int *widthPtr, int *heightPtr, + /* The dimensions of the image are returned * here if the file is a valid raw GIF file. */ - Tcl_Interp *interp; /* not used */ + Tcl_Interp *interp) /* not used */ { GIFImageConfig gifConf; @@ -238,18 +239,17 @@ FileMatchGIF(chan, fileName, format, widthPtr, heightPtr, interp) */ static int -FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, - width, height, srcX, srcY) - Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ - Tcl_Channel chan; /* The image file, open for reading. */ - CONST char *fileName; /* The name of the image file. */ - Tcl_Obj *format; /* User-specified format object, or NULL. */ - Tk_PhotoHandle imageHandle; /* The photo image to write into. */ - int destX, destY; /* Coordinates of top-left pixel in photo +FileReadGIF( + Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ + Tcl_Channel chan, /* The image file, open for reading. */ + CONST char *fileName, /* The name of the image file. */ + Tcl_Obj *format, /* User-specified format object, or NULL. */ + Tk_PhotoHandle imageHandle, /* The photo image to write into. */ + int destX, int destY, /* Coordinates of top-left pixel in photo * image to be written to. */ - int width, height; /* Dimensions of block of photo image to be + int width, int height, /* Dimensions of block of photo image to be * written to. */ - int srcX, srcY; /* Coordinates of top-left pixel to be used in + int srcX, int srcY) /* Coordinates of top-left pixel to be used in * image being read. */ { int fileWidth, fileHeight; @@ -262,7 +262,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, unsigned char colorMap[MAXCOLORMAPSIZE][4]; int transparent = -1; static CONST char *optionStrings[] = { - "-index", NULL + "-index", NULL }; GIFImageConfig gifConf, *gifConfPtr = &gifConf; @@ -288,7 +288,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, } if (i == (argc-1)) { Tcl_AppendResult(interp, "no value given for \"", - Tcl_GetString(objv[i]), "\" option", (char *) NULL); + Tcl_GetString(objv[i]), "\" option", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[++i], &index) != TCL_OK) { @@ -302,7 +302,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, } if ((fileWidth <= 0) || (fileHeight <= 0)) { Tcl_AppendResult(interp, "GIF image file \"", fileName, - "\" has dimension(s) <= 0", (char *) NULL); + "\" has dimension(s) <= 0", NULL); return TCL_ERROR; } @@ -313,8 +313,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, if (BitSet(buf[0], LOCALCOLORMAP)) { /* Global Colormap */ if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) { - Tcl_AppendResult(interp, "error reading color map", - (char *) NULL); + Tcl_AppendResult(interp, "error reading color map", NULL); return TCL_ERROR; } } @@ -352,8 +351,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, */ Tcl_AppendResult(interp, - "premature end of image data for this index", - (char *) NULL); + "premature end of image data for this index", NULL); goto error; } @@ -362,8 +360,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, * GIF terminator. */ - Tcl_AppendResult(interp, "no image data for this index", - (char *) NULL); + Tcl_AppendResult(interp, "no image data for this index", NULL); goto error; } @@ -414,8 +411,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, if (BitSet(buf[8], LOCALCOLORMAP)) { if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) { - Tcl_AppendResult(interp, - "error reading color map", (char *) NULL); + Tcl_AppendResult(interp, "error reading color map", NULL); goto error; } } @@ -456,9 +452,8 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, if (BitSet(buf[8], LOCALCOLORMAP)) { if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) { - Tcl_AppendResult(interp, "error reading color map", - (char *) NULL); - goto error; + Tcl_AppendResult(interp, "error reading color map", NULL); + goto error; } } @@ -520,7 +515,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, if (block.pixelPtr) { ckfree((char *) block.pixelPtr); } - Tcl_AppendResult(interp, tkImgFmtGIF.name, (char *) NULL); + Tcl_AppendResult(interp, tkImgFmtGIF.name, NULL); return TCL_OK; error: @@ -556,12 +551,12 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, */ static int -StringMatchGIF(dataObj, format, widthPtr, heightPtr, interp) - Tcl_Obj *dataObj; /* the object containing the image data */ - Tcl_Obj *format; /* the image format object, or NULL */ - int *widthPtr; /* where to put the string width */ - int *heightPtr; /* where to put the string height */ - Tcl_Interp *interp; /* not used */ +StringMatchGIF( + Tcl_Obj *dataObj, /* the object containing the image data */ + Tcl_Obj *format, /* the image format object, or NULL */ + int *widthPtr, /* where to put the string width */ + int *heightPtr, /* where to put the string height */ + Tcl_Interp *interp) /* not used */ { unsigned char *data, header[10]; int got, length; @@ -595,7 +590,7 @@ StringMatchGIF(dataObj, format, widthPtr, heightPtr, interp) return 0; } } else { - memcpy((VOID *) header, (VOID *) data, 10); + memcpy((void *) header, (void *) data, 10); } *widthPtr = LM_to_uint(header[6], header[7]); *heightPtr = LM_to_uint(header[8], header[9]); @@ -623,15 +618,14 @@ StringMatchGIF(dataObj, format, widthPtr, heightPtr, interp) */ static int -StringReadGIF(interp, dataObj, format, imageHandle, - destX, destY, width, height, srcX, srcY) - Tcl_Interp *interp; /* interpreter for reporting errors in */ - Tcl_Obj *dataObj; /* object containing the image */ - Tcl_Obj *format; /* format object, or NULL */ - Tk_PhotoHandle imageHandle; /* the image to write this data into */ - int destX, destY; /* The rectangular region of the */ - int width, height; /* image to copy */ - int srcX, srcY; +StringReadGIF( + Tcl_Interp *interp, /* interpreter for reporting errors in */ + Tcl_Obj *dataObj, /* object containing the image */ + Tcl_Obj *format, /* format object, or NULL */ + Tk_PhotoHandle imageHandle, /* the image to write this data into */ + int destX, int destY, /* The rectangular region of the */ + int width, int height, /* image to copy */ + int srcX, int srcY) { MFile handle; int length; @@ -675,10 +669,11 @@ StringReadGIF(interp, dataObj, format, imageHandle, */ static int -ReadGIFHeader(gifConfPtr, chan, widthPtr, heightPtr) - GIFImageConfig *gifConfPtr; - Tcl_Channel chan; /* Image file to read the header from */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned +ReadGIFHeader( + GIFImageConfig *gifConfPtr, + Tcl_Channel chan, /* Image file to read the header from */ + int *widthPtr, int *heightPtr) + /* The dimensions of the image are returned * here. */ { unsigned char buf[7]; @@ -706,11 +701,11 @@ ReadGIFHeader(gifConfPtr, chan, widthPtr, heightPtr) */ static int -ReadColorMap(gifConfPtr, chan, number, buffer) - GIFImageConfig *gifConfPtr; - Tcl_Channel chan; - int number; - unsigned char buffer[MAXCOLORMAPSIZE][4]; +ReadColorMap( + GIFImageConfig *gifConfPtr, + Tcl_Channel chan, + int number, + unsigned char buffer[MAXCOLORMAPSIZE][4]) { int i; unsigned char rgb[3]; @@ -731,12 +726,12 @@ ReadColorMap(gifConfPtr, chan, number, buffer) } static int -DoExtension(gifConfPtr, chan, label, buf, transparent) - GIFImageConfig *gifConfPtr; - Tcl_Channel chan; - int label; - unsigned char *buf; - int *transparent; +DoExtension( + GIFImageConfig *gifConfPtr, + Tcl_Channel chan, + int label, + unsigned char *buf, + int *transparent) { int count; @@ -749,12 +744,12 @@ DoExtension(gifConfPtr, chan, label, buf, transparent) case 0xfe: /* Comment Extension */ do { - count = GetDataBlock(gifConfPtr, chan, (unsigned char*) buf); + count = GetDataBlock(gifConfPtr, chan, buf); } while (count > 0); return count; case 0xf9: /* Graphic Control Extension */ - count = GetDataBlock(gifConfPtr, chan, (unsigned char*) buf); + count = GetDataBlock(gifConfPtr, chan, buf); if (count < 0) { return 1; } @@ -763,22 +758,22 @@ DoExtension(gifConfPtr, chan, label, buf, transparent) } do { - count = GetDataBlock(gifConfPtr, chan, (unsigned char*) buf); + count = GetDataBlock(gifConfPtr, chan, buf); } while (count > 0); return count; } do { - count = GetDataBlock(gifConfPtr, chan, (unsigned char*) buf); + count = GetDataBlock(gifConfPtr, chan, buf); } while (count > 0); return count; } static int -GetDataBlock(gifConfPtr, chan, buf) - GIFImageConfig *gifConfPtr; - Tcl_Channel chan; - unsigned char *buf; +GetDataBlock( + GIFImageConfig *gifConfPtr, + Tcl_Channel chan, + unsigned char *buf) { unsigned char count; @@ -821,21 +816,19 @@ GetDataBlock(gifConfPtr, chan, buf) */ static int -ReadImage(gifConfPtr, interp, imagePtr, chan, len, rows, cmap, - width, height, srcX, srcY, interlace, transparent) - GIFImageConfig *gifConfPtr; - Tcl_Interp *interp; - char *imagePtr; - Tcl_Channel chan; - int len, rows; - unsigned char cmap[MAXCOLORMAPSIZE][4]; - int width, height; - int srcX, srcY; - int interlace; - int transparent; +ReadImage( + GIFImageConfig *gifConfPtr, + Tcl_Interp *interp, + char *imagePtr, + Tcl_Channel chan, + int len, int rows, + unsigned char cmap[MAXCOLORMAPSIZE][4], + int width, int height, + int srcX, int srcY, + int interlace, + int transparent) { unsigned char initialCodeSize; - int v; int xpos = 0, ypos = 0, pass = 0, i; register char *pixelPtr; CONST static int interlaceStep[] = { 8, 8, 4, 2 }; @@ -845,7 +838,7 @@ ReadImage(gifConfPtr, interp, imagePtr, chan, len, rows, cmap, unsigned char stack[(1 << MAX_LWZ_BITS)*2]; register unsigned char *top; int codeSize, clearCode, inCode, endCode, oldCode, maxCode; - int code, firstCode; + int code, firstCode, v; /* * Initialize the decoder @@ -853,7 +846,7 @@ ReadImage(gifConfPtr, interp, imagePtr, chan, len, rows, cmap, if (Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) <= 0) { Tcl_AppendResult(interp, "error reading GIF image: ", - Tcl_PosixError(interp), (char *) NULL); + Tcl_PosixError(interp), NULL); return TCL_ERROR; } if (transparent != -1) { @@ -897,7 +890,6 @@ ReadImage(gifConfPtr, interp, imagePtr, chan, len, rows, cmap, for (i = 0, ypos = 0; i < rows; i++) { for (xpos = 0; xpos < len; ) { - if (top == stack) { /* * Bummer - our stack is empty. Now we have to work! @@ -1084,11 +1076,11 @@ ReadImage(gifConfPtr, interp, imagePtr, chan, len, rows, cmap, */ static int -GetCode(chan, code_size, flag, gifConfPtr) - Tcl_Channel chan; - int code_size; - int flag; - GIFImageConfig *gifConfPtr; +GetCode( + Tcl_Channel chan, + int code_size, + int flag, + GIFImageConfig *gifConfPtr) { int ret; @@ -1170,15 +1162,15 @@ GetCode(chan, code_size, flag, gifConfPtr) */ static void -mInit(string, handle, length) - unsigned char *string; /* string containing initial mmencoded data */ - MFile *handle; /* mmdecode "file" handle */ - int length; /* Number of bytes in string */ +mInit( + unsigned char *string, /* string containing initial mmencoded data */ + MFile *handle, /* mmdecode "file" handle */ + int length) /* Number of bytes in string */ { - handle->data = string; - handle->state = 0; - handle->c = 0; - handle->length = length; + handle->data = string; + handle->state = 0; + handle->c = 0; + handle->length = length; } /* @@ -1200,19 +1192,19 @@ mInit(string, handle, length) */ static int -Mread(dst, chunkSize, numChunks, handle) - unsigned char *dst; /* where to put the result */ - size_t chunkSize; /* size of each transfer */ - size_t numChunks; /* number of chunks */ - MFile *handle; /* mmdecode "file" handle */ +Mread( + unsigned char *dst, /* where to put the result */ + size_t chunkSize, /* size of each transfer */ + size_t numChunks, /* number of chunks */ + MFile *handle) /* mmdecode "file" handle */ { - register int i, c; - int count = chunkSize * numChunks; + register int i, c; + int count = chunkSize * numChunks; - for (i=0; ilength <= 0 || (size_t)handle->length < hunk*count) { return -1; } - memcpy((VOID *)dst, (VOID *) handle->data, (size_t) (hunk * count)); + memcpy((void *)dst, (void *) handle->data, (size_t) (hunk * count)); handle->data += hunk * count; return (int)(hunk * count); } @@ -1381,13 +1373,13 @@ Fread(gifConfPtr, dst, hunk, count, chan) /* * ChanWriteGIF - writes a image in GIF format. *------------------------------------------------------------------------- - * Author: Lolo - * Engeneering Projects Area - * Department of Mining - * University of Oviedo - * e-mail zz11425958@zeus.etsimo.uniovi.es - * lolo@pcsig22.etsimo.uniovi.es - * Date: Fri September 20 1996 + * Author: Lolo + * Engeneering Projects Area + * Department of Mining + * University of Oviedo + * e-mail zz11425958@zeus.etsimo.uniovi.es + * lolo@pcsig22.etsimo.uniovi.es + * Date: Fri September 20 1996 * * Modified for transparency handling (gif89a) and miGIF compression * by Jan Nijtmans @@ -1449,11 +1441,11 @@ static void savemap(GifWriterState *statePtr, static int ReadValue(ClientData clientData); static int -FileWriteGIF(interp, filename, format, blockPtr) - Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ - CONST char *filename; - Tcl_Obj *format; - Tk_PhotoImageBlock *blockPtr; +FileWriteGIF( + Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ + CONST char *filename, + Tcl_Obj *format, + Tk_PhotoImageBlock *blockPtr) { Tcl_Channel chan = NULL; int result; @@ -1477,11 +1469,11 @@ FileWriteGIF(interp, filename, format, blockPtr) } static int -CommonWriteGIF(interp, handle, format, blockPtr) - Tcl_Interp *interp; - Tcl_Channel handle; - Tcl_Obj *format; - Tk_PhotoImageBlock *blockPtr; +CommonWriteGIF( + Tcl_Interp *interp, + Tcl_Channel handle, + Tcl_Obj *format, + Tk_PhotoImageBlock *blockPtr) { GifWriterState state, *statePtr = &state; int resolution; @@ -1515,14 +1507,13 @@ CommonWriteGIF(interp, handle, format, blockPtr) statePtr->mapa[x][CM_BLUE] = 255; } - width = blockPtr->width; height = blockPtr->height; statePtr->pixelo = blockPtr->pixelPtr + blockPtr->offset[0]; statePtr->pixelPitch = blockPtr->pitch; savemap(statePtr, blockPtr, statePtr->mapa); if (statePtr->num >= MAXCOLORMAPSIZE) { - Tcl_AppendResult(interp, "too many colors", (char *) NULL); + Tcl_AppendResult(interp, "too many colors", NULL); return TCL_ERROR; } if (statePtr->num<2) { @@ -1617,12 +1608,10 @@ CommonWriteGIF(interp, handle, format, blockPtr) } static int -color(statePtr, red, green, blue, mapa) - GifWriterState *statePtr; - int red; - int green; - int blue; - unsigned char mapa[MAXCOLORMAPSIZE][3]; +color( + GifWriterState *statePtr, + int red, int green, int blue, + unsigned char mapa[MAXCOLORMAPSIZE][3]) { int x; for (x=(statePtr->alphaOffset != 0) ; x<=MAXCOLORMAPSIZE ; x++) { @@ -1635,10 +1624,10 @@ color(statePtr, red, green, blue, mapa) } static int -nuevo(statePtr, red, green, blue, mapa) - GifWriterState *statePtr; - int red, green, blue; - unsigned char mapa[MAXCOLORMAPSIZE][3]; +nuevo( + GifWriterState *statePtr, + int red, int green, int blue, + unsigned char mapa[MAXCOLORMAPSIZE][3]) { int x = (statePtr->alphaOffset != 0); for (; x<=statePtr->num ; x++) { @@ -1651,10 +1640,10 @@ nuevo(statePtr, red, green, blue, mapa) } static void -savemap(statePtr, blockPtr, mapa) - GifWriterState *statePtr; - Tk_PhotoImageBlock *blockPtr; - unsigned char mapa[MAXCOLORMAPSIZE][3]; +savemap( + GifWriterState *statePtr, + Tk_PhotoImageBlock *blockPtr, + unsigned char mapa[MAXCOLORMAPSIZE][3]) { unsigned char *colores; int x, y; @@ -1693,8 +1682,8 @@ savemap(statePtr, blockPtr, mapa) } static int -ReadValue(clientData) - ClientData clientData; +ReadValue( + ClientData clientData) { GifWriterState *statePtr = (GifWriterState *) clientData; unsigned int col; @@ -1815,9 +1804,9 @@ setVerbose(void) } static const char * -binformat(v, nbits) - unsigned int v; - int nbits; +binformat( + unsigned int v, + int nbits) { static char bufs[8][64]; static int bhand = 0; @@ -1844,8 +1833,8 @@ binformat(v, nbits) #endif static void -writeBlock(statePtr) - miGIFState_t *statePtr; +writeBlock( + miGIFState_t *statePtr) { unsigned char c; @@ -1866,9 +1855,9 @@ writeBlock(statePtr) } static void -blockOut(statePtr, c) - miGIFState_t *statePtr; - unsigned char c; +blockOut( + miGIFState_t *statePtr, + unsigned char c) { DEBUGMSG(("blockOut %s\n", binformat(c, 8))); statePtr->oblock[statePtr->oblen++] = c; @@ -1878,8 +1867,8 @@ blockOut(statePtr, c) } static void -blockFlush(statePtr) - miGIFState_t *statePtr; +blockFlush( + miGIFState_t *statePtr) { DEBUGMSG(("blockFlush\n")); if (statePtr->oblen > 0) { @@ -1888,9 +1877,9 @@ blockFlush(statePtr) } static void -output(statePtr, val) - miGIFState_t *statePtr; - int val; +output( + miGIFState_t *statePtr, + int val) { DEBUGMSG(("output %s [%s %d %d]\n", binformat(val, statePtr->outputBits), binformat(statePtr->obuf, statePtr->obits), statePtr->obits, @@ -1907,8 +1896,8 @@ output(statePtr, val) } static void -outputFlush(statePtr) - miGIFState_t *statePtr; +outputFlush( + miGIFState_t *statePtr) { DEBUGMSG(("outputFlush\n")); if (statePtr->obits > 0) { @@ -1918,8 +1907,8 @@ outputFlush(statePtr) } static void -didClear(statePtr) - miGIFState_t *statePtr; +didClear( + miGIFState_t *statePtr) { DEBUGMSG(("didClear\n")); statePtr->outputBits = statePtr->outputBitsInit; @@ -1931,9 +1920,9 @@ didClear(statePtr) } static void -outputPlain(statePtr, c) - miGIFState_t *statePtr; - int c; +outputPlain( + miGIFState_t *statePtr, + int c) { DEBUGMSG(("outputPlain %s\n", binformat(c, statePtr->outputBits))); statePtr->justCleared = 0; @@ -1950,8 +1939,8 @@ outputPlain(statePtr, c) } static unsigned int -isqrt(x) - unsigned int x; +isqrt( + unsigned int x) { unsigned int r; unsigned int v; @@ -1970,9 +1959,9 @@ isqrt(x) } static unsigned int -computeTriangleCount(count, nrepcodes) - unsigned int count; - unsigned int nrepcodes; +computeTriangleCount( + unsigned int count, + unsigned int nrepcodes) { unsigned int perrep; unsigned int cost; @@ -1998,15 +1987,15 @@ computeTriangleCount(count, nrepcodes) } static void -maxOutputClear(statePtr) - miGIFState_t *statePtr; +maxOutputClear( + miGIFState_t *statePtr) { statePtr->outputClear = statePtr->maxOcodes; } static void -resetOutputClear(statePtr) - miGIFState_t *statePtr; +resetOutputClear( + miGIFState_t *statePtr) { statePtr->outputClear = statePtr->outputClearInit; if (statePtr->outputCount >= statePtr->outputClear) { @@ -2016,9 +2005,9 @@ resetOutputClear(statePtr) } static void -runlengthFlushFromClear(statePtr, count) - miGIFState_t *statePtr; - int count; +runlengthFlushFromClear( + miGIFState_t *statePtr, + int count) { int n; @@ -2056,9 +2045,9 @@ runlengthFlushFromClear(statePtr, count) } static void -runlengthFlushClearOrRep(statePtr, count) - miGIFState_t *statePtr; - int count; +runlengthFlushClearOrRep( + miGIFState_t *statePtr, + int count) { int withclr; @@ -2076,9 +2065,9 @@ runlengthFlushClearOrRep(statePtr, count) } static void -runlengthFlushWithTable(statePtr, count) - miGIFState_t *statePtr; - int count; +runlengthFlushWithTable( + miGIFState_t *statePtr, + int count) { int repmax; int repleft; @@ -2120,8 +2109,8 @@ runlengthFlushWithTable(statePtr, count) } static void -runlengthFlush(statePtr) - miGIFState_t *statePtr; +runlengthFlush( + miGIFState_t *statePtr) { DEBUGMSG(("runlengthFlush [ %d %d\n", statePtr->runlengthCount, statePtr->runlengthPixel)); @@ -2144,11 +2133,11 @@ runlengthFlush(statePtr) } static void -compress(initBits, handle, readValue, clientData) - int initBits; - Tcl_Channel handle; - ifunptr readValue; - ClientData clientData; +compress( + int initBits, + Tcl_Channel handle, + ifunptr readValue, + ClientData clientData) { int c; miGIFState_t state, *statePtr = &state; diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index 73f4844..b1b4ad4 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -13,7 +13,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPPM.c,v 1.15 2005/08/10 22:02:22 dkf Exp $ + * RCS: @(#) $Id: tkImgPPM.c,v 1.16 2005/11/17 16:21:55 dkf Exp $ */ #include "tkInt.h" @@ -55,7 +55,6 @@ static int StringReadPPM(Tcl_Interp *interp, Tcl_Obj *dataObj, int destX, int destY, int width, int height, int srcX, int srcY); - Tk_PhotoImageFormat tkImgFmtPPM = { "ppm", /* name */ FileMatchPPM, /* fileMatchProc */ @@ -95,14 +94,15 @@ static int ReadPPMStringHeader(Tcl_Obj *dataObj, int *widthPtr, */ static int -FileMatchPPM(chan, fileName, format, widthPtr, heightPtr, interp) - Tcl_Channel chan; /* The image file, open for reading. */ - CONST char *fileName; /* The name of the image file. */ - Tcl_Obj *format; /* User-specified format string, or NULL. */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned +FileMatchPPM( + Tcl_Channel chan, /* The image file, open for reading. */ + CONST char *fileName, /* The name of the image file. */ + Tcl_Obj *format, /* User-specified format string, or NULL. */ + int *widthPtr, int *heightPtr, + /* The dimensions of the image are returned * here if the file is a valid raw PPM * file. */ - Tcl_Interp *interp; /* unused */ + Tcl_Interp *interp) /* unused */ { int dummy; @@ -129,18 +129,17 @@ FileMatchPPM(chan, fileName, format, widthPtr, heightPtr, interp) */ static int -FileReadPPM(interp, chan, fileName, format, imageHandle, destX, destY, - width, height, srcX, srcY) - Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ - Tcl_Channel chan; /* The image file, open for reading. */ - CONST char *fileName; /* The name of the image file. */ - Tcl_Obj *format; /* User-specified format string, or NULL. */ - Tk_PhotoHandle imageHandle; /* The photo image to write into. */ - int destX, destY; /* Coordinates of top-left pixel in photo +FileReadPPM( + Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ + Tcl_Channel chan, /* The image file, open for reading. */ + CONST char *fileName, /* The name of the image file. */ + Tcl_Obj *format, /* User-specified format string, or NULL. */ + Tk_PhotoHandle imageHandle, /* The photo image to write into. */ + int destX, int destY, /* Coordinates of top-left pixel in photo * image to be written to. */ - int width, height; /* Dimensions of block of photo image to be + int width, int height, /* Dimensions of block of photo image to be * written to. */ - int srcX, srcY; /* Coordinates of top-left pixel to be used in + int srcX, int srcY) /* Coordinates of top-left pixel to be used in * image being read. */ { int fileWidth, fileHeight, maxIntensity; @@ -267,11 +266,11 @@ FileReadPPM(interp, chan, fileName, format, imageHandle, destX, destY, */ static int -FileWritePPM(interp, fileName, format, blockPtr) - Tcl_Interp *interp; - CONST char *fileName; - Tcl_Obj *format; - Tk_PhotoImageBlock *blockPtr; +FileWritePPM( + Tcl_Interp *interp, + CONST char *fileName, + Tcl_Obj *format, + Tk_PhotoImageBlock *blockPtr) { Tcl_Channel chan; int w, h; @@ -356,10 +355,10 @@ FileWritePPM(interp, fileName, format, blockPtr) */ static int -StringWritePPM(interp, format, blockPtr) - Tcl_Interp *interp; - Tcl_Obj *format; - Tk_PhotoImageBlock *blockPtr; +StringWritePPM( + Tcl_Interp *interp, + Tcl_Obj *format, + Tk_PhotoImageBlock *blockPtr) { int w, h, size, greenOffset, blueOffset; unsigned char *pixLinePtr, *byteArray; @@ -432,13 +431,14 @@ StringWritePPM(interp, format, blockPtr) */ static int -StringMatchPPM(dataObj, format, widthPtr, heightPtr, interp) - Tcl_Obj *dataObj; /* The image data. */ - Tcl_Obj *format; /* User-specified format string, or NULL. */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned +StringMatchPPM( + Tcl_Obj *dataObj, /* The image data. */ + Tcl_Obj *format, /* User-specified format string, or NULL. */ + int *widthPtr, int *heightPtr, + /* The dimensions of the image are returned * here if the file is a valid raw PPM * file. */ - Tcl_Interp *interp; /* unused */ + Tcl_Interp *interp) /* unused */ { int dummy; @@ -465,17 +465,16 @@ StringMatchPPM(dataObj, format, widthPtr, heightPtr, interp) */ static int -StringReadPPM(interp, dataObj, format, imageHandle, destX, destY, - width, height, srcX, srcY) - Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ - Tcl_Obj *dataObj; /* The image data. */ - Tcl_Obj *format; /* User-specified format string, or NULL. */ - Tk_PhotoHandle imageHandle; /* The photo image to write into. */ - int destX, destY; /* Coordinates of top-left pixel in photo +StringReadPPM( + Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ + Tcl_Obj *dataObj, /* The image data. */ + Tcl_Obj *format, /* User-specified format string, or NULL. */ + Tk_PhotoHandle imageHandle, /* The photo image to write into. */ + int destX, int destY, /* Coordinates of top-left pixel in photo * image to be written to. */ - int width, height; /* Dimensions of block of photo image to be + int width, int height, /* Dimensions of block of photo image to be * written to. */ - int srcX, srcY; /* Coordinates of top-left pixel to be used in + int srcX, int srcY) /* Coordinates of top-left pixel to be used in * image being read. */ { int fileWidth, fileHeight, maxIntensity; @@ -618,11 +617,12 @@ StringReadPPM(interp, dataObj, format, imageHandle, destX, destY, */ static int -ReadPPMFileHeader(chan, widthPtr, heightPtr, maxIntensityPtr) - Tcl_Channel chan; /* Image file to read the header from. */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned +ReadPPMFileHeader( + Tcl_Channel chan, /* Image file to read the header from. */ + int *widthPtr, int *heightPtr, + /* The dimensions of the image are returned * here. */ - int *maxIntensityPtr; /* The maximum intensity value for the image + int *maxIntensityPtr) /* The maximum intensity value for the image * is stored here. */ { #define BUFFER_SIZE 1000 @@ -724,15 +724,15 @@ ReadPPMFileHeader(chan, widthPtr, heightPtr, maxIntensityPtr) */ static int -ReadPPMStringHeader(dataPtr, widthPtr, heightPtr, maxIntensityPtr, - dataBufferPtr, dataSizePtr) - Tcl_Obj *dataPtr; /* Object to read the header from. */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned +ReadPPMStringHeader( + Tcl_Obj *dataPtr, /* Object to read the header from. */ + int *widthPtr, int *heightPtr, + /* The dimensions of the image are returned * here. */ - int *maxIntensityPtr; /* The maximum intensity value for the image + int *maxIntensityPtr, /* The maximum intensity value for the image * is stored here. */ - unsigned char **dataBufferPtr; - int *dataSizePtr; + unsigned char **dataBufferPtr, + int *dataSizePtr) { #define BUFFER_SIZE 1000 char buffer[BUFFER_SIZE]; diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 79b502f..2e41606 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.58 2005/09/06 12:30:24 dkf Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.59 2005/11/17 16:21:55 dkf Exp $ */ #include "tkInt.h" @@ -279,7 +279,7 @@ static char *optionNames[] = { "-subsample", "-to", "-zoom", - (char *) NULL + NULL }; /* @@ -322,7 +322,7 @@ Tk_ImageType tkPhotoImageType = { ImgPhotoFree, /* freeProc */ ImgPhotoDelete, /* deleteProc */ ImgPhotoPostscript, /* postscriptProc */ - (Tk_ImageType *) NULL /* nextPtr */ + NULL /* nextPtr */ }; typedef struct ThreadSpecificData { @@ -351,18 +351,17 @@ static Tcl_ThreadDataKey dataKey; */ static Tk_ConfigSpec configSpecs[] = { - {TK_CONFIG_STRING, "-file", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(PhotoMaster, fileString), TK_CONFIG_NULL_OK}, - {TK_CONFIG_DOUBLE, "-gamma", (char *) NULL, (char *) NULL, + {TK_CONFIG_STRING, "-file", NULL, NULL, + NULL, Tk_Offset(PhotoMaster, fileString), TK_CONFIG_NULL_OK}, + {TK_CONFIG_DOUBLE, "-gamma", NULL, NULL, DEF_PHOTO_GAMMA, Tk_Offset(PhotoMaster, gamma), 0}, - {TK_CONFIG_INT, "-height", (char *) NULL, (char *) NULL, + {TK_CONFIG_INT, "-height", NULL, NULL, DEF_PHOTO_HEIGHT, Tk_Offset(PhotoMaster, userHeight), 0}, - {TK_CONFIG_UID, "-palette", (char *) NULL, (char *) NULL, + {TK_CONFIG_UID, "-palette", NULL, NULL, DEF_PHOTO_PALETTE, Tk_Offset(PhotoMaster, palette), 0}, - {TK_CONFIG_INT, "-width", (char *) NULL, (char *) NULL, + {TK_CONFIG_INT, "-width", NULL, NULL, DEF_PHOTO_WIDTH, Tk_Offset(PhotoMaster, userWidth), 0}, - {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, 0} + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0} }; /* @@ -457,8 +456,8 @@ static void PhotoOptionCleanupProc(ClientData clientData, */ static void -PhotoFormatThreadExitProc(clientData) - ClientData clientData; /* not used */ +PhotoFormatThreadExitProc( + ClientData clientData) /* not used */ { Tk_PhotoImageFormat *freePtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) @@ -497,8 +496,8 @@ PhotoFormatThreadExitProc(clientData) *---------------------------------------------------------------------- */ void -Tk_CreateOldPhotoImageFormat(formatPtr) - Tk_PhotoImageFormat *formatPtr; +Tk_CreateOldPhotoImageFormat( + Tk_PhotoImageFormat *formatPtr) /* Structure describing the format. All of the * fields except "nextPtr" must be filled in * by caller. Must not have been passed to @@ -521,8 +520,8 @@ Tk_CreateOldPhotoImageFormat(formatPtr) } void -Tk_CreatePhotoImageFormat(formatPtr) - Tk_PhotoImageFormat *formatPtr; +Tk_CreatePhotoImageFormat( + Tk_PhotoImageFormat *formatPtr) /* Structure describing the format. All of the * fields except "nextPtr" must be filled in * by caller. Must not have been passed to @@ -567,17 +566,17 @@ Tk_CreatePhotoImageFormat(formatPtr) */ static int -ImgPhotoCreate(interp, name, objc, objv, typePtr, master, clientDataPtr) - Tcl_Interp *interp; /* Interpreter for application containing +ImgPhotoCreate( + Tcl_Interp *interp, /* Interpreter for application containing * image. */ - char *name; /* Name to use for image. */ - int objc; /* Number of arguments. */ - Tcl_Obj *CONST objv[]; /* Argument objects for options (doesn't + char *name, /* Name to use for image. */ + int objc, /* Number of arguments. */ + Tcl_Obj *CONST objv[], /* Argument objects for options (doesn't * include image name or type). */ - Tk_ImageType *typePtr; /* Pointer to our type record (not used). */ - Tk_ImageMaster master; /* Token for image, to be used by us in later + Tk_ImageType *typePtr, /* Pointer to our type record (not used). */ + Tk_ImageMaster master, /* Token for image, to be used by us in later * callbacks. */ - ClientData *clientDataPtr; /* Store manager's token for image here; it + ClientData *clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { PhotoMaster *masterPtr; @@ -629,16 +628,16 @@ ImgPhotoCreate(interp, name, objc, objv, typePtr, master, clientDataPtr) */ static int -ImgPhotoCmd(clientData, interp, objc, objv) - ClientData clientData; /* Information about photo master. */ - Tcl_Interp *interp; /* Current interpreter. */ - int objc; /* Number of arguments. */ - Tcl_Obj *CONST objv[]; /* Argument objects. */ +ImgPhotoCmd( + ClientData clientData, /* Information about photo master. */ + Tcl_Interp *interp, /* Current interpreter. */ + int objc, /* Number of arguments. */ + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int oldformat = 0; static CONST char *photoOptions[] = { "blank", "cget", "configure", "copy", "data", "get", "put", - "read", "redither", "transparency", "write", (char *) NULL + "read", "redither", "transparency", "write", NULL }; enum options { PHOTO_BLANK, PHOTO_CGET, PHOTO_CONFIGURE, PHOTO_COPY, PHOTO_DATA, @@ -673,7 +672,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) &index) != TCL_OK) { Tcl_ObjCmdProc *proc; proc = PhotoOptionFind(interp, objv[1]); - if (proc == (Tcl_ObjCmdProc *) NULL) { + if (proc == NULL) { return TCL_ERROR; } return proc(clientData, interp, objc, objv); @@ -689,7 +688,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) Tk_PhotoBlank(masterPtr); return TCL_OK; } else { - Tcl_WrongNumArgs(interp, 2, objv, (char *) NULL); + Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } @@ -725,7 +724,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) Tcl_Obj *obj, *subobj; result = Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) masterPtr, (char *) NULL, 0); + configSpecs, (char *) masterPtr, NULL, 0); if (result != TCL_OK) { return result; } @@ -734,14 +733,14 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (masterPtr->dataString) { Tcl_ListObjAppendElement(NULL, subobj, masterPtr->dataString); } else { - Tcl_AppendStringsToObj(subobj, " {}", (char *) NULL); + Tcl_AppendStringsToObj(subobj, " {}", NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewStringObj("-format {} {} {}", 16); if (masterPtr->format) { Tcl_ListObjAppendElement(NULL, subobj, masterPtr->format); } else { - Tcl_AppendStringsToObj(subobj, " {}", (char *) NULL); + Tcl_AppendStringsToObj(subobj, " {}", NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_ListObjAppendList(interp, obj, Tcl_GetObjResult(interp)); @@ -752,26 +751,22 @@ ImgPhotoCmd(clientData, interp, objc, objv) char *arg = Tcl_GetStringFromObj(objv[2], &length); if (length > 1 && !strncmp(arg, "-data", (unsigned) length)) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "-data {} {} {}", (char *) NULL); + Tcl_AppendResult(interp, "-data {} {} {}", NULL); if (masterPtr->dataString) { Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), masterPtr->dataString); } else { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - " {}", (char *) NULL); + Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else if (length > 1 && !strncmp(arg, "-format", (unsigned) length)) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "-format {} {} {}", (char *) NULL); + Tcl_AppendResult(interp, "-format {} {} {}", NULL); if (masterPtr->format) { Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), masterPtr->format); } else { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - " {}", (char *) NULL); + Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else { @@ -813,7 +808,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (srcHandle == NULL) { Tcl_AppendResult(interp, "image \"", Tcl_GetString(options.name), "\" doesn't", - " exist or is not a photo image", (char *) NULL); + " exist or is not a photo image", NULL); return TCL_ERROR; } Tk_PhotoGetImage(srcHandle, &block); @@ -821,7 +816,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) || (options.fromX2 > block.width) || (options.fromY2 > block.height)) { Tcl_AppendResult(interp, "coordinates for -from option extend ", - "outside source image", (char *) NULL); + "outside source image", NULL); return TCL_ERROR; } @@ -865,8 +860,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (ImgPhotoSetSize(masterPtr, options.toX2, options.toY2) != TCL_OK) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); return TCL_ERROR; } } @@ -914,7 +908,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) || (options.fromX2 > masterPtr->width) || (options.fromY2 > masterPtr->height)) { Tcl_AppendResult(interp, "coordinates for -from option extend ", - "outside image", (char *) NULL); + "outside image", NULL); return TCL_ERROR; } @@ -962,8 +956,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (stringWriteProc == NULL) { Tcl_AppendResult(interp, "image string format \"", Tcl_GetString(options.format), "\" is ", - (matched ? "not supported" : "unknown"), - (char *) NULL); + (matched ? "not supported" : "unknown"), NULL); return TCL_ERROR; } } else { @@ -994,7 +987,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) result = ((int (*) (Tcl_Interp *interp, Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr, VOID *dummy)) stringWriteProc) - (interp, options.format, &block, (VOID *) NULL); + (interp, options.format, &block, NULL); } if (options.background) { Tk_FreeColor(options.background); @@ -1023,7 +1016,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if ((x < 0) || (x >= masterPtr->width) || (y < 0) || (y >= masterPtr->height)) { Tcl_AppendResult(interp, Tcl_GetString(objv[0]), " get: ", - "coordinates out of range", (char *) NULL); + "coordinates out of range", NULL); return TCL_ERROR; } @@ -1034,7 +1027,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) pixelPtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; sprintf(string, "%d %d %d", pixelPtr[0], pixelPtr[1], pixelPtr[2]); - Tcl_AppendResult(interp, string, (char *) NULL); + Tcl_AppendResult(interp, string, NULL); return TCL_OK; } @@ -1119,7 +1112,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) block.pixelPtr = pixelPtr; } else if (listObjc != dataWidth) { Tcl_AppendResult(interp, "all elements of color list must", - " have the same number of elements", (char *) NULL); + " have the same number of elements", NULL); break; } @@ -1163,7 +1156,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (!XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), colorString, &color)) { Tcl_AppendResult(interp, "can't parse color \"", - colorString, "\"", (char *) NULL); + colorString, "\"", NULL); break; } *pixelPtr++ = color.red >> 8; @@ -1235,7 +1228,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (Tcl_IsSafe(interp)) { Tcl_AppendResult(interp, "can't get image from a file in a", - " safe interpreter", (char *) NULL); + " safe interpreter", NULL); return TCL_ERROR; } @@ -1274,7 +1267,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) || (options.fromX2 > imageWidth) || (options.fromY2 > imageHeight)) { Tcl_AppendResult(interp, "coordinates for -from option extend ", - "outside source image", (char *) NULL); + "outside source image", NULL); Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1294,8 +1287,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (ImgPhotoSetSize(masterPtr, options.toX + width, options.toY + height) != TCL_OK) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); return TCL_ERROR; } } @@ -1321,7 +1313,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) case PHOTO_REDITHER: if (objc != 2) { - Tcl_WrongNumArgs(interp, 2, objv, (char *) NULL); + Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } @@ -1356,7 +1348,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) case PHOTO_TRANS: { static CONST char *photoTransOptions[] = { - "get", "set", (char *) NULL + "get", "set", NULL }; enum transOptions { PHOTO_TRANS_GET, PHOTO_TRANS_SET @@ -1387,8 +1379,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if ((x < 0) || (x >= masterPtr->width) || (y < 0) || (y >= masterPtr->height)) { Tcl_AppendResult(interp, Tcl_GetString(objv[0]), - " transparency get: coordinates out of range", - (char *) NULL); + " transparency get: coordinates out of range", NULL); return TCL_ERROR; } @@ -1425,8 +1416,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if ((x < 0) || (x >= masterPtr->width) || (y < 0) || (y >= masterPtr->height)) { Tcl_AppendResult(interp, Tcl_GetString(objv[0]), - " transparency set: coordinates out of range", - (char *) NULL); + " transparency set: coordinates out of range", NULL); return TCL_ERROR; } @@ -1484,7 +1474,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (Tcl_IsSafe(interp)) { Tcl_AppendResult(interp, "can't write image to a file in a", - " safe interpreter", (char *) NULL); + " safe interpreter", NULL); return TCL_ERROR; } @@ -1510,7 +1500,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) || (options.fromX2 > masterPtr->width) || (options.fromY2 > masterPtr->height)) { Tcl_AppendResult(interp, "coordinates for -from option extend ", - "outside image", (char *) NULL); + "outside image", NULL); return TCL_ERROR; } @@ -1557,16 +1547,15 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (imageFormat == NULL) { if (options.format == NULL) { Tcl_AppendResult(interp, "no available image file format ", - "has file writing capability", (char *) NULL); + "has file writing capability", NULL); } else if (!matched) { Tcl_AppendResult(interp, "image file format \"", Tcl_GetString(options.format), - "\" is unknown", (char *) NULL); + "\" is unknown", NULL); } else { Tcl_AppendResult(interp, "image file format \"", Tcl_GetString(options.format), - "\" has no file writing capability", - (char *) NULL); + "\" has no file writing capability", NULL); } return TCL_ERROR; } @@ -1615,18 +1604,18 @@ ImgPhotoCmd(clientData, interp, objc, objv) */ static int -ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) - struct SubcommandOptions *optPtr; +ParseSubcommandOptions( + struct SubcommandOptions *optPtr, /* Information about the options specified and * the values given is returned here. */ - Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ - int allowedOptions; /* Indicates which options are valid for the + Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ + int allowedOptions, /* Indicates which options are valid for the * current command. */ - int *optIndexPtr; /* Points to a variable containing the current + int *optIndexPtr, /* Points to a variable containing the current * index in objv; this variable is updated by * this function. */ - int objc; /* Number of arguments in objv[]. */ - Tcl_Obj *CONST objv[]; /* Arguments to be parsed. */ + int objc, /* Number of arguments in objv[]. */ + Tcl_Obj *CONST objv[]) /* Arguments to be parsed. */ { int index, c, bit, currentBit; int length; @@ -1676,17 +1665,17 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) if ((allowedOptions & bit) == 0) { Tcl_AppendResult(interp, "unrecognized option \"", Tcl_GetString(objv[index]), - "\": must be ", (char *)NULL); + "\": must be ", NULL); bit = 1; for (listPtr = optionNames; *listPtr != NULL; ++listPtr) { if ((allowedOptions & bit) != 0) { if ((allowedOptions & (bit - 1)) != 0) { - Tcl_AppendResult(interp, ", ", (char *) NULL); + Tcl_AppendResult(interp, ", ", NULL); if ((allowedOptions & ~((bit << 1) - 1)) == 0) { - Tcl_AppendResult(interp, "or ", (char *) NULL); + Tcl_AppendResult(interp, "or ", NULL); } } - Tcl_AppendResult(interp, *listPtr, (char *) NULL); + Tcl_AppendResult(interp, *listPtr, NULL); } bit <<= 1; } @@ -1712,7 +1701,7 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) } } else { Tcl_AppendResult(interp, "the \"-background\" option ", - "requires a value", (char *) NULL); + "requires a value", NULL); return TCL_ERROR; } } else if (bit == OPT_FORMAT) { @@ -1726,7 +1715,7 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) optPtr->format = objv[index]; } else { Tcl_AppendResult(interp, "the \"-format\" option ", - "requires a value", (char *) NULL); + "requires a value", NULL); return TCL_ERROR; } } else if (bit == OPT_COMPOSITE) { @@ -1755,7 +1744,7 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) *optIndexPtr = index; } else { Tcl_AppendResult(interp, "the \"-compositingrule\" option ", - "requires a value", (char *) NULL); + "requires a value", NULL); return TCL_ERROR; } } else if ((bit != OPT_SHRINK) && (bit != OPT_GRAYSCALE)) { @@ -1782,7 +1771,7 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) if (numValues == 0) { Tcl_AppendResult(interp, "the \"", option, "\" option ", "requires one ", maxValues == 2? "or two": "to four", - " integer values", (char *) NULL); + " integer values", NULL); return TCL_ERROR; } *optIndexPtr = (index += numValues); @@ -1808,7 +1797,7 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) if ((values[0] < 0) || (values[1] < 0) || ((numValues > 2) && ((values[2] < 0) || (values[3] < 0)))) { Tcl_AppendResult(interp, "value(s) for the -from", - " option must be non-negative", (char *) NULL); + " option must be non-negative", NULL); return TCL_ERROR; } if (numValues <= 2) { @@ -1831,7 +1820,7 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) if ((values[0] < 0) || (values[1] < 0) || ((numValues > 2) && ((values[2] < 0) || (values[3] < 0)))) { Tcl_AppendResult(interp, "value(s) for the -to", - " option must be non-negative", (char *) NULL); + " option must be non-negative", NULL); return TCL_ERROR; } if (numValues <= 2) { @@ -1849,7 +1838,7 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) case OPT_ZOOM: if ((values[0] <= 0) || (values[1] <= 0)) { Tcl_AppendResult(interp, "value(s) for the -zoom", - " option must be positive", (char *) NULL); + " option must be positive", NULL); return TCL_ERROR; } optPtr->zoomX = values[0]; @@ -1889,13 +1878,13 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) */ static int -ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) - Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ - PhotoMaster *masterPtr; /* Pointer to data structure describing +ImgPhotoConfigureMaster( + Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ + PhotoMaster *masterPtr, /* Pointer to data structure describing * overall photo image to (re)configure. */ - int objc; /* Number of entries in objv. */ - Tcl_Obj *CONST objv[]; /* Pairs of configuration options for image. */ - int flags; /* Flags to pass to Tk_ConfigureWidget, such + int objc, /* Number of entries in objv. */ + Tcl_Obj *CONST objv[], /* Pairs of configuration options for image. */ + int flags) /* Flags to pass to Tk_ConfigureWidget, such * as TK_CONFIG_ARGV_ONLY. */ { PhotoInstance *instancePtr; @@ -1922,7 +1911,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) j--; } else { Tcl_AppendResult(interp, - "value for \"-data\" missing", (char *) NULL); + "value for \"-data\" missing", NULL); return TCL_ERROR; } } else if ((args[j][1] == 'f') && @@ -1932,7 +1921,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) j--; } else { Tcl_AppendResult(interp, - "value for \"-format\" missing", (char *) NULL); + "value for \"-format\" missing", NULL); return TCL_ERROR; } } @@ -2023,8 +2012,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) if (ImgPhotoSetSize(masterPtr, masterPtr->width, masterPtr->height) != TCL_OK) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); goto errorExit; } @@ -2043,9 +2031,8 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) if (Tcl_IsSafe(interp)) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "can't get image from a file in a safe interpreter", - (char *) NULL); + Tcl_AppendResult(interp, + "can't get image from a file in a safe interpreter", NULL); goto errorExit; } @@ -2068,8 +2055,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) if (result != TCL_OK) { Tcl_Close(NULL, chan); Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); goto errorExit; } tempformat = masterPtr->format; @@ -2099,8 +2085,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) } if (ImgPhotoSetSize(masterPtr, imageWidth, imageHeight) != TCL_OK) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); goto errorExit; } tempformat = masterPtr->format; @@ -2195,8 +2180,8 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) */ static void -ImgPhotoConfigureInstance(instancePtr) - PhotoInstance *instancePtr; /* Instance to reconfigure. */ +ImgPhotoConfigureInstance( + PhotoInstance *instancePtr) /* Instance to reconfigure. */ { PhotoMaster *masterPtr = instancePtr->masterPtr; XImage *imagePtr; @@ -2257,7 +2242,7 @@ ImgPhotoConfigureInstance(instancePtr) } imagePtr = XCreateImage(instancePtr->display, instancePtr->visualInfo.visual, (unsigned) bitsPerPixel, - (bitsPerPixel > 1? ZPixmap: XYBitmap), 0, (char *) NULL, + (bitsPerPixel > 1? ZPixmap: XYBitmap), 0, NULL, 1, 1, 32, 0); instancePtr->imagePtr = imagePtr; @@ -2332,10 +2317,10 @@ ImgPhotoConfigureInstance(instancePtr) */ static ClientData -ImgPhotoGet(tkwin, masterData) - Tk_Window tkwin; /* Window in which the instance will be +ImgPhotoGet( + Tk_Window tkwin, /* Window in which the instance will be * used. */ - ClientData masterData; /* Pointer to our master structure for the + ClientData masterData) /* Pointer to our master structure for the * image. */ { PhotoMaster *masterPtr = (PhotoMaster *) masterData; @@ -2523,7 +2508,8 @@ ImgPhotoGet(tkwin, masterData) */ static int -ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr) +ToggleComplexAlphaIfNeeded( + PhotoMaster *mPtr) { size_t len = MAX(mPtr->userWidth, mPtr->width) * MAX(mPtr->userHeight, mPtr->height) * 4; @@ -2592,11 +2578,11 @@ ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr) #endif /* !__WIN32__ */ static void -ImgPhotoBlendComplexAlpha(bgImg, iPtr, xOffset, yOffset, width, height) - XImage *bgImg; /* background image to draw on */ - PhotoInstance *iPtr; /* image instance to draw */ - int xOffset, yOffset; /* X & Y offset into image instance to draw */ - int width, height; /* width & height of image to draw */ +ImgPhotoBlendComplexAlpha( + XImage *bgImg, /* background image to draw on */ + PhotoInstance *iPtr, /* image instance to draw */ + int xOffset, int yOffset, /* X & Y offset into image instance to draw */ + int width, int height) /* width & height of image to draw */ { int x, y, line; unsigned long pixel; @@ -2609,6 +2595,9 @@ ImgPhotoBlendComplexAlpha(bgImg, iPtr, xOffset, yOffset, width, height) * (see Porter&Duff, "Compositing Digital Images", proceedings of SIGGRAPH * 1984) that has been hard-coded (for speed) to work with targetting a * solid surface. + * + * The 'unalpha' field must be 255-alpha; it is separated out to encourage + * more efficient compilation. */ #define ALPHA_BLEND(bgPix, imgPix, alpha, unalpha) \ @@ -2643,7 +2632,7 @@ ImgPhotoBlendComplexAlpha(bgImg, iPtr, xOffset, yOffset, width, height) #endif /* !__WIN32__ */ /* - * Only unix requires the special case for <24bpp. It varies with 3 extra + * Only UNIX requires the special case for <24bpp. It varies with 3 extra * shifts and uses RGB15. The 24+bpp version could also then be further * optimized. */ @@ -2757,17 +2746,16 @@ ImgPhotoBlendComplexAlpha(bgImg, iPtr, xOffset, yOffset, width, height) */ static void -ImgPhotoDisplay(clientData, display, drawable, imageX, imageY, width, - height, drawableX, drawableY) - ClientData clientData; /* Pointer to PhotoInstance structure for +ImgPhotoDisplay( + ClientData clientData, /* Pointer to PhotoInstance structure for * instance to be displayed. */ - Display *display; /* Display on which to draw image. */ - Drawable drawable; /* Pixmap or window in which to draw image. */ - int imageX, imageY; /* Upper-left corner of region within image to + Display *display, /* Display on which to draw image. */ + Drawable drawable, /* Pixmap or window in which to draw image. */ + int imageX, int imageY, /* Upper-left corner of region within image to * draw. */ - int width, height; /* Dimensions of region within image to + int width, int height, /* Dimensions of region within image to * draw. */ - int drawableX, drawableY; /* Coordinates within drawable that correspond + int drawableX,int drawableY)/* Coordinates within drawable that correspond * to imageX and imageY. */ { PhotoInstance *instancePtr = (PhotoInstance *) clientData; @@ -2793,8 +2781,8 @@ ImgPhotoDisplay(clientData, display, drawable, imageX, imageY, width, * not properly constrained, which can cause an X error. [Bug 979239] */ - handler = Tk_CreateErrorHandler(display, -1, -1, -1, - (Tk_ErrorProc *) NULL, (ClientData) NULL); + handler = Tk_CreateErrorHandler(display, -1, -1, -1, NULL, + (ClientData) NULL); /* * Pull the current background from the display to blend with @@ -2859,10 +2847,10 @@ ImgPhotoDisplay(clientData, display, drawable, imageX, imageY, width, */ static void -ImgPhotoFree(clientData, display) - ClientData clientData; /* Pointer to PhotoInstance structure for +ImgPhotoFree( + ClientData clientData, /* Pointer to PhotoInstance structure for * instance to be displayed. */ - Display *display; /* Display containing window that used + Display *display) /* Display containing window that used * image. */ { PhotoInstance *instancePtr = (PhotoInstance *) clientData; @@ -2906,8 +2894,8 @@ ImgPhotoFree(clientData, display) */ static void -ImgPhotoDelete(masterData) - ClientData masterData; /* Pointer to PhotoMaster structure for image. +ImgPhotoDelete( + ClientData masterData) /* Pointer to PhotoMaster structure for image. * Must not have any more instances. */ { PhotoMaster *masterPtr = (PhotoMaster *) masterData; @@ -2936,7 +2924,7 @@ ImgPhotoDelete(masterData) if (masterPtr->format != NULL) { Tcl_DecrRefCount(masterPtr->format); } - Tk_FreeOptions(configSpecs, (char *) masterPtr, (Display *) NULL, 0); + Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); ckfree((char *) masterPtr); } @@ -2958,8 +2946,8 @@ ImgPhotoDelete(masterData) */ static void -ImgPhotoCmdDeletedProc(clientData) - ClientData clientData; /* Pointer to PhotoMaster structure for +ImgPhotoCmdDeletedProc( + ClientData clientData) /* Pointer to PhotoMaster structure for * image. */ { PhotoMaster *masterPtr = (PhotoMaster *) clientData; @@ -2990,9 +2978,9 @@ ImgPhotoCmdDeletedProc(clientData) */ static int -ImgPhotoSetSize(masterPtr, width, height) - PhotoMaster *masterPtr; - int width, height; +ImgPhotoSetSize( + PhotoMaster *masterPtr, + int width, int height) { unsigned char *newPix32 = NULL; int h, offset, pitch; @@ -3177,8 +3165,8 @@ ImgPhotoSetSize(masterPtr, width, height) */ static void -ImgPhotoInstanceSetSize(instancePtr) - PhotoInstance *instancePtr; /* Instance whose size is to be changed. */ +ImgPhotoInstanceSetSize( + PhotoInstance *instancePtr) /* Instance whose size is to be changed. */ { PhotoMaster *masterPtr; schar *newError; @@ -3316,10 +3304,10 @@ ImgPhotoInstanceSetSize(instancePtr) */ static int -IsValidPalette(instancePtr, palette) - PhotoInstance *instancePtr; /* Instance to which the palette specification +IsValidPalette( + PhotoInstance *instancePtr, /* Instance to which the palette specification * is to be applied. */ - CONST char *palette; /* Palette specification string. */ + CONST char *palette) /* Palette specification string. */ { int nRed, nGreen, nBlue, mono, numColors; char *endp; @@ -3400,8 +3388,8 @@ IsValidPalette(instancePtr, palette) */ static int -CountBits(mask) - pixel mask; /* Value to count the 1 bits in. */ +CountBits( + pixel mask) /* Value to count the 1 bits in. */ { int n; @@ -3435,8 +3423,8 @@ CountBits(mask) */ static void -GetColorTable(instancePtr) - PhotoInstance *instancePtr; /* Instance needing a color table. */ +GetColorTable( + PhotoInstance *instancePtr) /* Instance needing a color table. */ { ColorTable *colorPtr; Tcl_HashEntry *entry; @@ -3530,10 +3518,10 @@ GetColorTable(instancePtr) */ static void -FreeColorTable(colorPtr, force) - ColorTable *colorPtr; /* Pointer to the color table which is no +FreeColorTable( + ColorTable *colorPtr, /* Pointer to the color table which is no * longer required by an instance. */ - int force; /* Force free to happen immediately. */ + int force) /* Force free to happen immediately. */ { colorPtr->refCount--; if (colorPtr->refCount > 0) { @@ -3571,8 +3559,8 @@ FreeColorTable(colorPtr, force) */ static void -AllocateColors(colorPtr) - ColorTable *colorPtr; /* Pointer to the color table requiring colors +AllocateColors( + ColorTable *colorPtr) /* Pointer to the color table requiring colors * to be allocated. */ { int i, r, g, b, rMult, mono; @@ -3851,8 +3839,8 @@ AllocateColors(colorPtr) */ static void -DisposeColorTable(clientData) - ClientData clientData; /* Pointer to the ColorTable whose +DisposeColorTable( + ClientData clientData) /* Pointer to the ColorTable whose * colors are to be released. */ { ColorTable *colorPtr; @@ -3899,10 +3887,10 @@ DisposeColorTable(clientData) */ static int -ReclaimColors(id, numColors) - ColorTableId *id; /* Pointer to information identifying +ReclaimColors( + ColorTableId *id, /* Pointer to information identifying * the color table which needs more colors. */ - int numColors; /* Number of colors required. */ + int numColors) /* Number of colors required. */ { Tcl_HashSearch srch; Tcl_HashEntry *entry; @@ -3987,8 +3975,8 @@ ReclaimColors(id, numColors) */ static void -DisposeInstance(clientData) - ClientData clientData; /* Pointer to the instance whose resources are +DisposeInstance( + ClientData clientData) /* Pointer to the instance whose resources are * to be released. */ { PhotoInstance *instancePtr = (PhotoInstance *) clientData; @@ -4046,18 +4034,18 @@ DisposeInstance(clientData) */ static int -MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr, - widthPtr, heightPtr, oldformat) - Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ - Tcl_Channel chan; /* The image file, open for reading. */ - char *fileName; /* The name of the image file. */ - Tcl_Obj *formatObj; /* User-specified format string, or NULL. */ - Tk_PhotoImageFormat **imageFormatPtr; +MatchFileFormat( + Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ + Tcl_Channel chan, /* The image file, open for reading. */ + char *fileName, /* The name of the image file. */ + Tcl_Obj *formatObj, /* User-specified format string, or NULL. */ + Tk_PhotoImageFormat **imageFormatPtr, /* A pointer to the photo image format record * is returned here. */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned + int *widthPtr, int *heightPtr, + /* The dimensions of the image are returned * here. */ - int *oldformat; /* returns 1 if the old image API is used */ + int *oldformat) /* returns 1 if the old image API is used */ { int matched; int useoldformat = 0; @@ -4086,7 +4074,7 @@ MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr, matched = 1; if (formatPtr->fileMatchProc == NULL) { Tcl_AppendResult(interp, "-file option isn't supported for ", - formatString, " images", (char *) NULL); + formatString, " images", NULL); return TCL_ERROR; } } @@ -4117,7 +4105,7 @@ MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr, matched = 1; if (formatPtr->fileMatchProc == NULL) { Tcl_AppendResult(interp, "-file option isn't supported", - " for ", formatString, " images", (char *) NULL); + " for ", formatString, " images", NULL); return TCL_ERROR; } } @@ -4140,11 +4128,11 @@ MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr, if (formatPtr == NULL) { if ((formatObj != NULL) && !matched) { Tcl_AppendResult(interp, "image file format \"", formatString, - "\" is not supported", (char *) NULL); + "\" is not supported", NULL); } else { Tcl_AppendResult(interp, "couldn't recognize data in image file \"", fileName, "\"", - (char *) NULL); + NULL); } return TCL_ERROR; } @@ -4178,17 +4166,17 @@ MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr, */ static int -MatchStringFormat(interp, data, formatObj, imageFormatPtr, - widthPtr, heightPtr, oldformat) - Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ - Tcl_Obj *data; /* Object containing the image data. */ - Tcl_Obj *formatObj; /* User-specified format string, or NULL. */ - Tk_PhotoImageFormat **imageFormatPtr; +MatchStringFormat( + Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ + Tcl_Obj *data, /* Object containing the image data. */ + Tcl_Obj *formatObj, /* User-specified format string, or NULL. */ + Tk_PhotoImageFormat **imageFormatPtr, /* A pointer to the photo image format record * is returned here. */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned + int *widthPtr, int *heightPtr, + /* The dimensions of the image are returned * here. */ - int *oldformat; /* returns 1 if the old image API is used */ + int *oldformat) /* returns 1 if the old image API is used */ { int matched; int useoldformat = 0; @@ -4217,7 +4205,7 @@ MatchStringFormat(interp, data, formatObj, imageFormatPtr, matched = 1; if (formatPtr->stringMatchProc == NULL) { Tcl_AppendResult(interp, "-data option isn't supported for ", - formatString, " images", (char *) NULL); + formatString, " images", NULL); return TCL_ERROR; } } @@ -4241,7 +4229,7 @@ MatchStringFormat(interp, data, formatObj, imageFormatPtr, matched = 1; if (formatPtr->stringMatchProc == NULL) { Tcl_AppendResult(interp, "-data option isn't supported", - " for ", formatString, " images", (char *) NULL); + " for ", formatString, " images", NULL); return TCL_ERROR; } } @@ -4258,10 +4246,9 @@ MatchStringFormat(interp, data, formatObj, imageFormatPtr, if (formatPtr == NULL) { if ((formatObj != NULL) && !matched) { Tcl_AppendResult(interp, "image format \"", formatString, - "\" is not supported", (char *) NULL); + "\" is not supported", NULL); } else { - Tcl_AppendResult(interp, "couldn't recognize image data", - (char *) NULL); + Tcl_AppendResult(interp, "couldn't recognize image data", NULL); } return TCL_ERROR; } @@ -4292,10 +4279,10 @@ MatchStringFormat(interp, data, formatObj, imageFormatPtr, */ Tk_PhotoHandle -Tk_FindPhoto(interp, imageName) - Tcl_Interp *interp; /* Interpreter (application) in which image +Tk_FindPhoto( + Tcl_Interp *interp, /* Interpreter (application) in which image * exists. */ - CONST char *imageName; /* Name of the desired photo image. */ + CONST char *imageName) /* Name of the desired photo image. */ { ClientData clientData; Tk_ImageType *typePtr; @@ -4327,19 +4314,19 @@ Tk_FindPhoto(interp, imageName) */ int -Tk_PhotoPutBlock(interp, handle, blockPtr, x, y, width, height, compRule) - Tcl_Interp *interp; /* Interpreter for passing back error +Tk_PhotoPutBlock( + Tcl_Interp *interp, /* Interpreter for passing back error * messages, or NULL. */ - Tk_PhotoHandle handle; /* Opaque handle for the photo image to be + Tk_PhotoHandle handle, /* Opaque handle for the photo image to be * updated. */ - register Tk_PhotoImageBlock *blockPtr; + register Tk_PhotoImageBlock *blockPtr, /* Pointer to a structure describing the pixel * data to be copied into the image. */ - int x, y; /* Coordinates of the top-left pixel to be + int x, int y, /* Coordinates of the top-left pixel to be * updated in the image. */ - int width, height; /* Dimensions of the area of the image to be + int width, int height, /* Dimensions of the area of the image to be * updated. */ - int compRule; /* Compositing rule to use when processing + int compRule) /* Compositing rule to use when processing * transparent pixels. */ { register PhotoMaster *masterPtr; @@ -4374,8 +4361,7 @@ Tk_PhotoPutBlock(interp, handle, blockPtr, x, y, width, height, compRule) MAX(yEnd, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); } return TCL_ERROR; } @@ -4650,23 +4636,23 @@ Tk_PhotoPutBlock(interp, handle, blockPtr, x, y, width, height, compRule) */ int -Tk_PhotoPutZoomedBlock(interp, handle, blockPtr, x, y, width, height, - zoomX, zoomY, subsampleX, subsampleY, compRule) - Tcl_Interp *interp; /* Interpreter for passing back error +Tk_PhotoPutZoomedBlock( + Tcl_Interp *interp, /* Interpreter for passing back error * messages, or NULL. */ - Tk_PhotoHandle handle; /* Opaque handle for the photo image to be + Tk_PhotoHandle handle, /* Opaque handle for the photo image to be * updated. */ - register Tk_PhotoImageBlock *blockPtr; + register Tk_PhotoImageBlock *blockPtr, /* Pointer to a structure describing the pixel * data to be copied into the image. */ - int x, y; /* Coordinates of the top-left pixel to be + int x, int y, /* Coordinates of the top-left pixel to be * updated in the image. */ - int width, height; /* Dimensions of the area of the image to be + int width, int height, /* Dimensions of the area of the image to be * updated. */ - int zoomX, zoomY; /* Zoom factors for the X and Y axes. */ - int subsampleX, subsampleY; /* Subsampling factors for the X and Y + int zoomX, int zoomY, /* Zoom factors for the X and Y axes. */ + int subsampleX, int subsampleY, + /* Subsampling factors for the X and Y * axes. */ - int compRule; /* Compositing rule to use when processing + int compRule) /* Compositing rule to use when processing * transparent pixels. */ { register PhotoMaster *masterPtr; @@ -4711,8 +4697,7 @@ Tk_PhotoPutZoomedBlock(interp, handle, blockPtr, x, y, width, height, MAX(yEnd, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); } return TCL_ERROR; } @@ -4931,12 +4916,12 @@ Tk_PhotoPutZoomedBlock(interp, handle, blockPtr, x, y, width, height, */ void -Tk_DitherPhoto(photo, x, y, width, height) - Tk_PhotoHandle photo; /* Image master whose instances are to be +Tk_DitherPhoto( + Tk_PhotoHandle photo, /* Image master whose instances are to be * updated. */ - int x, y; /* Coordinates of the top-left pixel in the + int x, int y, /* Coordinates of the top-left pixel in the * area to be dithered. */ - int width, height; /* Dimensions of the area to be dithered. */ + int width, int height) /* Dimensions of the area to be dithered. */ { PhotoMaster *masterPtr = (PhotoMaster *) photo; PhotoInstance *instancePtr; @@ -5008,11 +4993,11 @@ Tk_DitherPhoto(photo, x, y, width, height) */ static void -DitherInstance(instancePtr, xStart, yStart, width, height) - PhotoInstance *instancePtr; /* The instance to be updated. */ - int xStart, yStart; /* Coordinates of the top-left pixel in the +DitherInstance( + PhotoInstance *instancePtr, /* The instance to be updated. */ + int xStart, int yStart, /* Coordinates of the top-left pixel in the * block to be dithered. */ - int width, height; /* Dimensions of the block to be dithered. */ + int width, int height) /* Dimensions of the block to be dithered. */ { PhotoMaster *masterPtr; ColorTable *colorPtr; @@ -5351,8 +5336,8 @@ DitherInstance(instancePtr, xStart, yStart, width, height) */ void -Tk_PhotoBlank(handle) - Tk_PhotoHandle handle; /* Handle for the image to be blanked. */ +Tk_PhotoBlank( + Tk_PhotoHandle handle) /* Handle for the image to be blanked. */ { PhotoMaster *masterPtr; PhotoInstance *instancePtr; @@ -5415,11 +5400,11 @@ Tk_PhotoBlank(handle) */ int -Tk_PhotoExpand(interp, handle, width, height) - Tcl_Interp *interp; /* Interpreter for passing back error +Tk_PhotoExpand( + Tcl_Interp *interp, /* Interpreter for passing back error * messages, or NULL. */ - Tk_PhotoHandle handle; /* Handle for the image to be expanded. */ - int width, height; /* Desired minimum dimensions of the image. */ + Tk_PhotoHandle handle, /* Handle for the image to be expanded. */ + int width, int height) /* Desired minimum dimensions of the image. */ { PhotoMaster *masterPtr; @@ -5436,8 +5421,7 @@ Tk_PhotoExpand(interp, handle, width, height) MAX(height, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); } return TCL_ERROR; } @@ -5464,10 +5448,11 @@ Tk_PhotoExpand(interp, handle, width, height) */ void -Tk_PhotoGetSize(handle, widthPtr, heightPtr) - Tk_PhotoHandle handle; /* Handle for the image whose dimensions are +Tk_PhotoGetSize( + Tk_PhotoHandle handle, /* Handle for the image whose dimensions are * requested. */ - int *widthPtr, *heightPtr; /* The dimensions of the image are returned + int *widthPtr, int *heightPtr) + /* The dimensions of the image are returned * here. */ { PhotoMaster *masterPtr; @@ -5496,12 +5481,12 @@ Tk_PhotoGetSize(handle, widthPtr, heightPtr) */ int -Tk_PhotoSetSize(interp, handle, width, height) - Tcl_Interp *interp; /* Interpreter for passing back error +Tk_PhotoSetSize( + Tcl_Interp *interp, /* Interpreter for passing back error * messages, or NULL. */ - Tk_PhotoHandle handle; /* Handle for the image whose size is to be + Tk_PhotoHandle handle, /* Handle for the image whose size is to be * set. */ - int width, height; /* New dimensions for the image. */ + int width, int height) /* New dimensions for the image. */ { PhotoMaster *masterPtr; @@ -5513,8 +5498,7 @@ Tk_PhotoSetSize(interp, handle, width, height) ((height > 0) ? height: masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + Tcl_AppendResult(interp, TK_PHOTO_ALLOC_FAILURE_MESSAGE, NULL); } return TCL_ERROR; } @@ -5544,8 +5528,8 @@ Tk_PhotoSetSize(interp, handle, width, height) */ TkRegion -TkPhotoGetValidRegion(handle) - Tk_PhotoHandle handle; /* Handle for the image whose valid region is +TkPhotoGetValidRegion( + Tk_PhotoHandle handle) /* Handle for the image whose valid region is * to obtained. */ { PhotoMaster *masterPtr; @@ -5576,13 +5560,13 @@ TkPhotoGetValidRegion(handle) */ static char * -ImgGetPhoto(masterPtr, blockPtr, optPtr) - PhotoMaster *masterPtr; /* Handle for the photo image from which image +ImgGetPhoto( + PhotoMaster *masterPtr, /* Handle for the photo image from which image * data is desired. */ - Tk_PhotoImageBlock *blockPtr; + Tk_PhotoImageBlock *blockPtr, /* Information about the address and layout of * the image data is returned here. */ - struct SubcommandOptions *optPtr; + struct SubcommandOptions *optPtr) { unsigned char *pixelPtr; int x, y, greenOffset, blueOffset, alphaOffset; @@ -5758,10 +5742,10 @@ ImgGetPhoto(masterPtr, blockPtr, optPtr) */ static int -ImgStringWrite(interp, formatString, blockPtr) - Tcl_Interp *interp; - Tcl_Obj *formatString; - Tk_PhotoImageBlock *blockPtr; +ImgStringWrite( + Tcl_Interp *interp, + Tcl_Obj *formatString, + Tk_PhotoImageBlock *blockPtr) { int row,col; char *line, *linePtr; @@ -5814,10 +5798,10 @@ ImgStringWrite(interp, formatString, blockPtr) */ int -Tk_PhotoGetImage(handle, blockPtr) - Tk_PhotoHandle handle; /* Handle for the photo image from which image +Tk_PhotoGetImage( + Tk_PhotoHandle handle, /* Handle for the photo image from which image * data is desired. */ - Tk_PhotoImageBlock *blockPtr; + Tk_PhotoImageBlock *blockPtr) /* Information about the address and layout of * the image data is returned here. */ { @@ -5860,37 +5844,37 @@ typedef struct OptionAssocData { } OptionAssocData; static Tcl_ObjCmdProc * -PhotoOptionFind(interp, obj) - Tcl_Interp *interp; /* Interpreter that is being deleted. */ - Tcl_Obj *obj; /* Name of option to be found. */ +PhotoOptionFind( + Tcl_Interp *interp, /* Interpreter that is being deleted. */ + Tcl_Obj *obj) /* Name of option to be found. */ { int length; char *name = Tcl_GetStringFromObj(obj, &length); char *prevname = NULL; - Tcl_ObjCmdProc *proc = (Tcl_ObjCmdProc *) NULL; + Tcl_ObjCmdProc *proc = NULL; OptionAssocData *list = (OptionAssocData *) Tcl_GetAssocData(interp, - "photoOption", (Tcl_InterpDeleteProc **) NULL); + "photoOption", NULL); - while (list != (OptionAssocData *) NULL) { + while (list != NULL) { if (strncmp(name, list->name, (unsigned) length) == 0) { - if (proc != (Tcl_ObjCmdProc *) NULL) { + if (proc != NULL) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "ambiguous option \"", name, - "\": must be ", prevname, (char *) NULL); - while (list->nextPtr != (OptionAssocData *) NULL) { - Tcl_AppendResult(interp, prevname, ", ",(char *) NULL); + "\": must be ", prevname, NULL); + while (list->nextPtr != NULL) { + Tcl_AppendResult(interp, prevname, ", ",NULL); list = list->nextPtr; prevname = list->name; } - Tcl_AppendResult(interp, ", or", prevname, (char *) NULL); - return (Tcl_ObjCmdProc *) NULL; + Tcl_AppendResult(interp, ", or", prevname, NULL); + return NULL; } proc = list->command; prevname = list->name; } list = list->nextPtr; } - if (proc != (Tcl_ObjCmdProc *) NULL) { + if (proc != NULL) { Tcl_ResetResult(interp); } return proc; @@ -5914,10 +5898,10 @@ PhotoOptionFind(interp, obj) */ static void -PhotoOptionCleanupProc(clientData, interp) - ClientData clientData; /* Points to "photoVisitor" AssocData for the +PhotoOptionCleanupProc( + ClientData clientData, /* Points to "photoVisitor" AssocData for the * interpreter. */ - Tcl_Interp *interp; /* Interpreter that is being deleted. */ + Tcl_Interp *interp) /* Interpreter that is being deleted. */ { OptionAssocData *list = (OptionAssocData *) clientData; OptionAssocData *ptr; @@ -5946,16 +5930,15 @@ PhotoOptionCleanupProc(clientData, interp) */ void -Tk_CreatePhotoOption(interp, name, proc) - Tcl_Interp *interp; /* Interpreter */ - CONST char *name; /* Option name */ - Tcl_ObjCmdProc *proc; /* Function to execute command */ +Tk_CreatePhotoOption( + Tcl_Interp *interp, /* Interpreter */ + CONST char *name, /* Option name */ + Tcl_ObjCmdProc *proc) /* Function to execute command */ { OptionAssocData *typePtr2, *prevPtr, *ptr; OptionAssocData *list; - list = (OptionAssocData *) Tcl_GetAssocData(interp, "photoOption", - (Tcl_InterpDeleteProc **) NULL); + list = (OptionAssocData *) Tcl_GetAssocData(interp, "photoOption", NULL); /* * If there's already a photo option with the given name, remove it. @@ -5978,7 +5961,7 @@ Tk_CreatePhotoOption(interp, name, proc) ptr->command = proc; ptr->nextPtr = list; Tcl_SetAssocData(interp, "photoOption", PhotoOptionCleanupProc, - (ClientData) ptr); + (ClientData) ptr); } /* @@ -5997,16 +5980,16 @@ Tk_CreatePhotoOption(interp, name, proc) * *-------------------------------------------------------------- */ + static int -ImgPhotoPostscript(clientData, interp, tkwin, psInfo, - x, y, width, height, prepass) - ClientData clientData; /* Handle for the photo image */ - Tcl_Interp *interp; /* Interpreter */ - Tk_Window tkwin; /* (unused) */ - Tk_PostscriptInfo psInfo; /* postscript info */ - int x, y; /* First pixel to output */ - int width, height; /* Width and height of area */ - int prepass; /* (unused) */ +ImgPhotoPostscript( + ClientData clientData, /* Handle for the photo image */ + Tcl_Interp *interp, /* Interpreter */ + Tk_Window tkwin, /* (unused) */ + Tk_PostscriptInfo psInfo, /* postscript info */ + int x, int y, /* First pixel to output */ + int width, int height, /* Width and height of area */ + int prepass) /* (unused) */ { Tk_PhotoImageBlock block; @@ -6029,11 +6012,12 @@ ImgPhotoPostscript(clientData, interp, tkwin, psInfo, * *---------------------------------------------------------------------- */ + void -Tk_PhotoPutBlock_NoComposite(handle, blockPtr, x, y, width, height) - Tk_PhotoHandle handle; - Tk_PhotoImageBlock *blockPtr; - int x, y, width, height; +Tk_PhotoPutBlock_NoComposite( + Tk_PhotoHandle handle, + Tk_PhotoImageBlock *blockPtr, + int x, int y, int width, int height) { if (Tk_PhotoPutBlock(NULL, handle, blockPtr, x, y, width, height, TK_PHOTO_COMPOSITE_OVERLAY) != TCL_OK) { @@ -6042,11 +6026,11 @@ Tk_PhotoPutBlock_NoComposite(handle, blockPtr, x, y, width, height) } void -Tk_PhotoPutZoomedBlock_NoComposite(handle, blockPtr, x, y, width, height, - zoomX, zoomY, subsampleX, subsampleY) - Tk_PhotoHandle handle; - Tk_PhotoImageBlock *blockPtr; - int x, y, width, height, zoomX, zoomY, subsampleX, subsampleY; +Tk_PhotoPutZoomedBlock_NoComposite( + Tk_PhotoHandle handle, + Tk_PhotoImageBlock *blockPtr, + int x, int y, int width, int height, + int zoomX, int zoomY, int subsampleX, int subsampleY) { if (Tk_PhotoPutZoomedBlock(NULL, handle, blockPtr, x, y, width, height, zoomX, zoomY, subsampleX, subsampleY, @@ -6071,9 +6055,9 @@ Tk_PhotoPutZoomedBlock_NoComposite(handle, blockPtr, x, y, width, height, */ void -Tk_PhotoExpand_Panic(handle, width, height) - Tk_PhotoHandle handle; - int width, height; +Tk_PhotoExpand_Panic( + Tk_PhotoHandle handle, + int width, int height) { if (Tk_PhotoExpand(NULL, handle, width, height) != TCL_OK) { Tcl_Panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE); @@ -6081,10 +6065,10 @@ Tk_PhotoExpand_Panic(handle, width, height) } void -Tk_PhotoPutBlock_Panic(handle, blockPtr, x, y, width, height, compRule) - Tk_PhotoHandle handle; - Tk_PhotoImageBlock *blockPtr; - int x, y, width, height, compRule; +Tk_PhotoPutBlock_Panic( + Tk_PhotoHandle handle, + Tk_PhotoImageBlock *blockPtr, + int x, int y, int width, int height, int compRule) { if (Tk_PhotoPutBlock(NULL, handle, blockPtr, x, y, width, height, compRule) != TCL_OK) { @@ -6093,11 +6077,11 @@ Tk_PhotoPutBlock_Panic(handle, blockPtr, x, y, width, height, compRule) } void -Tk_PhotoPutZoomedBlock_Panic(handle, blockPtr, x, y, width, height, - zoomX, zoomY, subsampleX, subsampleY, compRule) - Tk_PhotoHandle handle; - register Tk_PhotoImageBlock *blockPtr; - int x, y, width, height, zoomX, zoomY, subsampleX, subsampleY, compRule; +Tk_PhotoPutZoomedBlock_Panic( + Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, + int x, int y, int width, int height, + int zoomX, int zoomY, int subsampleX, int subsampleY, + int compRule) { if (Tk_PhotoPutZoomedBlock(NULL, handle, blockPtr, x, y, width, height, zoomX, zoomY, subsampleX, subsampleY, compRule) != TCL_OK) { @@ -6106,9 +6090,9 @@ Tk_PhotoPutZoomedBlock_Panic(handle, blockPtr, x, y, width, height, } void -Tk_PhotoSetSize_Panic(handle, width, height) - Tk_PhotoHandle handle; - int width, height; +Tk_PhotoSetSize_Panic( + Tk_PhotoHandle handle, + int width, int height) { if (Tk_PhotoSetSize(NULL, handle, width, height) != TCL_OK) { Tcl_Panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE); diff --git a/generic/tkListbox.c b/generic/tkListbox.c index ec49093..8856fa0 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkListbox.c,v 1.33 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkListbox.c,v 1.34 2005/11/17 16:21:55 dkf Exp $ */ #include "tkPort.h" @@ -214,7 +214,7 @@ enum state { }; static char *stateStrings[] = { - "disabled", "normal", (char *) NULL + "disabled", "normal", NULL }; enum activeStyle { @@ -222,7 +222,7 @@ enum activeStyle { }; static char *activeStyleStrings[] = { - "dotbox", "none", "underline", (char *) NULL + "dotbox", "none", "underline", NULL }; /* @@ -237,10 +237,10 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", DEF_LISTBOX_BG_COLOR, -1, Tk_Offset(Listbox, normalBorder), 0, (ClientData) DEF_LISTBOX_BG_MONO, 0}, - {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, - {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-background", 0}, + {TK_OPTION_SYNONYM, "-bd", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + {TK_OPTION_SYNONYM, "-bg", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_LISTBOX_BORDER_WIDTH, -1, Tk_Offset(Listbox, borderWidth), 0, 0, 0}, @@ -253,8 +253,8 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, -1, Tk_Offset(Listbox, exportSelection), 0, 0, 0}, - {TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, + NULL, 0, -1, 0, (ClientData) "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_LISTBOX_FONT, -1, Tk_Offset(Listbox, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", @@ -303,8 +303,7 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING, "-listvariable", "listVariable", "Variable", DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, 0, 0} + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0} }; /* @@ -314,26 +313,25 @@ static Tk_OptionSpec optionSpecs[] = { static Tk_OptionSpec itemAttrOptionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", - (char *)NULL, -1, Tk_Offset(ItemAttr, border), + NULL, -1, Tk_Offset(ItemAttr, border), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, (ClientData) DEF_LISTBOX_BG_MONO, 0}, - {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-background", 0}, - {TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + {TK_OPTION_SYNONYM, "-bg", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-background", 0}, + {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, + NULL, 0, -1, 0, (ClientData) "-foreground", 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", - (char *) NULL, -1, Tk_Offset(ItemAttr, fgColor), + NULL, -1, Tk_Offset(ItemAttr, fgColor), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", - (char *) NULL, -1, Tk_Offset(ItemAttr, selBorder), + NULL, -1, Tk_Offset(ItemAttr, selBorder), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, (ClientData) DEF_LISTBOX_SELECT_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", - (char *) NULL, -1, Tk_Offset(ItemAttr, selFgColor), + NULL, -1, Tk_Offset(ItemAttr, selFgColor), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, (ClientData) DEF_LISTBOX_SELECT_FG_MONO, 0}, - {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, 0, 0} + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0} }; /* @@ -345,8 +343,7 @@ static Tk_OptionSpec itemAttrOptionSpecs[] = { static CONST char *commandNames[] = { "activate", "bbox", "cget", "configure", "curselection", "delete", "get", "index", "insert", "itemcget", "itemconfigure", "nearest", "scan", - "see", "selection", "size", "xview", "yview", - (char *) NULL + "see", "selection", "size", "xview", "yview", NULL }; enum command { COMMAND_ACTIVATE, COMMAND_BBOX, COMMAND_CGET, COMMAND_CONFIGURE, @@ -357,21 +354,21 @@ enum command { }; static CONST char *selCommandNames[] = { - "anchor", "clear", "includes", "set", (char *) NULL + "anchor", "clear", "includes", "set", NULL }; enum selcommand { SELECTION_ANCHOR, SELECTION_CLEAR, SELECTION_INCLUDES, SELECTION_SET }; static CONST char *scanCommandNames[] = { - "mark", "dragto", (char *) NULL + "mark", "dragto", NULL }; enum scancommand { SCAN_MARK, SCAN_DRAGTO }; static CONST char *indexNames[] = { - "active", "anchor", "end", (char *)NULL + "active", "anchor", "end", NULL }; enum indices { INDEX_ACTIVE, INDEX_ANCHOR, INDEX_END @@ -478,7 +475,7 @@ Tk_ListboxObjCmd(clientData, interp, objc, objv) } tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), - Tcl_GetString(objv[1]), (char *) NULL); + Tcl_GetString(objv[1]), NULL); if (tkwin == NULL) { return TCL_ERROR; } @@ -692,7 +689,7 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (objc <= 3) { objPtr = Tk_GetOptionInfo(interp, (char *) listPtr, listPtr->optionTable, - (objc == 3) ? objv[2] : (Tcl_Obj *) NULL, listPtr->tkwin); + (objc == 3) ? objv[2] : NULL, listPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; break; @@ -879,7 +876,7 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (index < 0 || index >= listPtr->nElements) { Tcl_AppendResult(interp, "item number \"", - Tcl_GetString(objv[2]), "\" out of range", (char *)NULL); + Tcl_GetString(objv[2]), "\" out of range", NULL); result = TCL_ERROR; break; } @@ -915,7 +912,7 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (index < 0 || index >= listPtr->nElements) { Tcl_AppendResult(interp, "item number \"", Tcl_GetString(objv[2]), - "\" out of range", (char *) NULL); + "\" out of range", NULL); result = TCL_ERROR; break; } @@ -924,7 +921,7 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (objc <= 4) { objPtr = Tk_GetOptionInfo(interp, (char *)attrPtr, listPtr->itemAttrOptionTable, - (objc == 4) ? objv[3] : (Tcl_Obj *) NULL, listPtr->tkwin); + (objc == 4) ? objv[3] : NULL, listPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; break; @@ -1562,7 +1559,7 @@ ConfigureListbox(interp, listPtr, objc, objv, flags) if (Tk_SetOptions(interp, (char *) listPtr, listPtr->optionTable, objc, objv, - listPtr->tkwin, &savedOptions, (int *) NULL) != TCL_OK) { + listPtr->tkwin, &savedOptions, NULL) != TCL_OK) { continue; } } else { @@ -1618,12 +1615,12 @@ ConfigureListbox(interp, listPtr, objc, objv, flags) oldListObj = listPtr->listObj; if (listPtr->listVarName != NULL) { Tcl_Obj *listVarObj = Tcl_GetVar2Ex(interp, listPtr->listVarName, - (char *) NULL, TCL_GLOBAL_ONLY); + NULL, TCL_GLOBAL_ONLY); int dummy; if (listVarObj == NULL) { listVarObj = (oldListObj ? oldListObj : Tcl_NewObj()); - if (Tcl_SetVar2Ex(interp, listPtr->listVarName, (char *) NULL, + if (Tcl_SetVar2Ex(interp, listPtr->listVarName, NULL, listVarObj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { if (oldListObj == NULL) { @@ -1639,7 +1636,7 @@ ConfigureListbox(interp, listPtr, objc, objv, flags) if (Tcl_ListObjLength(listPtr->interp, listVarObj, &dummy) != TCL_OK) { Tcl_AppendResult(listPtr->interp, - ": invalid -listvariable value", (char *) NULL); + ": invalid -listvariable value", NULL); continue; } @@ -1709,7 +1706,7 @@ ConfigureListboxItem(interp, listPtr, attrs, objc, objv) if (Tk_SetOptions(interp, (char *)attrs, listPtr->itemAttrOptionTable, objc, objv, listPtr->tkwin, - &savedOptions, (int *)NULL) != TCL_OK) { + &savedOptions, NULL) != TCL_OK) { Tk_RestoreSavedOptions(&savedOptions); return TCL_ERROR; } @@ -2344,7 +2341,7 @@ ListboxInsertSubCmd(listPtr, index, objc, objv) if (listPtr->listVarName != NULL) { if (Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName, - (char *)NULL, newListObj, TCL_GLOBAL_ONLY) == NULL) { + NULL, newListObj, TCL_GLOBAL_ONLY) == NULL) { Tcl_DecrRefCount(newListObj); return TCL_ERROR; } @@ -2524,7 +2521,7 @@ ListboxDeleteSubCmd(listPtr, first, last) if (listPtr->listVarName != NULL) { if (Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName, - (char *)NULL, newListObj, TCL_GLOBAL_ONLY) == NULL) { + NULL, newListObj, TCL_GLOBAL_ONLY) == NULL) { Tcl_DecrRefCount(newListObj); return TCL_ERROR; } @@ -2759,7 +2756,7 @@ GetListboxIndex(interp, listPtr, indexObj, endIsSize, indexPtr) if ((start == end) || (*end != ',')) { Tcl_AppendResult(interp, "bad listbox index \"", stringRep, "\": must be active, anchor, end, @x,y, or a number", - (char *)NULL); + NULL); return TCL_ERROR; } start = end+1; @@ -2767,7 +2764,7 @@ GetListboxIndex(interp, listPtr, indexObj, endIsSize, indexPtr) if ((start == end) || (*end != '\0')) { Tcl_AppendResult(interp, "bad listbox index \"", stringRep, "\": must be active, anchor, end, @x,y, or a number", - (char *)NULL); + NULL); return TCL_ERROR; } *indexPtr = NearestListboxElement(listPtr, y); @@ -2789,7 +2786,7 @@ GetListboxIndex(interp, listPtr, indexObj, endIsSize, indexPtr) Tcl_ResetResult(interp); Tcl_AppendResult(interp, "bad listbox index \"", Tcl_GetString(indexObj), "\": must be active, anchor, ", - "end, @x,y, or a number", (char *) NULL); + "end, @x,y, or a number", NULL); return TCL_ERROR; } @@ -3290,8 +3287,7 @@ ListboxUpdateVScrollbar(listPtr) interp = listPtr->interp; Tcl_Preserve((ClientData) interp); - result = Tcl_VarEval(interp, listPtr->yScrollCmd, string, - (char *) NULL); + result = Tcl_VarEval(interp, listPtr->yScrollCmd, string, NULL); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (vertical scrolling command executed by listbox)"); @@ -3354,8 +3350,7 @@ ListboxUpdateHScrollbar(listPtr) interp = listPtr->interp; Tcl_Preserve((ClientData) interp); - result = Tcl_VarEval(interp, listPtr->xScrollCmd, string, - (char *) NULL); + result = Tcl_VarEval(interp, listPtr->xScrollCmd, string, NULL); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (horizontal scrolling command executed by listbox)"); @@ -3400,17 +3395,17 @@ ListboxListVarProc(clientData, interp, name1, name2, flags) if (flags & TCL_TRACE_UNSETS) { if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) { - Tcl_SetVar2Ex(interp, listPtr->listVarName, - (char *)NULL, listPtr->listObj, TCL_GLOBAL_ONLY); + Tcl_SetVar2Ex(interp, listPtr->listVarName, NULL, + listPtr->listObj, TCL_GLOBAL_ONLY); Tcl_TraceVar(interp, listPtr->listVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ListboxListVarProc, clientData); - return (char *)NULL; + return NULL; } } else { oldListObj = listPtr->listObj; varListObj = Tcl_GetVar2Ex(listPtr->interp, listPtr->listVarName, - (char *)NULL, TCL_GLOBAL_ONLY); + NULL, TCL_GLOBAL_ONLY); /* * Make sure the new value is a good list; if it's not, disallow the @@ -3419,15 +3414,23 @@ ListboxListVarProc(clientData, interp, name1, name2, flags) */ if (Tcl_ListObjLength(listPtr->interp, varListObj, &i) != TCL_OK) { - Tcl_SetVar2Ex(interp, listPtr->listVarName, (char *)NULL, - oldListObj, TCL_GLOBAL_ONLY); - return("invalid listvar value"); + Tcl_SetVar2Ex(interp, listPtr->listVarName, NULL, oldListObj, + TCL_GLOBAL_ONLY); + return "invalid listvar value"; } listPtr->listObj = varListObj; - /* Incr the obj ref count so it doesn't vanish if the var is unset */ + + /* + * Incr the obj ref count so it doesn't vanish if the var is unset. + */ + Tcl_IncrRefCount(listPtr->listObj); - /* Clean up the ref to our old list obj */ + + /* + * Clean up the ref to our old list obj. + */ + Tcl_DecrRefCount(oldListObj); } @@ -3477,7 +3480,7 @@ ListboxListVarProc(clientData, interp, name1, name2, flags) listPtr->flags |= MAXWIDTH_IS_STALE; EventuallyRedrawRange(listPtr, 0, listPtr->nElements-1); - return (char*)NULL; + return NULL; } /* diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 69ff080..998d5cc 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -1,18 +1,18 @@ -/* +/* * tkMenu.c -- * * This file contains most of the code for implementing menus in Tk. It takes - * care of all of the generic (platform-independent) parts of menus, and - * is supplemented by platform-specific files. The geometry calculation - * and drawing code for menus is in the file tkMenuDraw.c + * care of all of the generic (platform-independent) parts of menus, and is + * supplemented by platform-specific files. The geometry calculation and + * drawing code for menus is in the file tkMenuDraw.c * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1998 Sun Microsystems, Inc. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.c,v 1.32 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.33 2005/11/17 16:21:55 dkf Exp $ */ /* @@ -20,43 +20,41 @@ * * Menus can be used in three ways: * - as a popup menu, either as part of a menubutton or standalone. - * - as a menubar. The menu's cascade items are arranged according to - * the specific platform to provide the user access to the menus at all - * times + * - as a menubar. The menu's cascade items are arranged according to the + * specific platform to provide the user access to the menus at all times * - as a tearoff palette. This is a window with the menu's items in it. * - * The goal is to provide the Tk developer with a way to use a common - * set of menus for all of these tasks. + * The goal is to provide the Tk developer with a way to use a common set of + * menus for all of these tasks. * * In order to make the bindings for cascade menus work properly under Unix, - * the cascade menus' pathnames must be proper children of the menu that - * they are cascade from. So if there is a menu .m, and it has two - * cascades labelled "File" and "Edit", the cascade menus might have - * the pathnames .m.file and .m.edit. Another constraint is that the menus - * used for menubars must be children of the toplevel widget that they - * are attached to. And on the Macintosh, the platform specific menu handle - * for cascades attached to a menu bar must have a title that matches the - * label for the cascade menu. + * the cascade menus' pathnames must be proper children of the menu that they + * are cascade from. So if there is a menu .m, and it has two cascades + * labelled "File" and "Edit", the cascade menus might have the pathnames + * .m.file and .m.edit. Another constraint is that the menus used for menubars + * must be children of the toplevel widget that they are attached to. And on + * the Macintosh, the platform specific menu handle for cascades attached to a + * menu bar must have a title that matches the label for the cascade menu. * * To handle all of the constraints, Tk menubars and tearoff menus are * implemented using menu clones. Menu clones are full menus in their own - * right; they have a Tk window and pathname associated with them; they have - * a TkMenu structure and array of entries. However, they are linked with the - * original menu that they were cloned from. The reflect the attributes of - * the original, or "master", menu. So if an item is added to a menu, and - * that menu has clones, then the item must be added to all of its clones - * also. Menus are cloned when a menu is torn-off or when a menu is assigned - * as a menubar using the "-menu" option of the toplevel's pathname configure + * right; they have a Tk window and pathname associated with them; they have a + * TkMenu structure and array of entries. However, they are linked with the + * original menu that they were cloned from. The reflect the attributes of the + * original, or "master", menu. So if an item is added to a menu, and that + * menu has clones, then the item must be added to all of its clones also. + * Menus are cloned when a menu is torn-off or when a menu is assigned as a + * menubar using the "-menu" option of the toplevel's pathname configure * subcommand. When a clone is destroyed, only the clone is destroyed, but * when the master menu is destroyed, all clones are also destroyed. This - * allows the developer to just deal with one set of menus when creating - * and destroying. + * allows the developer to just deal with one set of menus when creating and + * destroying. * * Clones are rather tricky when a menu with cascade entries is cloned (such * as a menubar). Not only does the menu have to be cloned, but each cascade * entry's corresponding menu must also be cloned. This maintains the pathname - * parent-child hierarchy necessary for menubars and toplevels to work. - * This leads to several special cases: + * parent-child hierarchy necessary for menubars and toplevels to work. This + * leads to several special cases: * * 1. When a new menu is created, and it is pointed to by cascade entries in * cloned menus, the new menu has to be cloned to parallel the cascade @@ -65,7 +63,6 @@ * menu that the cascade item points to exists, that menu has to be cloned. * 3. When the menu that a cascade entry points to is changed, the old * cloned cascade menu has to be discarded, and the new one has to be cloned. - * */ #if 0 @@ -90,9 +87,8 @@ typedef struct ThreadSpecificData { static Tcl_ThreadDataKey dataKey; /* - * The following flag indicates whether the process-wide state for - * the Menu module has been intialized. The Mutex protects access to - * that flag. + * The following flag indicates whether the process-wide state for the Menu + * module has been intialized. The Mutex protects access to that flag. */ static int menusInitialized; @@ -103,134 +99,133 @@ TCL_DECLARE_MUTEX(menuMutex) * to update code in TkpMenuInit that changes the font string entry. */ -char *tkMenuStateStrings[] = {"active", "normal", "disabled", (char *) NULL}; +char *tkMenuStateStrings[] = {"active", "normal", "disabled", NULL}; static CONST char *menuEntryTypeStrings[] = { - "cascade", "checkbutton", "command", "radiobutton", "separator", - (char *) NULL + "cascade", "checkbutton", "command", "radiobutton", "separator", NULL }; /* - * The following table defines the legal values for the -compound option. - * It is used with the "enum compound" declaration in tkMenu.h + * The following table defines the legal values for the -compound option. It + * is used with the "enum compound" declaration in tkMenu.h */ static char *compoundStrings[] = { - "bottom", "center", "left", "none", "right", "top", (char *) NULL + "bottom", "center", "left", "none", "right", "top", NULL }; Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = { - {TK_OPTION_BORDER, "-activebackground", (char *) NULL, (char *) NULL, + {TK_OPTION_BORDER, "-activebackground", NULL, NULL, DEF_MENU_ENTRY_ACTIVE_BG, Tk_Offset(TkMenuEntry, activeBorderPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_COLOR, "-activeforeground", (char *) NULL, (char *) NULL, + {TK_OPTION_COLOR, "-activeforeground", NULL, NULL, DEF_MENU_ENTRY_ACTIVE_FG, Tk_Offset(TkMenuEntry, activeFgPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_STRING, "-accelerator", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-accelerator", NULL, NULL, DEF_MENU_ENTRY_ACCELERATOR, Tk_Offset(TkMenuEntry, accelPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_BORDER, "-background", (char *) NULL, (char *) NULL, + {TK_OPTION_BORDER, "-background", NULL, NULL, DEF_MENU_ENTRY_BG, Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_BITMAP, "-bitmap", (char *) NULL, (char *) NULL, + {TK_OPTION_BITMAP, "-bitmap", NULL, NULL, DEF_MENU_ENTRY_BITMAP, Tk_Offset(TkMenuEntry, bitmapPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_BOOLEAN, "-columnbreak", (char *) NULL, (char *) NULL, + {TK_OPTION_BOOLEAN, "-columnbreak", NULL, NULL, DEF_MENU_ENTRY_COLUMN_BREAK, -1, Tk_Offset(TkMenuEntry, columnBreak)}, - {TK_OPTION_STRING, "-command", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-command", NULL, NULL, DEF_MENU_ENTRY_COMMAND, Tk_Offset(TkMenuEntry, commandPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0, (ClientData) compoundStrings, 0}, - {TK_OPTION_FONT, "-font", (char *) NULL, (char *) NULL, + {TK_OPTION_FONT, "-font", NULL, NULL, DEF_MENU_ENTRY_FONT, Tk_Offset(TkMenuEntry, fontPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_COLOR, "-foreground", (char *) NULL, (char *) NULL, + {TK_OPTION_COLOR, "-foreground", NULL, NULL, DEF_MENU_ENTRY_FG, Tk_Offset(TkMenuEntry, fgPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_BOOLEAN, "-hidemargin", (char *) NULL, (char *) NULL, + {TK_OPTION_BOOLEAN, "-hidemargin", NULL, NULL, DEF_MENU_ENTRY_HIDE_MARGIN, -1, Tk_Offset(TkMenuEntry, hideMargin)}, - {TK_OPTION_STRING, "-image", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-image", NULL, NULL, DEF_MENU_ENTRY_IMAGE, Tk_Offset(TkMenuEntry, imagePtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_STRING, "-label", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-label", NULL, NULL, DEF_MENU_ENTRY_LABEL, Tk_Offset(TkMenuEntry, labelPtr), -1, 0}, - {TK_OPTION_STRING_TABLE, "-state", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING_TABLE, "-state", NULL, NULL, DEF_MENU_ENTRY_STATE, -1, Tk_Offset(TkMenuEntry, state), 0, (ClientData) tkMenuStateStrings}, - {TK_OPTION_INT, "-underline", (char *) NULL, (char *) NULL, + {TK_OPTION_INT, "-underline", NULL, NULL, DEF_MENU_ENTRY_UNDERLINE, -1, Tk_Offset(TkMenuEntry, underline)}, {TK_OPTION_END} }; Tk_OptionSpec tkSeparatorEntryConfigSpecs[] = { - {TK_OPTION_BORDER, "-background", (char *) NULL, (char *) NULL, + {TK_OPTION_BORDER, "-background", NULL, NULL, DEF_MENU_ENTRY_BG, Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_END} }; Tk_OptionSpec tkCheckButtonEntryConfigSpecs[] = { - {TK_OPTION_BOOLEAN, "-indicatoron", (char *) NULL, (char *) NULL, + {TK_OPTION_BOOLEAN, "-indicatoron", NULL, NULL, DEF_MENU_ENTRY_INDICATOR, -1, Tk_Offset(TkMenuEntry, indicatorOn)}, - {TK_OPTION_STRING, "-offvalue", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-offvalue", NULL, NULL, DEF_MENU_ENTRY_OFF_VALUE, Tk_Offset(TkMenuEntry, offValuePtr), -1}, - {TK_OPTION_STRING, "-onvalue", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-onvalue", NULL, NULL, DEF_MENU_ENTRY_ON_VALUE, Tk_Offset(TkMenuEntry, onValuePtr), -1}, - {TK_OPTION_COLOR, "-selectcolor", (char *) NULL, (char *) NULL, + {TK_OPTION_COLOR, "-selectcolor", NULL, NULL, DEF_MENU_ENTRY_SELECT, Tk_Offset(TkMenuEntry, indicatorFgPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_STRING, "-selectimage", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-selectimage", NULL, NULL, DEF_MENU_ENTRY_SELECT_IMAGE, Tk_Offset(TkMenuEntry, selectImagePtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_STRING, "-variable", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-variable", NULL, NULL, DEF_MENU_ENTRY_CHECK_VARIABLE, Tk_Offset(TkMenuEntry, namePtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) tkBasicMenuEntryConfigSpecs} + {TK_OPTION_END, NULL, NULL, NULL, + NULL, 0, -1, 0, (ClientData) tkBasicMenuEntryConfigSpecs} }; Tk_OptionSpec tkRadioButtonEntryConfigSpecs[] = { - {TK_OPTION_BOOLEAN, "-indicatoron", (char *) NULL, (char *) NULL, + {TK_OPTION_BOOLEAN, "-indicatoron", NULL, NULL, DEF_MENU_ENTRY_INDICATOR, -1, Tk_Offset(TkMenuEntry, indicatorOn)}, - {TK_OPTION_COLOR, "-selectcolor", (char *) NULL, (char *) NULL, + {TK_OPTION_COLOR, "-selectcolor", NULL, NULL, DEF_MENU_ENTRY_SELECT, Tk_Offset(TkMenuEntry, indicatorFgPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_STRING, "-selectimage", (char *) NULL, (char *) NULL, - DEF_MENU_ENTRY_SELECT_IMAGE, + {TK_OPTION_STRING, "-selectimage", NULL, NULL, + DEF_MENU_ENTRY_SELECT_IMAGE, Tk_Offset(TkMenuEntry, selectImagePtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_STRING, "-value", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-value", NULL, NULL, DEF_MENU_ENTRY_VALUE, Tk_Offset(TkMenuEntry, onValuePtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_STRING, "-variable", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-variable", NULL, NULL, DEF_MENU_ENTRY_RADIO_VARIABLE, Tk_Offset(TkMenuEntry, namePtr), -1, 0}, - {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) tkBasicMenuEntryConfigSpecs} + {TK_OPTION_END, NULL, NULL, NULL, + NULL, 0, -1, 0, (ClientData) tkBasicMenuEntryConfigSpecs} }; Tk_OptionSpec tkCascadeEntryConfigSpecs[] = { - {TK_OPTION_STRING, "-menu", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING, "-menu", NULL, NULL, DEF_MENU_ENTRY_MENU, Tk_Offset(TkMenuEntry, namePtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) tkBasicMenuEntryConfigSpecs} + {TK_OPTION_END, NULL, NULL, NULL, + NULL, 0, -1, 0, (ClientData) tkBasicMenuEntryConfigSpecs} }; Tk_OptionSpec tkTearoffEntryConfigSpecs[] = { - {TK_OPTION_BORDER, "-background", (char *) NULL, (char *) NULL, + {TK_OPTION_BORDER, "-background", NULL, NULL, DEF_MENU_ENTRY_BG, Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK}, - {TK_OPTION_STRING_TABLE, "-state", (char *) NULL, (char *) NULL, + {TK_OPTION_STRING_TABLE, "-state", NULL, NULL, DEF_MENU_ENTRY_STATE, -1, Tk_Offset(TkMenuEntry, state), 0, (ClientData) tkMenuStateStrings}, {TK_OPTION_END} @@ -239,34 +234,36 @@ Tk_OptionSpec tkTearoffEntryConfigSpecs[] = { static Tk_OptionSpec *specsArray[] = { tkCascadeEntryConfigSpecs, tkCheckButtonEntryConfigSpecs, tkBasicMenuEntryConfigSpecs, tkRadioButtonEntryConfigSpecs, - tkSeparatorEntryConfigSpecs, tkTearoffEntryConfigSpecs}; - + tkSeparatorEntryConfigSpecs, tkTearoffEntryConfigSpecs +}; + /* * Menu type strings for use with Tcl_GetIndexFromObj. */ -static CONST char *menuTypeStrings[] = {"normal", "tearoff", "menubar", - (char *) NULL}; +static CONST char *menuTypeStrings[] = { + "normal", "tearoff", "menubar", NULL +}; Tk_OptionSpec tkMenuConfigSpecs[] = { - {TK_OPTION_BORDER, "-activebackground", "activeBackground", - "Foreground", DEF_MENU_ACTIVE_BG_COLOR, + {TK_OPTION_BORDER, "-activebackground", "activeBackground", + "Foreground", DEF_MENU_ACTIVE_BG_COLOR, Tk_Offset(TkMenu, activeBorderPtr), -1, 0, (ClientData) DEF_MENU_ACTIVE_BG_MONO}, {TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth", "BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH, Tk_Offset(TkMenu, activeBorderWidthPtr), -1}, - {TK_OPTION_COLOR, "-activeforeground", "activeForeground", - "Background", DEF_MENU_ACTIVE_FG_COLOR, + {TK_OPTION_COLOR, "-activeforeground", "activeForeground", + "Background", DEF_MENU_ACTIVE_FG_COLOR, Tk_Offset(TkMenu, activeFgPtr), -1, 0, (ClientData) DEF_MENU_ACTIVE_FG_MONO}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_MENU_BG_COLOR, Tk_Offset(TkMenu, borderPtr), -1, 0, (ClientData) DEF_MENU_BG_MONO}, - {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth"}, - {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-background"}, + {TK_OPTION_SYNONYM, "-bd", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-borderwidth"}, + {TK_OPTION_SYNONYM, "-bg", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-background"}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_MENU_BORDER_WIDTH, Tk_Offset(TkMenu, borderWidthPtr), -1, 0}, @@ -277,14 +274,14 @@ Tk_OptionSpec tkMenuConfigSpecs[] = { "DisabledForeground", DEF_MENU_DISABLED_FG_COLOR, Tk_Offset(TkMenu, disabledFgPtr), -1, TK_OPTION_NULL_OK, (ClientData) DEF_MENU_DISABLED_FG_MONO}, - {TK_OPTION_SYNONYM, "-fg", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-foreground"}, + {TK_OPTION_SYNONYM, "-fg", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-foreground"}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_MENU_FONT, Tk_Offset(TkMenu, fontPtr), -1}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_MENU_FG, Tk_Offset(TkMenu, fgPtr), -1}, {TK_OPTION_STRING, "-postcommand", "postCommand", "Command", - DEF_MENU_POST_COMMAND, + DEF_MENU_POST_COMMAND, Tk_Offset(TkMenu, postCommandPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENU_RELIEF, Tk_Offset(TkMenu, reliefPtr), -1}, @@ -296,7 +293,7 @@ Tk_OptionSpec tkMenuConfigSpecs[] = { Tk_Offset(TkMenu, takeFocusPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_BOOLEAN, "-tearoff", "tearOff", "TearOff", DEF_MENU_TEAROFF, -1, Tk_Offset(TkMenu, tearoff)}, - {TK_OPTION_STRING, "-tearoffcommand", "tearOffCommand", + {TK_OPTION_STRING, "-tearoffcommand", "tearOffCommand", "TearOffCommand", DEF_MENU_TEAROFF_CMD, Tk_Offset(TkMenu, tearoffCommandPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_STRING, "-title", "title", "Title", @@ -309,14 +306,14 @@ Tk_OptionSpec tkMenuConfigSpecs[] = { }; /* - * Command line options. Put here because MenuCmd has to look at them - * along with MenuWidgetObjCmd. + * Command line options. Put here because MenuCmd has to look at them along + * with MenuWidgetObjCmd. */ static CONST char *menuOptions[] = { "activate", "add", "cget", "clone", "configure", "delete", "entrycget", "entryconfigure", "index", "insert", "invoke", "post", "postcascade", - "type", "unpost", "yposition", (char *) NULL + "type", "unpost", "yposition", NULL }; enum options { MENU_ACTIVATE, MENU_ADD, MENU_CGET, MENU_CLONE, MENU_CONFIGURE, @@ -326,56 +323,51 @@ enum options { }; /* - * Prototypes for static procedures in this file: + * Prototypes for static functions in this file: */ -static int CloneMenu _ANSI_ARGS_((TkMenu *menuPtr, - Tcl_Obj *newMenuName, Tcl_Obj *newMenuTypeString)); -static int ConfigureMenu _ANSI_ARGS_((Tcl_Interp *interp, - TkMenu *menuPtr, int objc, Tcl_Obj *CONST objv[])); -static int ConfigureMenuCloneEntries _ANSI_ARGS_(( - Tcl_Interp *interp, TkMenu *menuPtr, int index, - int objc, Tcl_Obj *CONST objv[])); -static int ConfigureMenuEntry _ANSI_ARGS_((TkMenuEntry *mePtr, - int objc, Tcl_Obj *CONST objv[])); -static void DeleteMenuCloneEntries _ANSI_ARGS_((TkMenu *menuPtr, - int first, int last)); -static void DestroyMenuHashTable _ANSI_ARGS_(( - ClientData clientData, Tcl_Interp *interp)); -static void DestroyMenuInstance _ANSI_ARGS_((TkMenu *menuPtr)); -static void DestroyMenuEntry _ANSI_ARGS_((char *memPtr)); -static int GetIndexFromCoords - _ANSI_ARGS_((Tcl_Interp *interp, TkMenu *menuPtr, - char *string, int *indexPtr)); -static int MenuDoYPosition _ANSI_ARGS_((Tcl_Interp *interp, - TkMenu *menuPtr, Tcl_Obj *objPtr)); -static int MenuAddOrInsert _ANSI_ARGS_((Tcl_Interp *interp, +static int CloneMenu(TkMenu *menuPtr, Tcl_Obj *newMenuName, + Tcl_Obj *newMenuTypeString); +static int ConfigureMenu(Tcl_Interp *interp, TkMenu *menuPtr, + int objc, Tcl_Obj *CONST objv[]); +static int ConfigureMenuCloneEntries(Tcl_Interp *interp, + TkMenu *menuPtr, int index, + int objc, Tcl_Obj *CONST objv[]); +static int ConfigureMenuEntry(TkMenuEntry *mePtr, + int objc, Tcl_Obj *CONST objv[]); +static void DeleteMenuCloneEntries(TkMenu *menuPtr, + int first, int last); +static void DestroyMenuHashTable(ClientData clientData, + Tcl_Interp *interp); +static void DestroyMenuInstance(TkMenu *menuPtr); +static void DestroyMenuEntry(char *memPtr); +static int GetIndexFromCoords(Tcl_Interp *interp, TkMenu *menuPtr, + char *string, int *indexPtr); +static int MenuDoYPosition(Tcl_Interp *interp, + TkMenu *menuPtr, Tcl_Obj *objPtr); +static int MenuAddOrInsert(Tcl_Interp *interp, TkMenu *menuPtr, Tcl_Obj *indexPtr, int objc, - Tcl_Obj *CONST objv[])); -static int MenuCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *CONST objv[])); -static void MenuCmdDeletedProc _ANSI_ARGS_(( - ClientData clientData)); -static TkMenuEntry * MenuNewEntry _ANSI_ARGS_((TkMenu *menuPtr, int index, - int type)); -static char * MenuVarProc _ANSI_ARGS_((ClientData clientData, + Tcl_Obj *CONST objv[]); +static int MenuCmd(ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +static void MenuCmdDeletedProc(ClientData clientData); +static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, int index, int type); +static char * MenuVarProc(ClientData clientData, Tcl_Interp *interp, CONST char *name1, - CONST char *name2, int flags)); -static int MenuWidgetObjCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *CONST objv[])); -static void MenuWorldChanged _ANSI_ARGS_(( - ClientData instanceData)); -static int PostProcessEntry _ANSI_ARGS_((TkMenuEntry *mePtr)); -static void RecursivelyDeleteMenu _ANSI_ARGS_((TkMenu *menuPtr)); -static void UnhookCascadeEntry _ANSI_ARGS_((TkMenuEntry *mePtr)); -static void TkMenuCleanup _ANSI_ARGS_((ClientData unused)); + CONST char *name2, int flags); +static int MenuWidgetObjCmd(ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[]); +static void MenuWorldChanged(ClientData instanceData); +static int PostProcessEntry(TkMenuEntry *mePtr); +static void RecursivelyDeleteMenu(TkMenu *menuPtr); +static void UnhookCascadeEntry(TkMenuEntry *mePtr); +static void TkMenuCleanup(ClientData unused); /* * The structure below is a list of procs that respond to certain window - * manager events. One of these includes a font change, which forces - * the geometry proc to be called. + * manager events. One of these includes a font change, which forces the + * geometry proc to be called. */ static Tk_ClassProcs menuClass = { @@ -388,8 +380,7 @@ static Tk_ClassProcs menuClass = { * * TkCreateMenuCmd -- * - * Called by Tk at initialization time to create the menu - * command. + * Called by Tk at initialization time to create the menu command. * * Results: * A standard Tcl result. @@ -401,14 +392,14 @@ static Tk_ClassProcs menuClass = { */ int -TkCreateMenuCmd(interp) - Tcl_Interp *interp; /* Interpreter we are creating the - * command in. */ +TkCreateMenuCmd( + Tcl_Interp *interp) /* Interpreter we are creating the command + * in. */ { - TkMenuOptionTables *optionTablesPtr = + TkMenuOptionTables *optionTablesPtr = (TkMenuOptionTables *) ckalloc(sizeof(TkMenuOptionTables)); - optionTablesPtr->menuOptionTable = + optionTablesPtr->menuOptionTable = Tk_CreateOptionTable(interp, tkMenuConfigSpecs); optionTablesPtr->entryOptionTables[TEAROFF_ENTRY] = Tk_CreateOptionTable(interp, specsArray[TEAROFF_ENTRY]); @@ -438,9 +429,8 @@ TkCreateMenuCmd(interp) * * MenuCmd -- * - * This procedure is invoked to process the "menu" Tcl - * command. See the user documentation for details on - * what it does. + * This function is invoked to process the "menu" Tcl command. See the + * user documentation for details on what it does. * * Results: * A standard Tcl result. @@ -452,12 +442,11 @@ TkCreateMenuCmd(interp) */ static int -MenuCmd(clientData, interp, objc, objv) - ClientData clientData; /* Main window associated with - * interpreter. */ - Tcl_Interp *interp; /* Current interpreter. */ - int objc; /* Number of arguments. */ - Tcl_Obj *CONST objv[]; /* Argument strings. */ +MenuCmd( + ClientData clientData, /* Main window associated with interpreter. */ + Tcl_Interp *interp, /* Current interpreter. */ + int objc, /* Number of arguments. */ + Tcl_Obj *CONST objv[]) /* Argument strings. */ { Tk_Window tkwin = Tk_MainWindow(interp); Tk_Window newWin; @@ -488,7 +477,7 @@ MenuCmd(clientData, interp, objc, objv) } } - windowName = Tcl_GetStringFromObj(objv[1], NULL); + windowName = Tcl_GetString(objv[1]); newWin = Tk_CreateWindowFromPath(interp, tkwin, windowName, toplevel ? "" : NULL); if (newWin == NULL) { @@ -496,9 +485,9 @@ MenuCmd(clientData, interp, objc, objv) } /* - * Initialize the data structure for the menu. Note that the - * menuPtr is eventually freed in 'TkMenuEventProc' in tkMenuDraw.c, - * when Tcl_EventuallyFree is called. + * Initialize the data structure for the menu. Note that the menuPtr is + * eventually freed in 'TkMenuEventProc' in tkMenuDraw.c, when + * Tcl_EventuallyFree is called. */ menuPtr = (TkMenu *) ckalloc(sizeof(TkMenu)); @@ -545,19 +534,19 @@ MenuCmd(clientData, interp, objc, objv) /* * If a menu has a parent menu pointing to it as a cascade entry, the - * parent menu needs to be told that this menu now exists so that - * the platform-part of the menu is correctly updated. + * parent menu needs to be told that this menu now exists so that the + * platform-part of the menu is correctly updated. * * If a menu has an instance and has cascade entries, then each cascade - * menu must also have a parallel instance. This is especially true on - * the Mac, where each menu has to have a separate title everytime it is in - * a menubar. For instance, say you have a menu .m1 with a cascade entry - * for .m2, where .m2 does not exist yet. You then put .m1 into a menubar. + * menu must also have a parallel instance. This is especially true on the + * Mac, where each menu has to have a separate title everytime it is in a + * menubar. For instance, say you have a menu .m1 with a cascade entry for + * .m2, where .m2 does not exist yet. You then put .m1 into a menubar. * This creates a menubar instance for .m1, but since .m2 is not there, * nothing else happens. When we go to create .m2, we hook it up properly * with .m1. However, we now need to clone .m2 and assign the clone of .m2 - * to be the cascade entry for the clone of .m1. This is special case - * #1 listed in the introductory comment. + * to be the cascade entry for the clone of .m1. This is special case #1 + * listed in the introductory comment. */ if (menuRefPtr->parentEntryPtr != NULL) { @@ -567,16 +556,15 @@ MenuCmd(clientData, interp, objc, objv) Tcl_Obj *newObjv[2]; while (cascadeListPtr != NULL) { - nextCascadePtr = cascadeListPtr->nextCascadePtr; /* - * If we have a new master menu, and an existing cloned menu - * points to this menu in a cascade entry, we have to clone - * the new menu and point the entry to the clone instead - * of the menu we are creating. Otherwise, ConfigureMenuEntry - * will hook up the platform-specific cascade linkages now - * that the menu we are creating exists. + * If we have a new master menu, and an existing cloned menu + * points to this menu in a cascade entry, we have to clone the + * new menu and point the entry to the clone instead of the menu + * we are creating. Otherwise, ConfigureMenuEntry will hook up the + * platform-specific cascade linkages now that the menu we are + * creating exists. */ if ((menuPtr->masterMenuPtr != menuPtr) @@ -603,8 +591,8 @@ MenuCmd(clientData, interp, objc, objv) CloneMenu(menuPtr, newMenuName, normalPtr); /* - * Now we can set the new menu instance to be the cascade entry - * of the parent's instance. + * Now we can set the new menu instance to be the cascade + * entry of the parent's instance. */ newObjv[0] = Tcl_NewStringObj("-menu", -1); @@ -621,9 +609,9 @@ MenuCmd(clientData, interp, objc, objv) } /* - * If there already exist toplevel widgets that refer to this menu, - * find them and notify them so that they can reconfigure their - * geometry to reflect the menu. + * If there already exist toplevel widgets that refer to this menu, find + * them and notify them so that they can reconfigure their geometry to + * reflect the menu. */ if (menuRefPtr->topLevelListPtr != NULL) { @@ -633,14 +621,14 @@ MenuCmd(clientData, interp, objc, objv) while (topLevelListPtr != NULL) { /* - * Need to get the next pointer first. TkSetWindowMenuBar - * changes the list, so that the next pointer is different - * after calling it. + * Need to get the next pointer first. TkSetWindowMenuBar changes + * the list, so that the next pointer is different after calling + * it. */ nextPtr = topLevelListPtr->nextPtr; listtkwin = topLevelListPtr->tkwin; - TkSetWindowMenuBar(menuPtr->interp, listtkwin, + TkSetWindowMenuBar(menuPtr->interp, listtkwin, Tk_PathName(menuPtr->tkwin), Tk_PathName(menuPtr->tkwin)); topLevelListPtr = nextPtr; } @@ -655,9 +643,9 @@ MenuCmd(clientData, interp, objc, objv) * * MenuWidgetObjCmd -- * - * This procedure is invoked to process the Tcl command - * that corresponds to a widget managed by this module. - * See the user documentation for details on what it does. + * This function is invoked to process the Tcl command that corresponds + * to a widget managed by this module. See the user documentation for + * details on what it does. * * Results: * A standard Tcl result. @@ -669,11 +657,11 @@ MenuCmd(clientData, interp, objc, objv) */ static int -MenuWidgetObjCmd(clientData, interp, objc, objv) - ClientData clientData; /* Information about menu widget. */ - Tcl_Interp *interp; /* Current interpreter. */ - int objc; /* Number of arguments. */ - Tcl_Obj *CONST objv[]; /* Argument strings. */ +MenuWidgetObjCmd( + ClientData clientData, /* Information about menu widget. */ + Tcl_Interp *interp, /* Current interpreter. */ + int objc, /* Number of arguments. */ + Tcl_Obj *CONST objv[]) /* Argument strings. */ { register TkMenu *menuPtr = (TkMenu *) clientData; register TkMenuEntry *mePtr; @@ -691,335 +679,314 @@ MenuWidgetObjCmd(clientData, interp, objc, objv) Tcl_Preserve((ClientData) menuPtr); switch ((enum options) option) { - case MENU_ACTIVATE: { - int index; + case MENU_ACTIVATE: { + int index; - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "activate index"); - goto error; - } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) - != TCL_OK) { - goto error; - } - if (menuPtr->active == index) { - goto done; - } - if ((index >= 0) - && ((menuPtr->entries[index]->type == SEPARATOR_ENTRY) - || (menuPtr->entries[index]->state - == ENTRY_DISABLED))) { - index = -1; - } - result = TkActivateMenuEntry(menuPtr, index); - break; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "activate index"); + goto error; + } + if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if (menuPtr->active == index) { + goto done; + } + if ((index >= 0) && ((menuPtr->entries[index]->type==SEPARATOR_ENTRY) + || (menuPtr->entries[index]->state == ENTRY_DISABLED))) { + index = -1; + } + result = TkActivateMenuEntry(menuPtr, index); + break; + } + case MENU_ADD: + if (objc < 3) { + Tcl_WrongNumArgs(interp, 1, objv, "add type ?options?"); + goto error; } - case MENU_ADD: - if (objc < 3) { - Tcl_WrongNumArgs(interp, 1, objv, "add type ?options?"); - goto error; - } - if (MenuAddOrInsert(interp, menuPtr, (Tcl_Obj *) NULL, - objc - 2, objv + 2) != TCL_OK) { - goto error; - } - break; - case MENU_CGET: { - Tcl_Obj *resultPtr; + if (MenuAddOrInsert(interp, menuPtr, NULL, objc-2, objv+2) != TCL_OK) { + goto error; + } + break; + case MENU_CGET: { + Tcl_Obj *resultPtr; - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "cget option"); - goto error; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "cget option"); + goto error; + } + resultPtr = Tk_GetOptionValue(interp, (char *) menuPtr, + menuPtr->optionTablesPtr->menuOptionTable, objv[2], + menuPtr->tkwin); + if (resultPtr == NULL) { + goto error; + } + Tcl_SetObjResult(interp, resultPtr); + break; + } + case MENU_CLONE: + if ((objc < 3) || (objc > 4)) { + Tcl_WrongNumArgs(interp, 1, objv, "clone newMenuName ?menuType?"); + goto error; + } + result = CloneMenu(menuPtr, objv[2], (objc == 3) ? NULL : objv[3]); + break; + case MENU_CONFIGURE: { + Tcl_Obj *resultPtr; + + if (objc == 2) { + resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr, + menuPtr->optionTablesPtr->menuOptionTable, NULL, + menuPtr->tkwin); + if (resultPtr == NULL) { + result = TCL_ERROR; + } else { + result = TCL_OK; + Tcl_SetObjResult(interp, resultPtr); } - resultPtr = Tk_GetOptionValue(interp, (char *) menuPtr, + } else if (objc == 3) { + resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr, menuPtr->optionTablesPtr->menuOptionTable, objv[2], menuPtr->tkwin); if (resultPtr == NULL) { - goto error; - } - Tcl_SetObjResult(interp, resultPtr); - break; - } - case MENU_CLONE: - if ((objc < 3) || (objc > 4)) { - Tcl_WrongNumArgs(interp, 1, objv, - "clone newMenuName ?menuType?"); - goto error; - } - result = CloneMenu(menuPtr, objv[2], (objc == 3) ? NULL : objv[3]); - break; - case MENU_CONFIGURE: { - Tcl_Obj *resultPtr; - - if (objc == 2) { - resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr, - menuPtr->optionTablesPtr->menuOptionTable, - (Tcl_Obj *) NULL, menuPtr->tkwin); - if (resultPtr == NULL) { - result = TCL_ERROR; - } else { - result = TCL_OK; - Tcl_SetObjResult(interp, resultPtr); - } - } else if (objc == 3) { - resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr, - menuPtr->optionTablesPtr->menuOptionTable, - objv[2], menuPtr->tkwin); - if (resultPtr == NULL) { - result = TCL_ERROR; - } else { - result = TCL_OK; - Tcl_SetObjResult(interp, resultPtr); - } + result = TCL_ERROR; } else { - result = ConfigureMenu(interp, menuPtr, objc - 2, objv + 2); + result = TCL_OK; + Tcl_SetObjResult(interp, resultPtr); } - if (result != TCL_OK) { - goto error; - } - break; + } else { + result = ConfigureMenu(interp, menuPtr, objc - 2, objv + 2); + } + if (result != TCL_OK) { + goto error; } - case MENU_DELETE: { - int first, last; + break; + } + case MENU_DELETE: { + int first, last; - if ((objc != 3) && (objc != 4)) { - Tcl_WrongNumArgs(interp, 1, objv, "delete first ?last?"); - goto error; - } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &first) - != TCL_OK) { - goto error; - } - if (objc == 3) { - last = first; - } else { - if (TkGetMenuIndex(interp, menuPtr, objv[3], 0, &last) - != TCL_OK) { - goto error; - } - } - if (menuPtr->tearoff && (first == 0)) { + if ((objc != 3) && (objc != 4)) { + Tcl_WrongNumArgs(interp, 1, objv, "delete first ?last?"); + goto error; + } + if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &first) != TCL_OK) { + goto error; + } + if (objc == 3) { + last = first; + } else if (TkGetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) { + goto error; + } - /* - * Sorry, can't delete the tearoff entry; must reconfigure - * the menu. - */ + if (menuPtr->tearoff && (first == 0)) { + /* + * Sorry, can't delete the tearoff entry; must reconfigure the + * menu. + */ - first = 1; - } - if ((first < 0) || (last < first)) { - goto done; - } - DeleteMenuCloneEntries(menuPtr, first, last); - break; + first = 1; + } + if ((first < 0) || (last < first)) { + goto done; } - case MENU_ENTRYCGET: { - int index; - Tcl_Obj *resultPtr; + DeleteMenuCloneEntries(menuPtr, first, last); + break; + } + case MENU_ENTRYCGET: { + int index; + Tcl_Obj *resultPtr; - if (objc != 4) { - Tcl_WrongNumArgs(interp, 1, objv, "entrycget index option"); - goto error; - } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) - != TCL_OK) { - goto error; - } - if (index < 0) { - goto done; - } - mePtr = menuPtr->entries[index]; - Tcl_Preserve((ClientData) mePtr); - resultPtr = Tk_GetOptionValue(interp, (char *) mePtr, - mePtr->optionTable, objv[3], menuPtr->tkwin); - Tcl_Release((ClientData) mePtr); - if (resultPtr == NULL) { - goto error; - } - Tcl_SetObjResult(interp, resultPtr); - break; + if (objc != 4) { + Tcl_WrongNumArgs(interp, 1, objv, "entrycget index option"); + goto error; + } + if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if (index < 0) { + goto done; + } + mePtr = menuPtr->entries[index]; + Tcl_Preserve((ClientData) mePtr); + resultPtr = Tk_GetOptionValue(interp, (char *) mePtr, + mePtr->optionTable, objv[3], menuPtr->tkwin); + Tcl_Release((ClientData) mePtr); + if (resultPtr == NULL) { + goto error; } - case MENU_ENTRYCONFIGURE: { - int index; - Tcl_Obj *resultPtr; + Tcl_SetObjResult(interp, resultPtr); + break; + } + case MENU_ENTRYCONFIGURE: { + int index; + Tcl_Obj *resultPtr; - if (objc < 3) { - Tcl_WrongNumArgs(interp, 1, objv, - "entryconfigure index ?option value ...?"); - goto error; - } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) - != TCL_OK) { - goto error; - } - if (index < 0) { - goto done; + if (objc < 3) { + Tcl_WrongNumArgs(interp, 1, objv, + "entryconfigure index ?option value ...?"); + goto error; + } + if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if (index < 0) { + goto done; + } + mePtr = menuPtr->entries[index]; + Tcl_Preserve((ClientData) mePtr); + if (objc == 3) { + resultPtr = Tk_GetOptionInfo(interp, (char *) mePtr, + mePtr->optionTable, NULL, menuPtr->tkwin); + if (resultPtr == NULL) { + result = TCL_ERROR; + } else { + result = TCL_OK; + Tcl_SetObjResult(interp, resultPtr); } - mePtr = menuPtr->entries[index]; - Tcl_Preserve((ClientData) mePtr); - if (objc == 3) { - resultPtr = Tk_GetOptionInfo(interp, (char *) mePtr, - mePtr->optionTable, (Tcl_Obj *) NULL, menuPtr->tkwin); - if (resultPtr == NULL) { - result = TCL_ERROR; - } else { - result = TCL_OK; - Tcl_SetObjResult(interp, resultPtr); - } - } else if (objc == 4) { - resultPtr = Tk_GetOptionInfo(interp, (char *) mePtr, - mePtr->optionTable, objv[3], menuPtr->tkwin); - if (resultPtr == NULL) { - result = TCL_ERROR; - } else { - result = TCL_OK; - Tcl_SetObjResult(interp, resultPtr); - } + } else if (objc == 4) { + resultPtr = Tk_GetOptionInfo(interp, (char *) mePtr, + mePtr->optionTable, objv[3], menuPtr->tkwin); + if (resultPtr == NULL) { + result = TCL_ERROR; } else { - result = ConfigureMenuCloneEntries(interp, menuPtr, index, - objc - 3, objv + 3); + result = TCL_OK; + Tcl_SetObjResult(interp, resultPtr); } - Tcl_Release((ClientData) mePtr); - break; + } else { + result = ConfigureMenuCloneEntries(interp, menuPtr, index, + objc-3, objv+3); } - case MENU_INDEX: { - int index; + Tcl_Release((ClientData) mePtr); + break; + } + case MENU_INDEX: { + int index; - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "index string"); - goto error; - } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) - != TCL_OK) { - goto error; - } - if (index < 0) { - Tcl_SetResult(interp, "none", TCL_STATIC); - } else { - Tcl_SetIntObj(Tcl_GetObjResult(interp), index); - } - break; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "index string"); + goto error; } - case MENU_INSERT: - if (objc < 4) { - Tcl_WrongNumArgs(interp, 1, objv, - "insert index type ?options?"); - goto error; - } - if (MenuAddOrInsert(interp, menuPtr, objv[2], objc - 3, - objv + 3) != TCL_OK) { - goto error; - } - break; - case MENU_INVOKE: { - int index; + if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if (index < 0) { + Tcl_SetResult(interp, "none", TCL_STATIC); + } else { + Tcl_SetIntObj(Tcl_GetObjResult(interp), index); + } + break; + } + case MENU_INSERT: + if (objc < 4) { + Tcl_WrongNumArgs(interp, 1, objv, "insert index type ?options?"); + goto error; + } + if (MenuAddOrInsert(interp,menuPtr,objv[2],objc-3,objv+3) != TCL_OK) { + goto error; + } + break; + case MENU_INVOKE: { + int index; - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "invoke index"); - goto error; - } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) - != TCL_OK) { - goto error; - } - if (index < 0) { - goto done; - } - result = TkInvokeMenu(interp, menuPtr, index); - break; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "invoke index"); + goto error; } - case MENU_POST: { - int x, y; + if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if (index < 0) { + goto done; + } + result = TkInvokeMenu(interp, menuPtr, index); + break; + } + case MENU_POST: { + int x, y; - if (objc != 4) { - Tcl_WrongNumArgs(interp, 1, objv, "post x y"); - goto error; - } - if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) - || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { - goto error; - } + if (objc != 4) { + Tcl_WrongNumArgs(interp, 1, objv, "post x y"); + goto error; + } + if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { + goto error; + } - /* - * Tearoff menus are posted differently on Mac and Windows than - * non-tearoffs. TkpPostMenu does not actually map the menu's - * window on those platforms, and popup menus have to be - * handled specially. - */ + /* + * Tearoff menus are posted differently on Mac and Windows than + * non-tearoffs. TkpPostMenu does not actually map the menu's window + * on those platforms, and popup menus have to be handled specially. + */ - if (menuPtr->menuType != TEAROFF_MENU) { - result = TkpPostMenu(interp, menuPtr, x, y); - } else { - result = TkPostTearoffMenu(interp, menuPtr, x, y); - } - break; + if (menuPtr->menuType != TEAROFF_MENU) { + result = TkpPostMenu(interp, menuPtr, x, y); + } else { + result = TkPostTearoffMenu(interp, menuPtr, x, y); } - case MENU_POSTCASCADE: { - int index; + break; + } + case MENU_POSTCASCADE: { + int index; - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "postcascade index"); - goto error; - } + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "postcascade index"); + goto error; + } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) - != TCL_OK) { - goto error; - } - if ((index < 0) || (menuPtr->entries[index]->type - != CASCADE_ENTRY)) { - result = TkPostSubmenu(interp, menuPtr, (TkMenuEntry *) NULL); - } else { - result = TkPostSubmenu(interp, menuPtr, - menuPtr->entries[index]); - } - break; + if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if ((index < 0) || (menuPtr->entries[index]->type != CASCADE_ENTRY)) { + result = TkPostSubmenu(interp, menuPtr, NULL); + } else { + result = TkPostSubmenu(interp, menuPtr, menuPtr->entries[index]); } - case MENU_TYPE: { - int index; + break; + } + case MENU_TYPE: { + int index; - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "type index"); - goto error; - } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) - != TCL_OK) { - goto error; - } - if (index < 0) { - goto done; - } - if (menuPtr->entries[index]->type == TEAROFF_ENTRY) { - Tcl_SetResult(interp, "tearoff", TCL_STATIC); - } else { - Tcl_SetStringObj(Tcl_GetObjResult(interp), - menuEntryTypeStrings[menuPtr->entries[index]->type], - -1); - } - break; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "type index"); + goto error; } - case MENU_UNPOST: - if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "unpost"); - goto error; - } - Tk_UnmapWindow(menuPtr->tkwin); - result = TkPostSubmenu(interp, menuPtr, (TkMenuEntry *) NULL); - break; - case MENU_YPOSITION: - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "yposition index"); - goto error; - } - result = MenuDoYPosition(interp, menuPtr, objv[2]); - break; + if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if (index < 0) { + goto done; + } + if (menuPtr->entries[index]->type == TEAROFF_ENTRY) { + Tcl_SetResult(interp, "tearoff", TCL_STATIC); + } else { + Tcl_SetStringObj(Tcl_GetObjResult(interp), + menuEntryTypeStrings[menuPtr->entries[index]->type], -1); + } + break; + } + case MENU_UNPOST: + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "unpost"); + goto error; + } + Tk_UnmapWindow(menuPtr->tkwin); + result = TkPostSubmenu(interp, menuPtr, NULL); + break; + case MENU_YPOSITION: + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "yposition index"); + goto error; + } + result = MenuDoYPosition(interp, menuPtr, objv[2]); + break; } - done: + done: Tcl_Release((ClientData) menuPtr); return result; - error: + error: Tcl_Release((ClientData) menuPtr); return TCL_ERROR; } @@ -1029,29 +996,29 @@ MenuWidgetObjCmd(clientData, interp, objc, objv) * * TkInvokeMenu -- * - * Given a menu and an index, takes the appropriate action for the - * entry associated with that index. + * Given a menu and an index, takes the appropriate action for the entry + * associated with that index. * * Results: * Standard Tcl result. * * Side effects: - * Commands may get excecuted; variables may get set; sub-menus may - * get posted. + * Commands may get excecuted; variables may get set; sub-menus may get + * posted. * *---------------------------------------------------------------------- */ int -TkInvokeMenu(interp, menuPtr, index) - Tcl_Interp *interp; /* The interp that the menu lives in. */ - TkMenu *menuPtr; /* The menu we are invoking. */ - int index; /* The zero based index of the item we - * are invoking */ +TkInvokeMenu( + Tcl_Interp *interp, /* The interp that the menu lives in. */ + TkMenu *menuPtr, /* The menu we are invoking. */ + int index) /* The zero based index of the item we are + * invoking */ { int result = TCL_OK; TkMenuEntry *mePtr; - + if (index < 0) { goto done; } @@ -1099,11 +1066,13 @@ TkInvokeMenu(interp, menuPtr, index) } Tcl_DecrRefCount(valuePtr); } + /* - * We check numEntries in addition to whether the menu entry - * has a command because that goes to zero if the menu gets - * deleted (e.g., during command evaluation). + * We check numEntries in addition to whether the menu entry has a command + * because that goes to zero if the menu gets deleted (e.g., during + * command evaluation). */ + if ((menuPtr->numEntries != 0) && (result == TCL_OK) && (mePtr->commandPtr != NULL)) { Tcl_Obj *commandPtr = mePtr->commandPtr; @@ -1113,7 +1082,7 @@ TkInvokeMenu(interp, menuPtr, index) Tcl_DecrRefCount(commandPtr); } Tcl_Release((ClientData) mePtr); - done: + done: return result; } @@ -1122,10 +1091,9 @@ TkInvokeMenu(interp, menuPtr, index) * * DestroyMenuInstance -- * - * This procedure is invoked by TkDestroyMenu - * to clean up the internal structure of a menu at a safe time - * (when no-one is using it anymore). Only takes care of one instance - * of the menu. + * This function is invoked by TkDestroyMenu to clean up the internal + * structure of a menu at a safe time (when no-one is using it anymore). + * Only takes care of one instance of the menu. * * Results: * None. @@ -1137,8 +1105,8 @@ TkInvokeMenu(interp, menuPtr, index) */ static void -DestroyMenuInstance(menuPtr) - TkMenu *menuPtr; /* Info about menu widget. */ +DestroyMenuInstance( + TkMenu *menuPtr) /* Info about menu widget. */ { int i; TkMenu *menuInstancePtr; @@ -1146,19 +1114,19 @@ DestroyMenuInstance(menuPtr) Tcl_Obj *newObjv[2]; TkMenu *parentMasterMenuPtr; TkMenuEntry *parentMasterEntryPtr; - + /* * If the menu has any cascade menu entries pointing to it, the cascade * entries need to be told that the menu is going away. We need to clear - * the menu ptr field in the menu reference at this point in the code - * so that everything else can forget about this menu properly. We also - * need to reset -menu field of all entries that are not master menus - * back to this entry name if this is a master menu pointed to by another - * master menu. If there is a clone menu that points to this menu, - * then this menu is itself a clone, so when this menu goes away, - * the -menu field of the pointing entry must be set back to this - * menu's master menu name so that later if another menu is created - * the cascade hierarchy can be maintained. + * the menu ptr field in the menu reference at this point in the code so + * that everything else can forget about this menu properly. We also need + * to reset -menu field of all entries that are not master menus back to + * this entry name if this is a master menu pointed to by another master + * menu. If there is a clone menu that points to this menu, then this menu + * is itself a clone, so when this menu goes away, the -menu field of the + * pointing entry must be set back to this menu's master menu name so that + * later if another menu is created the cascade hierarchy can be + * maintained. */ TkpDestroyMenu(menuPtr); @@ -1182,10 +1150,12 @@ DestroyMenuInstance(menuPtr) parentMasterMenuPtr->entries[cascadePtr->index]; newObjv[0] = menuNamePtr; newObjv[1] = parentMasterEntryPtr->namePtr; + /* - * It is possible that the menu info is out of sync, and - * these things point to NULL, so verify existence [Bug: 3402] + * It is possible that the menu info is out of sync, and these + * things point to NULL, so verify existence [Bug: 3402] */ + if (newObjv[0] && newObjv[1]) { Tcl_IncrRefCount(newObjv[0]); Tcl_IncrRefCount(newObjv[1]); @@ -1194,16 +1164,16 @@ DestroyMenuInstance(menuPtr) Tcl_DecrRefCount(newObjv[1]); } } else { - ConfigureMenuEntry(cascadePtr, 0, (Tcl_Obj **) NULL); + ConfigureMenuEntry(cascadePtr, 0, NULL); } } if (menuPtr->masterMenuPtr != menuPtr) { - for (menuInstancePtr = menuPtr->masterMenuPtr; + for (menuInstancePtr = menuPtr->masterMenuPtr; menuInstancePtr != NULL; menuInstancePtr = menuInstancePtr->nextInstancePtr) { if (menuInstancePtr->nextInstancePtr == menuPtr) { - menuInstancePtr->nextInstancePtr = + menuInstancePtr->nextInstancePtr = menuInstancePtr->nextInstancePtr->nextInstancePtr; break; } @@ -1213,17 +1183,16 @@ DestroyMenuInstance(menuPtr) } /* - * Free up all the stuff that requires special handling, then - * let Tk_FreeConfigOptions handle all the standard option-related - * stuff. + * Free up all the stuff that requires special handling, then let + * Tk_FreeConfigOptions handle all the standard option-related stuff. */ for (i = menuPtr->numEntries; --i >= 0; ) { /* - * As each menu entry is deleted from the end of the array of - * entries, decrement menuPtr->numEntries. Otherwise, the act of - * deleting menu entry i will dereference freed memory attempting - * to queue a redraw for menu entries (i+1)...numEntries. + * As each menu entry is deleted from the end of the array of entries, + * decrement menuPtr->numEntries. Otherwise, the act of deleting menu + * entry i will dereference freed memory attempting to queue a redraw + * for menu entries (i+1)...numEntries. */ DestroyMenuEntry((char *) menuPtr->entries[i]); @@ -1233,7 +1202,7 @@ DestroyMenuInstance(menuPtr) ckfree((char *) menuPtr->entries); } TkMenuFreeDrawOptions(menuPtr); - Tk_FreeConfigOptions((char *) menuPtr, + Tk_FreeConfigOptions((char *) menuPtr, menuPtr->optionTablesPtr->menuOptionTable, menuPtr->tkwin); if (menuPtr->tkwin != NULL) { Tk_Window tkwin = menuPtr->tkwin; @@ -1247,11 +1216,11 @@ DestroyMenuInstance(menuPtr) * * TkDestroyMenu -- * - * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release - * to clean up the internal structure of a menu at a safe time - * (when no-one is using it anymore). If called on a master instance, - * destroys all of the slave instances. If called on a non-master - * instance, just destroys that instance. + * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean + * up the internal structure of a menu at a safe time (when no-one is + * using it anymore). If called on a master instance, destroys all of the + * slave instances. If called on a non-master instance, just destroys + * that instance. * * Results: * None. @@ -1263,8 +1232,8 @@ DestroyMenuInstance(menuPtr) */ void -TkDestroyMenu(menuPtr) - TkMenu *menuPtr; /* Info about menu widget. */ +TkDestroyMenu( + TkMenu *menuPtr) /* Info about menu widget. */ { TkMenu *menuInstancePtr; TkMenuTopLevelList *topLevelListPtr, *nextTopLevelPtr; @@ -1276,18 +1245,19 @@ TkDestroyMenu(menuPtr) Tcl_Preserve(menuPtr); /* - * Now destroy all non-tearoff instances of this menu if this is a - * parent menu. Is this loop safe enough? Are there going to be - * destroy bindings on child menus which kill the parent? If not, - * we have to do a slightly more complex scheme. + * Now destroy all non-tearoff instances of this menu if this is a parent + * menu. Is this loop safe enough? Are there going to be destroy bindings + * on child menus which kill the parent? If not, we have to do a slightly + * more complex scheme. */ menuPtr->menuFlags |= MENU_DELETION_PENDING; if (menuPtr->menuRefPtr != NULL) { /* - * If any toplevel widgets have this menu as their menubar, - * the geometry of the window may have to be recalculated. + * If any toplevel widgets have this menu as their menubar, the + * geometry of the window may have to be recalculated. */ + topLevelListPtr = menuPtr->menuRefPtr->topLevelListPtr; while (topLevelListPtr != NULL) { nextTopLevelPtr = topLevelListPtr->nextPtr; @@ -1301,11 +1271,13 @@ TkDestroyMenu(menuPtr) menuPtr->nextInstancePtr = menuInstancePtr->nextInstancePtr; if (menuInstancePtr->tkwin != NULL) { Tk_Window tkwin = menuInstancePtr->tkwin; - /* - * Note: it may be desirable to NULL out the tkwin - * field of menuInstancePtr here: + + /* + * Note: it may be desirable to NULL out the tkwin field of + * menuInstancePtr here: * menuInstancePtr->tkwin = NULL; */ + Tk_DestroyWindow(tkwin); } } @@ -1322,12 +1294,12 @@ TkDestroyMenu(menuPtr) * UnhookCascadeEntry -- * * This entry is removed from the list of entries that point to the - * cascade menu. This is done in preparation for changing the menu - * that this entry points to. + * cascade menu. This is done in preparation for changing the menu that + * this entry points to. * - * At the end of this function, the menu entry no longer contains - * a reference to a 'TkMenuReferences' structure, and therefore - * no such structure contains a reference to this menu entry either. + * At the end of this function, the menu entry no longer contains a + * reference to a 'TkMenuReferences' structure, and therefore no such + * structure contains a reference to this menu entry either. * * Results: * None @@ -1339,9 +1311,9 @@ TkDestroyMenu(menuPtr) */ static void -UnhookCascadeEntry(mePtr) - TkMenuEntry *mePtr; /* The cascade entry we are removing - * from the cascade list. */ +UnhookCascadeEntry( + TkMenuEntry *mePtr) /* The cascade entry we are removing from the + * cascade list. */ { TkMenuEntry *cascadeEntryPtr; TkMenuEntry *prevCascadePtr; @@ -1360,24 +1332,23 @@ UnhookCascadeEntry(mePtr) } /* - * Singularly linked list deletion. The two special cases are - * 1. one element; 2. The first element is the one we want. + * Singularly linked list deletion. The two special cases are 1. one + * element; 2. The first element is the one we want. */ if (cascadeEntryPtr == mePtr) { if (cascadeEntryPtr->nextCascadePtr == NULL) { - /* - * This is the last menu entry which points to this - * menu, so we need to clear out the list pointer in the - * cascade itself. + * This is the last menu entry which points to this menu, so we + * need to clear out the list pointer in the cascade itself. */ menuRefPtr->parentEntryPtr = NULL; - /* - * The original field is set to zero below, after it is - * freed. + + /* + * The original field is set to zero below, after it is freed. */ + TkFreeMenuReferences(menuRefPtr); } else { menuRefPtr->parentEntryPtr = cascadeEntryPtr->nextCascadePtr; @@ -1406,9 +1377,9 @@ UnhookCascadeEntry(mePtr) * * DestroyMenuEntry -- * - * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release - * to clean up the internal structure of a menu entry at a safe time - * (when no-one is using it anymore). + * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean + * up the internal structure of a menu entry at a safe time (when no-one + * is using it anymore). * * Results: * None. @@ -1420,48 +1391,49 @@ UnhookCascadeEntry(mePtr) */ static void -DestroyMenuEntry(memPtr) - char *memPtr; /* Pointer to entry to be freed. */ +DestroyMenuEntry( + char *memPtr) /* Pointer to entry to be freed. */ { register TkMenuEntry *mePtr = (TkMenuEntry *) memPtr; TkMenu *menuPtr = mePtr->menuPtr; if (menuPtr->postedCascade == mePtr) { /* - * Ignore errors while unposting the menu, since it's possible - * that the menu has already been deleted and the unpost will - * generate an error. + * Ignore errors while unposting the menu, since it's possible that + * the menu has already been deleted and the unpost will generate an + * error. */ - TkPostSubmenu(menuPtr->interp, menuPtr, (TkMenuEntry *) NULL); + TkPostSubmenu(menuPtr->interp, menuPtr, NULL); } /* - * Free up all the stuff that requires special handling, then - * let Tk_FreeConfigOptions handle all the standard option-related - * stuff. + * Free up all the stuff that requires special handling, then let + * Tk_FreeConfigOptions handle all the standard option-related stuff. */ if (mePtr->type == CASCADE_ENTRY) { if (menuPtr->masterMenuPtr != menuPtr) { TkMenu *destroyThis = NULL; - /* - * The menu as a whole is a clone. We must delete the clone - * of the cascaded menu for the particular entry we are - * destroying. + /* + * The menu as a whole is a clone. We must delete the clone of the + * cascaded menu for the particular entry we are destroying. */ + TkMenuReferences *menuRefPtr = mePtr->childMenuRefPtr; + if (menuRefPtr != NULL) { destroyThis = menuRefPtr->menuPtr; - /* - * But only if it is a clone. What can happen is that - * we are in the middle of deleting a menu and this - * menu pointer has already been reset to point to the - * original menu. In that case we have nothing special - * to do. + + /* + * But only if it is a clone. What can happen is that we are + * in the middle of deleting a menu and this menu pointer has + * already been reset to point to the original menu. In that + * case we have nothing special to do. */ - if ((destroyThis != NULL) - && (destroyThis->masterMenuPtr == destroyThis)) { + + if ((destroyThis != NULL) + && (destroyThis->masterMenuPtr == destroyThis)) { destroyThis = NULL; } } @@ -1484,10 +1456,11 @@ DestroyMenuEntry(memPtr) if (mePtr->selectImage != NULL) { Tk_FreeImage(mePtr->selectImage); } - if (((mePtr->type == CHECK_BUTTON_ENTRY) + if (((mePtr->type == CHECK_BUTTON_ENTRY) || (mePtr->type == RADIO_BUTTON_ENTRY)) && (mePtr->namePtr != NULL)) { - char *varName = Tcl_GetStringFromObj(mePtr->namePtr, NULL); + char *varName = Tcl_GetString(mePtr->namePtr); + Tcl_UntraceVar(menuPtr->interp, varName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuVarProc, (ClientData) mePtr); @@ -1503,9 +1476,9 @@ DestroyMenuEntry(memPtr) * * MenuWorldChanged -- * - * This procedure is called when the world has changed in some - * way (such as the fonts in the system changing) and the widget needs - * to recompute all its graphics contexts and determine its new geometry. + * This function is called when the world has changed in some way (such + * as the fonts in the system changing) and the widget needs to recompute + * all its graphics contexts and determine its new geometry. * * Results: * None. @@ -1517,8 +1490,8 @@ DestroyMenuEntry(memPtr) */ static void -MenuWorldChanged(instanceData) - ClientData instanceData; /* Information about widget. */ +MenuWorldChanged( + ClientData instanceData) /* Information about widget. */ { TkMenu *menuPtr = (TkMenu *) instanceData; int i; @@ -1537,28 +1510,27 @@ MenuWorldChanged(instanceData) * * ConfigureMenu -- * - * This procedure is called to process an argv/argc list, plus - * the Tk option database, in order to configure (or - * reconfigure) a menu widget. + * This function is called to process an argv/argc list, plus the Tk + * option database, in order to configure (or reconfigure) a menu widget. * * Results: - * The return value is a standard Tcl result. If TCL_ERROR is - * returned, then the interp's result contains an error message. + * The return value is a standard Tcl result. If TCL_ERROR is returned, + * then the interp's result contains an error message. * * Side effects: - * Configuration information, such as colors, font, etc. get set - * for menuPtr; old resources get freed, if there were any. + * Configuration information, such as colors, font, etc. get set for + * menuPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ static int -ConfigureMenu(interp, menuPtr, objc, objv) - Tcl_Interp *interp; /* Used for error reporting. */ - register TkMenu *menuPtr; /* Information about widget; may or may +ConfigureMenu( + Tcl_Interp *interp, /* Used for error reporting. */ + register TkMenu *menuPtr, /* Information about widget; may or may * not already have values for some fields. */ - int objc; /* Number of valid entries in argv. */ - Tcl_Obj *CONST objv[]; /* Arguments. */ + int objc, /* Number of valid entries in argv. */ + Tcl_Obj *CONST objv[]) /* Arguments. */ { int i; TkMenu *menuListPtr, *cleanupPtr; @@ -1569,8 +1541,8 @@ ConfigureMenu(interp, menuPtr, objc, objv) menuListPtr->errorStructPtr = (Tk_SavedOptions *) ckalloc(sizeof(Tk_SavedOptions)); result = Tk_SetOptions(interp, (char *) menuListPtr, - menuListPtr->optionTablesPtr->menuOptionTable, objc, objv, - menuListPtr->tkwin, menuListPtr->errorStructPtr, (int *) NULL); + menuListPtr->optionTablesPtr->menuOptionTable, objc, objv, + menuListPtr->tkwin, menuListPtr->errorStructPtr, NULL); if (result != TCL_OK) { for (cleanupPtr = menuPtr->masterMenuPtr; cleanupPtr != menuListPtr; @@ -1588,10 +1560,10 @@ ConfigureMenu(interp, menuPtr, objc, objv) } /* - * When a menu is created, the type is in all of the arguments - * to the menu command. Let Tk_ConfigureWidget take care of - * parsing them, and then set the type after we can look at - * the type string. Once set, a menu's type cannot be changed + * When a menu is created, the type is in all of the arguments to the + * menu command. Let Tk_ConfigureWidget take care of parsing them, and + * then set the type after we can look at the type string. Once set, a + * menu's type cannot be changed */ if (menuListPtr->menuType == UNKNOWN_TYPE) { @@ -1599,11 +1571,10 @@ ConfigureMenu(interp, menuPtr, objc, objv) menuTypeStrings, NULL, 0, &menuListPtr->menuType); /* - * Configure the new window to be either a pop-up menu - * or a tear-off menu. - * We don't do this for menubars since they are not toplevel - * windows. Also, since this gets called before CloneMenu has - * a chance to set the menuType field, we have to look at the + * Configure the new window to be either a pop-up menu or a + * tear-off menu. We don't do this for menubars since they are not + * toplevel windows. Also, since this gets called before CloneMenu + * has a chance to set the menuType field, we have to look at the * menuTypeName field to tell that this is a menu bar. */ @@ -1616,8 +1587,8 @@ ConfigureMenu(interp, menuPtr, objc, objv) /* - * Depending on the -tearOff option, make sure that there is or - * isn't an initial tear-off entry at the beginning of the menu. + * Depending on the -tearOff option, make sure that there is or isn't + * an initial tear-off entry at the beginning of the menu. */ if (menuListPtr->tearoff) { @@ -1661,16 +1632,16 @@ ConfigureMenu(interp, menuPtr, objc, objv) /* * After reconfiguring a menu, we need to reconfigure all of the - * entries in the menu, since some of the things in the children - * (such as graphics contexts) may have to change to reflect changes - * in the parent. + * entries in the menu, since some of the things in the children (such + * as graphics contexts) may have to change to reflect changes in the + * parent. */ for (i = 0; i < menuListPtr->numEntries; i++) { TkMenuEntry *mePtr; mePtr = menuListPtr->entries[i]; - ConfigureMenuEntry(mePtr, 0, (Tcl_Obj **) NULL); + ConfigureMenuEntry(mePtr, 0, NULL); } TkEventuallyRecomputeMenu(menuListPtr); @@ -1692,23 +1663,23 @@ ConfigureMenu(interp, menuPtr, objc, objv) * PostProcessEntry -- * * This is called by ConfigureMenuEntry to do all of the configuration - * after Tk_SetOptions is called. This is separate - * so that error handling is easier. + * after Tk_SetOptions is called. This is separate so that error handling + * is easier. * * Results: - * The return value is a standard Tcl result. If TCL_ERROR is - * returned, then the interp's result contains an error message. + * The return value is a standard Tcl result. If TCL_ERROR is returned, + * then the interp's result contains an error message. * * Side effects: - * Configuration information such as label and accelerator get - * set for mePtr; old resources get freed, if there were any. + * Configuration information such as label and accelerator get set for + * mePtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ static int -PostProcessEntry(mePtr) - TkMenuEntry *mePtr; /* The entry we are configuring. */ +PostProcessEntry( + TkMenuEntry *mePtr) /* The entry we are configuring. */ { TkMenu *menuPtr = mePtr->menuPtr; int index = mePtr->index; @@ -1716,9 +1687,9 @@ PostProcessEntry(mePtr) Tk_Image image; /* - * The code below handles special configuration stuff not taken - * care of by Tk_ConfigureWidget, such as special processing for - * defaults, sizing strings, graphics contexts, etc. + * The code below handles special configuration stuff not taken care of by + * Tk_ConfigureWidget, such as special processing for defaults, sizing + * strings, graphics contexts, etc. */ if (mePtr->labelPtr == NULL) { @@ -1746,16 +1717,15 @@ PostProcessEntry(mePtr) * prevent compiler warning. */ /* - * This is a cascade entry. If the menu that the cascade entry - * is pointing to has changed, we need to remove this entry - * from the list of entries pointing to the old menu, and add a - * cascade reference to the list of entries pointing to the - * new menu. + * This is a cascade entry. If the menu that the cascade entry is + * pointing to has changed, we need to remove this entry from the list + * of entries pointing to the old menu, and add a cascade reference to + * the list of entries pointing to the new menu. * * BUG: We are not recloning for special case #3 yet. */ - name = Tcl_GetStringFromObj(mePtr->namePtr, NULL); + name = Tcl_GetString(mePtr->namePtr); if (mePtr->childMenuRefPtr != NULL) { oldHashKey = Tcl_GetHashKey(TkGetMenuHashTable(menuPtr->interp), mePtr->childMenuRefPtr->hashEntryPtr); @@ -1764,7 +1734,7 @@ PostProcessEntry(mePtr) } } - if ((mePtr->childMenuRefPtr == NULL) + if ((mePtr->childMenuRefPtr == NULL) || (strcmp(oldHashKey, name) != 0)) { menuRefPtr = TkCreateMenuReferences(menuPtr->interp, name); mePtr->childMenuRefPtr = menuRefPtr; @@ -1804,13 +1774,14 @@ PostProcessEntry(mePtr) } /* - * Get the images for the entry, if there are any. Allocate the - * new images before freeing the old ones, so that the reference - * counts don't go to zero and cause image data to be discarded. + * Get the images for the entry, if there are any. Allocate the new images + * before freeing the old ones, so that the reference counts don't go to + * zero and cause image data to be discarded. */ if (mePtr->imagePtr != NULL) { - char *imageString = Tcl_GetStringFromObj(mePtr->imagePtr, NULL); + char *imageString = Tcl_GetString(mePtr->imagePtr); + image = Tk_GetImage(menuPtr->interp, menuPtr->tkwin, imageString, TkMenuImageProc, (ClientData) mePtr); if (image == NULL) { @@ -1824,8 +1795,8 @@ PostProcessEntry(mePtr) } mePtr->image = image; if (mePtr->selectImagePtr != NULL) { - char *selectImageString = Tcl_GetStringFromObj( - mePtr->selectImagePtr, NULL); + char *selectImageString = Tcl_GetString(mePtr->selectImagePtr); + image = Tk_GetImage(menuPtr->interp, menuPtr->tkwin, selectImageString, TkMenuSelectImageProc, (ClientData) mePtr); if (image == NULL) { @@ -1862,10 +1833,9 @@ PostProcessEntry(mePtr) } /* - * Select the entry if the associated variable has the - * appropriate value, initialize the variable if it doesn't - * exist, then set a trace on the variable to monitor future - * changes to its value. + * Select the entry if the associated variable has the appropriate + * value, initialize the variable if it doesn't exist, then set a + * trace on the variable to monitor future changes to its value. */ if (mePtr->namePtr != NULL) { @@ -1877,10 +1847,8 @@ PostProcessEntry(mePtr) mePtr->entryFlags &= ~ENTRY_SELECTED; if (valuePtr != NULL) { if (mePtr->onValuePtr != NULL) { - char *value = Tcl_GetStringFromObj(valuePtr, NULL); - char *onValue = Tcl_GetStringFromObj(mePtr->onValuePtr, - NULL); - + char *value = Tcl_GetString(valuePtr); + char *onValue = Tcl_GetString(mePtr->onValuePtr); if (strcmp(value, onValue) == 0) { mePtr->entryFlags |= ENTRY_SELECTED; @@ -1890,13 +1858,11 @@ PostProcessEntry(mePtr) if (mePtr->namePtr != NULL) { Tcl_ObjSetVar2(menuPtr->interp, mePtr->namePtr, NULL, (mePtr->type == CHECK_BUTTON_ENTRY) - ? mePtr->offValuePtr - : Tcl_NewObj(), - TCL_GLOBAL_ONLY); + ? mePtr->offValuePtr : Tcl_NewObj(), TCL_GLOBAL_ONLY); } } if (mePtr->namePtr != NULL) { - name = Tcl_GetStringFromObj(mePtr->namePtr, NULL); + name = Tcl_GetString(mePtr->namePtr); Tcl_TraceVar(menuPtr->interp, name, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuVarProc, (ClientData) mePtr); @@ -1911,41 +1877,41 @@ PostProcessEntry(mePtr) * * ConfigureMenuEntry -- * - * This procedure is called to process an argv/argc list in order - * to configure (or reconfigure) one entry in a menu. + * This function is called to process an argv/argc list in order to + * configure (or reconfigure) one entry in a menu. * * Results: - * The return value is a standard Tcl result. If TCL_ERROR is - * returned, then the interp's result contains an error message. + * The return value is a standard Tcl result. If TCL_ERROR is returned, + * then the interp's result contains an error message. * * Side effects: - * Configuration information such as label and accelerator get - * set for mePtr; old resources get freed, if there were any. + * Configuration information such as label and accelerator get set for + * mePtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ static int -ConfigureMenuEntry(mePtr, objc, objv) - register TkMenuEntry *mePtr; /* Information about menu entry; may - * or may not already have values for - * some fields. */ - int objc; /* Number of valid entries in argv. */ - Tcl_Obj *CONST objv[]; /* Arguments. */ +ConfigureMenuEntry( + register TkMenuEntry *mePtr,/* Information about menu entry; may or may + * not already have values for some fields. */ + int objc, /* Number of valid entries in argv. */ + Tcl_Obj *CONST objv[]) /* Arguments. */ { TkMenu *menuPtr = mePtr->menuPtr; Tk_SavedOptions errorStruct; int result; /* - * If this entry is a check button or radio button, then remove - * its old trace procedure. + * If this entry is a check button or radio button, then remove its old + * trace function. */ if ((mePtr->namePtr != NULL) && ((mePtr->type == CHECK_BUTTON_ENTRY) || (mePtr->type == RADIO_BUTTON_ENTRY))) { - char *name = Tcl_GetStringFromObj(mePtr->namePtr, NULL); + char *name = Tcl_GetString(mePtr->namePtr); + Tcl_UntraceVar(menuPtr->interp, name, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuVarProc, (ClientData) mePtr); @@ -1955,7 +1921,7 @@ ConfigureMenuEntry(mePtr, objc, objv) if (menuPtr->tkwin != NULL) { if (Tk_SetOptions(menuPtr->interp, (char *) mePtr, mePtr->optionTable, objc, objv, menuPtr->tkwin, - &errorStruct, (int *) NULL) != TCL_OK) { + &errorStruct, NULL) != TCL_OK) { return TCL_ERROR; } result = PostProcessEntry(mePtr); @@ -1979,39 +1945,38 @@ ConfigureMenuEntry(mePtr, objc, objv) * Calls ConfigureMenuEntry for each menu in the clone chain. * * Results: - * The return value is a standard Tcl result. If TCL_ERROR is - * returned, then the interp's result contains an error message. + * The return value is a standard Tcl result. If TCL_ERROR is returned, + * then the interp's result contains an error message. * * Side effects: - * Configuration information such as label and accelerator get - * set for mePtr; old resources get freed, if there were any. + * Configuration information such as label and accelerator get set for + * mePtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ static int -ConfigureMenuCloneEntries(interp, menuPtr, index, objc, objv) - Tcl_Interp *interp; /* Used for error reporting. */ - TkMenu *menuPtr; /* Information about whole menu. */ - int index; /* Index of mePtr within menuPtr's - * entries. */ - int objc; /* Number of valid entries in argv. */ - Tcl_Obj *CONST objv[]; /* Arguments. */ +ConfigureMenuCloneEntries( + Tcl_Interp *interp, /* Used for error reporting. */ + TkMenu *menuPtr, /* Information about whole menu. */ + int index, /* Index of mePtr within menuPtr's entries. */ + int objc, /* Number of valid entries in argv. */ + Tcl_Obj *CONST objv[]) /* Arguments. */ { TkMenuEntry *mePtr; TkMenu *menuListPtr; int cascadeEntryChanged = 0; - TkMenuReferences *oldCascadeMenuRefPtr, *cascadeMenuRefPtr = NULL; + TkMenuReferences *oldCascadeMenuRefPtr, *cascadeMenuRefPtr = NULL; Tcl_Obj *oldCascadePtr = NULL; char *newCascadeName; /* - * Cascades are kind of tricky here. This is special case #3 in the comment - * at the top of this file. Basically, if a menu is the master menu of a - * clone chain, and has an entry with a cascade menu, the clones of - * the menu will point to clones of the cascade menu. We have - * to destroy the clones of the cascades, clone the new cascade - * menu, and configure the entry to point to the new clone. + * Cascades are kind of tricky here. This is special case #3 in the + * comment at the top of this file. Basically, if a menu is the master + * menu of a clone chain, and has an entry with a cascade menu, the clones + * of the menu will point to clones of the cascade menu. We have to + * destroy the clones of the cascades, clone the new cascade menu, and + * configure the entry to point to the new clone. */ mePtr = menuPtr->masterMenuPtr->entries[index]; @@ -2030,7 +1995,7 @@ ConfigureMenuCloneEntries(interp, menuPtr, index, objc, objv) char *oldCascadeName; if (mePtr->namePtr != NULL) { - newCascadeName = Tcl_GetStringFromObj(mePtr->namePtr, NULL); + newCascadeName = Tcl_GetString(mePtr->namePtr); } else { newCascadeName = NULL; } @@ -2038,13 +2003,12 @@ ConfigureMenuCloneEntries(interp, menuPtr, index, objc, objv) if ((oldCascadePtr == NULL) && (mePtr->namePtr == NULL)) { cascadeEntryChanged = 0; } else if (((oldCascadePtr == NULL) && (mePtr->namePtr != NULL)) - || ((oldCascadePtr != NULL) + || ((oldCascadePtr != NULL) && (mePtr->namePtr == NULL))) { cascadeEntryChanged = 1; } else { - oldCascadeName = Tcl_GetStringFromObj(oldCascadePtr, - NULL); - cascadeEntryChanged = (strcmp(oldCascadeName, newCascadeName) + oldCascadeName = Tcl_GetString(oldCascadePtr); + cascadeEntryChanged = (strcmp(oldCascadeName, newCascadeName) != 0); } if (oldCascadePtr != NULL) { @@ -2054,20 +2018,20 @@ ConfigureMenuCloneEntries(interp, menuPtr, index, objc, objv) if (cascadeEntryChanged) { if (mePtr->namePtr != NULL) { - newCascadeName = Tcl_GetStringFromObj(mePtr->namePtr, NULL); + newCascadeName = Tcl_GetString(mePtr->namePtr); cascadeMenuRefPtr = TkFindMenuReferences(menuPtr->interp, newCascadeName); } } - for (menuListPtr = menuPtr->masterMenuPtr->nextInstancePtr; + for (menuListPtr = menuPtr->masterMenuPtr->nextInstancePtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { mePtr = menuListPtr->entries[index]; if (cascadeEntryChanged && (mePtr->namePtr != NULL)) { - oldCascadeMenuRefPtr = TkFindMenuReferencesObj(menuPtr->interp, + oldCascadeMenuRefPtr = TkFindMenuReferencesObj(menuPtr->interp, mePtr->namePtr); if ((oldCascadeMenuRefPtr != NULL) @@ -2091,7 +2055,7 @@ ConfigureMenuCloneEntries(interp, menuPtr, index, objc, objv) Tcl_IncrRefCount(pathNamePtr); newCloneNamePtr = TkNewMenuName(menuPtr->interp, - pathNamePtr, + pathNamePtr, cascadeMenuRefPtr->menuPtr); Tcl_IncrRefCount(newCloneNamePtr); Tcl_IncrRefCount(normalPtr); @@ -2117,14 +2081,14 @@ ConfigureMenuCloneEntries(interp, menuPtr, index, objc, objv) * * TkGetMenuIndex -- * - * Parse a textual index into a menu and return the numerical - * index of the indicated entry. + * Parse a textual index into a menu and return the numerical index of + * the indicated entry. * * Results: - * A standard Tcl result. If all went well, then *indexPtr is - * filled in with the entry index corresponding to string - * (ranges from -1 to the number of entries in the menu minus - * one). Otherwise an error message is left in the interp's result. + * A standard Tcl result. If all went well, then *indexPtr is filled in + * with the entry index corresponding to string (ranges from -1 to the + * number of entries in the menu minus one). Otherwise an error message + * is left in the interp's result. * * Side effects: * None. @@ -2133,18 +2097,18 @@ ConfigureMenuCloneEntries(interp, menuPtr, index, objc, objv) */ int -TkGetMenuIndex(interp, menuPtr, objPtr, lastOK, indexPtr) - Tcl_Interp *interp; /* For error messages. */ - TkMenu *menuPtr; /* Menu for which the index is being +TkGetMenuIndex( + Tcl_Interp *interp, /* For error messages. */ + TkMenu *menuPtr, /* Menu for which the index is being * specified. */ - Tcl_Obj *objPtr; /* Specification of an entry in menu. See + Tcl_Obj *objPtr, /* Specification of an entry in menu. See * manual entry for valid .*/ - int lastOK; /* Non-zero means its OK to return index - * just *after* last entry. */ - int *indexPtr; /* Where to store converted index. */ + int lastOK, /* Non-zero means its OK to return index just + * *after* last entry. */ + int *indexPtr) /* Where to store converted index. */ { int i; - char *string = Tcl_GetStringFromObj(objPtr, NULL); + char *string = Tcl_GetString(objPtr); if ((string[0] == 'a') && (strcmp(string, "active") == 0)) { *indexPtr = menuPtr->active; @@ -2183,26 +2147,23 @@ TkGetMenuIndex(interp, menuPtr, objPtr, lastOK, indexPtr) *indexPtr = i; goto success; } - Tcl_SetResult(interp, (char *) NULL, TCL_STATIC); + Tcl_SetResult(interp, NULL, TCL_STATIC); } for (i = 0; i < menuPtr->numEntries; i++) { Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr; - char *label = (labelPtr == NULL) ? NULL - : Tcl_GetStringFromObj(labelPtr, NULL); + char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr); - if ((label != NULL) - && (Tcl_StringMatch(label, string))) { + if ((label != NULL) && (Tcl_StringMatch(label, string))) { *indexPtr = i; goto success; } } - Tcl_AppendResult(interp, "bad menu entry index \"", - string, "\"", (char *) NULL); + Tcl_AppendResult(interp, "bad menu entry index \"", string, "\"", NULL); return TCL_ERROR; -success: + success: return TCL_OK; } @@ -2211,9 +2172,9 @@ success: * * MenuCmdDeletedProc -- * - * This procedure is invoked when a widget command is deleted. If - * the widget isn't already in the process of being destroyed, - * this command destroys it. + * This function is invoked when a widget command is deleted. If the + * widget isn't already in the process of being destroyed, this command + * destroys it. * * Results: * None. @@ -2225,25 +2186,26 @@ success: */ static void -MenuCmdDeletedProc(clientData) - ClientData clientData; /* Pointer to widget record for widget. */ +MenuCmdDeletedProc( + ClientData clientData) /* Pointer to widget record for widget. */ { TkMenu *menuPtr = (TkMenu *) clientData; Tk_Window tkwin = menuPtr->tkwin; /* - * This procedure could be invoked either because the window was - * destroyed and the command was then deleted (in which case tkwin - * is NULL) or because the command was deleted, and then this procedure - * destroys the widget. + * This function could be invoked either because the window was destroyed + * and the command was then deleted (in which case tkwin is NULL) or + * because the command was deleted, and then this function destroys the + * widget. */ if (tkwin != NULL) { - /* - * Note: it may be desirable to NULL out the tkwin - * field of menuPtr here: + /* + * Note: it may be desirable to NULL out the tkwin field of menuPtr + * here: * menuPtr->tkwin = NULL; */ + Tk_DestroyWindow(tkwin); } } @@ -2253,12 +2215,12 @@ MenuCmdDeletedProc(clientData) * * MenuNewEntry -- * - * This procedure allocates and initializes a new menu entry. + * This function allocates and initializes a new menu entry. * * Results: - * The return value is a pointer to a new menu entry structure, - * which has been malloc-ed, initialized, and entered into the - * entry array for the menu. + * The return value is a pointer to a new menu entry structure, which has + * been malloc-ed, initialized, and entered into the entry array for the + * menu. * * Side effects: * Storage gets allocated. @@ -2267,19 +2229,18 @@ MenuCmdDeletedProc(clientData) */ static TkMenuEntry * -MenuNewEntry(menuPtr, index, type) - TkMenu *menuPtr; /* Menu that will hold the new entry. */ - int index; /* Where in the menu the new entry is to +MenuNewEntry( + TkMenu *menuPtr, /* Menu that will hold the new entry. */ + int index, /* Where in the menu the new entry is to * go. */ - int type; /* The type of the new entry. */ + int type) /* The type of the new entry. */ { TkMenuEntry *mePtr; TkMenuEntry **newEntries; int i; /* - * Create a new array of entries with an empty slot for the - * new entry. + * Create a new array of entries with an empty slot for the new entry. */ newEntries = (TkMenuEntry **) ckalloc((unsigned) @@ -2350,8 +2311,8 @@ MenuNewEntry(menuPtr, index, type) * * MenuAddOrInsert -- * - * This procedure does all of the work of the "add" and "insert" - * widget commands, allowing the code for these to be shared. + * This function does all of the work of the "add" and "insert" widget + * commands, allowing the code for these to be shared. * * Results: * A standard Tcl return value. @@ -2363,34 +2324,29 @@ MenuNewEntry(menuPtr, index, type) */ static int -MenuAddOrInsert(interp, menuPtr, indexPtr, objc, objv) - Tcl_Interp *interp; /* Used for error reporting. */ - TkMenu *menuPtr; /* Widget in which to create new - * entry. */ - Tcl_Obj *indexPtr; /* Object describing index at which - * to insert. NULL means insert at - * end. */ - int objc; /* Number of elements in objv. */ - Tcl_Obj *CONST objv[]; /* Arguments to command: first arg - * is type of entry, others are - * config options. */ +MenuAddOrInsert( + Tcl_Interp *interp, /* Used for error reporting. */ + TkMenu *menuPtr, /* Widget in which to create new entry. */ + Tcl_Obj *indexPtr, /* Object describing index at which to insert. + * NULL means insert at end. */ + int objc, /* Number of elements in objv. */ + Tcl_Obj *CONST objv[]) /* Arguments to command: first arg is type of + * entry, others are config options. */ { int type, index; TkMenuEntry *mePtr; TkMenu *menuListPtr; if (indexPtr != NULL) { - if (TkGetMenuIndex(interp, menuPtr, indexPtr, 1, &index) - != TCL_OK) { + if (TkGetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) { return TCL_ERROR; } } else { index = menuPtr->numEntries; } if (index < 0) { - char *indexString = Tcl_GetStringFromObj(indexPtr, NULL); - Tcl_AppendResult(interp, "bad index \"", indexString, "\"", - (char *) NULL); + char *indexString = Tcl_GetString(indexPtr); + Tcl_AppendResult(interp, "bad index \"", indexString, "\"", NULL); return TCL_ERROR; } if (menuPtr->tearoff && (index == 0)) { @@ -2443,12 +2399,11 @@ MenuAddOrInsert(interp, menuPtr, indexPtr, objc, objv) } /* - * If a menu has cascades, then every instance of the menu has - * to have its own parallel cascade structure. So adding an - * entry to a menu with clones means that the menu that the - * entry points to has to be cloned for every clone the - * master menu has. This is special case #2 in the comment - * at the top of this file. + * If a menu has cascades, then every instance of the menu has to have + * its own parallel cascade structure. So adding an entry to a menu + * with clones means that the menu that the entry points to has to be + * cloned for every clone the master menu has. This is special case #2 + * in the comment at the top of this file. */ if ((menuPtr != menuListPtr) && (type == CASCADE_ENTRY)) { @@ -2459,7 +2414,7 @@ MenuAddOrInsert(interp, menuPtr, indexPtr, objc, objv) mePtr->childMenuRefPtr->menuPtr->masterMenuPtr; Tcl_Obj *newCascadePtr; Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1); - Tcl_Obj *windowNamePtr = + Tcl_Obj *windowNamePtr = Tcl_NewStringObj(Tk_PathName(menuListPtr->tkwin), -1); Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", -1); Tcl_Obj *newObjv[2]; @@ -2497,10 +2452,9 @@ MenuAddOrInsert(interp, menuPtr, indexPtr, objc, objv) * * MenuVarProc -- * - * This procedure is invoked when someone changes the - * state variable associated with a radiobutton or checkbutton - * menu entry. The entry's selected state is set to match - * the value of the variable. + * This function is invoked when someone changes the state variable + * associated with a radiobutton or checkbutton menu entry. The entry's + * selected state is set to match the value of the variable. * * Results: * NULL is always returned. @@ -2512,12 +2466,12 @@ MenuAddOrInsert(interp, menuPtr, indexPtr, objc, objv) */ static char * -MenuVarProc(clientData, interp, name1, name2, flags) - ClientData clientData; /* Information about menu entry. */ - Tcl_Interp *interp; /* Interpreter containing variable. */ - CONST char *name1; /* First part of variable's name. */ - CONST char *name2; /* Second part of variable's name. */ - int flags; /* Describes what just happened. */ +MenuVarProc( + ClientData clientData, /* Information about menu entry. */ + Tcl_Interp *interp, /* Interpreter containing variable. */ + CONST char *name1, /* First part of variable's name. */ + CONST char *name2, /* Second part of variable's name. */ + int flags) /* Describes what just happened. */ { TkMenuEntry *mePtr = (TkMenuEntry *) clientData; TkMenu *menuPtr; @@ -2530,11 +2484,11 @@ MenuVarProc(clientData, interp, name1, name2, flags) * Do nothing if the interpreter is going away. */ - return (char *) NULL; + return NULL; } menuPtr = mePtr->menuPtr; - name = Tcl_GetStringFromObj(mePtr->namePtr, NULL); + name = Tcl_GetString(mePtr->namePtr); /* * If the variable is being unset, then re-establish the trace. @@ -2548,13 +2502,13 @@ MenuVarProc(clientData, interp, name1, name2, flags) MenuVarProc, clientData); } TkpConfigureMenuEntry(mePtr); - TkEventuallyRedrawMenu(menuPtr, (TkMenuEntry *) NULL); - return (char *) NULL; + TkEventuallyRedrawMenu(menuPtr, NULL); + return NULL; } /* - * Use the value of the variable to update the selected status of - * the menu entry. + * Use the value of the variable to update the selected status of the menu + * entry. */ value = Tcl_GetVar(interp, name, TCL_GLOBAL_ONLY); @@ -2562,23 +2516,23 @@ MenuVarProc(clientData, interp, name1, name2, flags) value = ""; } if (mePtr->onValuePtr != NULL) { - onValue = Tcl_GetStringFromObj(mePtr->onValuePtr, NULL); + onValue = Tcl_GetString(mePtr->onValuePtr); if (strcmp(value, onValue) == 0) { if (mePtr->entryFlags & ENTRY_SELECTED) { - return (char *) NULL; + return NULL; } mePtr->entryFlags |= ENTRY_SELECTED; } else if (mePtr->entryFlags & ENTRY_SELECTED) { mePtr->entryFlags &= ~ENTRY_SELECTED; } else { - return (char *) NULL; + return NULL; } } else { - return (char *) NULL; + return NULL; } TkpConfigureMenuEntry(mePtr); TkEventuallyRedrawMenu(menuPtr, mePtr); - return (char *) NULL; + return NULL; } /* @@ -2586,26 +2540,25 @@ MenuVarProc(clientData, interp, name1, name2, flags) * * TkActivateMenuEntry -- * - * This procedure is invoked to make a particular menu entry - * the active one, deactivating any other entry that might - * currently be active. + * This function is invoked to make a particular menu entry the active + * one, deactivating any other entry that might currently be active. * * Results: - * The return value is a standard Tcl result (errors can occur - * while posting and unposting submenus). + * The return value is a standard Tcl result (errors can occur while + * posting and unposting submenus). * * Side effects: - * Menu entries get redisplayed, and the active entry changes. - * Submenus may get posted and unposted. + * Menu entries get redisplayed, and the active entry changes. Submenus + * may get posted and unposted. * *---------------------------------------------------------------------- */ int -TkActivateMenuEntry(menuPtr, index) - register TkMenu *menuPtr; /* Menu in which to activate. */ - int index; /* Index of entry to activate, or - * -1 to deactivate all entries. */ +TkActivateMenuEntry( + register TkMenu *menuPtr, /* Menu in which to activate. */ + int index) /* Index of entry to activate, or -1 to + * deactivate all entries. */ { register TkMenuEntry *mePtr; int result = TCL_OK; @@ -2614,8 +2567,8 @@ TkActivateMenuEntry(menuPtr, index) mePtr = menuPtr->entries[menuPtr->active]; /* - * Don't change the state unless it's currently active (state - * might already have been changed to disabled). + * Don't change the state unless it's currently active (state might + * already have been changed to disabled). */ if (mePtr->state == ENTRY_ACTIVE) { @@ -2640,8 +2593,8 @@ TkActivateMenuEntry(menuPtr, index) * Execute the postcommand for the given menu. * * Results: - * The return value is a standard Tcl result (errors can occur - * while the postcommands are being processed). + * The return value is a standard Tcl result (errors can occur while the + * postcommands are being processed). * * Side effects: * Since commands can get executed while this routine is being executed, @@ -2649,17 +2602,17 @@ TkActivateMenuEntry(menuPtr, index) * *---------------------------------------------------------------------- */ - + int -TkPostCommand(menuPtr) - TkMenu *menuPtr; +TkPostCommand( + TkMenu *menuPtr) { int result; /* - * If there is a command for the menu, execute it. This - * may change the size of the menu, so be sure to recompute - * the menu's geometry if needed. + * If there is a command for the menu, execute it. This may change the + * size of the menu, so be sure to recompute the menu's geometry if + * needed. */ if (menuPtr->postCommandPtr != NULL) { @@ -2682,27 +2635,26 @@ TkPostCommand(menuPtr) * * CloneMenu -- * - * Creates a child copy of the menu. It will be inserted into - * the menu's instance chain. All attributes and entry - * attributes will be duplicated. + * Creates a child copy of the menu. It will be inserted into the menu's + * instance chain. All attributes and entry attributes will be + * duplicated. * * Results: * A standard Tcl result. * * Side effects: - * Allocates storage. After the menu is created, any - * configuration done with this menu or any related one - * will be reflected in all of them. + * Allocates storage. After the menu is created, any configuration done + * with this menu or any related one will be reflected in all of them. * *-------------------------------------------------------------- */ static int -CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) - TkMenu *menuPtr; /* The menu we are going to clone */ - Tcl_Obj *newMenuNamePtr; /* The name to give the new menu */ - Tcl_Obj *newMenuTypePtr; /* What kind of menu is this, a normal menu - * a menubar, or a tearoff? */ +CloneMenu( + TkMenu *menuPtr, /* The menu we are going to clone */ + Tcl_Obj *newMenuNamePtr, /* The name to give the new menu */ + Tcl_Obj *newMenuTypePtr) /* What kind of menu is this, a normal menu a + * menubar, or a tearoff? */ { int returnResult; int menuType, i; @@ -2712,7 +2664,7 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) if (newMenuTypePtr == NULL) { menuType = MASTER_MENU; } else { - if (Tcl_GetIndexFromObj(menuPtr->interp, newMenuTypePtr, + if (Tcl_GetIndexFromObj(menuPtr->interp, newMenuTypePtr, menuTypeStrings, "menu type", 0, &menuType) != TCL_OK) { return TCL_ERROR; } @@ -2740,8 +2692,8 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) */ if ((returnResult == TCL_OK) && - ((menuRefPtr = TkFindMenuReferencesObj(menuPtr->interp, - newMenuNamePtr)) != (TkMenuReferences *) NULL) + ((menuRefPtr = TkFindMenuReferencesObj(menuPtr->interp, + newMenuNamePtr)) != NULL) && (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) { TkMenu *newMenuPtr = menuRefPtr->menuPtr; Tcl_Obj *newObjv[3]; @@ -2765,17 +2717,17 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) } /* - * Add the master menu's window to the bind tags for this window - * after this window's tag. This is so the user can bind to either - * this clone (which may not be easy to do) or the entire menu - * clone structure. + * Add the master menu's window to the bind tags for this window after + * this window's tag. This is so the user can bind to either this + * clone (which may not be easy to do) or the entire menu clone + * structure. */ newObjv[0] = Tcl_NewStringObj("bindtags", -1); newObjv[1] = Tcl_NewStringObj(Tk_PathName(newMenuPtr->tkwin), -1); Tcl_IncrRefCount(newObjv[0]); Tcl_IncrRefCount(newObjv[1]); - if (Tk_BindtagsObjCmd((ClientData)newMenuPtr->tkwin, + if (Tk_BindtagsObjCmd((ClientData)newMenuPtr->tkwin, newMenuPtr->interp, 2, newObjv) == TCL_OK) { char *windowName; Tcl_Obj *bindingsPtr = @@ -2787,15 +2739,17 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) for (i = 0; i < numElements; i++) { Tcl_ListObjIndex(newMenuPtr->interp, bindingsPtr, i, &elementPtr); - windowName = Tcl_GetStringFromObj(elementPtr, NULL); + windowName = Tcl_GetString(elementPtr); if (strcmp(windowName, Tk_PathName(newMenuPtr->tkwin)) == 0) { Tcl_Obj *newElementPtr = Tcl_NewStringObj( Tk_PathName(newMenuPtr->masterMenuPtr->tkwin), -1); - /* + + /* * The newElementPtr will have its refCount incremented * here, so we don't need to worry about it any more. */ + Tcl_ListObjReplace(menuPtr->interp, bindingsPtr, i + 1, 0, 1, &newElementPtr); newObjv[2] = bindingsPtr; @@ -2824,7 +2778,7 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) TkFindMenuReferencesObj(menuPtr->interp, menuPtr->entries[i]->namePtr); if ((cascadeRefPtr != NULL) && (cascadeRefPtr->menuPtr)) { - Tcl_Obj *windowNamePtr = + Tcl_Obj *windowNamePtr = Tcl_NewStringObj(Tk_PathName(newMenuPtr->tkwin), -1); Tcl_Obj *newCascadePtr; @@ -2873,10 +2827,10 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) */ static int -MenuDoYPosition(interp, menuPtr, objPtr) - Tcl_Interp *interp; - TkMenu *menuPtr; - Tcl_Obj *objPtr; +MenuDoYPosition( + Tcl_Interp *interp, + TkMenu *menuPtr, + Tcl_Obj *objPtr) { int index; @@ -2893,7 +2847,7 @@ MenuDoYPosition(interp, menuPtr, objPtr) return TCL_OK; -error: + error: return TCL_ERROR; } @@ -2906,9 +2860,9 @@ error: * to int. * * Results: - * If int is a valid number, *indexPtr will be the number of the menuentry - * that is the correct height. If int is invaled, *indexPtr will be - * unchanged. Returns appropriate Tcl error number. + * If int is a valid number, *indexPtr will be the number of the + * menuentry that is the correct height. If int is invaled, *indexPtr + * will be unchanged. Returns appropriate Tcl error number. * * Side effects: * If int is invalid, interp's result will set to NULL. @@ -2917,15 +2871,15 @@ error: */ static int -GetIndexFromCoords(interp, menuPtr, string, indexPtr) - Tcl_Interp *interp; /* interp of menu */ - TkMenu *menuPtr; /* the menu we are searching */ - char *string; /* The @string we are parsing */ - int *indexPtr; /* The index of the item that matches */ +GetIndexFromCoords( + Tcl_Interp *interp, /* interp of menu */ + TkMenu *menuPtr, /* the menu we are searching */ + char *string, /* The @string we are parsing */ + int *indexPtr) /* The index of the item that matches */ { int x, y, i; char *p, *end; - + TkRecomputeMenu(menuPtr); p = string + 1; y = strtol(p, &end, 0); @@ -2940,7 +2894,7 @@ GetIndexFromCoords(interp, menuPtr, string, indexPtr) goto error; } } else { - Tk_GetPixelsFromObj(interp, menuPtr->tkwin, + Tk_GetPixelsFromObj(interp, menuPtr->tkwin, menuPtr->borderWidthPtr, &x); } @@ -2959,8 +2913,8 @@ GetIndexFromCoords(interp, menuPtr, string, indexPtr) *indexPtr = i; return TCL_OK; - error: - Tcl_SetResult(interp, (char *) NULL, TCL_STATIC); + error: + Tcl_SetResult(interp, NULL, TCL_STATIC); return TCL_ERROR; } @@ -2970,8 +2924,8 @@ GetIndexFromCoords(interp, menuPtr, string, indexPtr) * RecursivelyDeleteMenu -- * * Deletes a menu and any cascades underneath it. Used for deleting - * instances when a menu is no longer being used as a menubar, - * for instance. + * instances when a menu is no longer being used as a menubar, for + * instance. * * Results: * None. @@ -2983,17 +2937,17 @@ GetIndexFromCoords(interp, menuPtr, string, indexPtr) */ static void -RecursivelyDeleteMenu(menuPtr) - TkMenu *menuPtr; /* The menubar instance we are deleting */ +RecursivelyDeleteMenu( + TkMenu *menuPtr) /* The menubar instance we are deleting */ { int i; TkMenuEntry *mePtr; /* - * It is not 100% clear that this preserve/release pair is - * required, but we have added them for safety in this - * very complex code. + * It is not 100% clear that this preserve/release pair is required, but + * we have added them for safety in this very complex code. */ + Tcl_Preserve(menuPtr); for (i = 0; i < menuPtr->numEntries; i++) { @@ -3016,8 +2970,7 @@ RecursivelyDeleteMenu(menuPtr) * * TkNewMenuName -- * - * Makes a new unique name for a cloned menu. Will be a child - * of oldName. + * Makes a new unique name for a cloned menu. Will be a child of oldName. * * Results: * Returns a char * which has been allocated; caller must free. @@ -3029,10 +2982,10 @@ RecursivelyDeleteMenu(menuPtr) */ Tcl_Obj * -TkNewMenuName(interp, parentPtr, menuPtr) - Tcl_Interp *interp; /* The interp the new name has to live in.*/ - Tcl_Obj *parentPtr; /* The prefix path of the new name. */ - TkMenu *menuPtr; /* The menu we are cloning. */ +TkNewMenuName( + Tcl_Interp *interp, /* The interp the new name has to live in.*/ + Tcl_Obj *parentPtr, /* The prefix path of the new name. */ + TkMenu *menuPtr) /* The menu we are cloning. */ { Tcl_Obj *resultPtr = NULL; /* Initialization needed only to prevent * compiler warning. */ @@ -3043,7 +2996,7 @@ TkNewMenuName(interp, parentPtr, menuPtr) Tcl_CmdInfo cmdInfo; Tcl_HashTable *nameTablePtr = NULL; TkWindow *winPtr = (TkWindow *) menuPtr->tkwin; - char *parentName = Tcl_GetStringFromObj(parentPtr, NULL); + char *parentName = Tcl_GetString(parentPtr); if (winPtr->mainPtr != NULL) { nameTablePtr = &(winPtr->mainPtr->nameTable); @@ -3052,7 +3005,7 @@ TkNewMenuName(interp, parentPtr, menuPtr) doDot = parentName[strlen(parentName) - 1] != '.'; childPtr = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin), -1); - for (destString = Tcl_GetStringFromObj(childPtr, NULL); + for (destString = Tcl_GetString(childPtr); *destString != '\0'; destString++) { if (*destString == '.') { *destString = '#'; @@ -3079,7 +3032,7 @@ TkNewMenuName(interp, parentPtr, menuPtr) Tcl_AppendObjToObj(resultPtr, intPtr); Tcl_DecrRefCount(intPtr); } - destString = Tcl_GetStringFromObj(resultPtr, NULL); + destString = Tcl_GetString(resultPtr); if ((Tcl_GetCommandInfo(interp, destString, &cmdInfo) == 0) && ((nameTablePtr == NULL) || (Tcl_FindHashEntry(nameTablePtr, destString) == NULL))) { @@ -3095,27 +3048,27 @@ TkNewMenuName(interp, parentPtr, menuPtr) * * TkSetWindowMenuBar -- * - * Associates a menu with a window. Called by ConfigureFrame in - * in response to a "-menu .foo" configuration option for a top - * level. + * Associates a menu with a window. Called by ConfigureFrame in in + * response to a "-menu .foo" configuration option for a top level. * * Results: * None. * * Side effects: - * The old menu clones for the menubar are thrown away, and a - * handler is set up to allocate the new ones. + * The old menu clones for the menubar are thrown away, and a handler is + * set up to allocate the new ones. * *---------------------------------------------------------------------- */ + void -TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName) - Tcl_Interp *interp; /* The interpreter the toplevel lives in. */ - Tk_Window tkwin; /* The toplevel window */ - char *oldMenuName; /* The name of the menubar previously set in - * this toplevel. NULL means no menu was - * set previously. */ - char *menuName; /* The name of the new menubar that the +TkSetWindowMenuBar( + Tcl_Interp *interp, /* The interpreter the toplevel lives in. */ + Tk_Window tkwin, /* The toplevel window */ + char *oldMenuName, /* The name of the menubar previously set in + * this toplevel. NULL means no menu was set + * previously. */ + char *menuName) /* The name of the new menubar that the * toplevel needs to be set to. NULL means * that their is no menu now. */ { @@ -3126,25 +3079,25 @@ TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName) /* * Avoid reinitialization if we are just cleaning up dead windows. - * Perhaps knowing when Tcl was really exiting would be better than - * just checking for this winPtr being dead. [Bug 749908] + * Perhaps knowing when Tcl was really exiting would be better than just + * checking for this winPtr being dead. [Bug 749908] */ + if (!(winPtr->flags & TK_ALREADY_DEAD)) { TkMenuInit(); } /* - * Destroy the menubar instances of the old menu. Take this window - * out of the old menu's top level reference list. + * Destroy the menubar instances of the old menu. Take this window out of + * the old menu's top level reference list. */ if (oldMenuName != NULL) { menuRefPtr = TkFindMenuReferences(interp, oldMenuName); if (menuRefPtr != NULL) { - /* - * Find the menubar instance that is to be removed. Destroy - * it and all of the cascades underneath it. + * Find the menubar instance that is to be removed. Destroy it and + * all of the cascades underneath it. */ if (menuRefPtr->menuPtr != NULL) { @@ -3153,9 +3106,9 @@ TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName) menuPtr = menuRefPtr->menuPtr; for (instancePtr = menuPtr->masterMenuPtr; - instancePtr != NULL; + instancePtr != NULL; instancePtr = instancePtr->nextInstancePtr) { - if (instancePtr->menuType == MENUBAR + if (instancePtr->menuType == MENUBAR && instancePtr->parentTopLevelPtr == tkwin) { RecursivelyDeleteMenu(instancePtr); break; @@ -3171,7 +3124,7 @@ TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName) topLevelListPtr = menuRefPtr->topLevelListPtr; prevTopLevelPtr = NULL; - while ((topLevelListPtr != NULL) + while ((topLevelListPtr != NULL) && (topLevelListPtr->tkwin != tkwin)) { prevTopLevelPtr = topLevelListPtr; topLevelListPtr = topLevelListPtr->nextPtr; @@ -3209,7 +3162,7 @@ TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName) Tcl_Obj *cloneMenuPtr; TkMenuReferences *cloneMenuRefPtr; Tcl_Obj *newObjv[4]; - Tcl_Obj *windowNamePtr = Tcl_NewStringObj(Tk_PathName(tkwin), + Tcl_Obj *windowNamePtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1); Tcl_Obj *menubarPtr = Tcl_NewStringObj("menubar", -1); @@ -3250,8 +3203,8 @@ TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName) } /* - * Add this window to the menu's list of windows that refer - * to this menu. + * Add this window to the menu's list of windows that refer to this + * menu. */ topLevelListPtr = (TkMenuTopLevelList *) @@ -3270,8 +3223,8 @@ TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName) * * DestroyMenuHashTable -- * - * Called when an interp is deleted and a menu hash table has - * been set in it. + * Called when an interp is deleted and a menu hash table has been set in + * it. * * Results: * None. @@ -3283,9 +3236,9 @@ TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName) */ static void -DestroyMenuHashTable(clientData, interp) - ClientData clientData; /* The menu hash table we are destroying */ - Tcl_Interp *interp; /* The interpreter we are destroying */ +DestroyMenuHashTable( + ClientData clientData, /* The menu hash table we are destroying */ + Tcl_Interp *interp) /* The interpreter we are destroying */ { Tcl_DeleteHashTable((Tcl_HashTable *) clientData); ckfree((char *) clientData); @@ -3296,8 +3249,8 @@ DestroyMenuHashTable(clientData, interp) * * TkGetMenuHashTable -- * - * For a given interp, give back the menu hash table that goes with - * it. If the hash table does not exist, it is created. + * For a given interp, give back the menu hash table that goes with it. + * If the hash table does not exist, it is created. * * Results: * Returns a hash table pointer. @@ -3310,13 +3263,13 @@ DestroyMenuHashTable(clientData, interp) */ Tcl_HashTable * -TkGetMenuHashTable(interp) - Tcl_Interp *interp; /* The interp we need the hash table in.*/ +TkGetMenuHashTable( + Tcl_Interp *interp) /* The interp we need the hash table in.*/ { Tcl_HashTable *menuTablePtr; - menuTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, MENU_HASH_KEY, - NULL); + menuTablePtr = (Tcl_HashTable *) + Tcl_GetAssocData(interp, MENU_HASH_KEY, NULL); if (menuTablePtr == NULL) { menuTablePtr = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(menuTablePtr, TCL_STRING_KEYS); @@ -3331,25 +3284,26 @@ TkGetMenuHashTable(interp) * * TkCreateMenuReferences -- * - * Given a pathname, gives back a pointer to a TkMenuReferences structure. - * If a reference is not already in the hash table, one is created. + * Given a pathname, gives back a pointer to a TkMenuReferences + * structure. If a reference is not already in the hash table, one is + * created. * * Results: - * Returns a pointer to a menu reference structure. Should not - * be freed by calller; when a field of the reference is cleared, + * Returns a pointer to a menu reference structure. Should not be freed + * by calller; when a field of the reference is cleared, * TkFreeMenuReferences should be called. * * Side effects: - * A new hash table entry is created if there were no references - * to the menu originally. + * A new hash table entry is created if there were no references to the + * menu originally. * *---------------------------------------------------------------------- */ TkMenuReferences * -TkCreateMenuReferences(interp, pathName) - Tcl_Interp *interp; - char *pathName; /* The path of the menu widget */ +TkCreateMenuReferences( + Tcl_Interp *interp, + char *pathName) /* The path of the menu widget */ { Tcl_HashEntry *hashEntryPtr; TkMenuReferences *menuRefPtr; @@ -3379,8 +3333,8 @@ TkCreateMenuReferences(interp, pathName) * structure. * * Results: - * Returns a pointer to a menu reference structure. Should not - * be freed by calller; when a field of the reference is cleared, + * Returns a pointer to a menu reference structure. Should not be freed + * by calller; when a field of the reference is cleared, * TkFreeMenuReferences should be called. Returns NULL if no reference * with this pathname exists. * @@ -3391,9 +3345,9 @@ TkCreateMenuReferences(interp, pathName) */ TkMenuReferences * -TkFindMenuReferences(interp, pathName) - Tcl_Interp *interp; /* The interp the menu is living in. */ - char *pathName; /* The path of the menu widget */ +TkFindMenuReferences( + Tcl_Interp *interp, /* The interp the menu is living in. */ + char *pathName) /* The path of the menu widget */ { Tcl_HashEntry *hashEntryPtr; TkMenuReferences *menuRefPtr = NULL; @@ -3416,8 +3370,8 @@ TkFindMenuReferences(interp, pathName) * structure. * * Results: - * Returns a pointer to a menu reference structure. Should not - * be freed by calller; when a field of the reference is cleared, + * Returns a pointer to a menu reference structure. Should not be freed + * by calller; when a field of the reference is cleared, * TkFreeMenuReferences should be called. Returns NULL if no reference * with this pathname exists. * @@ -3428,11 +3382,11 @@ TkFindMenuReferences(interp, pathName) */ TkMenuReferences * -TkFindMenuReferencesObj(interp, objPtr) - Tcl_Interp *interp; /* The interp the menu is living in. */ - Tcl_Obj *objPtr; /* The path of the menu widget */ +TkFindMenuReferencesObj( + Tcl_Interp *interp, /* The interp the menu is living in. */ + Tcl_Obj *objPtr) /* The path of the menu widget */ { - char *pathName = Tcl_GetStringFromObj(objPtr, NULL); + char *pathName = Tcl_GetString(objPtr); return TkFindMenuReferences(interp, pathName); } @@ -3441,26 +3395,25 @@ TkFindMenuReferencesObj(interp, objPtr) * * TkFreeMenuReferences -- * - * This is called after one of the fields in a menu reference - * is cleared. It cleans up the ref if it is now empty. + * This is called after one of the fields in a menu reference is cleared. + * It cleans up the ref if it is now empty. * * Results: - * Returns 1 if the references structure was freed, and 0 - * otherwise. + * Returns 1 if the references structure was freed, and 0 otherwise. * * Side effects: - * If this is the last field to be cleared, the menu ref is - * taken out of the hash table. + * If this is the last field to be cleared, the menu ref is taken out of + * the hash table. * *---------------------------------------------------------------------- */ int -TkFreeMenuReferences(menuRefPtr) - TkMenuReferences *menuRefPtr; /* The menu reference to - * free */ +TkFreeMenuReferences( + TkMenuReferences *menuRefPtr) + /* The menu reference to free */ { - if ((menuRefPtr->menuPtr == NULL) + if ((menuRefPtr->menuPtr == NULL) && (menuRefPtr->parentEntryPtr == NULL) && (menuRefPtr->topLevelListPtr == NULL)) { Tcl_DeleteHashEntry(menuRefPtr->hashEntryPtr); @@ -3475,8 +3428,8 @@ TkFreeMenuReferences(menuRefPtr) * * DeleteMenuCloneEntries -- * - * For every clone in this clone chain, delete the menu entries - * given by the parameters. + * For every clone in this clone chain, delete the menu entries given by + * the parameters. * * Results: * None. @@ -3488,13 +3441,12 @@ TkFreeMenuReferences(menuRefPtr) */ static void -DeleteMenuCloneEntries(menuPtr, first, last) - TkMenu *menuPtr; /* the menu the command was issued with */ - int first; /* the zero-based first entry in the set - * of entries to delete. */ - int last; /* the zero-based last entry */ +DeleteMenuCloneEntries( + TkMenu *menuPtr, /* The menu the command was issued with. */ + int first, /* The zero-based first entry in the set of + * entries to delete. */ + int last) /* The zero-based last entry. */ { - TkMenu *menuListPtr; int numDeleted, i; @@ -3514,7 +3466,7 @@ DeleteMenuCloneEntries(menuPtr, first, last) ckfree((char *) menuListPtr->entries); menuListPtr->entries = NULL; } - if ((menuListPtr->active >= first) + if ((menuListPtr->active >= first) && (menuListPtr->active <= last)) { menuListPtr->active = -1; } else if (menuListPtr->active > last) { @@ -3529,8 +3481,8 @@ DeleteMenuCloneEntries(menuPtr, first, last) * * TkMenuCleanup -- * - * Resets menusInitialized to allow Tk to be finalized and reused - * without the DLL being unloaded. + * Resets menusInitialized to allow Tk to be finalized and reused without + * the DLL being unloaded. * * Results: * None. @@ -3541,8 +3493,9 @@ DeleteMenuCloneEntries(menuPtr, first, last) *---------------------------------------------------------------------- */ -static void -TkMenuCleanup(ClientData unused) +static void +TkMenuCleanup( + ClientData unused) { menusInitialized = 0; } @@ -3565,9 +3518,9 @@ TkMenuCleanup(ClientData unused) */ void -TkMenuInit() +TkMenuInit(void) { - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!menusInitialized) { @@ -3576,9 +3529,11 @@ TkMenuInit() TkpMenuInit(); menusInitialized = 1; } + /* * Make sure we cleanup on finalize. */ + TkCreateExitHandler((Tcl_ExitProc *) TkMenuCleanup, NULL); Tcl_MutexUnlock(&menuMutex); } @@ -3587,3 +3542,11 @@ TkMenuInit() tsdPtr->menusInitialized = 1; } } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/generic/tkObj.c b/generic/tkObj.c index 6c96364..f4ca2fd 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkObj.c,v 1.14 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkObj.c,v 1.15 2005/11/17 16:21:56 dkf Exp $ */ #include "tkInt.h" @@ -512,7 +512,7 @@ UpdateStringOfMM( Tcl_Panic("UpdateStringOfMM: false precondition"); } - Tcl_PrintDouble((Tcl_Interp *) NULL, mmPtr->value, buffer); + Tcl_PrintDouble(NULL, mmPtr->value, buffer); len = strlen(buffer); objPtr->bytes = (char *) ckalloc((unsigned) len + 1); @@ -594,7 +594,7 @@ SetMMFromAny( error: Tcl_AppendResult(interp, "bad screen distance \"", string, - "\"", (char *) NULL); + "\"", NULL); return TCL_ERROR; } while ((*rest != '\0') && isspace(UCHAR(*rest))) { @@ -859,7 +859,7 @@ TkParsePadAmount( Tcl_ResetResult(interp); Tcl_AppendResult(interp, "bad pad value \"", Tcl_GetString(specObj), - "\": must be positive screen distance", (char *) NULL); + "\": must be positive screen distance", NULL); return TCL_ERROR; } secondInt = firstInt; @@ -888,7 +888,7 @@ TkParsePadAmount( (firstInt < 0)) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "bad pad value \"", Tcl_GetString(objv[0]), - "\": must be positive screen distance", (char *) NULL); + "\": must be positive screen distance", NULL); return TCL_ERROR; } @@ -904,7 +904,7 @@ TkParsePadAmount( Tcl_ResetResult(interp); Tcl_AppendResult(interp, "bad 2nd pad value \"", Tcl_GetString(objv[1]), - "\": must be positive screen distance", (char *) NULL); + "\": must be positive screen distance", NULL); return TCL_ERROR; } diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index c0b40b7..ce2c544 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkOldConfig.c,v 1.19 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkOldConfig.c,v 1.20 2005/11/17 16:21:56 dkf Exp $ */ #include "tkPort.h" @@ -98,7 +98,7 @@ Tk_ConfigureWidget(interp, tkwin, specs, argc, argv, widgRec, flags) * we're on our way out of the application */ - Tcl_AppendResult(interp, "NULL main window", (char *)NULL); + Tcl_AppendResult(interp, "NULL main window", NULL); return TCL_ERROR; } @@ -138,8 +138,7 @@ Tk_ConfigureWidget(interp, tkwin, specs, argc, argv, widgRec, flags) */ if (argc < 2) { - Tcl_AppendResult(interp, "value for \"", arg, - "\" missing", (char *) NULL); + Tcl_AppendResult(interp, "value for \"", arg, "\" missing", NULL); return TCL_ERROR; } if (flags & TK_CONFIG_OBJS) { @@ -277,16 +276,15 @@ FindConfigSpec(interp, specs, argvName, needFlags, hateFlags) } if (matchPtr != NULL) { Tcl_AppendResult(interp, "ambiguous option \"", argvName, - "\"", (char *) NULL); - return (Tk_ConfigSpec *) NULL; + "\"", NULL); + return NULL; } matchPtr = specPtr; } if (matchPtr == NULL) { - Tcl_AppendResult(interp, "unknown option \"", argvName, - "\"", (char *) NULL); - return (Tk_ConfigSpec *) NULL; + Tcl_AppendResult(interp, "unknown option \"", argvName, "\"", NULL); + return NULL; } /* @@ -299,10 +297,9 @@ FindConfigSpec(interp, specs, argvName, needFlags, hateFlags) if (specPtr->type == TK_CONFIG_SYNONYM) { for (specPtr = specs; ; specPtr++) { if (specPtr->type == TK_CONFIG_END) { - Tcl_AppendResult(interp, - "couldn't find synonym for option \"", - argvName, "\"", (char *) NULL); - return (Tk_ConfigSpec *) NULL; + Tcl_AppendResult(interp, "couldn't find synonym for option \"", + argvName, "\"", NULL); + return NULL; } if ((specPtr->dbName == matchPtr->dbName) && (specPtr->type != TK_CONFIG_SYNONYM) @@ -631,7 +628,7 @@ Tk_ConfigureInfo(interp, tkwin, specs, widgRec, argvName, flags) * handle that one spec specially. */ - Tcl_SetResult(interp, (char *) NULL, TCL_STATIC); + Tcl_SetResult(interp, NULL, TCL_STATIC); if (argvName != NULL) { specPtr = FindConfigSpec(interp, specs, argvName, needFlags,hateFlags); if (specPtr == NULL) { @@ -660,7 +657,7 @@ Tk_ConfigureInfo(interp, tkwin, specs, widgRec, argvName, flags) continue; } list = FormatConfigInfo(interp, tkwin, specPtr, widgRec); - Tcl_AppendResult(interp, leader, list, "}", (char *) NULL); + Tcl_AppendResult(interp, leader, list, "}", NULL); ckfree(list); leader = " {"; } @@ -699,7 +696,7 @@ FormatConfigInfo(interp, tkwin, specPtr, widgRec) CONST char *argv[6]; char *result; char buffer[200]; - Tcl_FreeProc *freeProc = (Tcl_FreeProc *) NULL; + Tcl_FreeProc *freeProc = NULL; argv[0] = specPtr->argvName; argv[1] = specPtr->dbName; diff --git a/generic/tkScale.c b/generic/tkScale.c index 2b688b5..b97485a 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScale.c,v 1.21 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkScale.c,v 1.22 2005/11/17 16:21:56 dkf Exp $ */ #include "tkPort.h" @@ -30,7 +30,7 @@ */ static char *orientStrings[] = { - "horizontal", "vertical", (char *) NULL + "horizontal", "vertical", NULL }; /* @@ -39,7 +39,7 @@ static char *orientStrings[] = { */ static char *stateStrings[] = { - "active", "disabled", "normal", (char *) NULL + "active", "disabled", "normal", NULL }; static Tk_OptionSpec optionSpecs[] = { @@ -52,10 +52,10 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_DOUBLE, "-bigincrement", "bigIncrement", "BigIncrement", DEF_SCALE_BIG_INCREMENT, -1, Tk_Offset(TkScale, bigIncrement), 0, 0, 0}, - {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, - {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-background", 0}, + {TK_OPTION_SYNONYM, "-bd", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + {TK_OPTION_SYNONYM, "-bg", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_SCALE_BORDER_WIDTH, -1, Tk_Offset(TkScale, borderWidth), 0, 0, 0}, @@ -68,8 +68,8 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_INT, "-digits", "digits", "Digits", DEF_SCALE_DIGITS, -1, Tk_Offset(TkScale, digits), 0, 0, 0}, - {TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, + NULL, 0, -1, 0, (ClientData) "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_SCALE_FONT, -1, Tk_Offset(TkScale, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", @@ -134,8 +134,7 @@ static Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-width", "width", "Width", DEF_SCALE_WIDTH, -1, Tk_Offset(TkScale, width), 0, 0, 0}, - {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, 0, 0} + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0} }; /* @@ -145,7 +144,7 @@ static Tk_OptionSpec optionSpecs[] = { */ static CONST char *commandNames[] = { - "cget", "configure", "coords", "get", "identify", "set", (char *) NULL + "cget", "configure", "coords", "get", "identify", "set", NULL }; enum command { @@ -218,7 +217,7 @@ Tk_ScaleObjCmd( } tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), - Tcl_GetString(objv[1]), (char *) NULL); + Tcl_GetString(objv[1]), NULL); if (tkwin == NULL) { return TCL_ERROR; } @@ -367,7 +366,7 @@ ScaleWidgetObjCmd( if (objc <= 3) { objPtr = Tk_GetOptionInfo(interp, (char *) scalePtr, scalePtr->optionTable, - (objc == 3) ? objv[2] : (Tcl_Obj *) NULL, scalePtr->tkwin); + (objc == 3) ? objv[2] : NULL, scalePtr->tkwin); if (objPtr == NULL) { goto error; } else { @@ -584,7 +583,7 @@ ConfigureScale( if (Tk_SetOptions(interp, (char *) scalePtr, scalePtr->optionTable, objc, objv, - scalePtr->tkwin, &savedOptions, (int *) NULL) != TCL_OK) { + scalePtr->tkwin, &savedOptions, NULL) != TCL_OK) { continue; } } else { @@ -1192,7 +1191,7 @@ ScaleVarProc( scalePtr->flags |= NEVER_SET; TkScaleSetValue(scalePtr, scalePtr->value, 1, 0); } - return (char *) NULL; + return NULL; } /* @@ -1202,7 +1201,7 @@ ScaleVarProc( */ if (scalePtr->flags & SETTING_VAR) { - return (char *) NULL; + return NULL; } resultStr = NULL; valuePtr = Tcl_ObjGetVar2(interp, scalePtr->varNamePtr, NULL, diff --git a/generic/tkSelect.c b/generic/tkSelect.c index a12bcc2..4d8617e 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkSelect.c,v 1.17 2005/11/14 16:29:15 dkf Exp $ + * RCS: @(#) $Id: tkSelect.c,v 1.18 2005/11/17 16:21:56 dkf Exp $ */ #include "tkInt.h" @@ -644,7 +644,7 @@ Tk_GetSelection( cantget: Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection), " selection doesn't exist or form \"", - Tk_GetAtomName(tkwin, target), "\" not defined", (char *) NULL); + Tk_GetAtomName(tkwin, target), "\" not defined", NULL); return TCL_ERROR; } @@ -680,7 +680,7 @@ Tk_SelectionObjCmd( int count, index; Tcl_Obj **objs; static CONST char *optionStrings[] = { - "clear", "get", "handle", "own", (char *) NULL + "clear", "get", "handle", "own", NULL }; enum options { SELECTION_CLEAR, SELECTION_GET, SELECTION_HANDLE, SELECTION_OWN @@ -699,7 +699,7 @@ Tk_SelectionObjCmd( switch ((enum options) index) { case SELECTION_CLEAR: { static CONST char *clearOptionStrings[] = { - "-displayof", "-selection", (char *) NULL + "-displayof", "-selection", NULL }; enum clearOptions { CLEAR_DISPLAYOF, CLEAR_SELECTION }; int clearIndex; @@ -712,7 +712,7 @@ Tk_SelectionObjCmd( } if (count < 2) { Tcl_AppendResult(interp, "value for \"", string, - "\" missing", (char *) NULL); + "\" missing", NULL); return TCL_ERROR; } @@ -758,7 +758,7 @@ Tk_SelectionObjCmd( Tcl_DString selBytes; int result; static CONST char *getOptionStrings[] = { - "-displayof", "-selection", "-type", (char *) NULL + "-displayof", "-selection", "-type", NULL }; enum getOptions { GET_DISPLAYOF, GET_SELECTION, GET_TYPE }; int getIndex; @@ -771,7 +771,7 @@ Tk_SelectionObjCmd( } if (count < 2) { Tcl_AppendResult(interp, "value for \"", string, - "\" missing", (char *) NULL); + "\" missing", NULL); return TCL_ERROR; } @@ -833,7 +833,7 @@ Tk_SelectionObjCmd( register CommandInfo *cmdInfoPtr; int cmdLength; static CONST char *handleOptionStrings[] = { - "-format", "-selection", "-type", (char *) NULL + "-format", "-selection", "-type", NULL }; enum handleOptions { HANDLE_FORMAT, HANDLE_SELECTION, HANDLE_TYPE @@ -848,7 +848,7 @@ Tk_SelectionObjCmd( } if (count < 2) { Tcl_AppendResult(interp, "value for \"", string, - "\" missing", (char *) NULL); + "\" missing", NULL); return TCL_ERROR; } @@ -921,7 +921,7 @@ Tk_SelectionObjCmd( char *script = NULL; int cmdLength; static CONST char *ownOptionStrings[] = { - "-command", "-displayof", "-selection", (char *) NULL + "-command", "-displayof", "-selection", NULL }; enum ownOptions { OWN_COMMAND, OWN_DISPLAYOF, OWN_SELECTION }; int ownIndex; @@ -934,7 +934,7 @@ Tk_SelectionObjCmd( } if (count < 2) { Tcl_AppendResult(interp, "value for \"", string, - "\" missing", (char *) NULL); + "\" missing", NULL); return TCL_ERROR; } @@ -1003,8 +1003,7 @@ Tk_SelectionObjCmd( script = Tcl_GetString(objs[1]); } if (script == NULL) { - Tk_OwnSelection(tkwin, selection, (Tk_LostSelProc *) NULL, - (ClientData) NULL); + Tk_OwnSelection(tkwin, selection, NULL, (ClientData) NULL); return TCL_OK; } cmdLength = strlen(script); diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index c4b6c9d..2cfa16c 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -1,14 +1,14 @@ -/* +/* * tkStubInit.c -- * * This file contains the initializers for the Tk stub vectors. * * Copyright (c) 1998-1999 by Scriptics Corporation. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkStubInit.c,v 1.52 2005/09/21 10:56:33 dkf Exp $ + * RCS: @(#) $Id: tkStubInit.c,v 1.53 2005/11/17 16:21:56 dkf Exp $ */ #include "tkInt.h" @@ -38,10 +38,10 @@ * Remove macros that will interfere with the definitions below. */ -#define Tk_CreateCanvasVisitor ((void (*) _ANSI_ARGS_((Tcl_Interp * interp, \ - VOID * typePtr))) NULL) -#define Tk_GetCanvasVisitor ((VOID * (*) _ANSI_ARGS_((Tcl_Interp * interp, \ - CONST char * name))) NULL) +#define Tk_CreateCanvasVisitor \ + ((void (*)(Tcl_Interp * interp, VOID * typePtr)) NULL) +#define Tk_GetCanvasVisitor \ + ((VOID * (*)(Tcl_Interp * interp, CONST char * name)) NULL) /* * WARNING: The contents of this file is automatically generated by the diff --git a/generic/tkTest.c b/generic/tkTest.c index 7b24555..55fa1eb 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTest.c,v 1.26 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkTest.c,v 1.27 2005/11/17 16:21:56 dkf Exp $ */ #include "tkInt.h" @@ -90,8 +90,8 @@ static Tk_ImageType imageType = { ImageDisplay, /* displayProc */ ImageFree, /* freeProc */ ImageDelete, /* deleteProc */ - (Tk_ImagePostscriptProc *) NULL,/* postscriptPtr */ - (Tk_ImageType *) NULL /* nextPtr */ + NULL, /* postscriptPtr */ + NULL /* nextPtr */ }; /* diff --git a/generic/tkText.c b/generic/tkText.c index 59071cd..870555e 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.62 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkText.c,v 1.63 2005/11/17 16:21:56 dkf Exp $ */ #include "default.h" @@ -52,7 +52,7 @@ */ static char *stateStrings[] = { - "disabled", "normal", (char *) NULL + "disabled", "normal", NULL }; /* @@ -62,7 +62,7 @@ static char *stateStrings[] = { */ static char *wrapStrings[] = { - "char", "none", "word", (char *) NULL + "char", "none", "word", NULL }; /* @@ -72,7 +72,7 @@ static char *wrapStrings[] = { */ static char *tabStyleStrings[] = { - "tabular", "wordprocessor", (char *) NULL + "tabular", "wordprocessor", NULL }; /* @@ -99,11 +99,11 @@ static void RestoreLineStartEnd(ClientData clientData, static int ObjectIsEmpty(Tcl_Obj *objPtr); static Tk_ObjCustomOption lineOption = { - "line", /* name */ - SetLineStartEnd, /* setProc */ - GetLineStartEnd, /* getProc */ - RestoreLineStartEnd, /* restoreProc */ - (Tk_CustomOptionFreeProc *)NULL, /* freeProc */ + "line", /* name */ + SetLineStartEnd, /* setProc */ + GetLineStartEnd, /* getProc */ + RestoreLineStartEnd, /* restoreProc */ + NULL, /* freeProc */ 0 }; @@ -118,11 +118,11 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", DEF_TEXT_BG_COLOR, -1, Tk_Offset(TkText, border), 0, (ClientData) DEF_TEXT_BG_MONO, 0}, - {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", + {TK_OPTION_SYNONYM, "-bd", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-borderwidth", TK_TEXT_LINE_GEOMETRY}, - {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-background", 0}, + {TK_OPTION_SYNONYM, "-bg", NULL, NULL, + NULL, 0, -1, 0, (ClientData) "-background", 0}, {TK_OPTION_BOOLEAN, "-blockcursor", "blockCursor", "BlockCursor", DEF_TEXT_BLOCK_CURSOR, -1, Tk_Offset(TkText, insertCursorType), 0, 0, 0}, @@ -132,14 +132,14 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_TEXT_CURSOR, -1, Tk_Offset(TkText, cursor), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_CUSTOM, "-endline", (char *) NULL, (char *) NULL, + {TK_OPTION_CUSTOM, "-endline", NULL, NULL, NULL, -1, Tk_Offset(TkText, end), TK_OPTION_NULL_OK, (ClientData) &lineOption, TK_TEXT_LINE_RANGE}, {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", "ExportSelection", DEF_TEXT_EXPORT_SELECTION, -1, Tk_Offset(TkText, exportSelection), 0, 0, 0}, - {TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, + NULL, 0, -1, 0, (ClientData) "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_TEXT_FONT, -1, Tk_Offset(TkText, tkfont), 0, 0, TK_TEXT_LINE_GEOMETRY}, @@ -215,7 +215,7 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing", DEF_TEXT_SPACING3, -1, Tk_Offset(TkText, spacing3), TK_OPTION_DONT_SET_DEFAULT, 0 , TK_TEXT_LINE_GEOMETRY }, - {TK_OPTION_CUSTOM, "-startline", (char *) NULL, (char *) NULL, + {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, -1, Tk_Offset(TkText, start), TK_OPTION_NULL_OK, (ClientData) &lineOption, TK_TEXT_LINE_RANGE}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", @@ -496,7 +496,7 @@ CreateWidget(sharedPtr, tkwin, interp, parent, objc, objv) */ newWin = Tk_CreateWindowFromPath(interp, tkwin, Tcl_GetString(objv[1]), - (char *) NULL); + NULL); if (newWin == NULL) { return TCL_ERROR; } @@ -691,7 +691,7 @@ TextWidgetObjCmd(clientData, interp, objc, objv) "bbox", "cget", "compare", "configure", "count", "debug", "delete", "dlineinfo", "dump", "edit", "get", "image", "index", "insert", "mark", "peer", "replace", "scan", "search", "see", - "tag", "window", "xview", "yview", (char *) NULL + "tag", "window", "xview", "yview", NULL }; enum options { TEXT_BBOX, TEXT_CGET, TEXT_COMPARE, TEXT_CONFIGURE, TEXT_COUNT, @@ -783,8 +783,7 @@ TextWidgetObjCmd(clientData, interp, objc, objv) compareError: Tcl_AppendResult(interp, "bad comparison operator \"", Tcl_GetString(objv[3]), - "\": must be <, <=, ==, >=, >, or !=", - (char *) NULL); + "\": must be <, <=, ==, >=, >, or !=", NULL); result = TCL_ERROR; goto done; } @@ -808,8 +807,7 @@ TextWidgetObjCmd(clientData, interp, objc, objv) case TEXT_CONFIGURE: if (objc <= 3) { Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *) textPtr, - textPtr->optionTable, - ((objc == 3) ? objv[2] : (Tcl_Obj *) NULL), + textPtr->optionTable, ((objc == 3) ? objv[2] : NULL), textPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; @@ -1539,7 +1537,7 @@ SharedTextObjCmd(clientData, interp, objc, objv) int index; static CONST char *optionStrings[] = { - "delete", "insert", (char *) NULL + "delete", "insert", NULL }; enum options { TEXT_DELETE, TEXT_INSERT @@ -1644,7 +1642,7 @@ TextPeerCmd(textPtr, interp, objc, objv) int index; static CONST char *peerOptionStrings[] = { - "create", "names", (char *) NULL + "create", "names", NULL }; enum peerOptions { PEER_CREATE, PEER_NAMES @@ -2168,8 +2166,7 @@ ConfigureText(interp, textPtr, objc, objv) || (textPtr->selTagPtr->underlineString != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } - TkTextRedrawTag(NULL, textPtr, (TkTextIndex *) NULL, (TkTextIndex *) NULL, - textPtr->selTagPtr, 1); + TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); /* * Claim the selection if we've suddenly started exporting it and there @@ -3611,8 +3608,7 @@ TextSearchCmd(textPtr, interp, objc, objv) Tcl_AppendResult(interp, "bad switch \"", Tcl_GetString(objv[i]), "\": must be --, -all, -backward, -count, -elide, ", "-exact, -forward, -nocase, -nolinestop, -overlap, ", - "-regexp, or -strictlimits", - (char *) NULL); + "-regexp, or -strictlimits", NULL); return TCL_ERROR; } @@ -4261,7 +4257,7 @@ TkTextGetTabs(interp, textPtr, stringPtr) * Map these strings to TkTextTabAlign values. */ static CONST char *tabOptionStrings[] = { - "left", "right", "center", "numeric", (char *) NULL + "left", "right", "center", "numeric", NULL }; if (Tcl_ListObjGetElements(interp, stringPtr, &objc, &objv) != TCL_OK) { @@ -4584,7 +4580,7 @@ DumpLine(interp, textPtr, what, linePtr, startByte, endByte, lineno, command) */ for (offset = 0, segPtr = linePtr->segPtr ; - (offset < endByte) && (segPtr != (TkTextSegment *)NULL) ; + (offset < endByte) && (segPtr != NULL) ; offset += segPtr->size, segPtr = segPtr->nextPtr) { if ((what & TK_DUMP_TEXT) && (segPtr->typePtr == &tkTextCharType) && (offset + segPtr->size > startByte)) { @@ -4709,7 +4705,7 @@ DumpSegment(textPtr, interp, key, value, command, index, what) argv[2] = buffer; argv[3] = NULL; list = Tcl_Merge(3, argv); - result = Tcl_VarEval(interp, command, " ", list, (char *) NULL); + result = Tcl_VarEval(interp, command, " ", list, NULL); ckfree(list); return result; } @@ -4825,7 +4821,7 @@ TextEditCmd(textPtr, interp, objc, objv) int index; static CONST char *editOptionStrings[] = { - "modified", "redo", "reset", "separator", "undo", (char *) NULL + "modified", "redo", "reset", "separator", "undo", NULL }; enum editOptions { EDIT_MODIFIED, EDIT_REDO, EDIT_RESET, EDIT_SEPARATOR, EDIT_UNDO @@ -4891,7 +4887,7 @@ TextEditCmd(textPtr, interp, objc, objv) return TCL_ERROR; } if (TextEditRedo(textPtr)) { - Tcl_AppendResult(interp, "nothing to redo", (char *) NULL); + Tcl_AppendResult(interp, "nothing to redo", NULL); return TCL_ERROR; } break; @@ -4915,7 +4911,7 @@ TextEditCmd(textPtr, interp, objc, objv) return TCL_ERROR; } if (TextEditUndo(textPtr)) { - Tcl_AppendResult(interp, "nothing to undo", (char *) NULL); + Tcl_AppendResult(interp, "nothing to undo", NULL); return TCL_ERROR; } break; diff --git a/generic/tkText.h b/generic/tkText.h index 2ccbfa9..3fd92ab 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -1,16 +1,15 @@ /* * tkText.h -- * - * Declarations shared among the files that implement text - * widgets. + * Declarations shared among the files that implement text widgets. * * Copyright (c) 1992-1994 The Regents of the University of California. * Copyright (c) 1994-1995 Sun Microsystems, Inc. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.h,v 1.27 2005/10/10 10:36:35 vincentdarley Exp $ + * RCS: @(#) $Id: tkText.h,v 1.28 2005/11/17 16:21:56 dkf Exp $ */ #ifndef _TKTEXT @@ -30,156 +29,142 @@ #endif /* - * Opaque types for structures whose guts are only needed by a single - * file. + * Opaque types for structures whose guts are only needed by a single file. */ typedef struct TkTextBTree_ *TkTextBTree; /* * The data structure below defines a single logical line of text (from - * newline to newline, not necessarily what appears on one display line - * of the screen). + * newline to newline, not necessarily what appears on one display line of the + * screen). */ typedef struct TkTextLine { - struct Node *parentPtr; /* Pointer to parent node containing - * line. */ - struct TkTextLine *nextPtr; /* Next in linked list of lines with - * same parent node in B-tree. NULL - * means end of list. */ - struct TkTextSegment *segPtr; /* First in ordered list of segments - * that make up the line. */ - int *pixels; /* Array containing two integers - * for each referring text widget. - * The first of these is the number - * of vertical pixels taken up by - * this line, whether currently - * displayed or not. This number - * is only updated asychronously. - * The second of these is the last - * epoch at which the pixel height - * was recalculated. */ + struct Node *parentPtr; /* Pointer to parent node containing line. */ + struct TkTextLine *nextPtr; /* Next in linked list of lines with same + * parent node in B-tree. NULL means end of + * list. */ + struct TkTextSegment *segPtr; + /* First in ordered list of segments that make + * up the line. */ + int *pixels; /* Array containing two integers for each + * referring text widget. The first of these + * is the number of vertical pixels taken up + * by this line, whether currently displayed + * or not. This number is only updated + * asychronously. The second of these is the + * last epoch at which the pixel height was + * recalculated. */ } TkTextLine; /* * ----------------------------------------------------------------------- * Segments: each line is divided into one or more segments, where each - * segment is one of several things, such as a group of characters, a - * tag toggle, a mark, or an embedded widget. Each segment starts with - * a standard header followed by a body that varies from type to type. + * segment is one of several things, such as a group of characters, a tag + * toggle, a mark, or an embedded widget. Each segment starts with a standard + * header followed by a body that varies from type to type. * ----------------------------------------------------------------------- */ /* - * The data structure below defines the body of a segment that represents - * a tag toggle. There is one of these structures at both the beginning - * and end of each tagged range. + * The data structure below defines the body of a segment that represents a + * tag toggle. There is one of these structures at both the beginning and end + * of each tagged range. */ typedef struct TkTextToggle { - struct TkTextTag *tagPtr; /* Tag that starts or ends here. */ - int inNodeCounts; /* 1 means this toggle has been - * accounted for in node toggle - * counts; 0 means it hasn't, yet. */ + struct TkTextTag *tagPtr; /* Tag that starts or ends here. */ + int inNodeCounts; /* 1 means this toggle has been accounted for + * in node toggle counts; 0 means it hasn't, + * yet. */ } TkTextToggle; /* - * The data structure below defines line segments that represent - * marks. There is one of these for each mark in the text. + * The data structure below defines line segments that represent marks. There + * is one of these for each mark in the text. */ typedef struct TkTextMark { - struct TkText *textPtr; /* Overall information about text - * widget. */ - TkTextLine *linePtr; /* Line structure that contains the - * segment. */ - Tcl_HashEntry *hPtr; /* Pointer to hash table entry for mark - * (in sharedTextPtr->markTable). */ + struct TkText *textPtr; /* Overall information about text widget. */ + TkTextLine *linePtr; /* Line structure that contains the + * segment. */ + Tcl_HashEntry *hPtr; /* Pointer to hash table entry for mark (in + * sharedTextPtr->markTable). */ } TkTextMark; /* * A structure of the following type holds information for each window - * embedded in a text widget. This information is only used by the - * file tkTextWind.c + * embedded in a text widget. This information is only used by the file + * tkTextWind.c */ typedef struct TkTextEmbWindowClient { - struct TkText *textPtr; /* Information about the overall text - * widget. */ - Tk_Window tkwin; /* Window for this segment. NULL - * means that the window hasn't - * been created yet. */ - int chunkCount; /* Number of display chunks that - * refer to this window. */ - int displayed; /* Non-zero means that the window - * has been displayed on the screen - * recently. */ + struct TkText *textPtr; /* Information about the overall text + * widget. */ + Tk_Window tkwin; /* Window for this segment. NULL means that + * the window hasn't been created yet. */ + int chunkCount; /* Number of display chunks that refer to this + * window. */ + int displayed; /* Non-zero means that the window has been + * displayed on the screen recently. */ struct TkTextSegment *parent; struct TkTextEmbWindowClient *next; } TkTextEmbWindowClient; typedef struct TkTextEmbWindow { - struct TkSharedText *sharedTextPtr; /* Information about the shared - * portion of the text widget. */ - Tk_Window tkwin; /* Window for this segment. - * This is just a temporary - * value, copied from - * 'clients', to make option - * table updating easier. NULL - * means that the window hasn't - * been created yet. */ - TkTextLine *linePtr; /* Line structure that contains this - * window. */ - char *create; /* Script to create window on-demand. - * NULL means no such script. - * Malloc-ed. */ - int align; /* How to align window in vertical - * space. See definitions in - * tkTextWind.c. */ - int padX, padY; /* Padding to leave around each side - * of window, in pixels. */ - int stretch; /* Should window stretch to fill - * vertical space of line (except for - * pady)? 0 or 1. */ - Tk_OptionTable optionTable; /* Token representing the - * configuration specifications. */ - TkTextEmbWindowClient *clients; /* Linked list of peer-widget - * specific information for - * this embedded window. */ + struct TkSharedText *sharedTextPtr; + /* Information about the shared portion of the + * text widget. */ + Tk_Window tkwin; /* Window for this segment. This is just a + * temporary value, copied from 'clients', to + * make option table updating easier. NULL + * means that the window hasn't been created + * yet. */ + TkTextLine *linePtr; /* Line structure that contains this + * window. */ + char *create; /* Script to create window on-demand. NULL + * means no such script. Malloc-ed. */ + int align; /* How to align window in vertical space. See + * definitions in tkTextWind.c. */ + int padX, padY; /* Padding to leave around each side of + * window, in pixels. */ + int stretch; /* Should window stretch to fill vertical + * space of line (except for pady)? 0 or 1. */ + Tk_OptionTable optionTable; /* Token representing the configuration + * specifications. */ + TkTextEmbWindowClient *clients; + /* Linked list of peer-widget specific + * information for this embedded window. */ } TkTextEmbWindow; /* - * A structure of the following type holds information for each image - * embedded in a text widget. This information is only used by the - * file tkTextImage.c + * A structure of the following type holds information for each image embedded + * in a text widget. This information is only used by the file tkTextImage.c */ typedef struct TkTextEmbImage { - struct TkSharedText *sharedTextPtr; /* Information about the shared - * portion of the text widget. - * This is used when the image - * changes or is deleted. */ - TkTextLine *linePtr; /* Line structure that contains this - * image. */ - char *imageString; /* Name of the image for this segment */ - char *imageName; /* Name used by text widget to identify - * this image. May be unique-ified */ - char *name; /* Name used in the hash table. - * used by "image names" to identify - * this instance of the image */ - Tk_Image image; /* Image for this segment. NULL - * means that the image hasn't - * been created yet. */ - int align; /* How to align image in vertical - * space. See definitions in - * tkTextImage.c. */ - int padX, padY; /* Padding to leave around each side - * of image, in pixels. */ - int chunkCount; /* Number of display chunks that - * refer to this image. */ - Tk_OptionTable optionTable; /* Token representing the - * configuration specifications. */ + struct TkSharedText *sharedTextPtr; + /* Information about the shared portion of the + * text widget. This is used when the image + * changes or is deleted. */ + TkTextLine *linePtr; /* Line structure that contains this image. */ + char *imageString; /* Name of the image for this segment */ + char *imageName; /* Name used by text widget to identify this + * image. May be unique-ified */ + char *name; /* Name used in the hash table. Used by + * "image names" to identify this instance of + * the image */ + Tk_Image image; /* Image for this segment. NULL means that the + * image hasn't been created yet. */ + int align; /* How to align image in vertical space. See + * definitions in tkTextImage.c. */ + int padX, padY; /* Padding to leave around each side of image, + * in pixels. */ + int chunkCount; /* Number of display chunks that refer to this + * image. */ + Tk_OptionTable optionTable; /* Token representing the configuration + * specifications. */ } TkTextEmbImage; /* @@ -187,45 +172,42 @@ typedef struct TkTextEmbImage { */ typedef struct TkTextSegment { - struct Tk_SegType *typePtr; /* Pointer to record describing - * segment's type. */ - struct TkTextSegment *nextPtr; /* Next in list of segments for this - * line, or NULL for end of list. */ - int size; /* Size of this segment (# of bytes - * of index space it occupies). */ + struct Tk_SegType *typePtr; /* Pointer to record describing segment's + * type. */ + struct TkTextSegment *nextPtr; + /* Next in list of segments for this line, or + * NULL for end of list. */ + int size; /* Size of this segment (# of bytes of index + * space it occupies). */ union { - char chars[4]; /* Characters that make up character - * info. Actual length varies to - * hold as many characters as needed.*/ - TkTextToggle toggle; /* Information about tag toggle. */ - TkTextMark mark; /* Information about mark. */ - TkTextEmbWindow ew; /* Information about embedded - * window. */ - TkTextEmbImage ei; /* Information about embedded - * image. */ + char chars[4]; /* Characters that make up character info. + * Actual length varies to hold as many + * characters as needed.*/ + TkTextToggle toggle; /* Information about tag toggle. */ + TkTextMark mark; /* Information about mark. */ + TkTextEmbWindow ew; /* Information about embedded window. */ + TkTextEmbImage ei; /* Information about embedded image. */ } body; } TkTextSegment; /* - * Data structures of the type defined below are used during the - * execution of Tcl commands to keep track of various interesting - * places in a text. An index is only valid up until the next - * modification to the character structure of the b-tree so they - * can't be retained across Tcl commands. However, mods to marks - * or tags don't invalidate indices. + * Data structures of the type defined below are used during the execution of + * Tcl commands to keep track of various interesting places in a text. An + * index is only valid up until the next modification to the character + * structure of the b-tree so they can't be retained across Tcl commands. + * However, mods to marks or tags don't invalidate indices. */ typedef struct TkTextIndex { - TkTextBTree tree; /* Tree containing desired position. */ - TkTextLine *linePtr; /* Pointer to line containing position - * of interest. */ - int byteIndex; /* Index within line of desired - * character (0 means first one). */ - struct TkText *textPtr; /* May be NULL, but otherwise - * the text widget with which - * this index is associated. - * If not NULL, then we have a - * refCount on the widget. */ + TkTextBTree tree; /* Tree containing desired position. */ + TkTextLine *linePtr; /* Pointer to line containing position of + * interest. */ + int byteIndex; /* Index within line of desired character (0 + * means first one). */ + struct TkText *textPtr; /* May be NULL, but otherwise the text widget + * with which this index is associated. If not + * NULL, then we have a refCount on the + * widget. */ } TkTextIndex; /* @@ -234,207 +216,197 @@ typedef struct TkTextIndex { typedef struct TkTextDispChunk TkTextDispChunk; -typedef void Tk_ChunkDisplayProc _ANSI_ARGS_(( - struct TkText *textPtr, +typedef void Tk_ChunkDisplayProc(struct TkText *textPtr, TkTextDispChunk *chunkPtr, int x, int y, int height, int baseline, Display *display, - Drawable dst, int screenY)); -typedef void Tk_ChunkUndisplayProc _ANSI_ARGS_(( - struct TkText *textPtr, - TkTextDispChunk *chunkPtr)); -typedef int Tk_ChunkMeasureProc _ANSI_ARGS_(( - TkTextDispChunk *chunkPtr, int x)); -typedef void Tk_ChunkBboxProc _ANSI_ARGS_(( - struct TkText *textPtr, + Drawable dst, int screenY); +typedef void Tk_ChunkUndisplayProc(struct TkText *textPtr, + TkTextDispChunk *chunkPtr); +typedef int Tk_ChunkMeasureProc(TkTextDispChunk *chunkPtr, int x); +typedef void Tk_ChunkBboxProc(struct TkText *textPtr, TkTextDispChunk *chunkPtr, int index, int y, int lineHeight, int baseline, int *xPtr, - int *yPtr, int *widthPtr, int *heightPtr)); + int *yPtr, int *widthPtr, int *heightPtr); /* - * The structure below represents a chunk of stuff that is displayed - * together on the screen. This structure is allocated and freed by - * generic display code but most of its fields are filled in by - * segment-type-specific code. + * The structure below represents a chunk of stuff that is displayed together + * on the screen. This structure is allocated and freed by generic display + * code but most of its fields are filled in by segment-type-specific code. */ struct TkTextDispChunk { /* - * The fields below are set by the type-independent code before - * calling the segment-type-specific layoutProc. They should not - * be modified by segment-type-specific code. + * The fields below are set by the type-independent code before calling + * the segment-type-specific layoutProc. They should not be modified by + * segment-type-specific code. */ - int x; /* X position of chunk, in pixels. - * This position is measured from the - * left edge of the logical line, - * not from the left edge of the - * window (i.e. it doesn't change - * under horizontal scrolling). */ - struct TkTextDispChunk *nextPtr; /* Next chunk in the display line - * or NULL for the end of the list. */ - struct TextStyle *stylePtr; /* Display information, known only - * to tkTextDisp.c. */ + int x; /* X position of chunk, in pixels. This + * position is measured from the left edge of + * the logical line, not from the left edge of + * the window (i.e. it doesn't change under + * horizontal scrolling). */ + struct TkTextDispChunk *nextPtr; + /* Next chunk in the display line or NULL for + * the end of the list. */ + struct TextStyle *stylePtr; /* Display information, known only to + * tkTextDisp.c. */ /* - * The fields below are set by the layoutProc that creates the - * chunk. + * The fields below are set by the layoutProc that creates the chunk. */ - Tk_ChunkDisplayProc *displayProc; /* Procedure to invoke to draw this - * chunk on the display or an - * off-screen pixmap. */ + Tk_ChunkDisplayProc *displayProc; + /* Procedure to invoke to draw this chunk on + * the display or an off-screen pixmap. */ Tk_ChunkUndisplayProc *undisplayProc; - /* Procedure to invoke when segment - * ceases to be displayed on screen - * anymore. */ - Tk_ChunkMeasureProc *measureProc; /* Procedure to find character under - * a given x-location. */ - Tk_ChunkBboxProc *bboxProc; /* Procedure to find bounding box - * of character in chunk. */ - int numBytes; /* Number of bytes that will be - * displayed in the chunk. */ - int minAscent; /* Minimum space above the baseline - * needed by this chunk. */ - int minDescent; /* Minimum space below the baseline - * needed by this chunk. */ - int minHeight; /* Minimum total line height needed - * by this chunk. */ - int width; /* Width of this chunk, in pixels. - * Initially set by chunk-specific - * code, but may be increased to - * include tab or extra space at end - * of line. */ - int breakIndex; /* Index within chunk of last - * acceptable position for a line - * (break just before this byte index). - * <= 0 means don't break during or - * immediately after this chunk. */ - ClientData clientData; /* Additional information for use - * of displayProc and undisplayProc. */ + /* Procedure to invoke when segment ceases to + * be displayed on screen anymore. */ + Tk_ChunkMeasureProc *measureProc; + /* Procedure to find character under a given + * x-location. */ + Tk_ChunkBboxProc *bboxProc; /* Procedure to find bounding box of character + * in chunk. */ + int numBytes; /* Number of bytes that will be displayed in + * the chunk. */ + int minAscent; /* Minimum space above the baseline needed by + * this chunk. */ + int minDescent; /* Minimum space below the baseline needed by + * this chunk. */ + int minHeight; /* Minimum total line height needed by this + * chunk. */ + int width; /* Width of this chunk, in pixels. Initially + * set by chunk-specific code, but may be + * increased to include tab or extra space at + * end of line. */ + int breakIndex; /* Index within chunk of last acceptable + * position for a line (break just before this + * byte index). <= 0 means don't break during + * or immediately after this chunk. */ + ClientData clientData; /* Additional information for use of + * displayProc and undisplayProc. */ }; /* - * One data structure of the following type is used for each tag in a - * text widget. These structures are kept in sharedTextPtr->tagTable - * and referred to in other structures. + * One data structure of the following type is used for each tag in a text + * widget. These structures are kept in sharedTextPtr->tagTable and referred + * to in other structures. */ -typedef enum { TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, - TEXT_WRAPMODE_WORD, TEXT_WRAPMODE_NULL +typedef enum { + TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, + TEXT_WRAPMODE_NULL } TkWrapMode; typedef struct TkTextTag { - CONST char *name; /* Name of this tag. This field is - * actually a pointer to the key from - * the entry in - * sharedTextPtr->tagTable, so it - * needn't be freed explicitly. For - * 'sel' tags this is just a static - * string, so again need not be freed. - * */ - CONST struct TkText *textPtr;/* If non-NULL, then this tag only - * applies to the given text widget - * (when there are peer widgets). */ - int priority; /* Priority of this tag within widget. 0 - * means lowest priority. Exactly one tag - * has each integer value between 0 and - * numTags-1. */ - struct Node *tagRootPtr; /* Pointer into the B-Tree at the lowest - * node that completely dominates the ranges - * of text occupied by the tag. At this - * node there is no information about the - * tag. One or more children of the node - * do contain information about the tag. */ + CONST char *name; /* Name of this tag. This field is actually a + * pointer to the key from the entry in + * sharedTextPtr->tagTable, so it needn't be + * freed explicitly. For 'sel' tags this is + * just a static string, so again need not be + * freed. */ + CONST struct TkText*textPtr;/* If non-NULL, then this tag only applies to + * the given text widget (when there are peer + * widgets). */ + int priority; /* Priority of this tag within widget. 0 means + * lowest priority. Exactly one tag has each + * integer value between 0 and numTags-1. */ + struct Node *tagRootPtr; /* Pointer into the B-Tree at the lowest node + * that completely dominates the ranges of + * text occupied by the tag. At this node + * there is no information about the tag. One + * or more children of the node do contain + * information about the tag. */ int toggleCount; /* Total number of tag toggles */ /* - * Information for displaying text with this tag. The information - * belows acts as an override on information specified by lower-priority - * tags. If no value is specified, then the next-lower-priority tag - * on the text determins the value. The text widget itself provides - * defaults if no tag specifies an override. + * Information for displaying text with this tag. The information belows + * acts as an override on information specified by lower-priority tags. + * If no value is specified, then the next-lower-priority tag on the text + * determins the value. The text widget itself provides defaults if no tag + * specifies an override. */ - Tk_3DBorder border; /* Used for drawing background. NULL means - * no value specified here. */ + Tk_3DBorder border; /* Used for drawing background. NULL means no + * value specified here. */ int borderWidth; /* Width of 3-D border for background. */ Tcl_Obj* borderWidthPtr; /* Width of 3-D border for background. */ - char *reliefString; /* -relief option string (malloc-ed). - * NULL means option not specified. */ + char *reliefString; /* -relief option string (malloc-ed). NULL + * means option not specified. */ int relief; /* 3-D relief for background. */ - Pixmap bgStipple; /* Stipple bitmap for background. None - * means no value specified here. */ - XColor *fgColor; /* Foreground color for text. NULL means - * no value specified here. */ - Tk_Font tkfont; /* Font for displaying text. NULL means + Pixmap bgStipple; /* Stipple bitmap for background. None means * no value specified here. */ + XColor *fgColor; /* Foreground color for text. NULL means no + * value specified here. */ + Tk_Font tkfont; /* Font for displaying text. NULL means no + * value specified here. */ Pixmap fgStipple; /* Stipple bitmap for text and other - * foreground stuff. None means no value + * foreground stuff. None means no value * specified here.*/ - char *justifyString; /* -justify option string (malloc-ed). - * NULL means option not specified. */ + char *justifyString; /* -justify option string (malloc-ed). NULL + * means option not specified. */ Tk_Justify justify; /* How to justify text: TK_JUSTIFY_LEFT, * TK_JUSTIFY_RIGHT, or TK_JUSTIFY_CENTER. * Only valid if justifyString is non-NULL. */ - char *lMargin1String; /* -lmargin1 option string (malloc-ed). - * NULL means option not specified. */ - int lMargin1; /* Left margin for first display line of - * each text line, in pixels. Only valid - * if lMargin1String is non-NULL. */ - char *lMargin2String; /* -lmargin2 option string (malloc-ed). - * NULL means option not specified. */ + char *lMargin1String; /* -lmargin1 option string (malloc-ed). NULL + * means option not specified. */ + int lMargin1; /* Left margin for first display line of each + * text line, in pixels. Only valid if + * lMargin1String is non-NULL. */ + char *lMargin2String; /* -lmargin2 option string (malloc-ed). NULL + * means option not specified. */ int lMargin2; /* Left margin for second and later display - * lines of each text line, in pixels. Only + * lines of each text line, in pixels. Only * valid if lMargin2String is non-NULL. */ - char *offsetString; /* -offset option string (malloc-ed). - * NULL means option not specified. */ + char *offsetString; /* -offset option string (malloc-ed). NULL + * means option not specified. */ int offset; /* Vertical offset of text's baseline from - * baseline of line. Used for superscripts - * and subscripts. Only valid if - * offsetString is non-NULL. */ - char *overstrikeString; /* -overstrike option string (malloc-ed). - * NULL means option not specified. */ + * baseline of line. Used for superscripts and + * subscripts. Only valid if offsetString is + * non-NULL. */ + char *overstrikeString; /* -overstrike option string (malloc-ed). NULL + * means option not specified. */ int overstrike; /* Non-zero means draw horizontal line through - * middle of text. Only valid if + * middle of text. Only valid if * overstrikeString is non-NULL. */ - char *rMarginString; /* -rmargin option string (malloc-ed). - * NULL means option not specified. */ - int rMargin; /* Right margin for text, in pixels. Only + char *rMarginString; /* -rmargin option string (malloc-ed). NULL + * means option not specified. */ + int rMargin; /* Right margin for text, in pixels. Only * valid if rMarginString is non-NULL. */ - char *spacing1String; /* -spacing1 option string (malloc-ed). - * NULL means option not specified. */ - int spacing1; /* Extra spacing above first display - * line for text line. Only valid if - * spacing1String is non-NULL. */ - char *spacing2String; /* -spacing2 option string (malloc-ed). - * NULL means option not specified. */ - int spacing2; /* Extra spacing between display - * lines for the same text line. Only valid - * if spacing2String is non-NULL. */ - char *spacing3String; /* -spacing2 option string (malloc-ed). - * NULL means option not specified. */ - int spacing3; /* Extra spacing below last display - * line for text line. Only valid if - * spacing3String is non-NULL. */ - Tcl_Obj *tabStringPtr; /* -tabs option string. - * NULL means option not specified. */ + char *spacing1String; /* -spacing1 option string (malloc-ed). NULL + * means option not specified. */ + int spacing1; /* Extra spacing above first display line for + * text line. Only valid if spacing1String is + * non-NULL. */ + char *spacing2String; /* -spacing2 option string (malloc-ed). NULL + * means option not specified. */ + int spacing2; /* Extra spacing between display lines for the + * same text line. Only valid if + * spacing2String is non-NULL. */ + char *spacing3String; /* -spacing2 option string (malloc-ed). NULL + * means option not specified. */ + int spacing3; /* Extra spacing below last display line for + * text line. Only valid if spacing3String is + * non-NULL. */ + Tcl_Obj *tabStringPtr; /* -tabs option string. NULL means option not + * specified. */ struct TkTextTabArray *tabArrayPtr; - /* Info about tabs for tag (malloc-ed) - * or NULL. Corresponds to tabString. */ - int tabStyle; /* One of TABULAR or WORDPROCESSOR or - * NONE (if not specified). */ - char *underlineString; /* -underline option string (malloc-ed). - * NULL means option not specified. */ + /* Info about tabs for tag (malloc-ed) or + * NULL. Corresponds to tabString. */ + int tabStyle; /* One of TABULAR or WORDPROCESSOR or NONE (if + * not specified). */ + char *underlineString; /* -underline option string (malloc-ed). NULL + * means option not specified. */ int underline; /* Non-zero means draw underline underneath - * text. Only valid if underlineString is + * text. Only valid if underlineString is * non-NULL. */ TkWrapMode wrapMode; /* How to handle wrap-around for this tag. * Must be TEXT_WRAPMODE_CHAR, - * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, - * or TEXT_WRAPMODE_NULL to use wrapmode for + * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or + * TEXT_WRAPMODE_NULL to use wrapmode for * whole widget. */ - char *elideString; /* -elide option string (malloc-ed). - * NULL means option not specified. */ + char *elideString; /* -elide option string (malloc-ed). NULL + * means option not specified. */ int elide; /* Non-zero means that data under this tag * should not be displayed. */ int affectsDisplay; /* Non-zero means that this tag affects the @@ -442,9 +414,9 @@ typedef struct TkTextTag { * (so need to redisplay if tag changes). */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ - int affectsDisplayGeometry; /* Non-zero means that this tag affects the - * size with which information is displayed - * on the screen (so need to recalculate line + int affectsDisplayGeometry; /* Non-zero means that this tag affects the + * size with which information is displayed on + * the screen (so need to recalculate line * dimensions if tag changes). */ } TkTextTag; @@ -454,91 +426,86 @@ typedef struct TkTextTag { #define TK_TAG_OFFSET 0x10 /* - * The data structure below is used for searching a B-tree for transitions - * on a single tag (or for all tag transitions). No code outside of - * tkTextBTree.c should ever modify any of the fields in these structures, - * but it's OK to use them for read-only information. + * The data structure below is used for searching a B-tree for transitions on + * a single tag (or for all tag transitions). No code outside of tkTextBTree.c + * should ever modify any of the fields in these structures, but it's OK to + * use them for read-only information. */ typedef struct TkTextSearch { - TkTextIndex curIndex; /* Position of last tag transition - * returned by TkBTreeNextTag, or - * index of start of segment - * containing starting position for - * search if TkBTreeNextTag hasn't - * been called yet, or same as - * stopIndex if search is over. */ - TkTextSegment *segPtr; /* Actual tag segment returned by last - * call to TkBTreeNextTag, or NULL if - * TkBTreeNextTag hasn't returned - * anything yet. */ - TkTextSegment *nextPtr; /* Where to resume search in next - * call to TkBTreeNextTag. */ - TkTextSegment *lastPtr; /* Stop search before just before - * considering this segment. */ - TkTextTag *tagPtr; /* Tag to search for (or tag found, if - * allTags is non-zero). */ - int linesLeft; /* Lines left to search (including - * curIndex and stopIndex). When - * this becomes <= 0 the search is - * over. */ - int allTags; /* Non-zero means ignore tag check: - * search for transitions on all - * tags. */ + TkTextIndex curIndex; /* Position of last tag transition returned by + * TkBTreeNextTag, or index of start of + * segment containing starting position for + * search if TkBTreeNextTag hasn't been called + * yet, or same as stopIndex if search is + * over. */ + TkTextSegment *segPtr; /* Actual tag segment returned by last call to + * TkBTreeNextTag, or NULL if TkBTreeNextTag + * hasn't returned anything yet. */ + TkTextSegment *nextPtr; /* Where to resume search in next call to + * TkBTreeNextTag. */ + TkTextSegment *lastPtr; /* Stop search before just before considering + * this segment. */ + TkTextTag *tagPtr; /* Tag to search for (or tag found, if allTags + * is non-zero). */ + int linesLeft; /* Lines left to search (including curIndex + * and stopIndex). When this becomes <= 0 the + * search is over. */ + int allTags; /* Non-zero means ignore tag check: search for + * transitions on all tags. */ } TkTextSearch; /* - * The following data structure describes a single tab stop. It must be - * kept in sync with the 'tabOptionStrings' array in the function - * 'TkTextGetTabs' + * The following data structure describes a single tab stop. It must be kept + * in sync with the 'tabOptionStrings' array in the function 'TkTextGetTabs' */ typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign; /* - * The following are the supported styles of tabbing, used for the - * -tabstyle option of the text widget. The last element is only - * used for tag options. + * The following are the supported styles of tabbing, used for the -tabstyle + * option of the text widget. The last element is only used for tag options. */ + typedef enum { - TK_TEXT_TABSTYLE_TABULAR, - TK_TEXT_TABSTYLE_WORDPROCESSOR, + TK_TEXT_TABSTYLE_TABULAR, + TK_TEXT_TABSTYLE_WORDPROCESSOR, TK_TEXT_TABSTYLE_NONE } TkTextTabStyle; typedef struct TkTextTab { - int location; /* Offset in pixels of this tab stop - * from the left margin (lmargin2) of - * the text. */ - TkTextTabAlign alignment; /* Where the tab stop appears relative - * to the text. */ + int location; /* Offset in pixels of this tab stop from the + * left margin (lmargin2) of the text. */ + TkTextTabAlign alignment; /* Where the tab stop appears relative to the + * text. */ } TkTextTab; typedef struct TkTextTabArray { - int numTabs; /* Number of tab stops. */ - double lastTab; /* The accurate fractional pixel - * position of the last tab. */ - double tabIncrement; /* The accurate fractional pixel - * increment between interpolated - * tabs we have to create when - * we exceed numTabs. */ - TkTextTab tabs[1]; /* Array of tabs. The actual size - * will be numTabs. THIS FIELD MUST - * BE THE LAST IN THE STRUCTURE. */ + int numTabs; /* Number of tab stops. */ + double lastTab; /* The accurate fractional pixel position of + * the last tab. */ + double tabIncrement; /* The accurate fractional pixel increment + * between interpolated tabs we have to create + * when we exceed numTabs. */ + TkTextTab tabs[1]; /* Array of tabs. The actual size will be + * numTabs. THIS FIELD MUST BE THE LAST IN THE + * STRUCTURE. */ } TkTextTabArray; -/* enum definining the edit modes of */ +/* + * Enumeration definining the edit modes of the widget. + */ typedef enum { - TK_TEXT_EDIT_INSERT, /* insert mode */ - TK_TEXT_EDIT_DELETE, /* delete mode */ - TK_TEXT_EDIT_REPLACE, /* replace mode */ - TK_TEXT_EDIT_OTHER /* none of the above */ + TK_TEXT_EDIT_INSERT, /* insert mode */ + TK_TEXT_EDIT_DELETE, /* delete mode */ + TK_TEXT_EDIT_REPLACE, /* replace mode */ + TK_TEXT_EDIT_OTHER /* none of the above */ } TkTextEditMode; /* - * The following enum is used to define a type for the -state option - * of the Text widget. + * The following enum is used to define a type for the -state option of the + * Text widget. */ typedef enum { @@ -556,77 +523,64 @@ typedef struct TkSharedText { TkTextBTree tree; /* B-tree representation of text and tags for * widget. */ Tcl_HashTable tagTable; /* Hash table that maps from tag names to - * pointers to TkTextTag structures. - * The "sel" tag does not feature in - * this table, since there's one of - * those for each text peer. */ + * pointers to TkTextTag structures. The "sel" + * tag does not feature in this table, since + * there's one of those for each text peer. */ int numTags; /* Number of tags currently defined for - * widget; needed to keep track of + * widget; needed to keep track of * priorities. */ Tcl_HashTable markTable; /* Hash table that maps from mark names to - * pointers to mark segments. The - * special "insert" and "current" marks - * are not stored in this table, but - * directly accessed as fields of - * textPtr. */ - Tcl_HashTable windowTable; /* Hash table that maps from window names - * to pointers to window segments. If a - * window segment doesn't yet have an - * associated window, there is no entry for - * it here. */ - Tcl_HashTable imageTable; /* Hash table that maps from image names - * to pointers to image segments. If an - * image segment doesn't yet have an - * associated image, there is no entry for - * it here. */ + * pointers to mark segments. The special + * "insert" and "current" marks are not stored + * in this table, but directly accessed as + * fields of textPtr. */ + Tcl_HashTable windowTable; /* Hash table that maps from window names to + * pointers to window segments. If a window + * segment doesn't yet have an associated + * window, there is no entry for it here. */ + Tcl_HashTable imageTable; /* Hash table that maps from image names to + * pointers to image segments. If an image + * segment doesn't yet have an associated + * image, there is no entry for it here. */ Tk_BindingTable bindingTable; - /* Table of all bindings currently defined - * for this widget. NULL means that no - * bindings 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 contents change - * structurally, and means that any - * cached TkTextIndex objects are no + /* Table of all bindings currently defined for + * this widget. NULL means that no bindings + * 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 + * contents change structurally, and means + * that any cached TkTextIndex objects are no * longer valid. */ /* * Information related to the undo/redo functonality */ - + TkUndoRedoStack *undoStack; /* The undo/redo stack */ - - int undo; /* Non-zero means the undo/redo behaviour is + int undo; /* Non-zero means the undo/redo behaviour is * enabled */ - - int maxUndo; /* The maximum depth of the undo stack - * expressed as the maximum number of - * compound statements */ - - int autoSeparators; /* Non-zero means the separators will be + int maxUndo; /* The maximum depth of the undo stack + * expressed as the maximum number of compound + * statements */ + int autoSeparators; /* Non-zero means the separators will be * inserted automatically */ - int modifiedSet; /* Flag indicating that the 'dirtynesss' of - * the text widget has been expplicitly set. - */ - - int isDirty; /* Flag indicating the 'dirtynesss' of the text - * widget. If the flag is not zero, unsaved - * modifications have been applied to the - * text widget */ - + * the text widget has been expplicitly set. */ + int isDirty; /* Flag indicating the 'dirtynesss' of the + * text widget. If the flag is not zero, + * unsaved modifications have been applied to + * the text widget */ int isDirtyIncrement; /* Amount with which the isDirty flag is * incremented every edit action */ - - TkTextEditMode lastEditMode;/* Keeps track of what the last edit - * mode was */ + TkTextEditMode lastEditMode;/* Keeps track of what the last edit mode + * was */ /* * Keep track of all the peers */ - struct TkText *peers; + struct TkText *peers; } TkSharedText; /* @@ -642,38 +596,37 @@ typedef struct TkText { TkSharedText *sharedTextPtr;/* Shared section of all peers. */ struct TkText *next; /* Next in list of linked peers. */ - TkTextLine *start; /* First B-tree line to show, or NULL - * to start at the beginning. */ - TkTextLine *end; /* Last B-tree line to show, or NULL - * for up to the end. */ - int pixelReference; /* Counter into the current tree - * reference index corresponding to - * this widget */ - - int abortSelections; /* Set to 1 whenever the text is modified - * in a way that interferes with selection - * retrieval: used to abort incremental + TkTextLine *start; /* First B-tree line to show, or NULL to start + * at the beginning. */ + TkTextLine *end; /* Last B-tree line to show, or NULL for up to + * the end. */ + int pixelReference; /* Counter into the current tree reference + * index corresponding to this widget */ + + int abortSelections; /* Set to 1 whenever the text is modified in a + * way that interferes with selection + * retrieval: used to abort incremental * selection retrievals. */ - /* + /* * Standard Tk widget information and text-widget specific items */ - - Tk_Window tkwin; /* Window that embodies the text. NULL - * means that the window has been destroyed - * but the data structures haven't yet been - * cleaned up.*/ - Display *display; /* Display for widget. Needed, among other - * things, to allow resources to be freed - * even after tkwin has gone away. */ - Tcl_Interp *interp; /* Interpreter associated with widget. Used - * to delete widget command. */ + + Tk_Window tkwin; /* Window that embodies the text. NULL means + * that the window has been destroyed but the + * data structures haven't yet been cleaned + * up.*/ + Display *display; /* Display for widget. Needed, among other + * things, to allow resources to be freed even + * after tkwin has gone away. */ + Tcl_Interp *interp; /* Interpreter associated with widget. Used to + * delete widget command. */ Tcl_Command widgetCmd; /* Token for text's widget command. */ int state; /* Either STATE_NORMAL or STATE_DISABLED. A * text widget is read-only when disabled. */ /* - * Default information for displaying (may be overridden by tags - * applied to ranges of characters). + * Default information for displaying (may be overridden by tags applied + * to ranges of characters). */ Tk_3DBorder border; /* Structure used to draw 3-D border and @@ -681,14 +634,14 @@ typedef struct TkText { int borderWidth; /* Width of 3-D border to draw around entire * widget. */ int padX, padY; /* Padding between text and window border. */ - int relief; /* 3-d effect for border around entire - * widget: TK_RELIEF_RAISED etc. */ - int highlightWidth; /* Width in pixels of highlight to draw - * around widget when it has the focus. - * <= 0 means don't draw a highlight. */ + int relief; /* 3-d effect for border around entire widget: + * TK_RELIEF_RAISED etc. */ + int highlightWidth; /* Width in pixels of highlight to draw around + * widget when it has the focus. <= 0 means + * don't draw a highlight. */ XColor *highlightBgColorPtr; - /* Color for drawing traversal highlight - * area when highlight is off. */ + /* Color for drawing traversal highlight area + * when highlight is off. */ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ Tk_Cursor cursor; /* Current cursor for window, or None. */ XColor *fgColor; /* Default foreground color for text. */ @@ -714,14 +667,14 @@ typedef struct TkText { * Additional information used for displaying: */ - TkWrapMode wrapMode; /* How to handle wrap-around. Must be + TkWrapMode wrapMode; /* How to handle wrap-around. Must be * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or * TEXT_WRAPMODE_WORD. */ - int width, height; /* Desired dimensions for window, measured - * in characters. */ - int setGrid; /* Non-zero means pass gridding information - * to window manager. */ - int prevWidth, prevHeight; /* Last known dimensions of window; used to + int width, height; /* Desired dimensions for window, measured in + * characters. */ + int setGrid; /* Non-zero means pass gridding information to + * window manager. */ + int prevWidth, prevHeight; /* Last known dimensions of window; used to * detect changes in size. */ TkTextIndex topIndex; /* Identifies first character in top display * line of window. */ @@ -731,26 +684,27 @@ typedef struct TkText { * Information related to selection. */ - TkTextTag *selTagPtr; /* Pointer to "sel" tag. Used to tell when - * a new selection has been made. */ + TkTextTag *selTagPtr; /* Pointer to "sel" tag. Used to tell when a + * new selection has been made. */ Tk_3DBorder selBorder; /* Border and background for selected - * characters. This is a copy of information + * characters. This is a copy of information * in *selTagPtr, so it shouldn't be * explicitly freed. */ - Tk_3DBorder inactiveSelBorder;/* Border and background for selected + Tk_3DBorder inactiveSelBorder; + /* Border and background for selected * characters when they don't have the * focus. */ int selBorderWidth; /* Width of border around selection. */ Tcl_Obj* selBorderWidthPtr; /* Width of border around selection. */ - XColor *selFgColorPtr; /* Foreground color for selected text. - * This is a copy of information in - * *selTagPtr, so it shouldn't be - * explicitly freed. */ + XColor *selFgColorPtr; /* Foreground color for selected text. This is + * a copy of information in *selTagPtr, so it + * shouldn't be explicitly freed. */ int exportSelection; /* Non-zero means tie "sel" tag to X * selection. */ - TkTextIndex selIndex; /* Used during multi-pass selection retrievals. - * This index identifies the next character - * to be returned from the selection. */ + TkTextIndex selIndex; /* Used during multi-pass selection + * retrievals. This index identifies the next + * character to be returned from the + * selection. */ /* * Information related to insertion cursor: @@ -775,51 +729,50 @@ typedef struct TkText { */ TkTextSegment *currentMarkPtr; - /* Pointer to segment for "current" mark, - * or NULL if none. */ + /* Pointer to segment for "current" mark, or + * NULL if none. */ XEvent pickEvent; /* The event from which the current character - * was chosen. Must be saved so that we - * can repick after modifications to the - * text. */ - int numCurTags; /* Number of tags associated with character - * at current mark. */ - TkTextTag **curTagArrayPtr; /* Pointer to array of tags for current - * mark, or NULL if none. */ + * was chosen. Must be saved so that we can + * repick after modifications to the text. */ + int numCurTags; /* Number of tags associated with character at + * current mark. */ + TkTextTag **curTagArrayPtr; /* Pointer to array of tags for current mark, + * or NULL if none. */ /* * Miscellaneous additional information: */ - char *takeFocus; /* Value of -takeFocus option; not used in - * the C code, but used by keyboard traversal - * scripts. Malloc'ed, but may be NULL. */ + char *takeFocus; /* Value of -takeFocus option; not used in the + * C code, but used by keyboard traversal + * scripts. Malloc'ed, but may be NULL. */ char *xScrollCmd; /* Prefix of command to issue to update * horizontal scrollbar when view changes. */ char *yScrollCmd; /* Prefix of command to issue to update * vertical scrollbar when view changes. */ - int flags; /* Miscellaneous flags; see below for + int flags; /* Miscellaneous flags; see below for * definitions. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ - - int refCount; /* Number of cached TkTextIndex objects + + int refCount; /* Number of cached TkTextIndex objects * refering to us */ - int insertCursorType; /* 0 = standard insertion cursor, - * 1 = block cursor. */ + int insertCursorType; /* 0 = standard insertion cursor, 1 = block + * cursor. */ /* - * Copies of information from the shared section relating to the - * undo/redo functonality + * Copies of information from the shared section relating to the undo/redo + * functonality */ - - int undo; /* Non-zero means the undo/redo behaviour is + + int undo; /* Non-zero means the undo/redo behaviour is * enabled */ - - int maxUndo; /* The maximum depth of the undo stack - * expressed as the maximum number of - * compound statements */ - int autoSeparators; /* Non-zero means the separators will be + int maxUndo; /* The maximum depth of the undo stack + * expressed as the maximum number of compound + * statements */ + + int autoSeparators; /* Non-zero means the separators will be * inserted automatically */ } TkText; @@ -832,15 +785,15 @@ typedef struct TkText { * displayed on screen. * GOT_FOCUS: Non-zero means this window has the input * focus. - * BUTTON_DOWN: 1 means that a mouse button is currently - * down; this is used to implement grabs - * for the duration of button presses. + * BUTTON_DOWN: 1 means that a mouse button is currently down; + * this is used to implement grabs for the + * duration of button presses. * UPDATE_SCROLLBARS: Non-zero means scrollbar(s) should be updated * during next redisplay operation. - * NEED_REPICK This appears unused and should probably - * be ignored + * NEED_REPICK This appears unused and should probably be + * ignored * OPTIONS_FREED The widget's options have been freed - * DESTROYED The widget is going away + * DESTROYED The widget is going away */ #define GOT_SELECTION 1 @@ -853,67 +806,60 @@ typedef struct TkText { #define DESTROYED 0x80 /* - * Records of the following type define segment types in terms of - * a collection of procedures that may be called to manipulate - * segments of that type. + * Records of the following type define segment types in terms of a collection + * of procedures that may be called to manipulate segments of that type. */ -typedef TkTextSegment * Tk_SegSplitProc _ANSI_ARGS_(( - struct TkTextSegment *segPtr, int index)); -typedef int Tk_SegDeleteProc _ANSI_ARGS_(( - struct TkTextSegment *segPtr, - TkTextLine *linePtr, int treeGone)); -typedef TkTextSegment * Tk_SegCleanupProc _ANSI_ARGS_(( - struct TkTextSegment *segPtr, TkTextLine *linePtr)); -typedef void Tk_SegLineChangeProc _ANSI_ARGS_(( - struct TkTextSegment *segPtr, TkTextLine *linePtr)); -typedef int Tk_SegLayoutProc _ANSI_ARGS_((struct TkText *textPtr, - struct TkTextIndex *indexPtr, TkTextSegment *segPtr, - int offset, int maxX, int maxChars, - int noCharsYet, TkWrapMode wrapMode, - struct TkTextDispChunk *chunkPtr)); -typedef void Tk_SegCheckProc _ANSI_ARGS_((TkTextSegment *segPtr, - TkTextLine *linePtr)); +typedef TkTextSegment * Tk_SegSplitProc(struct TkTextSegment *segPtr, + int index); +typedef int Tk_SegDeleteProc(struct TkTextSegment *segPtr, + TkTextLine *linePtr, int treeGone); +typedef TkTextSegment * Tk_SegCleanupProc(struct TkTextSegment *segPtr, + TkTextLine *linePtr); +typedef void Tk_SegLineChangeProc(struct TkTextSegment *segPtr, + TkTextLine *linePtr); +typedef int Tk_SegLayoutProc(struct TkText *textPtr, + struct TkTextIndex *indexPtr, + TkTextSegment *segPtr, int offset, int maxX, + int maxChars, int noCharsYet, TkWrapMode wrapMode, + struct TkTextDispChunk *chunkPtr); +typedef void Tk_SegCheckProc(TkTextSegment *segPtr, + TkTextLine *linePtr); typedef struct Tk_SegType { - CONST char *name; /* Name of this kind of segment. */ - int leftGravity; /* If a segment has zero size (e.g. a - * mark or tag toggle), does it - * attach to character to its left - * or right? 1 means left, 0 means - * right. */ - Tk_SegSplitProc *splitProc; /* Procedure to split large segment - * into two smaller ones. */ - Tk_SegDeleteProc *deleteProc; /* Procedure to call to delete - * segment. */ - Tk_SegCleanupProc *cleanupProc; /* After any change to a line, this - * procedure is invoked for all - * segments left in the line to - * perform any cleanup they wish - * (e.g. joining neighboring - * segments). */ + CONST char *name; /* Name of this kind of segment. */ + int leftGravity; /* If a segment has zero size (e.g. a mark or + * tag toggle), does it attach to character to + * its left or right? 1 means left, 0 means + * right. */ + Tk_SegSplitProc *splitProc; /* Procedure to split large segment into two + * smaller ones. */ + Tk_SegDeleteProc *deleteProc; + /* Procedure to call to delete segment. */ + Tk_SegCleanupProc *cleanupProc; + /* After any change to a line, this procedure + * is invoked for all segments left in the + * line to perform any cleanup they wish + * (e.g. joining neighboring segments). */ Tk_SegLineChangeProc *lineChangeProc; - /* Invoked when a segment is about - * to be moved from its current line - * to an earlier line because of - * a deletion. The linePtr is that - * for the segment's old line. - * CleanupProc will be invoked after - * the deletion is finished. */ - Tk_SegLayoutProc *layoutProc; /* Returns size information when - * figuring out what to display in - * window. */ - Tk_SegCheckProc *checkProc; /* Called during consistency checks - * to check internal consistency of - * segment. */ + /* Invoked when a segment is about to be moved + * from its current line to an earlier line + * because of a deletion. The linePtr is that + * for the segment's old line. CleanupProc + * will be invoked after the deletion is + * finished. */ + Tk_SegLayoutProc *layoutProc; + /* Returns size information when figuring out + * what to display in window. */ + Tk_SegCheckProc *checkProc; /* Called during consistency checks to check + * internal consistency of segment. */ } Tk_SegType; - /* - * The following type and items describe different flags for text widget - * items to count. They are used in both tkText.c and tkTextIndex.c, - * in 'CountIndices', 'TkTextIndexBackChars', 'TkTextIndexForwChars', - * and 'TkTextIndexCount'. + * The following type and items describe different flags for text widget items + * to count. They are used in both tkText.c and tkTextIndex.c, in + * 'CountIndices', 'TkTextIndexBackChars', 'TkTextIndexForwChars', and + * 'TkTextIndexCount'. */ typedef int TkTextCountType; @@ -925,24 +871,23 @@ typedef int TkTextCountType; #define COUNT_DISPLAY_INDICES (COUNT_INDICES | COUNT_DISPLAY) /* - * The following structure is used to keep track of elided text - * taking account of different tag priorities, it is need for - * quick calculations of whether a single index is elided, and - * to start at a given index and maintain a correct elide state - * as we move or count forwards or backwards. + * The following structure is used to keep track of elided text taking account + * of different tag priorities, it is need for quick calculations of whether a + * single index is elided, and to start at a given index and maintain a + * correct elide state as we move or count forwards or backwards. */ #define LOTSA_TAGS 1000 typedef struct TkTextElideInfo { int numTags; /* Total tags in widget */ int elide; /* Is the state currently elided */ - int elidePriority; /* Tag priority controlling elide state */ + int elidePriority; /* Tag priority controlling elide state */ TkTextSegment *segPtr; /* Segment to look at next */ int segOffset; /* Offset of segment within line */ - int deftagCnts[LOTSA_TAGS]; + int deftagCnts[LOTSA_TAGS]; TkTextTag *deftagPtrs[LOTSA_TAGS]; - int *tagCnts; /* 0 or 1 depending if the tag with - * that priority is on or off */ + int *tagCnts; /* 0 or 1 depending if the tag with that + * priority is on or off */ TkTextTag **tagPtrs; /* Only filled with a tagPtr if the * corresponding tagCnt is 1 */ } TkTextElideInfo; @@ -955,34 +900,39 @@ typedef struct TkTextElideInfo { #define TK_END_OF_TEXT 1000000 /* - * The following definition specifies the maximum number of characters - * needed in a string to hold a position specifier. + * The following definition specifies the maximum number of characters needed + * in a string to hold a position specifier. */ #define TK_POS_CHARS 30 -/* - * Mask used for those options which may impact the pixel height - * calculations of individual lines displayed in the widget. +/* + * Mask used for those options which may impact the pixel height calculations + * of individual lines displayed in the widget. */ + #define TK_TEXT_LINE_GEOMETRY 1 -/* - * Mask used for those options which may impact the start and - * end lines used in the widget. + +/* + * Mask used for those options which may impact the start and end lines used + * in the widget. */ + #define TK_TEXT_LINE_RANGE 2 /* * Used as 'action' values in calls to TkTextInvalidateLineMetrics */ + #define TK_TEXT_INVALIDATE_ONLY 0 #define TK_TEXT_INVALIDATE_INSERT 1 #define TK_TEXT_INVALIDATE_DELETE 2 /* - * Used as special 'pickPlace' values in calls to TkTextSetYView. - * Zero or positive values indicate a number of pixels. + * Used as special 'pickPlace' values in calls to TkTextSetYView. Zero or + * positive values indicate a number of pixels. */ + #define TK_TEXT_PICKPLACE -1 #define TK_TEXT_NOPIXELADJUST -2 @@ -999,223 +949,209 @@ EXTERN Tk_SegType tkTextToggleOnType; EXTERN Tk_SegType tkTextToggleOffType; /* - * Convenience macros for use by B-tree clients which want to access - * pixel information on each line. Currently only used by TkTextDisp.c + * Convenience macros for use by B-tree clients which want to access pixel + * information on each line. Currently only used by TkTextDisp.c */ #define TkBTreeLinePixelCount(text, line) \ - line->pixels[2*text->pixelReference] + (line)->pixels[2*(text)->pixelReference] #define TkBTreeLinePixelEpoch(text, line) \ - line->pixels[1+2*text->pixelReference] + (line)->pixels[1+2*(text)->pixelReference] /* - * Declarations for procedures that are used by the text-related files - * but shouldn't be used anywhere else in Tk (or by Tk clients): + * Declarations for procedures that are used by the text-related files but + * shouldn't be used anywhere else in Tk (or by Tk clients): */ - -EXTERN int TkBTreeAdjustPixelHeight _ANSI_ARGS_((CONST TkText *textPtr, + +EXTERN int TkBTreeAdjustPixelHeight(CONST TkText *textPtr, TkTextLine *linePtr, int newPixelHeight, - int mergedLogicalLines)); -EXTERN int TkBTreeCharTagged _ANSI_ARGS_((CONST TkTextIndex *indexPtr, - TkTextTag *tagPtr)); -EXTERN void TkBTreeCheck _ANSI_ARGS_((TkTextBTree tree)); -EXTERN TkTextBTree TkBTreeCreate _ANSI_ARGS_((TkSharedText *sharedTextPtr)); -EXTERN void TkBTreeAddClient _ANSI_ARGS_((TkTextBTree tree, - TkText *textPtr, - int defaultHeight)); -EXTERN void TkBTreeClientRangeChanged _ANSI_ARGS_((TkText *textPtr, - int defaultHeight)); -EXTERN void TkBTreeRemoveClient _ANSI_ARGS_((TkTextBTree tree, - TkText *textPtr)); -EXTERN void TkBTreeDestroy _ANSI_ARGS_((TkTextBTree tree)); -EXTERN void TkBTreeDeleteIndexRange _ANSI_ARGS_((TkTextBTree tree, - TkTextIndex *index1Ptr, TkTextIndex *index2Ptr)); -EXTERN TkTextLine * TkBTreeFindLine _ANSI_ARGS_((TkTextBTree tree, - CONST TkText *textPtr, int line)); -EXTERN TkTextLine * TkBTreeFindPixelLine _ANSI_ARGS_((TkTextBTree tree, - CONST TkText *textPtr, int pixels, int *pixelOffset)); -EXTERN TkTextTag ** TkBTreeGetTags _ANSI_ARGS_((CONST TkTextIndex *indexPtr, - CONST TkText *textPtr, int *numTagsPtr)); -EXTERN void TkBTreeInsertChars _ANSI_ARGS_((TkTextBTree tree, - TkTextIndex *indexPtr, CONST char *string)); -EXTERN int TkBTreeLinesTo _ANSI_ARGS_((CONST TkText *textPtr, - TkTextLine *linePtr)); -EXTERN int TkBTreePixelsTo _ANSI_ARGS_((CONST TkText *textPtr, - TkTextLine *linePtr)); -EXTERN void TkBTreeLinkSegment _ANSI_ARGS_((TkTextSegment *segPtr, - TkTextIndex *indexPtr)); -EXTERN TkTextLine * TkBTreeNextLine _ANSI_ARGS_((CONST TkText *textPtr, - TkTextLine *linePtr)); -EXTERN int TkBTreeNextTag _ANSI_ARGS_((TkTextSearch *searchPtr)); -EXTERN int TkBTreeNumLines _ANSI_ARGS_((TkTextBTree tree, - CONST TkText *textPtr)); -EXTERN int TkBTreeNumPixels _ANSI_ARGS_((TkTextBTree tree, - CONST TkText *textPtr)); -EXTERN TkTextLine * TkBTreePreviousLine _ANSI_ARGS_((TkText *textPtr, - TkTextLine *linePtr)); -EXTERN int TkBTreePrevTag _ANSI_ARGS_((TkTextSearch *searchPtr)); -EXTERN void TkBTreeStartSearch _ANSI_ARGS_((TkTextIndex *index1Ptr, + int mergedLogicalLines); +EXTERN int TkBTreeCharTagged(CONST TkTextIndex *indexPtr, + TkTextTag *tagPtr); +EXTERN void TkBTreeCheck(TkTextBTree tree); +EXTERN TkTextBTree TkBTreeCreate(TkSharedText *sharedTextPtr); +EXTERN void TkBTreeAddClient(TkTextBTree tree, TkText *textPtr, + int defaultHeight); +EXTERN void TkBTreeClientRangeChanged(TkText *textPtr, + int defaultHeight); +EXTERN void TkBTreeRemoveClient(TkTextBTree tree, + TkText *textPtr); +EXTERN void TkBTreeDestroy(TkTextBTree tree); +EXTERN void TkBTreeDeleteIndexRange(TkTextBTree tree, + TkTextIndex *index1Ptr, TkTextIndex *index2Ptr); +EXTERN TkTextLine * TkBTreeFindLine(TkTextBTree tree, + CONST TkText *textPtr, int line); +EXTERN TkTextLine * TkBTreeFindPixelLine(TkTextBTree tree, + CONST TkText *textPtr, int pixels, + int *pixelOffset); +EXTERN TkTextTag ** TkBTreeGetTags(CONST TkTextIndex *indexPtr, + CONST TkText *textPtr, int *numTagsPtr); +EXTERN void TkBTreeInsertChars(TkTextBTree tree, + TkTextIndex *indexPtr, CONST char *string); +EXTERN int TkBTreeLinesTo(CONST TkText *textPtr, + TkTextLine *linePtr); +EXTERN int TkBTreePixelsTo(CONST TkText *textPtr, + TkTextLine *linePtr); +EXTERN void TkBTreeLinkSegment(TkTextSegment *segPtr, + TkTextIndex *indexPtr); +EXTERN TkTextLine * TkBTreeNextLine(CONST TkText *textPtr, + TkTextLine *linePtr); +EXTERN int TkBTreeNextTag(TkTextSearch *searchPtr); +EXTERN int TkBTreeNumLines(TkTextBTree tree, + CONST TkText *textPtr); +EXTERN int TkBTreeNumPixels(TkTextBTree tree, + CONST TkText *textPtr); +EXTERN TkTextLine * TkBTreePreviousLine(TkText *textPtr, + TkTextLine *linePtr); +EXTERN int TkBTreePrevTag(TkTextSearch *searchPtr); +EXTERN void TkBTreeStartSearch(TkTextIndex *index1Ptr, TkTextIndex *index2Ptr, TkTextTag *tagPtr, - TkTextSearch *searchPtr)); -EXTERN void TkBTreeStartSearchBack _ANSI_ARGS_((TkTextIndex *index1Ptr, + TkTextSearch *searchPtr); +EXTERN void TkBTreeStartSearchBack(TkTextIndex *index1Ptr, TkTextIndex *index2Ptr, TkTextTag *tagPtr, - TkTextSearch *searchPtr)); -EXTERN int TkBTreeTag _ANSI_ARGS_((TkTextIndex *index1Ptr, + TkTextSearch *searchPtr); +EXTERN int TkBTreeTag(TkTextIndex *index1Ptr, TkTextIndex *index2Ptr, TkTextTag *tagPtr, - int add)); -EXTERN void TkBTreeUnlinkSegment _ANSI_ARGS_(( - TkTextSegment *segPtr, TkTextLine *linePtr)); -EXTERN void TkTextBindProc _ANSI_ARGS_((ClientData clientData, - XEvent *eventPtr)); -EXTERN void TkTextSelectionEvent _ANSI_ARGS_((TkText *textPtr)); -EXTERN void TkTextChanged _ANSI_ARGS_((TkSharedText *sharedTextPtr, - TkText *textPtr, - CONST TkTextIndex *index1Ptr, - CONST TkTextIndex *index2Ptr)); -EXTERN int TkTextIndexBbox _ANSI_ARGS_((TkText *textPtr, + int add); +EXTERN void TkBTreeUnlinkSegment(TkTextSegment *segPtr, + TkTextLine *linePtr); +EXTERN void TkTextBindProc(ClientData clientData, + XEvent *eventPtr); +EXTERN void TkTextSelectionEvent(TkText *textPtr); +EXTERN void TkTextChanged(TkSharedText *sharedTextPtr, + TkText *textPtr, CONST TkTextIndex *index1Ptr, + CONST TkTextIndex *index2Ptr); +EXTERN int TkTextIndexBbox(TkText *textPtr, CONST TkTextIndex *indexPtr, int *xPtr, int *yPtr, - int *widthPtr, int *heightPtr, int *charWidthPtr)); -EXTERN int TkTextCharLayoutProc _ANSI_ARGS_((TkText *textPtr, + int *widthPtr, int *heightPtr, int *charWidthPtr); +EXTERN int TkTextCharLayoutProc(TkText *textPtr, TkTextIndex *indexPtr, TkTextSegment *segPtr, int offset, int maxX, int maxChars, int noBreakYet, - TkWrapMode wrapMode, TkTextDispChunk *chunkPtr)); -EXTERN void TkTextCreateDInfo _ANSI_ARGS_((TkText *textPtr)); -EXTERN int TkTextDLineInfo _ANSI_ARGS_((TkText *textPtr, + TkWrapMode wrapMode, TkTextDispChunk *chunkPtr); +EXTERN void TkTextCreateDInfo(TkText *textPtr); +EXTERN int TkTextDLineInfo(TkText *textPtr, CONST TkTextIndex *indexPtr, int *xPtr, int *yPtr, - int *widthPtr, int *heightPtr, int *basePtr)); -EXTERN void TkTextEmbWinDisplayProc _ANSI_ARGS_((TkText *textPtr, + int *widthPtr, int *heightPtr, int *basePtr); +EXTERN void TkTextEmbWinDisplayProc(TkText *textPtr, TkTextDispChunk *chunkPtr, int x, int y, int lineHeight, int baseline, Display *display, - Drawable dst, int screenY)); -EXTERN TkTextTag * TkTextCreateTag _ANSI_ARGS_((TkText *textPtr, - CONST char *tagName, int *newTag)); -EXTERN void TkTextFreeDInfo _ANSI_ARGS_((TkText *textPtr)); -EXTERN void TkTextDeleteTag _ANSI_ARGS_((TkText *textPtr, - TkTextTag *tagPtr)); -EXTERN void TkTextFreeTag _ANSI_ARGS_((TkText *textPtr, - TkTextTag *tagPtr)); -EXTERN int TkTextGetIndex _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, CONST char *string, - TkTextIndex *indexPtr)); -EXTERN int TkTextGetObjIndex _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, Tcl_Obj *idxPtr, - TkTextIndex *indexPtr)); -EXTERN int TkTextSharedGetObjIndex _ANSI_ARGS_((Tcl_Interp *interp, + Drawable dst, int screenY); +EXTERN TkTextTag * TkTextCreateTag(TkText *textPtr, + CONST char *tagName, int *newTag); +EXTERN void TkTextFreeDInfo(TkText *textPtr); +EXTERN void TkTextDeleteTag(TkText *textPtr, TkTextTag *tagPtr); +EXTERN void TkTextFreeTag(TkText *textPtr, TkTextTag *tagPtr); +EXTERN int TkTextGetIndex(Tcl_Interp *interp, TkText *textPtr, + CONST char *string, TkTextIndex *indexPtr); +EXTERN int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr, + Tcl_Obj *idxPtr, TkTextIndex *indexPtr); +EXTERN int TkTextSharedGetObjIndex(Tcl_Interp *interp, TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr, - TkTextIndex *indexPtr)); -EXTERN CONST TkTextIndex* TkTextGetIndexFromObj _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, Tcl_Obj *objPtr)); -EXTERN TkTextTabArray * TkTextGetTabs _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, Tcl_Obj *stringPtr)); -EXTERN void TkTextFindDisplayLineEnd _ANSI_ARGS_(( - TkText *textPtr, TkTextIndex *indexPtr, - int end, int *xOffset)); -EXTERN int TkTextIndexBackBytes _ANSI_ARGS_((CONST TkText *textPtr, + TkTextIndex *indexPtr); +EXTERN CONST TkTextIndex* TkTextGetIndexFromObj(Tcl_Interp *interp, + TkText *textPtr, Tcl_Obj *objPtr); +EXTERN TkTextTabArray * TkTextGetTabs(Tcl_Interp *interp, + TkText *textPtr, Tcl_Obj *stringPtr); +EXTERN void TkTextFindDisplayLineEnd(TkText *textPtr, + TkTextIndex *indexPtr, int end, int *xOffset); +EXTERN int TkTextIndexBackBytes(CONST TkText *textPtr, CONST TkTextIndex *srcPtr, int count, - TkTextIndex *dstPtr)); -EXTERN void TkTextIndexBackChars _ANSI_ARGS_(( - CONST TkText *textPtr, + TkTextIndex *dstPtr); +EXTERN void TkTextIndexBackChars(CONST TkText *textPtr, CONST TkTextIndex *srcPtr, int count, - TkTextIndex *dstPtr, TkTextCountType type)); -EXTERN int TkTextIndexCmp _ANSI_ARGS_(( - CONST TkTextIndex *index1Ptr, - CONST TkTextIndex *index2Ptr)); -EXTERN int TkTextIndexCount _ANSI_ARGS_((CONST TkText *textPtr, + TkTextIndex *dstPtr, TkTextCountType type); +EXTERN int TkTextIndexCmp(CONST TkTextIndex *index1Ptr, + CONST TkTextIndex *index2Ptr); +EXTERN int TkTextIndexCount(CONST TkText *textPtr, CONST TkTextIndex *index1Ptr, - CONST TkTextIndex *index2Ptr, - TkTextCountType type)); -EXTERN int TkTextIndexForwBytes _ANSI_ARGS_((CONST TkText *textPtr, + CONST TkTextIndex *index2Ptr, + TkTextCountType type); +EXTERN int TkTextIndexForwBytes(CONST TkText *textPtr, CONST TkTextIndex *srcPtr, int count, - TkTextIndex *dstPtr)); -EXTERN void TkTextIndexForwChars _ANSI_ARGS_(( - CONST TkText *textPtr, + TkTextIndex *dstPtr); +EXTERN void TkTextIndexForwChars(CONST TkText *textPtr, CONST TkTextIndex *srcPtr, int count, - TkTextIndex *dstPtr, TkTextCountType type)); -EXTERN void TkTextIndexOfX _ANSI_ARGS_((TkText *textPtr, - int x, TkTextIndex *indexPtr)); -EXTERN int TkTextIndexYPixels _ANSI_ARGS_((TkText *textPtr, - CONST TkTextIndex *indexPtr)); -EXTERN TkTextSegment * TkTextIndexToSeg _ANSI_ARGS_(( - CONST TkTextIndex *indexPtr, int *offsetPtr)); -EXTERN void TkTextInsertDisplayProc _ANSI_ARGS_((TkText *textPtr, - TkTextDispChunk *chunkPtr, int x, int y, int height, - int baseline, Display *display, Drawable dst, - int screenY)); -EXTERN void TkTextLostSelection _ANSI_ARGS_(( - ClientData clientData)); -EXTERN TkTextIndex * TkTextMakeCharIndex _ANSI_ARGS_((TkTextBTree tree, - TkText *textPtr, int lineIndex, int charIndex, - TkTextIndex *indexPtr)); -EXTERN int TkTextMeasureDown _ANSI_ARGS_((TkText *textPtr, - TkTextIndex *srcPtr, int distance)); -EXTERN void TkTextFreeElideInfo _ANSI_ARGS_(( - TkTextElideInfo *infoPtr)); -EXTERN int TkTextIsElided _ANSI_ARGS_((CONST TkText *textPtr, - CONST TkTextIndex *indexPtr, - TkTextElideInfo *infoPtr)); -EXTERN TkTextIndex * TkTextMakeByteIndex _ANSI_ARGS_((TkTextBTree tree, - CONST TkText *textPtr, int lineIndex, int byteIndex, - TkTextIndex *indexPtr)); -EXTERN int TkTextMakePixelIndex _ANSI_ARGS_((TkText *textPtr, - int pixelIndex, TkTextIndex *indexPtr)); -EXTERN void TkTextInvalidateLineMetrics _ANSI_ARGS_(( + TkTextIndex *dstPtr, TkTextCountType type); +EXTERN void TkTextIndexOfX(TkText *textPtr, int x, + TkTextIndex *indexPtr); +EXTERN int TkTextIndexYPixels(TkText *textPtr, + CONST TkTextIndex *indexPtr); +EXTERN TkTextSegment * TkTextIndexToSeg(CONST TkTextIndex *indexPtr, + int *offsetPtr); +EXTERN void TkTextInsertDisplayProc(TkText *textPtr, + TkTextDispChunk *chunkPtr, int x, int y, + int height, int baseline, Display *display, + Drawable dst, int screenY); +EXTERN void TkTextLostSelection(ClientData clientData); +EXTERN TkTextIndex * TkTextMakeCharIndex(TkTextBTree tree, TkText *textPtr, + int lineIndex, int charIndex, + TkTextIndex *indexPtr); +EXTERN int TkTextMeasureDown(TkText *textPtr, + TkTextIndex *srcPtr, int distance); +EXTERN void TkTextFreeElideInfo(TkTextElideInfo *infoPtr); +EXTERN int TkTextIsElided(CONST TkText *textPtr, + CONST TkTextIndex *indexPtr, + TkTextElideInfo *infoPtr); +EXTERN TkTextIndex * TkTextMakeByteIndex(TkTextBTree tree, + CONST TkText *textPtr, int lineIndex, + int byteIndex, TkTextIndex *indexPtr); +EXTERN int TkTextMakePixelIndex(TkText *textPtr, + int pixelIndex, TkTextIndex *indexPtr); +EXTERN void TkTextInvalidateLineMetrics( TkSharedText *sharedTextPtr, TkText *textPtr, - TkTextLine *linePtr, int lineCount, int action)); -EXTERN int TkTextUpdateLineMetrics _ANSI_ARGS_((TkText *textPtr, - int lineNum, int endLine, int doThisMuch)); -EXTERN int TkTextUpdateOneLine _ANSI_ARGS_((TkText *textPtr, - TkTextLine *linePtr, int pixelHeight, - TkTextIndex *indexPtr, int partialCalc)); -EXTERN int TkTextMarkCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int TkTextMarkNameToIndex _ANSI_ARGS_((TkText *textPtr, - CONST char *name, TkTextIndex *indexPtr)); -EXTERN void TkTextMarkSegToIndex _ANSI_ARGS_((TkText *textPtr, - TkTextSegment *markPtr, TkTextIndex *indexPtr)); -EXTERN void TkTextEventuallyRepick _ANSI_ARGS_((TkText *textPtr)); -EXTERN void TkTextPickCurrent _ANSI_ARGS_((TkText *textPtr, - XEvent *eventPtr)); -EXTERN void TkTextPixelIndex _ANSI_ARGS_((TkText *textPtr, - int x, int y, TkTextIndex *indexPtr, int *nearest)); -EXTERN int TkTextPrintIndex _ANSI_ARGS_((CONST TkText *textPtr, - CONST TkTextIndex *indexPtr, char *string)); -EXTERN Tcl_Obj* TkTextNewIndexObj _ANSI_ARGS_((TkText *textPtr, - CONST TkTextIndex *indexPtr)); -EXTERN void TkTextRedrawRegion _ANSI_ARGS_((TkText *textPtr, - int x, int y, int width, int height)); -EXTERN void TkTextRedrawTag _ANSI_ARGS_((TkSharedText *sharedTextPtr, - TkText *textPtr, - TkTextIndex *index1Ptr, TkTextIndex *index2Ptr, - TkTextTag *tagPtr, int withTag)); -EXTERN void TkTextRelayoutWindow _ANSI_ARGS_((TkText *textPtr, - int mask)); -EXTERN int TkTextScanCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int TkTextSeeCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int TkTextSegToOffset _ANSI_ARGS_(( - CONST TkTextSegment *segPtr, - CONST TkTextLine *linePtr)); -EXTERN TkTextSegment * TkTextSetMark _ANSI_ARGS_((TkText *textPtr, - CONST char *name, TkTextIndex *indexPtr)); -EXTERN void TkTextSetYView _ANSI_ARGS_((TkText *textPtr, - TkTextIndex *indexPtr, int pickPlace)); -EXTERN int TkTextTagCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int TkTextImageCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int TkTextImageIndex _ANSI_ARGS_((TkText *textPtr, - CONST char *name, TkTextIndex *indexPtr)); -EXTERN int TkTextWindowCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int TkTextWindowIndex _ANSI_ARGS_((TkText *textPtr, - CONST char *name, TkTextIndex *indexPtr)); -EXTERN int TkTextXviewCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int TkTextYviewCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN void TkTextWinFreeClient _ANSI_ARGS_((Tcl_HashEntry *hPtr, - TkTextEmbWindowClient *client)); + TkTextLine *linePtr, int lineCount, int action); +EXTERN int TkTextUpdateLineMetrics(TkText *textPtr, int lineNum, + int endLine, int doThisMuch); +EXTERN int TkTextUpdateOneLine(TkText *textPtr, + TkTextLine *linePtr, int pixelHeight, + TkTextIndex *indexPtr, int partialCalc); +EXTERN int TkTextMarkCmd(TkText *textPtr, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +EXTERN int TkTextMarkNameToIndex(TkText *textPtr, + CONST char *name, TkTextIndex *indexPtr); +EXTERN void TkTextMarkSegToIndex(TkText *textPtr, + TkTextSegment *markPtr, TkTextIndex *indexPtr); +EXTERN void TkTextEventuallyRepick(TkText *textPtr); +EXTERN void TkTextPickCurrent(TkText *textPtr, XEvent *eventPtr); +EXTERN void TkTextPixelIndex(TkText *textPtr, int x, int y, + TkTextIndex *indexPtr, int *nearest); +EXTERN int TkTextPrintIndex(CONST TkText *textPtr, + CONST TkTextIndex *indexPtr, char *string); +EXTERN Tcl_Obj* TkTextNewIndexObj(TkText *textPtr, + CONST TkTextIndex *indexPtr); +EXTERN void TkTextRedrawRegion(TkText *textPtr, int x, int y, + int width, int height); +EXTERN void TkTextRedrawTag(TkSharedText *sharedTextPtr, + TkText *textPtr, TkTextIndex *index1Ptr, + TkTextIndex *index2Ptr, TkTextTag *tagPtr, + int withTag); +EXTERN void TkTextRelayoutWindow(TkText *textPtr, int mask); +EXTERN int TkTextScanCmd(TkText *textPtr, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +EXTERN int TkTextSeeCmd(TkText *textPtr, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +EXTERN int TkTextSegToOffset(CONST TkTextSegment *segPtr, + CONST TkTextLine *linePtr); +EXTERN TkTextSegment * TkTextSetMark(TkText *textPtr, + CONST char *name, TkTextIndex *indexPtr); +EXTERN void TkTextSetYView(TkText *textPtr, + TkTextIndex *indexPtr, int pickPlace); +EXTERN int TkTextTagCmd(TkText *textPtr, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +EXTERN int TkTextImageCmd(TkText *textPtr, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +EXTERN int TkTextImageIndex(TkText *textPtr, + CONST char *name, TkTextIndex *indexPtr); +EXTERN int TkTextWindowCmd(TkText *textPtr, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +EXTERN int TkTextWindowIndex(TkText *textPtr, CONST char *name, + TkTextIndex *indexPtr); +EXTERN int TkTextXviewCmd(TkText *textPtr, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +EXTERN int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +EXTERN void TkTextWinFreeClient(Tcl_HashEntry *hPtr, + TkTextEmbWindowClient *client); # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLIMPORT diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 30309db..153c780 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextBTree.c,v 1.19 2005/10/10 10:36:35 vincentdarley Exp $ + * RCS: @(#) $Id: tkTextBTree.c,v 1.20 2005/11/17 16:21:56 dkf Exp $ */ #include "tkInt.h" @@ -1751,7 +1751,7 @@ TkBTreeNextLine(textPtr, linePtr) break; } if (nodePtr->parentPtr == NULL) { - return (TkTextLine *) NULL; + return NULL; } } while (nodePtr->level > 0) { @@ -1803,7 +1803,7 @@ TkBTreePreviousLine(textPtr, linePtr) return prevPtr; } prevPtr = prevPtr->nextPtr; - if (prevPtr == (TkTextLine *) NULL) { + if (prevPtr == NULL) { Tcl_Panic("TkBTreePreviousLine ran out of lines"); } } @@ -1815,8 +1815,8 @@ TkBTreePreviousLine(textPtr, linePtr) */ for (nodePtr = linePtr->parentPtr; ; nodePtr = nodePtr->parentPtr) { - if (nodePtr == (Node *) NULL || nodePtr->parentPtr == (Node *) NULL) { - return (TkTextLine *) NULL; + if (nodePtr == NULL || nodePtr->parentPtr == NULL) { + return NULL; } if (nodePtr != nodePtr->parentPtr->children.nodePtr) { break; @@ -1830,10 +1830,10 @@ TkBTreePreviousLine(textPtr, linePtr) if (node2Ptr->level == 0) { break; } - nodePtr = (Node *)NULL; + nodePtr = NULL; } for (prevPtr = node2Ptr->children.linePtr ; ; prevPtr = prevPtr->nextPtr) { - if (prevPtr->nextPtr == (TkTextLine *) NULL) { + if (prevPtr->nextPtr == NULL) { return prevPtr; } } @@ -2242,7 +2242,7 @@ ChangeNodeToggleCount(nodePtr, tagPtr, delta) int rootLevel; /* Level of original tag root */ tagPtr->toggleCount += delta; - if (tagPtr->tagRootPtr == (Node *) NULL) { + if (tagPtr->tagRootPtr == NULL) { tagPtr->tagRootPtr = nodePtr; return; } @@ -2344,7 +2344,7 @@ ChangeNodeToggleCount(nodePtr, tagPtr, delta) return; } if (tagPtr->toggleCount == 0) { - tagPtr->tagRootPtr = (Node *) NULL; + tagPtr->tagRootPtr = NULL; return; } nodePtr = tagPtr->tagRootPtr; @@ -2355,7 +2355,7 @@ ChangeNodeToggleCount(nodePtr, tagPtr, delta) */ for (node2Ptr = nodePtr->children.nodePtr; - node2Ptr != (Node *)NULL ; + node2Ptr != NULL ; node2Ptr = node2Ptr->nextPtr) { for (prevPtr = NULL, summaryPtr = node2Ptr->summaryPtr; summaryPtr != NULL; @@ -2424,7 +2424,7 @@ FindTagStart(tree, tagPtr, indexPtr) int offset; nodePtr = tagPtr->tagRootPtr; - if (nodePtr == (Node *) NULL) { + if (nodePtr == NULL) { return NULL; } @@ -2434,7 +2434,7 @@ FindTagStart(tree, tagPtr, indexPtr) */ while (nodePtr->level > 0) { - for (nodePtr = nodePtr->children.nodePtr ; nodePtr != (Node *) NULL; + for (nodePtr = nodePtr->children.nodePtr ; nodePtr != NULL; nodePtr = nodePtr->nextPtr) { for (summaryPtr = nodePtr->summaryPtr ; summaryPtr != NULL; summaryPtr = summaryPtr->nextPtr) { @@ -2451,7 +2451,7 @@ FindTagStart(tree, tagPtr, indexPtr) * Work through the lines attached to the level-0 node. */ - for (linePtr = nodePtr->children.linePtr; linePtr != (TkTextLine *) NULL; + for (linePtr = nodePtr->children.linePtr; linePtr != NULL; linePtr = linePtr->nextPtr) { for (offset = 0, segPtr = linePtr->segPtr ; segPtr != NULL; offset += segPtr->size, segPtr = segPtr->nextPtr) { @@ -2505,7 +2505,7 @@ FindTagEnd(tree, tagPtr, indexPtr) int lastoffset, lastoffset2, offset; nodePtr = tagPtr->tagRootPtr; - if (nodePtr == (Node *) NULL) { + if (nodePtr == NULL) { return NULL; } @@ -2516,7 +2516,7 @@ FindTagEnd(tree, tagPtr, indexPtr) while (nodePtr->level > 0) { for (lastNodePtr = NULL, nodePtr = nodePtr->children.nodePtr ; - nodePtr != (Node *) NULL; nodePtr = nodePtr->nextPtr) { + nodePtr != NULL; nodePtr = nodePtr->nextPtr) { for (summaryPtr = nodePtr->summaryPtr ; summaryPtr != NULL; summaryPtr = summaryPtr->nextPtr) { if (summaryPtr->tagPtr == tagPtr) { @@ -2536,7 +2536,7 @@ FindTagEnd(tree, tagPtr, indexPtr) lastoffset2 = 0; lastoffset = 0; for (lastLinePtr = NULL, linePtr = nodePtr->children.linePtr; - linePtr != (TkTextLine *) NULL; linePtr = linePtr->nextPtr) { + linePtr != NULL; linePtr = linePtr->nextPtr) { for (offset = 0, lastSegPtr = NULL, segPtr = linePtr->segPtr ; segPtr != NULL; offset += segPtr->size, segPtr = segPtr->nextPtr) { @@ -2604,7 +2604,7 @@ TkBTreeStartSearch(index1Ptr, index2Ptr, tagPtr, searchPtr) */ seg0Ptr = FindTagStart(index1Ptr->tree, tagPtr, &index0); - if (seg0Ptr == (TkTextSegment *) NULL) { + if (seg0Ptr == NULL) { /* * Even though there are no toggles, the display code still uses the * search curIndex, so initialize that anyway. @@ -2631,7 +2631,7 @@ TkBTreeStartSearch(index1Ptr, index2Ptr, tagPtr, searchPtr) searchPtr->nextPtr = TkTextIndexToSeg(index1Ptr, &offset); searchPtr->curIndex.byteIndex -= offset; } - searchPtr->lastPtr = TkTextIndexToSeg(index2Ptr, (int *) NULL); + searchPtr->lastPtr = TkTextIndexToSeg(index2Ptr, NULL); searchPtr->tagPtr = tagPtr; searchPtr->linesLeft = TkBTreeLinesTo(NULL, index2Ptr->linePtr) + 1 - TkBTreeLinesTo(NULL, index1Ptr->linePtr); @@ -2701,7 +2701,7 @@ TkBTreeStartSearchBack(index1Ptr, index2Ptr, tagPtr, searchPtr) */ seg0Ptr = FindTagEnd(index1Ptr->tree, tagPtr, &index0); - if (seg0Ptr == (TkTextSegment *) NULL) { + if (seg0Ptr == NULL) { /* * Even though there are no toggles, the display code still uses the * search curIndex, so initialize that anyway. @@ -2741,7 +2741,7 @@ TkBTreeStartSearchBack(index1Ptr, index2Ptr, tagPtr, searchPtr) searchPtr->lastPtr = NULL; /* Signals special case for 1.0 */ } else { TkTextIndexBackChars(NULL, index2Ptr, 1, &backOne, COUNT_INDICES); - searchPtr->lastPtr = TkTextIndexToSeg(&backOne, (int *) NULL); + searchPtr->lastPtr = TkTextIndexToSeg(&backOne, NULL); } searchPtr->tagPtr = tagPtr; searchPtr->linesLeft = TkBTreeLinesTo(NULL, index1Ptr->linePtr) + 1 @@ -3727,7 +3727,7 @@ TkBTreeCheck(tree) entryPtr != NULL ; entryPtr = Tcl_NextHashEntry(&search)) { tagPtr = (TkTextTag *) Tcl_GetHashValue(entryPtr); nodePtr = tagPtr->tagRootPtr; - if (nodePtr == (Node *) NULL) { + if (nodePtr == NULL) { if (tagPtr->toggleCount != 0) { Tcl_Panic("TkBTreeCheck found \"%s\" with toggles (%d) but no root", tagPtr->name, tagPtr->toggleCount); diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index c9ddab3..970c414 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextIndex.c,v 1.23 2005/10/10 10:36:35 vincentdarley Exp $ + * RCS: @(#) $Id: tkTextIndex.c,v 1.24 2005/11/17 16:21:56 dkf Exp $ */ #include "default.h" @@ -839,7 +839,7 @@ GetIndex(interp, sharedPtr, textPtr, string, indexPtr, canCachePtr) Tcl_ResetResult(interp); Tcl_AppendResult(interp, "text doesn't contain any characters tagged with \"", - tagName, "\"", (char *) NULL); + tagName, "\"", NULL); Tcl_DStringFree(©); return TCL_ERROR; } @@ -1003,7 +1003,7 @@ GetIndex(interp, sharedPtr, textPtr, string, indexPtr, canCachePtr) error: Tcl_DStringFree(©); Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad text index \"", string, "\"", (char *)NULL); + Tcl_AppendResult(interp, "bad text index \"", string, "\"", NULL); return TCL_ERROR; } diff --git a/generic/tkTrig.c b/generic/tkTrig.c index 4dbf755..e4f20a0 100644 --- a/generic/tkTrig.c +++ b/generic/tkTrig.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTrig.c,v 1.6 2005/08/18 18:32:38 dkf Exp $ + * RCS: @(#) $Id: tkTrig.c,v 1.7 2005/11/17 16:21:56 dkf Exp $ */ #include @@ -45,10 +45,10 @@ */ double -TkLineToPoint(end1Ptr, end2Ptr, pointPtr) - double end1Ptr[2]; /* Coordinates of first end-point of line. */ - double end2Ptr[2]; /* Coordinates of second end-point of line. */ - double pointPtr[2]; /* Points to coords for point. */ +TkLineToPoint( + double end1Ptr[2], /* Coordinates of first end-point of line. */ + double end2Ptr[2], /* Coordinates of second end-point of line. */ + double pointPtr[2]) /* Points to coords for point. */ { double x, y; @@ -149,12 +149,12 @@ TkLineToPoint(end1Ptr, end2Ptr, pointPtr) */ int -TkLineToArea(end1Ptr, end2Ptr, rectPtr) - double end1Ptr[2]; /* X and y coordinates for one endpoint of +TkLineToArea( + double end1Ptr[2], /* X and y coordinates for one endpoint of * line. */ - double end2Ptr[2]; /* X and y coordinates for other endpoint of + double end2Ptr[2], /* X and y coordinates for other endpoint of * line. */ - double rectPtr[4]; /* Points to coords for rectangle, in the + double rectPtr[4]) /* Points to coords for rectangle, in the * order x1, y1, x2, y2. X1 must be no larger * than x2, and y1 no larger than y2. */ { @@ -291,16 +291,16 @@ TkLineToArea(end1Ptr, end2Ptr, rectPtr) /* ARGSUSED */ int -TkThickPolyLineToArea(coordPtr, numPoints, width, capStyle, joinStyle, rectPtr) - double *coordPtr; /* Points to an array of coordinates for the +TkThickPolyLineToArea( + double *coordPtr, /* Points to an array of coordinates for the * polyline: x0, y0, x1, y1, ... */ - int numPoints; /* Total number of points at *coordPtr. */ - double width; /* Width of each line segment. */ - int capStyle; /* How are end-points of polyline drawn? + int numPoints, /* Total number of points at *coordPtr. */ + double width, /* Width of each line segment. */ + int capStyle, /* How are end-points of polyline drawn? * CapRound, CapButt, or CapProjecting. */ - int joinStyle; /* How are joints in polyline drawn? + int joinStyle, /* How are joints in polyline drawn? * JoinMiter, JoinRound, or JoinBevel. */ - double *rectPtr; /* Rectangular area to check against. */ + double *rectPtr) /* Rectangular area to check against. */ { double radius, poly[10]; int count; @@ -434,12 +434,12 @@ TkThickPolyLineToArea(coordPtr, numPoints, width, capStyle, joinStyle, rectPtr) */ double -TkPolygonToPoint(polyPtr, numPoints, pointPtr) - double *polyPtr; /* Points to an array coordinates for closed +TkPolygonToPoint( + double *polyPtr, /* Points to an array coordinates for closed * polygon: x0, y0, x1, y1, ... The polygon * may be self-intersecting. */ - int numPoints; /* Total number of points at *polyPtr. */ - double *pointPtr; /* Points to coords for point. */ + int numPoints, /* Total number of points at *polyPtr. */ + double *pointPtr) /* Points to coords for point. */ { double bestDist; /* Closest distance between point and any edge * in polygon. */ @@ -590,12 +590,12 @@ TkPolygonToPoint(polyPtr, numPoints, pointPtr) */ int -TkPolygonToArea(polyPtr, numPoints, rectPtr) - double *polyPtr; /* Points to an array coordinates for closed +TkPolygonToArea( + double *polyPtr, /* Points to an array coordinates for closed * polygon: x0, y0, x1, y1, ... The polygon * may be self-intersecting. */ - int numPoints; /* Total number of points at *polyPtr. */ - register double *rectPtr; /* Points to coords for rectangle, in the + int numPoints, /* Total number of points at *polyPtr. */ + register double *rectPtr) /* Points to coords for rectangle, in the * order x1, y1, x2, y2. X1 and y1 must be * lower-left corner. */ { @@ -661,15 +661,15 @@ TkPolygonToArea(polyPtr, numPoints, rectPtr) /* ARGSUSED */ double -TkOvalToPoint(ovalPtr, width, filled, pointPtr) - double ovalPtr[4]; /* Pointer to array of four coordinates (x1, +TkOvalToPoint( + double ovalPtr[4], /* Pointer to array of four coordinates (x1, * y1, x2, y2) defining oval's bounding * box. */ - double width; /* Width of outline for oval. */ - int filled; /* Non-zero means oval should be treated as + double width, /* Width of outline for oval. */ + int filled, /* Non-zero means oval should be treated as * filled; zero means only consider * outline. */ - double pointPtr[2]; /* Coordinates of point. */ + double pointPtr[2]) /* Coordinates of point. */ { double xDelta, yDelta, scaledDistance, distToOutline, distToCenter; double xDiam, yDiam; @@ -757,12 +757,12 @@ TkOvalToPoint(ovalPtr, width, filled, pointPtr) */ int -TkOvalToArea(ovalPtr, rectPtr) - register double *ovalPtr; /* Points to coordinates definining the +TkOvalToArea( + register double *ovalPtr, /* Points to coordinates definining the * bounding rectangle for the oval: x1, y1, * x2, y2. X1 must be less than x2 and y1 less * than y2. */ - register double *rectPtr; /* Points to coords for rectangle, in the + register double *rectPtr) /* Points to coords for rectangle, in the * order x1, y1, x2, y2. X1 and y1 must be * lower-left corner. */ { @@ -876,10 +876,10 @@ TkOvalToArea(ovalPtr, rectPtr) /* ARGSUSED */ void -TkIncludePoint(itemPtr, pointPtr) - register Tk_Item *itemPtr; /* Item whose bounding box is being +TkIncludePoint( + register Tk_Item *itemPtr, /* Item whose bounding box is being * calculated. */ - double *pointPtr; /* Address of two doubles giving x and y + double *pointPtr) /* Address of two doubles giving x and y * coordinates of point. */ { int tmp; @@ -921,12 +921,12 @@ TkIncludePoint(itemPtr, pointPtr) */ void -TkBezierScreenPoints(canvas, control, numSteps, xPointPtr) - Tk_Canvas canvas; /* Canvas in which curve is to be drawn. */ - double control[]; /* Array of coordinates for four control +TkBezierScreenPoints( + Tk_Canvas canvas, /* Canvas in which curve is to be drawn. */ + double control[], /* Array of coordinates for four control * points: x0, y0, x1, y1, ... x3 y3. */ - int numSteps; /* Number of curve points to generate. */ - register XPoint *xPointPtr; /* Where to put new points. */ + int numSteps, /* Number of curve points to generate. */ + register XPoint *xPointPtr) /* Where to put new points. */ { int i; double u, u2, u3, t, t2, t3; @@ -968,11 +968,11 @@ TkBezierScreenPoints(canvas, control, numSteps, xPointPtr) */ void -TkBezierPoints(control, numSteps, coordPtr) - double control[]; /* Array of coordinates for four control +TkBezierPoints( + double control[], /* Array of coordinates for four control * points: x0, y0, x1, y1, ... x3 y3. */ - int numSteps; /* Number of curve points to generate. */ - register double *coordPtr; /* Where to put new points. */ + int numSteps, /* Number of curve points to generate. */ + register double *coordPtr) /* Where to put new points. */ { int i; double u, u2, u3, t, t2, t3; @@ -1019,22 +1019,22 @@ TkBezierPoints(control, numSteps, coordPtr) */ int -TkMakeBezierCurve(canvas, pointPtr, numPoints, numSteps, xPoints, dblPoints) - Tk_Canvas canvas; /* Canvas in which curve is to be drawn. */ - double *pointPtr; /* Array of input coordinates: x0, y0, x1, y1, +TkMakeBezierCurve( + Tk_Canvas canvas, /* Canvas in which curve is to be drawn. */ + double *pointPtr, /* Array of input coordinates: x0, y0, x1, y1, * etc.. */ - int numPoints; /* Number of points at pointPtr. */ - int numSteps; /* Number of steps to use for each spline + int numPoints, /* Number of points at pointPtr. */ + int numSteps, /* Number of steps to use for each spline * segments (determines smoothness of * curve). */ - XPoint xPoints[]; /* Array of XPoints to fill in (e.g. for + XPoint xPoints[], /* Array of XPoints to fill in (e.g. for * display). NULL means don't fill in any * XPoints. */ - double dblPoints[]; /* Array of points to fill in as doubles, in + double dblPoints[]) /* Array of points to fill in as doubles, in * the form x0, y0, x1, y1, .... NULL means - * don't fill in anything in this form. - * Caller must make sure that this array has - * enough space. */ + * don't fill in anything in this form. Caller + * must make sure that this array has enough + * space. */ { int closed, outputPoints, i; int numCoords = numPoints*2; @@ -1193,18 +1193,18 @@ TkMakeBezierCurve(canvas, pointPtr, numPoints, numSteps, xPoints, dblPoints) */ int -TkMakeRawCurve(canvas, pointPtr, numPoints, numSteps, xPoints, dblPoints) - Tk_Canvas canvas; /* Canvas in which curve is to be drawn. */ - double *pointPtr; /* Array of input coordinates: x0, y0, x1, y1, +TkMakeRawCurve( + Tk_Canvas canvas, /* Canvas in which curve is to be drawn. */ + double *pointPtr, /* Array of input coordinates: x0, y0, x1, y1, * etc.. */ - int numPoints; /* Number of points at pointPtr. */ - int numSteps; /* Number of steps to use for each curve + int numPoints, /* Number of points at pointPtr. */ + int numSteps, /* Number of steps to use for each curve * segment (determines smoothness of * curve). */ - XPoint xPoints[]; /* Array of XPoints to fill in (e.g. for + XPoint xPoints[], /* Array of XPoints to fill in (e.g. for * display). NULL means don't fill in any * XPoints. */ - double dblPoints[]; /* Array of points to fill in as doubles, in + double dblPoints[]) /* Array of points to fill in as doubles, in * the form x0, y0, x1, y1, .... NULL means * don't fill in anything in this form. * Caller must make sure that this array has @@ -1370,14 +1370,14 @@ TkMakeRawCurve(canvas, pointPtr, numPoints, numSteps, xPoints, dblPoints) */ void -TkMakeBezierPostscript(interp, canvas, pointPtr, numPoints) - Tcl_Interp *interp; /* Interpreter in whose result the Postscript +TkMakeBezierPostscript( + Tcl_Interp *interp, /* Interpreter in whose result the Postscript * is to be stored. */ - Tk_Canvas canvas; /* Canvas widget for which the Postscript is + Tk_Canvas canvas, /* Canvas widget for which the Postscript is * being generated. */ - double *pointPtr; /* Array of input coordinates: x0, y0, x1, y1, + double *pointPtr, /* Array of input coordinates: x0, y0, x1, y1, * etc.. */ - int numPoints; /* Number of points at pointPtr. */ + int numPoints) /* Number of points at pointPtr. */ { int closed, i; int numCoords = numPoints*2; @@ -1413,7 +1413,7 @@ TkMakeBezierPostscript(interp, canvas, pointPtr, numPoints) sprintf(buffer, "%.15g %.15g moveto\n", control[6], Tk_CanvasPsY(canvas, control[7])); } - Tcl_AppendResult(interp, buffer, (char *) NULL); + Tcl_AppendResult(interp, buffer, NULL); /* * Cycle through all the remaining points in the curve, generating a curve @@ -1443,7 +1443,7 @@ TkMakeBezierPostscript(interp, canvas, pointPtr, numPoints) control[2], Tk_CanvasPsY(canvas, control[3]), control[4], Tk_CanvasPsY(canvas, control[5]), control[6], Tk_CanvasPsY(canvas, control[7])); - Tcl_AppendResult(interp, buffer, (char *) NULL); + Tcl_AppendResult(interp, buffer, NULL); } } @@ -1468,14 +1468,14 @@ TkMakeBezierPostscript(interp, canvas, pointPtr, numPoints) */ void -TkMakeRawCurvePostscript(interp, canvas, pointPtr, numPoints) - Tcl_Interp *interp; /* Interpreter in whose result the Postscript +TkMakeRawCurvePostscript( + Tcl_Interp *interp, /* Interpreter in whose result the Postscript * is to be stored. */ - Tk_Canvas canvas; /* Canvas widget for which the Postscript is + Tk_Canvas canvas, /* Canvas widget for which the Postscript is * being generated. */ - double *pointPtr; /* Array of input coordinates: x0, y0, x1, y1, + double *pointPtr, /* Array of input coordinates: x0, y0, x1, y1, * etc.. */ - int numPoints; /* Number of points at pointPtr. */ + int numPoints) /* Number of points at pointPtr. */ { int i; double *segPtr; @@ -1487,7 +1487,7 @@ TkMakeRawCurvePostscript(interp, canvas, pointPtr, numPoints) sprintf(buffer, "%.15g %.15g moveto\n", pointPtr[0], Tk_CanvasPsY(canvas, pointPtr[1])); - Tcl_AppendResult(interp, buffer, (char *) NULL); + Tcl_AppendResult(interp, buffer, NULL); /* * Loop through all the remaining points in the curve, generating a @@ -1514,7 +1514,7 @@ TkMakeRawCurvePostscript(interp, canvas, pointPtr, numPoints) segPtr[4], Tk_CanvasPsY(canvas, segPtr[5]), segPtr[6], Tk_CanvasPsY(canvas, segPtr[7])); } - Tcl_AppendResult(interp, buffer, (char *) NULL); + Tcl_AppendResult(interp, buffer, NULL); } /* @@ -1551,7 +1551,7 @@ TkMakeRawCurvePostscript(interp, canvas, pointPtr, numPoints) control[4], Tk_CanvasPsY(canvas, control[5]), control[6], Tk_CanvasPsY(canvas, control[7])); } - Tcl_AppendResult(interp, buffer, (char *) NULL); + Tcl_AppendResult(interp, buffer, NULL); } } @@ -1577,17 +1577,17 @@ TkMakeRawCurvePostscript(interp, canvas, pointPtr, numPoints) */ int -TkGetMiterPoints(p1, p2, p3, width, m1, m2) - double p1[]; /* Points to x- and y-coordinates of point +TkGetMiterPoints( + double p1[], /* Points to x- and y-coordinates of point * before vertex. */ - double p2[]; /* Points to x- and y-coordinates of vertex + double p2[], /* Points to x- and y-coordinates of vertex * for mitered joint. */ - double p3[]; /* Points to x- and y-coordinates of point + double p3[], /* Points to x- and y-coordinates of point * after vertex. */ - double width; /* Width of line. */ - double m1[]; /* Points to place to put "left" vertex point + double width, /* Width of line. */ + double m1[], /* Points to place to put "left" vertex point * (see as you face from p1 to p2). */ - double m2[]; /* Points to place to put "right" vertex + double m2[]) /* Points to place to put "right" vertex * point. */ { double theta1; /* Angle of segment p2-p1. */ @@ -1704,17 +1704,17 @@ TkGetMiterPoints(p1, p2, p3, width, m1, m2) */ void -TkGetButtPoints(p1, p2, width, project, m1, m2) - double p1[]; /* Points to x- and y-coordinates of point +TkGetButtPoints( + double p1[], /* Points to x- and y-coordinates of point * before vertex. */ - double p2[]; /* Points to x- and y-coordinates of vertex + double p2[], /* Points to x- and y-coordinates of vertex * for mitered joint. */ - double width; /* Width of line. */ - int project; /* Non-zero means project p2 by an additional + double width, /* Width of line. */ + int project, /* Non-zero means project p2 by an additional * width/2 before computing m1 and m2. */ - double m1[]; /* Points to place to put "left" result point, + double m1[], /* Points to place to put "left" result point, * as you face from p1 to p2. */ - double m2[]; /* Points to place to put "right" result + double m2[]) /* Points to place to put "right" result * point. */ { double length; /* Length of p1-p2 segment. */ diff --git a/generic/tkUndo.c b/generic/tkUndo.c index 9e9d6f3..76046f8 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -9,12 +9,13 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUndo.c,v 1.7 2005/10/17 20:52:01 dkf Exp $ + * RCS: @(#) $Id: tkUndo.c,v 1.8 2005/11/17 16:21:56 dkf Exp $ */ #include "tkUndo.h" -static int EvaluateActionList(Tcl_Interp *interp, TkUndoSubAtom *action); +static int EvaluateActionList(Tcl_Interp *interp, + TkUndoSubAtom *action); /* *---------------------------------------------------------------------- diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 33589e7..a5d64d1 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWindow.c,v 1.70 2005/11/17 10:57:35 dkf Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.71 2005/11/17 16:21:56 dkf Exp $ */ #include "tkPort.h" @@ -179,7 +179,7 @@ static TkCmd commands[] = { {"::tk::unsupported::MacWindowStyle", NULL, TkUnsupported1ObjCmd, 1, 1}, #endif - {(char *) NULL, NULL, NULL, 0, 0} + {NULL, NULL, NULL, 0, 0} }; /* @@ -197,24 +197,23 @@ static char *visual = NULL; static int rest = 0; static Tk_ArgvInfo argTable[] = { - {"-colormap", TK_ARGV_STRING, (char *) NULL, (char *) &colormap, + {"-colormap", TK_ARGV_STRING, NULL, (char *) &colormap, "Colormap for main window"}, - {"-display", TK_ARGV_STRING, (char *) NULL, (char *) &display, + {"-display", TK_ARGV_STRING, NULL, (char *) &display, "Display to use"}, - {"-geometry", TK_ARGV_STRING, (char *) NULL, (char *) &geometry, + {"-geometry", TK_ARGV_STRING, NULL, (char *) &geometry, "Initial geometry for window"}, - {"-name", TK_ARGV_STRING, (char *) NULL, (char *) &name, + {"-name", TK_ARGV_STRING, NULL, (char *) &name, "Name to use for application"}, {"-sync", TK_ARGV_CONSTANT, (char *) 1, (char *) &synchronize, "Use synchronous mode for display server"}, - {"-visual", TK_ARGV_STRING, (char *) NULL, (char *) &visual, + {"-visual", TK_ARGV_STRING, NULL, (char *) &visual, "Visual for main window"}, - {"-use", TK_ARGV_STRING, (char *) NULL, (char *) &use, + {"-use", TK_ARGV_STRING, NULL, (char *) &use, "Id of window in which to embed application"}, {"--", TK_ARGV_REST, (char *) 1, (char *) &rest, "Pass all remaining arguments through to script"}, - {(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL, - (char *) NULL} + {NULL, TK_ARGV_END, NULL, NULL, NULL} }; /* @@ -447,7 +446,7 @@ GetScreen(interp, screenName, screenPtr) Tcl_SetResult(interp, "no display name and no $DISPLAY environment variable", TCL_STATIC); - return (TkDisplay *) NULL; + return NULL; } length = strlen(screenName); screenId = 0; @@ -457,7 +456,7 @@ GetScreen(interp, screenName, screenPtr) } if ((*p == '.') && (p[1] != '\0')) { length = p - screenName; - screenId = strtoul(p+1, (char **) NULL, 10); + screenId = strtoul(p+1, NULL, 10); } /* @@ -476,8 +475,8 @@ GetScreen(interp, screenName, screenPtr) if (dispPtr == NULL) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "couldn't connect to display \"", - screenName, "\"", (char *) NULL); - return (TkDisplay *) NULL; + screenName, "\"", NULL); + return NULL; } dispPtr->nextPtr = tsdPtr->displayList; /* TkGetDisplayList(); */ tsdPtr->displayList = dispPtr; @@ -514,7 +513,7 @@ GetScreen(interp, screenName, screenPtr) sprintf(buf, "bad screen number \"%d\"", screenId); Tcl_SetResult(interp, buf, TCL_VOLATILE); - return (TkDisplay *) NULL; + return NULL; } *screenPtr = screenId; return dispPtr; @@ -766,7 +765,7 @@ NameWindow(interp, winPtr, parentPtr, name) if (isupper(UCHAR(name[0]))) { Tcl_AppendResult(interp, "window name starts with an upper-case letter: \"", - name, "\"", (char *) NULL); + name, "\"", NULL); return TCL_ERROR; } @@ -995,14 +994,12 @@ Tk_CreateWindow(interp, parent, name, screenName) if ((parentPtr != NULL) && (parentPtr->flags & TK_ALREADY_DEAD)) { Tcl_AppendResult(interp, - "can't create window: parent has been destroyed", - (char *) NULL); + "can't create window: parent has been destroyed", NULL); return NULL; } else if ((parentPtr != NULL) && (parentPtr->flags & TK_CONTAINER)) { Tcl_AppendResult(interp, - "can't create window: its parent has -container = yes", - (char *) NULL); + "can't create window: its parent has -container = yes", NULL); return NULL; } if (screenName == NULL) { @@ -1060,14 +1057,12 @@ Tk_CreateAnonymousWindow(interp, parent, screenName) if ((parentPtr != NULL) && (parentPtr->flags & TK_ALREADY_DEAD)) { Tcl_AppendResult(interp, - "can't create window: parent has been destroyed", - (char *) NULL); + "can't create window: parent has been destroyed", NULL); return NULL; } else if ((parentPtr != NULL) && (parentPtr->flags & TK_CONTAINER)) { Tcl_AppendResult(interp, - "can't create window: its parent has -container = yes", - (char *) NULL); + "can't create window: its parent has -container = yes", NULL); return NULL; } if (screenName == NULL) { @@ -1079,13 +1074,13 @@ Tk_CreateAnonymousWindow(interp, parent, screenName) */ winPtr->flags |= TK_ANONYMOUS_WINDOW; - if (NameWindow(interp, winPtr, parentPtr, (char *)NULL) != TCL_OK) { + if (NameWindow(interp, winPtr, parentPtr, NULL) != TCL_OK) { Tk_DestroyWindow((Tk_Window) winPtr); return NULL; } return (Tk_Window) winPtr; } else { - return CreateTopLevelWindow(interp, parent, (char *)NULL, screenName, + return CreateTopLevelWindow(interp, parent, NULL, screenName, TK_ANONYMOUS_WINDOW); } } @@ -1145,7 +1140,7 @@ Tk_CreateWindowFromPath(interp, tkwin, pathName, screenName) p = strrchr(pathName, '.'); if (p == NULL) { Tcl_AppendResult(interp, "bad window path name \"", pathName, - "\"", (char *) NULL); + "\"", NULL); return NULL; } numChars = (int) (p-pathName); @@ -1175,13 +1170,11 @@ Tk_CreateWindowFromPath(interp, tkwin, pathName, screenName) } if (((TkWindow *) parent)->flags & TK_ALREADY_DEAD) { Tcl_AppendResult(interp, - "can't create window: parent has been destroyed", - (char *) NULL); + "can't create window: parent has been destroyed", NULL); return NULL; } else if (((TkWindow *) parent)->flags & TK_CONTAINER) { Tcl_AppendResult(interp, - "can't create window: its parent has -container = yes", - (char *) NULL); + "can't create window: its parent has -container = yes", NULL); return NULL; } @@ -2289,7 +2282,7 @@ Tk_NameToWindow(interp, pathName, tkwin) * we're on our way out of the application. */ - Tcl_AppendResult(interp, "NULL main window", (char *)NULL); + Tcl_AppendResult(interp, "NULL main window", NULL); return NULL; } @@ -2297,7 +2290,7 @@ Tk_NameToWindow(interp, pathName, tkwin) pathName); if (hPtr == NULL) { Tcl_AppendResult(interp, "bad window path name \"", - pathName, "\"", (char *) NULL); + pathName, "\"", NULL); return NULL; } return (Tk_Window) Tcl_GetHashValue(hPtr); @@ -2923,7 +2916,7 @@ Initialize(interp) while (1) { master = Tcl_GetMaster(master); if (master == NULL) { - Tcl_AppendResult(interp, "NULL master", (char *) NULL); + Tcl_AppendResult(interp, "NULL master", NULL); Tcl_MutexUnlock(&windowMutex); return TCL_ERROR; } @@ -2938,8 +2931,7 @@ Initialize(interp) */ if (Tcl_GetInterpPath(master, interp) != TCL_OK) { - Tcl_AppendResult(interp, "error in Tcl_GetInterpPath", - (char *) NULL); + Tcl_AppendResult(interp, "error in Tcl_GetInterpPath", NULL); Tcl_MutexUnlock(&windowMutex); return TCL_ERROR; } @@ -2965,8 +2957,7 @@ Initialize(interp) Tcl_DStringFree(&ds); Tcl_AppendResult(interp, - "not allowed to start Tk by master's safe::TkInit", - (char *) NULL); + "not allowed to start Tk by master's safe::TkInit", NULL); Tcl_MutexUnlock(&windowMutex); return TCL_ERROR; } @@ -2986,7 +2977,7 @@ Initialize(interp) * that we used. */ - argString = Tcl_GetVar2(interp, "argv", (char *) NULL, TCL_GLOBAL_ONLY); + argString = Tcl_GetVar2(interp, "argv", NULL, TCL_GLOBAL_ONLY); } argv = NULL; if (argString != NULL) { @@ -3006,9 +2997,9 @@ Initialize(interp) goto argError; } p = Tcl_Merge(argc, argv); - Tcl_SetVar2(interp, "argv", (char *) NULL, p, TCL_GLOBAL_ONLY); + Tcl_SetVar2(interp, "argv", NULL, p, TCL_GLOBAL_ONLY); sprintf(buffer, "%d", argc); - Tcl_SetVar2(interp, "argc", (char *) NULL, buffer, TCL_GLOBAL_ONLY); + Tcl_SetVar2(interp, "argc", NULL, buffer, TCL_GLOBAL_ONLY); ckfree(p); } @@ -3095,7 +3086,7 @@ Initialize(interp) if (geometry != NULL) { Tcl_SetVar(interp, "geometry", geometry, TCL_GLOBAL_ONLY); - code = Tcl_VarEval(interp, "wm geometry . ", geometry, (char *) NULL); + code = Tcl_VarEval(interp, "wm geometry . ", geometry, NULL); if (code != TCL_OK) { goto done; } -- cgit v0.12