From c93dd2083f7175608a4a298176c8740d138d6d64 Mon Sep 17 00:00:00 2001 From: nijtmans Date: Wed, 14 Jan 2009 22:48:10 +0000 Subject: - fix for aMSN compatibility [tcl-Bug 2507326] - CONSTify Tk(Create|Find)menuReferences - various internal "const" decorations --- ChangeLog | 6 ++++++ generic/tkImgPhoto.c | 27 ++++++++++++++++----------- generic/tkMenu.c | 49 +++++++++++++++++++++++++------------------------ generic/tkMenu.h | 6 +++--- 4 files changed, 50 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee5325c..1488c64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-01-14 Jan Nijtmans + + * generic/tkImgPhoto.c: fix for aMSN compatibility [tcl-Bug 2507326] + * generic/tkMenu.h: CONSTify Tk(Create|Find)MenuReferences + * generic/tkMenu.c: various internal "const" decorations. + 2009-01-13 Jan Nijtmans * unix/tcl.m4: fix [tcl-Bug 2502365] Building of head on diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 4722095..3609af8 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.89 2009/01/06 09:22:30 dkf Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.90 2009/01/14 22:48:10 nijtmans Exp $ */ #include "tkImgPhoto.h" @@ -191,7 +191,7 @@ static char * ImgGetPhoto(PhotoMaster *masterPtr, Tk_PhotoImageBlock *blockPtr, struct SubcommandOptions *optPtr); static int MatchFileFormat(Tcl_Interp *interp, Tcl_Channel chan, - char *fileName, Tcl_Obj *formatString, + const char *fileName, Tcl_Obj *formatString, Tk_PhotoImageFormat **imageFormatPtr, int *widthPtr, int *heightPtr, int *oldformat); static int MatchStringFormat(Tcl_Interp *interp, Tcl_Obj *data, @@ -234,6 +234,7 @@ PhotoFormatThreadExitProc( while (tsdPtr->formatList != NULL) { freePtr = tsdPtr->formatList; tsdPtr->formatList = tsdPtr->formatList->nextPtr; + ckfree((char *) freePtr->name); ckfree((char *) freePtr); } } @@ -299,6 +300,10 @@ Tk_CreatePhotoImageFormat( copyPtr->nextPtr = tsdPtr->oldFormatList; tsdPtr->oldFormatList = copyPtr; } else { + /* for compatibility with aMSN: make a copy of formatPtr->name */ + char *name = ckalloc(strlen(formatPtr->name) + 1); + strcpy(name, formatPtr->name); + copyPtr->name = name; copyPtr->nextPtr = tsdPtr->formatList; tsdPtr->formatList = copyPtr; } @@ -444,7 +449,7 @@ ImgPhotoCmd( } case PHOTO_CGET: { - char *arg; + const char *arg; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); @@ -499,7 +504,7 @@ ImgPhotoCmd( return TCL_OK; } else if (objc == 3) { - char *arg = Tcl_GetStringFromObj(objv[2], &length); + const char *arg = Tcl_GetStringFromObj(objv[2], &length); if (length > 1 && !strncmp(arg, "-data", (unsigned) length)) { Tcl_AppendResult(interp, "-data {} {} {}", NULL); @@ -741,7 +746,7 @@ ImgPhotoCmd( if (oldformat) { Tcl_DString buffer; typedef int (*OldStringWriteProc)(Tcl_Interp *interp, - Tcl_DString *dataPtr, char *formatString, + Tcl_DString *dataPtr, const char *formatString, Tk_PhotoImageBlock *blockPtr); Tcl_DStringInit(&buffer); @@ -887,7 +892,7 @@ ImgPhotoCmd( } for (x = 0; x < dataWidth; ++x) { - char *colorString = Tcl_GetString(listObjv[x]); + const char *colorString = Tcl_GetString(listObjv[x]); XColor color; int tmpr, tmpg, tmpb; @@ -1520,7 +1525,7 @@ ParseSubcommandOptions( return TCL_ERROR; } } else if ((bit != OPT_SHRINK) && (bit != OPT_GRAYSCALE)) { - char *val; + const char *val; maxValues = ((bit == OPT_FROM) || (bit == OPT_TO))? 4: 2; argIndex = index + 1; for (numValues = 0; numValues < maxValues; ++numValues) { @@ -2267,7 +2272,7 @@ static int 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. */ + const 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 @@ -2281,7 +2286,7 @@ MatchFileFormat( Tk_PhotoImageFormat *formatPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - char *formatString = NULL; + const char *formatString = NULL; if (formatObj) { formatString = Tcl_GetString(formatObj); @@ -2410,7 +2415,7 @@ MatchStringFormat( Tk_PhotoImageFormat *formatPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - char *formatString = NULL; + const char *formatString = NULL; if (formatObj) { formatString = Tcl_GetString(formatObj); @@ -3797,7 +3802,7 @@ PhotoOptionFind( Tcl_Obj *obj) /* Name of option to be found. */ { int length; - char *name = Tcl_GetStringFromObj(obj, &length); + const char *name = Tcl_GetStringFromObj(obj, &length); char *prevname = NULL; Tcl_ObjCmdProc *proc = NULL; OptionAssocData *list = Tcl_GetAssocData(interp, "photoOption", NULL); diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 93726c8..3d2aa39 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -12,7 +12,7 @@ * 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.48 2008/11/27 23:26:05 nijtmans Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.49 2009/01/14 22:48:10 nijtmans Exp $ */ /* @@ -342,7 +342,7 @@ static void DestroyMenuHashTable(ClientData clientData, static void DestroyMenuInstance(TkMenu *menuPtr); static void DestroyMenuEntry(char *memPtr); static int GetIndexFromCoords(Tcl_Interp *interp, TkMenu *menuPtr, - char *string, int *indexPtr); + const char *string, int *indexPtr); static int MenuDoYPosition(Tcl_Interp *interp, TkMenu *menuPtr, Tcl_Obj *objPtr); static int MenuDoXPosition(Tcl_Interp *interp, @@ -454,7 +454,7 @@ MenuCmd( register TkMenu *menuPtr; TkMenuReferences *menuRefPtr; int i, index, toplevel; - char *windowName; + const char *windowName; static const char *const typeStringList[] = {"-type", NULL}; TkMenuOptionTables *optionTablesPtr = clientData; @@ -1467,7 +1467,7 @@ DestroyMenuEntry( if (((mePtr->type == CHECK_BUTTON_ENTRY) || (mePtr->type == RADIO_BUTTON_ENTRY)) && (mePtr->namePtr != NULL)) { - char *varName = Tcl_GetString(mePtr->namePtr); + const char *varName = Tcl_GetString(mePtr->namePtr); Tcl_UntraceVar(menuPtr->interp, varName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, @@ -1690,7 +1690,7 @@ PostProcessEntry( { TkMenu *menuPtr = mePtr->menuPtr; int index = mePtr->index; - char *name; + const char *name; Tk_Image image; /* @@ -1787,7 +1787,7 @@ PostProcessEntry( */ if (mePtr->imagePtr != NULL) { - char *imageString = Tcl_GetString(mePtr->imagePtr); + const char *imageString = Tcl_GetString(mePtr->imagePtr); image = Tk_GetImage(menuPtr->interp, menuPtr->tkwin, imageString, TkMenuImageProc, mePtr); @@ -1802,7 +1802,7 @@ PostProcessEntry( } mePtr->image = image; if (mePtr->selectImagePtr != NULL) { - char *selectImageString = Tcl_GetString(mePtr->selectImagePtr); + const char *selectImageString = Tcl_GetString(mePtr->selectImagePtr); image = Tk_GetImage(menuPtr->interp, menuPtr->tkwin, selectImageString, TkMenuSelectImageProc, mePtr); @@ -1820,7 +1820,7 @@ PostProcessEntry( if ((mePtr->type == CHECK_BUTTON_ENTRY) || (mePtr->type == RADIO_BUTTON_ENTRY)) { Tcl_Obj *valuePtr; - char *name; + const char *name; if (mePtr->namePtr == NULL) { if (mePtr->labelPtr == NULL) { @@ -1854,8 +1854,8 @@ PostProcessEntry( mePtr->entryFlags &= ~ENTRY_SELECTED; if (valuePtr != NULL) { if (mePtr->onValuePtr != NULL) { - char *value = Tcl_GetString(valuePtr); - char *onValue = Tcl_GetString(mePtr->onValuePtr); + const char *value = Tcl_GetString(valuePtr); + const char *onValue = Tcl_GetString(mePtr->onValuePtr); if (strcmp(value, onValue) == 0) { mePtr->entryFlags |= ENTRY_SELECTED; @@ -1917,7 +1917,7 @@ ConfigureMenuEntry( if ((mePtr->namePtr != NULL) && ((mePtr->type == CHECK_BUTTON_ENTRY) || (mePtr->type == RADIO_BUTTON_ENTRY))) { - char *name = Tcl_GetString(mePtr->namePtr); + const char *name = Tcl_GetString(mePtr->namePtr); Tcl_UntraceVar(menuPtr->interp, name, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, @@ -1975,7 +1975,7 @@ ConfigureMenuCloneEntries( int cascadeEntryChanged = 0; TkMenuReferences *oldCascadeMenuRefPtr, *cascadeMenuRefPtr = NULL; Tcl_Obj *oldCascadePtr = NULL; - char *newCascadeName; + const char *newCascadeName; /* * Cascades are kind of tricky here. This is special case #3 in the @@ -1999,7 +1999,7 @@ ConfigureMenuCloneEntries( } if (mePtr->type == CASCADE_ENTRY) { - char *oldCascadeName; + const char *oldCascadeName; if (mePtr->namePtr != NULL) { newCascadeName = Tcl_GetString(mePtr->namePtr); @@ -2115,7 +2115,7 @@ TkGetMenuIndex( int *indexPtr) /* Where to store converted index. */ { int i; - char *string = Tcl_GetString(objPtr); + const char *string = Tcl_GetString(objPtr); if ((string[0] == 'a') && (strcmp(string, "active") == 0)) { *indexPtr = menuPtr->active; @@ -2159,7 +2159,7 @@ TkGetMenuIndex( for (i = 0; i < menuPtr->numEntries; i++) { Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr; - char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr); + const char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr); if ((label != NULL) && (Tcl_StringMatch(label, string))) { *indexPtr = i; @@ -2352,7 +2352,7 @@ MenuAddOrInsert( index = menuPtr->numEntries; } if (index < 0) { - char *indexString = Tcl_GetString(indexPtr); + const char *indexString = Tcl_GetString(indexPtr); Tcl_AppendResult(interp, "bad index \"", indexString, "\"", NULL); return TCL_ERROR; } @@ -2482,7 +2482,7 @@ MenuVarProc( TkMenuEntry *mePtr = clientData; TkMenu *menuPtr; const char *value; - char *name, *onValue; + const char *name, *onValue; if (flags & TCL_INTERP_DESTROYED) { /* @@ -2734,7 +2734,7 @@ CloneMenu( Tcl_IncrRefCount(newObjv[1]); if (Tk_BindtagsObjCmd(newMenuPtr->tkwin, newMenuPtr->interp, 2, newObjv) == TCL_OK) { - char *windowName; + const char *windowName; Tcl_Obj *bindingsPtr = Tcl_DuplicateObj(Tcl_GetObjResult(newMenuPtr->interp)); Tcl_Obj *elementPtr; @@ -2916,11 +2916,12 @@ static int GetIndexFromCoords( Tcl_Interp *interp, /* Interpreter of menu. */ TkMenu *menuPtr, /* The menu we are searching. */ - char *string, /* The @string we are parsing. */ + const char *string, /* The @string we are parsing. */ int *indexPtr) /* The index of the item that matches. */ { int x, y, i; - char *p, *end; + const char *p; + char *end; TkRecomputeMenu(menuPtr); p = string + 1; @@ -3038,7 +3039,7 @@ TkNewMenuName( Tcl_CmdInfo cmdInfo; Tcl_HashTable *nameTablePtr = NULL; TkWindow *winPtr = (TkWindow *) menuPtr->tkwin; - char *parentName = Tcl_GetString(parentPtr); + const char *parentName = Tcl_GetString(parentPtr); if (winPtr->mainPtr != NULL) { nameTablePtr = &(winPtr->mainPtr->nameTable); @@ -3334,7 +3335,7 @@ TkGetMenuHashTable( TkMenuReferences * TkCreateMenuReferences( Tcl_Interp *interp, - char *pathName) /* The path of the menu widget. */ + const char *pathName) /* The path of the menu widget. */ { Tcl_HashEntry *hashEntryPtr; TkMenuReferences *menuRefPtr; @@ -3378,7 +3379,7 @@ TkCreateMenuReferences( TkMenuReferences * TkFindMenuReferences( Tcl_Interp *interp, /* The interp the menu is living in. */ - char *pathName) /* The path of the menu widget. */ + const char *pathName) /* The path of the menu widget. */ { Tcl_HashEntry *hashEntryPtr; TkMenuReferences *menuRefPtr = NULL; @@ -3417,7 +3418,7 @@ TkFindMenuReferencesObj( Tcl_Interp *interp, /* The interp the menu is living in. */ Tcl_Obj *objPtr) /* The path of the menu widget. */ { - char *pathName = Tcl_GetString(objPtr); + const char *pathName = Tcl_GetString(objPtr); return TkFindMenuReferences(interp, pathName); } diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 015b89b..e85c874 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -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: tkMenu.h,v 1.15 2008/10/17 23:18:37 nijtmans Exp $ + * RCS: @(#) $Id: tkMenu.h,v 1.16 2009/01/14 22:48:10 nijtmans Exp $ */ #ifndef _TKMENU @@ -492,12 +492,12 @@ typedef struct TkMenuOptionTables { MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, int index); MODULE_SCOPE void TkBindMenu(Tk_Window tkwin, TkMenu *menuPtr); MODULE_SCOPE TkMenuReferences*TkCreateMenuReferences(Tcl_Interp *interp, - char *name); + const char *name); MODULE_SCOPE void TkDestroyMenu(TkMenu *menuPtr); MODULE_SCOPE void TkEventuallyRecomputeMenu(TkMenu *menuPtr); MODULE_SCOPE void TkEventuallyRedrawMenu(TkMenu *menuPtr, TkMenuEntry *mePtr); -MODULE_SCOPE TkMenuReferences*TkFindMenuReferences(Tcl_Interp *interp, char *name); +MODULE_SCOPE TkMenuReferences*TkFindMenuReferences(Tcl_Interp *interp, const char *name); MODULE_SCOPE TkMenuReferences*TkFindMenuReferencesObj(Tcl_Interp *interp, Tcl_Obj *namePtr); MODULE_SCOPE int TkFreeMenuReferences(TkMenuReferences *menuRefPtr); -- cgit v0.12