summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-05-26 15:28:09 (GMT)
committernijtmans <nijtmans>2010-05-26 15:28:09 (GMT)
commit44956ea2ae237e8111e50cfde47883f81e24fb7b (patch)
treeb40da66d41c9fb7b65513e77544b1afb6c20b36f
parentd59e4da7e1c57fe1962f24cafedbc04cf2cc5b2b (diff)
downloadtk-44956ea2ae237e8111e50cfde47883f81e24fb7b.zip
tk-44956ea2ae237e8111e50cfde47883f81e24fb7b.tar.gz
tk-44956ea2ae237e8111e50cfde47883f81e24fb7b.tar.bz2
Fix some gcc strict-aliasing warnings (discovered with "-Wstrict-aliasing=2"
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkText.c8
-rw-r--r--unix/tkUnixFont.c14
-rw-r--r--unix/tkUnixSelect.c60
4 files changed, 46 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index e6eb52c..54544a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
* tests/wm.test: Fix 3 tests on Ubuntu 10.4, two of them timing dependent,
one wm-dependent.
+ * generic/tkText.c Fix some gcc strict-aliasing warnings (discovered
+ * unix/tkUnixFont.c with "-Wstrict-aliasing=2"
+ * unix/tkUnixSelect.c
2010-05-20 Donal K. Fellows <dkf@users.sf.net>
@@ -3545,7 +3548,7 @@
* changes: Updates for 8.5.2 release.
* unix/tkUnixCursor.c: Stop crash in [. configure -cursor] on X11.
- Thanks to emiliano gavilán. [Bug 1922466]
+ Thanks to emiliano gavilan. [Bug 1922466]
2008-03-26 Joe English <jenglish@users.sourceforge.net>
diff --git a/generic/tkText.c b/generic/tkText.c
index 3010d6e..ae0a49c 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.99 2010/03/11 09:43:19 dkf Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.100 2010/05/26 15:28:09 nijtmans Exp $
*/
#include "default.h"
@@ -4712,7 +4712,7 @@ DumpLine(
&& (segPtr->typePtr == &tkTextLeftMarkType
|| segPtr->typePtr == &tkTextRightMarkType)) {
const char *name;
- TkTextMark *markPtr = (TkTextMark *) &segPtr->body;
+ TkTextMark *markPtr = &segPtr->body.mark;
if (segPtr == textPtr->insertMarkPtr) {
name = "insert";
@@ -4747,7 +4747,7 @@ DumpLine(
what);
} else if ((what & TK_DUMP_IMG) &&
(segPtr->typePtr == &tkTextEmbImageType)) {
- TkTextEmbImage *eiPtr = (TkTextEmbImage *)&segPtr->body;
+ TkTextEmbImage *eiPtr = &segPtr->body.ei;
const char *name = (eiPtr->name == NULL) ? "" : eiPtr->name;
TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr,
@@ -4756,7 +4756,7 @@ DumpLine(
command, &index, what);
} else if ((what & TK_DUMP_WIN) &&
(segPtr->typePtr == &tkTextEmbWindowType)) {
- TkTextEmbWindow *ewPtr = (TkTextEmbWindow *)&segPtr->body;
+ TkTextEmbWindow *ewPtr = &segPtr->body.ew;
const char *pathname;
if (ewPtr->tkwin == (Tk_Window) NULL) {
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 3b9beae..cbfcdc9 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.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: tkUnixFont.c,v 1.41 2010/01/05 08:49:49 dkf Exp $
+ * RCS: @(#) $Id: tkUnixFont.c,v 1.42 2010/05/26 15:28:10 nijtmans Exp $
*/
#include "tkUnixInt.h"
@@ -1086,7 +1086,7 @@ Tk_MeasureChars(
int newX, termX, sawNonSpace, dstWrote;
Tcl_UniChar ch;
FontFamily *familyPtr;
- char buf[16];
+ XChar2b buf[8];
/*
* How many chars will fit in the space allotted? This first version
@@ -1108,14 +1108,14 @@ Tk_MeasureChars(
} else {
lastSubFontPtr = FindSubFontForChar(fontPtr, ch, NULL);
familyPtr = lastSubFontPtr->familyPtr;
- Tcl_UtfToExternal(NULL, familyPtr->encoding, p, next - p,
- 0, NULL, buf, sizeof(buf), NULL, &dstWrote, NULL);
+ Tcl_UtfToExternal(NULL, familyPtr->encoding, p, next - p, 0, NULL,
+ (char *)&buf[0].byte1, sizeof(buf), NULL, &dstWrote, NULL);
if (familyPtr->isTwoByteFont) {
newX += XTextWidth16(lastSubFontPtr->fontStructPtr,
- (XChar2b *) buf, dstWrote >> 1);
+ buf, dstWrote >> 1);
} else {
- newX += XTextWidth(lastSubFontPtr->fontStructPtr, buf,
- dstWrote);
+ newX += XTextWidth(lastSubFontPtr->fontStructPtr,
+ (char *)&buf[0].byte1, dstWrote);
}
}
if (newX > maxLength) {
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index 8f10766..1594e12 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.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: tkUnixSelect.c,v 1.25 2009/07/18 19:30:36 dkf Exp $
+ * RCS: @(#) $Id: tkUnixSelect.c,v 1.26 2010/05/26 15:28:10 nijtmans Exp $
*/
#include "tkInt.h"
@@ -793,7 +793,10 @@ ConvertSelection(
register XSelectionRequestEvent *eventPtr)
/* Event describing request. */
{
- XSelectionEvent reply; /* Used to notify requestor that selection
+ union {
+ XSelectionEvent xsel;
+ XEvent ev;
+ } reply; /* Used to notify requestor that selection
* info is ready. */
int multiple; /* Non-zero means a MULTIPLE request is being
* handled. */
@@ -814,18 +817,18 @@ ConvertSelection(
* Initialize the reply event.
*/
- reply.type = SelectionNotify;
- reply.serial = 0;
- reply.send_event = True;
- reply.display = eventPtr->display;
- reply.requestor = eventPtr->requestor;
- reply.selection = eventPtr->selection;
- reply.target = eventPtr->target;
- reply.property = eventPtr->property;
- if (reply.property == None) {
- reply.property = reply.target;
+ reply.xsel.type = SelectionNotify;
+ reply.xsel.serial = 0;
+ reply.xsel.send_event = True;
+ reply.xsel.display = eventPtr->display;
+ reply.xsel.requestor = eventPtr->requestor;
+ reply.xsel.selection = eventPtr->selection;
+ reply.xsel.target = eventPtr->target;
+ reply.xsel.property = eventPtr->property;
+ if (reply.xsel.property == None) {
+ reply.xsel.property = reply.xsel.target;
}
- reply.time = eventPtr->time;
+ reply.xsel.time = eventPtr->time;
for (infoPtr = winPtr->dispPtr->selectionInfoPtr; infoPtr != NULL;
infoPtr = infoPtr->nextPtr) {
@@ -848,8 +851,8 @@ ConvertSelection(
incr.selection = eventPtr->selection;
if (eventPtr->target != winPtr->dispPtr->multipleAtom) {
multiple = 0;
- singleInfo[0] = reply.target;
- singleInfo[1] = reply.property;
+ singleInfo[0] = reply.xsel.target;
+ singleInfo[1] = reply.xsel.property;
incr.multAtoms = singleInfo;
incr.numConversions = 1;
} else {
@@ -958,7 +961,7 @@ ConvertSelection(
propPtr = (char *) buffer;
format = 32;
incr.converts[i].offset = 0;
- XChangeProperty(reply.display, reply.requestor,
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
property, type, format, PropModeReplace,
(unsigned char *) propPtr, numItems);
} else if (type == winPtr->dispPtr->utf8Atom) {
@@ -967,7 +970,7 @@ ConvertSelection(
* allows us to pass our utf-8 information untouched.
*/
- XChangeProperty(reply.display, reply.requestor, property, type, 8,
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8,
PropModeReplace, (unsigned char *) buffer, numItems);
} else if ((type == XA_STRING)
|| (type == winPtr->dispPtr->compoundTextAtom)) {
@@ -986,7 +989,7 @@ ConvertSelection(
encoding = Tcl_GetEncoding(NULL, "iso2022");
}
Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds);
- XChangeProperty(reply.display, reply.requestor, property, type, 8,
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8,
PropModeReplace, (unsigned char *) Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds));
if (encoding) {
@@ -1000,7 +1003,7 @@ ConvertSelection(
goto refuse;
}
format = 32;
- XChangeProperty(reply.display, reply.requestor, property, type,
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type,
format, PropModeReplace, (unsigned char *) propPtr,
numItems);
ckfree(propPtr);
@@ -1014,17 +1017,16 @@ ConvertSelection(
*/
if (incr.numIncrs > 0) {
- XSelectInput(reply.display, reply.requestor, PropertyChangeMask);
- incr.timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc,
- (ClientData) &incr);
+ XSelectInput(reply.xsel.display, reply.xsel.requestor, PropertyChangeMask);
+ incr.timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc, &incr);
incr.idleTime = 0;
- incr.reqWindow = reply.requestor;
+ incr.reqWindow = reply.xsel.requestor;
incr.time = infoPtr->time;
incr.nextPtr = tsdPtr->pendingIncrs;
tsdPtr->pendingIncrs = &incr;
}
if (multiple) {
- XChangeProperty(reply.display, reply.requestor, reply.property,
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor, reply.xsel.property,
XA_ATOM, 32, PropModeReplace,
(unsigned char *) incr.multAtoms,
(int) incr.numConversions*2);
@@ -1034,9 +1036,9 @@ ConvertSelection(
* to None if there was an error in conversion.
*/
- reply.property = incr.multAtoms[1];
+ reply.xsel.property = incr.multAtoms[1];
}
- XSendEvent(reply.display, reply.requestor, False, 0, (XEvent *) &reply);
+ XSendEvent(reply.xsel.display, reply.xsel.requestor, False, 0, &reply.ev);
Tk_DeleteErrorHandler(errorHandler);
/*
@@ -1054,7 +1056,7 @@ ConvertSelection(
Tcl_DeleteTimerHandler(incr.timeout);
errorHandler = Tk_CreateErrorHandler(winPtr->display,
-1, -1,-1, (int (*)()) NULL, NULL);
- XSelectInput(reply.display, reply.requestor, 0L);
+ XSelectInput(reply.xsel.display, reply.xsel.requestor, 0L);
Tk_DeleteErrorHandler(errorHandler);
if (tsdPtr->pendingIncrs == &incr) {
tsdPtr->pendingIncrs = incr.nextPtr;
@@ -1084,8 +1086,8 @@ ConvertSelection(
*/
refuse:
- reply.property = None;
- XSendEvent(reply.display, reply.requestor, False, 0, (XEvent *) &reply);
+ reply.xsel.property = None;
+ XSendEvent(reply.xsel.display, reply.xsel.requestor, False, 0, &reply.ev);
Tk_DeleteErrorHandler(errorHandler);
return;
}