diff options
author | nijtmans <nijtmans> | 2009-12-16 22:00:30 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2009-12-16 22:00:30 (GMT) |
commit | 5a94ed5e36c396971c0dc7a1c193c734c799233c (patch) | |
tree | 8230caa2b08bf3c9ea41bd365636a69852c3c8a1 /generic | |
parent | 4e49c034fea39f59a67ca7461b12f3d936aa5f95 (diff) | |
download | tk-5a94ed5e36c396971c0dc7a1c193c734c799233c.zip tk-5a94ed5e36c396971c0dc7a1c193c734c799233c.tar.gz tk-5a94ed5e36c396971c0dc7a1c193c734c799233c.tar.bz2 |
CONSTify return values of TkKeysymToString,
TkFindStateString, TkpGetString, TkpGetChar,
which are all not supposed to be modified by
the caller. In tkUtil.c this gets rid of a
dangerous type cast.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkBind.c | 8 | ||||
-rw-r--r-- | generic/tkInt.decls | 8 | ||||
-rw-r--r-- | generic/tkIntDecls.h | 14 | ||||
-rw-r--r-- | generic/tkUtil.c | 6 |
4 files changed, 18 insertions, 18 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c index c460a8c..2277917 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.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: tkBind.c,v 1.57 2009/08/24 00:54:42 das Exp $ + * RCS: @(#) $Id: tkBind.c,v 1.58 2009/12/16 22:00:31 nijtmans Exp $ */ #include "tkInt.h" @@ -2532,7 +2532,7 @@ ExpandPercents( goto doNumber; case 'K': if (flags & KEY) { - char *name = TkKeysymToString(keySym); + const char *name = TkKeysymToString(keySym); if (name != NULL) { string = name; @@ -4504,7 +4504,7 @@ GetPatternString( if (patPtr->detail.clientData != 0) { if ((patPtr->eventType == KeyPress) || (patPtr->eventType == KeyRelease)) { - char *string = TkKeysymToString(patPtr->detail.keySym); + const char *string = TkKeysymToString(patPtr->detail.keySym); if (string != NULL) { Tcl_DStringAppend(dsPtr, string, -1); @@ -4599,7 +4599,7 @@ TkStringToKeysym( *---------------------------------------------------------------------- */ -char * +const char * TkKeysymToString( KeySym keysym) { diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 1ec641e..01be8a0 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -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: tkInt.decls,v 1.59 2009/12/12 00:23:49 nijtmans Exp $ +# RCS: @(#) $Id: tkInt.decls,v 1.60 2009/12/16 22:00:31 nijtmans Exp $ library tk @@ -105,7 +105,7 @@ declare 21 generic { const TkStateMap *mapPtr, const char *strKey) } declare 22 generic { - char *TkFindStateString(const TkStateMap *mapPtr, int numKey) + CONST86 char *TkFindStateString(const TkStateMap *mapPtr, int numKey) } declare 23 generic { void TkFocusDeadWindow(TkWindow *winPtr) @@ -188,7 +188,7 @@ declare 45 generic { void TkInstallFrameMenu(Tk_Window tkwin) } declare 46 generic { - char *TkKeysymToString(KeySym keysym) + CONST86 char *TkKeysymToString(KeySym keysym) } declare 47 generic { int TkLineToArea(double end1Ptr[], double end2Ptr[], double rectPtr[]) @@ -393,7 +393,7 @@ declare 108 generic { Tcl_Obj *objPtr, Tk_Window *windowPtr) } declare 109 generic { - char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr) + CONST86 char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr) } declare 110 generic { void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont) diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index 5ddb1a1..87f2003 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -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: tkIntDecls.h,v 1.46 2009/06/27 19:33:35 nijtmans Exp $ + * RCS: @(#) $Id: tkIntDecls.h,v 1.47 2009/12/16 22:00:31 nijtmans Exp $ */ #ifndef _TKINTDECLS @@ -182,7 +182,7 @@ EXTERN int TkFindStateNum (Tcl_Interp * interp, #ifndef TkFindStateString_TCL_DECLARED #define TkFindStateString_TCL_DECLARED /* 22 */ -EXTERN char * TkFindStateString (const TkStateMap * mapPtr, +EXTERN CONST86 char * TkFindStateString (const TkStateMap * mapPtr, int numKey); #endif #ifndef TkFocusDeadWindow_TCL_DECLARED @@ -321,7 +321,7 @@ EXTERN void TkInstallFrameMenu (Tk_Window tkwin); #ifndef TkKeysymToString_TCL_DECLARED #define TkKeysymToString_TCL_DECLARED /* 46 */ -EXTERN char * TkKeysymToString (KeySym keysym); +EXTERN CONST86 char * TkKeysymToString (KeySym keysym); #endif #ifndef TkLineToArea_TCL_DECLARED #define TkLineToArea_TCL_DECLARED @@ -665,7 +665,7 @@ EXTERN int TkGetWindowFromObj (Tcl_Interp * interp, #ifndef TkpGetString_TCL_DECLARED #define TkpGetString_TCL_DECLARED /* 109 */ -EXTERN char * TkpGetString (TkWindow * winPtr, XEvent * eventPtr, +EXTERN CONST86 char * TkpGetString (TkWindow * winPtr, XEvent * eventPtr, Tcl_DString * dsPtr); #endif #ifndef TkpGetSubFonts_TCL_DECLARED @@ -1157,7 +1157,7 @@ typedef struct TkIntStubs { void (*tkEventDeadWindow) (TkWindow * winPtr); /* 19 */ void (*tkFillPolygon) (Tk_Canvas canvas, double * coordPtr, int numPoints, Display * display, Drawable drawable, GC gc, GC outlineGC); /* 20 */ int (*tkFindStateNum) (Tcl_Interp * interp, const char * option, const TkStateMap * mapPtr, const char * strKey); /* 21 */ - char * (*tkFindStateString) (const TkStateMap * mapPtr, int numKey); /* 22 */ + CONST86 char * (*tkFindStateString) (const TkStateMap * mapPtr, int numKey); /* 22 */ void (*tkFocusDeadWindow) (TkWindow * winPtr); /* 23 */ int (*tkFocusFilterEvent) (TkWindow * winPtr, XEvent * eventPtr); /* 24 */ TkWindow * (*tkFocusKeyEvent) (TkWindow * winPtr, XEvent * eventPtr); /* 25 */ @@ -1181,7 +1181,7 @@ typedef struct TkIntStubs { void (*tkIncludePoint) (Tk_Item * itemPtr, double * pointPtr); /* 43 */ void (*tkInOutEvents) (XEvent * eventPtr, TkWindow * sourcePtr, TkWindow * destPtr, int leaveType, int enterType, Tcl_QueuePosition position); /* 44 */ void (*tkInstallFrameMenu) (Tk_Window tkwin); /* 45 */ - char * (*tkKeysymToString) (KeySym keysym); /* 46 */ + CONST86 char * (*tkKeysymToString) (KeySym keysym); /* 46 */ int (*tkLineToArea) (double end1Ptr[], double end2Ptr[], double rectPtr[]); /* 47 */ double (*tkLineToPoint) (double end1Ptr[], double end2Ptr[], double pointPtr[]); /* 48 */ int (*tkMakeBezierCurve) (Tk_Canvas canvas, double * pointPtr, int numPoints, int numSteps, XPoint xPoints[], double dblPoints[]); /* 49 */ @@ -1244,7 +1244,7 @@ typedef struct TkIntStubs { TkDisplay * (*tkGetDisplayList) (void); /* 106 */ TkMainInfo * (*tkGetMainInfoList) (void); /* 107 */ int (*tkGetWindowFromObj) (Tcl_Interp * interp, Tk_Window tkwin, Tcl_Obj * objPtr, Tk_Window * windowPtr); /* 108 */ - char * (*tkpGetString) (TkWindow * winPtr, XEvent * eventPtr, Tcl_DString * dsPtr); /* 109 */ + CONST86 char * (*tkpGetString) (TkWindow * winPtr, XEvent * eventPtr, Tcl_DString * dsPtr); /* 109 */ void (*tkpGetSubFonts) (Tcl_Interp * interp, Tk_Font tkfont); /* 110 */ Tcl_Obj * (*tkpGetSystemDefault) (Tk_Window tkwin, const char * dbName, const char * className); /* 111 */ void (*tkpMenuThreadInit) (void); /* 112 */ diff --git a/generic/tkUtil.c b/generic/tkUtil.c index e43613e..81ec092 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.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: tkUtil.c,v 1.31 2009/11/21 17:24:42 dkf Exp $ + * RCS: @(#) $Id: tkUtil.c,v 1.32 2009/12/16 22:00:31 nijtmans Exp $ */ #include "tkInt.h" @@ -856,14 +856,14 @@ TkComputeAnchor( *--------------------------------------------------------------------------- */ -char * +const char * TkFindStateString( const TkStateMap *mapPtr, /* The state table. */ int numKey) /* The key to try to find in the table. */ { for (; mapPtr->strKey!=NULL ; mapPtr++) { if (numKey == mapPtr->numKey) { - return (char *) mapPtr->strKey; + return mapPtr->strKey; } } return NULL; |