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 | |
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.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | carbon/tkMacOSXKeyboard.c | 4 | ||||
-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 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyboard.c | 4 | ||||
-rw-r--r-- | unix/tkUnixKey.c | 8 | ||||
-rw-r--r-- | win/tkWinKey.c | 4 |
9 files changed, 38 insertions, 32 deletions
@@ -1,11 +1,17 @@ 2009-12-16 Jan Nijtmans <nijtmans@users.sf.net> * generic/tkListbox.c: Fix gcc warning: ignoring return value of ‘strtol’, - declared with attribute warn_unused_result + declared with attribute warn_unused_result. * unix/tkUnixEvent.c: Fix gcc warning: dereferencing pointer ‘xgePtr’ does - break strict-aliasing rules - - + break strict-aliasing rules. + * generic/tkInt.decls: CONSTify return values of TkKeysymToString, + * generic/tkBind.c TkFindStateString, TkpGetString, TkpGetChar, + * generic/tkIntDecls.h which are all not supposed to be modified by + * generic/tkUtil.c the caller. In tkUtil.c this gets rid of a + * carbon/tkMacOSXKeyboard.c dangerous type cast. + * macosx/tkMacOSXKeyboard.c + * unix/tkUnixKey.c + * win/tkWinKey.c 2009-12-15 Don Porter <dgp@users.sourceforge.net> diff --git a/carbon/tkMacOSXKeyboard.c b/carbon/tkMacOSXKeyboard.c index 0d2bd21..d7638fd 100644 --- a/carbon/tkMacOSXKeyboard.c +++ b/carbon/tkMacOSXKeyboard.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: tkMacOSXKeyboard.c,v 1.1 2009/06/26 01:42:47 das Exp $ + * RCS: @(#) $Id: tkMacOSXKeyboard.c,v 1.2 2009/12/16 22:00:30 nijtmans Exp $ */ #include "tkMacOSXInt.h" @@ -330,7 +330,7 @@ XKeycodeToKeysym( *---------------------------------------------------------------------- */ -char * +const char * TkpGetString( TkWindow *winPtr, /* Window where event occurred: Needed to get * input context. */ 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; diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index e02b3cd..a12273e 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.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: tkMacOSXKeyboard.c,v 1.26 2009/07/06 20:29:21 dkf Exp $ + * RCS: @(#) $Id: tkMacOSXKeyboard.c,v 1.27 2009/12/16 22:00:30 nijtmans Exp $ */ #include "tkMacOSXPrivate.h" @@ -418,7 +418,7 @@ XKeycodeToKeysym( *---------------------------------------------------------------------- */ -char * +const char * TkpGetString( TkWindow *winPtr, /* Window where event occurred: Needed to get * input context. */ diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 77e782f..49ee3e0 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.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: tkUnixKey.c,v 1.15 2008/11/26 15:56:37 dkf Exp $ + * RCS: @(#) $Id: tkUnixKey.c,v 1.16 2009/12/16 22:00:30 nijtmans Exp $ */ #include "tkInt.h" @@ -90,7 +90,7 @@ Tk_SetCaretPos( * *---------------------------------------------------------------------- */ -static char * +static const char * TkpGetChar( XEvent *eventPtr, /* KeyPress or KeyRelease event */ Tcl_DString *dsPtr) /* Initialized, empty string to hold result. */ @@ -135,7 +135,7 @@ TkpGetChar( *---------------------------------------------------------------------- */ -char * +const char * TkpGetString( TkWindow *winPtr, /* Window where event occurred */ XEvent *eventPtr, /* X keyboard event. */ @@ -161,7 +161,7 @@ TkpGetString( Tcl_DStringSetLength(dsPtr, len); len = Xutf8LookupString(winPtr->inputContext, &eventPtr->xkey, - Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr), + Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr), NULL, &status); } if ((status != XLookupChars) && (status != XLookupBoth)) { diff --git a/win/tkWinKey.c b/win/tkWinKey.c index caa8cfb..3cc86b5 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.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: tkWinKey.c,v 1.19 2007/12/13 15:28:55 dgp Exp $ + * RCS: @(#) $Id: tkWinKey.c,v 1.20 2009/12/16 22:00:31 nijtmans Exp $ */ #include "tkWinInt.h" @@ -81,7 +81,7 @@ static KeySym KeycodeToKeysym(unsigned int keycode, *---------------------------------------------------------------------- */ -char * +const char * TkpGetString( TkWindow *winPtr, /* Window where event occurred: needed to get * input context. */ |