summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixSelect.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tkUnixSelect.c')
-rw-r--r--unix/tkUnixSelect.c273
1 files changed, 143 insertions, 130 deletions
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index 060fdd1..527bc4c 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -21,7 +21,7 @@ typedef struct ConvertInfo {
* offset of the next chunk of data to
* transfer. */
Tcl_EncodingState state; /* The encoding state needed across chunks. */
- char buffer[TCL_UTF_MAX]; /* A buffer to hold part of a UTF character
+ char buffer[4]; /* A buffer to hold part of a UTF character
* that is split across chunks.*/
} ConvertInfo;
@@ -68,7 +68,7 @@ typedef struct IncrInfo {
* currently pending. */
} IncrInfo;
-typedef struct ThreadSpecificData {
+typedef struct {
IncrInfo *pendingIncrs; /* List of all incr structures currently
* active. */
} ThreadSpecificData;
@@ -166,6 +166,13 @@ TkSelGetSelection(
pendingRetrievals = &retr;
/*
+ * Delete the property to indicate that no parameters are supplied for
+ * the conversion request.
+ */
+
+ XDeleteProperty(winPtr->display, retr.winPtr->window, retr.property);
+
+ /*
* Initiate the request for the selection. Note: can't use TkCurrentTime
* for the time. If we do, and this application hasn't received any X
* events in a long time, the current time will be way in the past and
@@ -183,7 +190,7 @@ TkSelGetSelection(
*/
retr.timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc,
- (ClientData) &retr);
+ &retr);
while (retr.result == -1) {
Tcl_DoOneEvent(0);
}
@@ -233,10 +240,10 @@ TkSelGetSelection(
void
TkSelPropProc(
- register XEvent *eventPtr) /* X PropertyChange event. */
+ XEvent *eventPtr) /* X PropertyChange event. */
{
- register IncrInfo *incrPtr;
- register TkSelHandler *selPtr;
+ IncrInfo *incrPtr;
+ TkSelHandler *selPtr;
int length, numItems;
unsigned long i;
Atom target, formatType;
@@ -326,7 +333,7 @@ TkSelPropProc(
length = strlen(incrPtr->converts[i].buffer);
strcpy((char *)buffer, incrPtr->converts[i].buffer);
- numItems = (*selPtr->proc)(selPtr->clientData,
+ numItems = selPtr->proc(selPtr->clientData,
incrPtr->converts[i].offset,
((char *) buffer) + length,
TK_SEL_BYTES_AT_ONCE - length);
@@ -349,7 +356,7 @@ TkSelPropProc(
((char *) buffer)[numItems] = 0;
errorHandler = Tk_CreateErrorHandler(eventPtr->xproperty.display,
- -1, -1, -1, (int (*)()) NULL, NULL);
+ -1, -1, -1, NULL, NULL);
/*
* Encode the data using the proper format for each type.
@@ -439,10 +446,10 @@ TkSelPropProc(
* Preserve any left-over bytes.
*/
- if (srcLen > TCL_UTF_MAX) {
+ if (srcLen > 3) {
Tcl_Panic("selection conversion left too many bytes unconverted");
}
- memcpy(incrPtr->converts[i].buffer, src, (size_t) srcLen+1);
+ memcpy(incrPtr->converts[i].buffer, src, srcLen + 1);
Tcl_DStringFree(&ds);
} else {
/*
@@ -512,10 +519,10 @@ TkSelPropProc(
void
TkSelEventProc(
Tk_Window tkwin, /* Window for which event was targeted. */
- register XEvent *eventPtr) /* X event: either SelectionClear,
+ XEvent *eventPtr) /* X event: either SelectionClear,
* SelectionRequest, or SelectionNotify. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
Tcl_Interp *interp;
@@ -533,12 +540,11 @@ TkSelEventProc(
*/
if (eventPtr->type == SelectionNotify) {
- register TkSelRetrievalInfo *retrPtr;
+ TkSelRetrievalInfo *retrPtr;
char *propInfo, **propInfoPtr = &propInfo;
Atom type;
int format, result;
unsigned long numItems, bytesAfter;
- Tcl_DString ds;
for (retrPtr = pendingRetrievals; ; retrPtr = retrPtr->nextPtr) {
if (retrPtr == NULL) {
@@ -552,12 +558,12 @@ TkSelEventProc(
break;
}
if (eventPtr->xselection.property == None) {
- Tcl_SetResult(retrPtr->interp, NULL, TCL_STATIC);
- Tcl_AppendResult(retrPtr->interp,
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
+ "%s selection doesn't exist or form \"%s\" not defined",
Tk_GetAtomName(tkwin, retrPtr->selection),
- " selection doesn't exist or form \"",
- Tk_GetAtomName(tkwin, retrPtr->target),
- "\" not defined", NULL);
+ Tk_GetAtomName(tkwin, retrPtr->target)));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION",
+ "NONE", NULL);
retrPtr->result = TCL_ERROR;
return;
}
@@ -574,8 +580,9 @@ TkSelEventProc(
return;
}
if (bytesAfter != 0) {
- Tcl_SetResult(retrPtr->interp, "selection property too large",
- TCL_STATIC);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj(
+ "selection property too large", -1));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "SIZE",NULL);
retrPtr->result = TCL_ERROR;
XFree(propInfo);
return;
@@ -583,18 +590,19 @@ TkSelEventProc(
if ((type == XA_STRING) || (type == dispPtr->textAtom)
|| (type == dispPtr->compoundTextAtom)) {
Tcl_Encoding encoding;
- if (format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
+ Tcl_DString ds;
- sprintf(buf,
+ if (format != 8) {
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
"bad format for string selection: wanted \"8\", got \"%d\"",
- format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
return;
}
interp = retrPtr->interp;
- Tcl_Preserve((ClientData) interp);
+ Tcl_Preserve(interp);
/*
* Convert the X selection data into UTF before passing it to the
@@ -617,10 +625,10 @@ TkSelEventProc(
Tcl_FreeEncoding(encoding);
}
- retrPtr->result = (*retrPtr->proc)(retrPtr->clientData,
- interp, Tcl_DStringValue(&ds));
+ retrPtr->result = retrPtr->proc(retrPtr->clientData, interp,
+ Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
} else if (type == dispPtr->utf8Atom) {
/*
* The X selection data is in UTF-8 format already. We can't
@@ -631,25 +639,24 @@ TkSelEventProc(
char *propData = propInfo;
if (format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf,
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
"bad format for string selection: wanted \"8\", got \"%d\"",
- format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
return;
}
if (propInfo[numItems] != '\0') {
- propData = ckalloc((size_t) numItems + 1);
+ propData = (char *)ckalloc(numItems + 1);
strcpy(propData, propInfo);
propData[numItems] = '\0';
}
- retrPtr->result = (*retrPtr->proc)(retrPtr->clientData,
+ retrPtr->result = retrPtr->proc(retrPtr->clientData,
retrPtr->interp, propData);
if (propData != propInfo) {
- ckfree((char *) propData);
+ ckfree(propData);
}
} else if (type == dispPtr->incrAtom) {
@@ -661,23 +668,23 @@ TkSelEventProc(
retrPtr->idleTime = 0;
Tk_CreateEventHandler(tkwin, PropertyChangeMask, SelRcvIncrProc,
- (ClientData) retrPtr);
+ retrPtr);
XDeleteProperty(Tk_Display(tkwin), Tk_WindowId(tkwin),
retrPtr->property);
while (retrPtr->result == -1) {
Tcl_DoOneEvent(0);
}
Tk_DeleteEventHandler(tkwin, PropertyChangeMask, SelRcvIncrProc,
- (ClientData) retrPtr);
+ retrPtr);
} else {
Tcl_DString ds;
if (format != 32 && format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf, "bad format for selection: wanted \"32\" or "
- "\"8\", got \"%d\"", format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
+ "bad format for selection: wanted \"32\" or "
+ "\"8\", got \"%d\"", format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
return;
}
@@ -690,10 +697,10 @@ TkSelEventProc(
(Tk_Window) winPtr, &ds);
}
interp = retrPtr->interp;
- Tcl_Preserve((ClientData) interp);
- retrPtr->result = (*retrPtr->proc)(retrPtr->clientData,
+ Tcl_Preserve(interp);
+ retrPtr->result = retrPtr->proc(retrPtr->clientData,
interp, Tcl_DStringValue(&ds));
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
Tcl_DStringFree(&ds);
}
XFree(propInfo);
@@ -735,7 +742,7 @@ static void
SelTimeoutProc(
ClientData clientData) /* Information about retrieval in progress. */
{
- register TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *) clientData;
+ TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *)clientData;
/*
* Make sure that the retrieval is still in progress. Then see how long
@@ -753,12 +760,13 @@ SelTimeoutProc(
* selection return.
*/
- Tcl_SetResult(retrPtr->interp, "selection owner didn't respond",
- TCL_STATIC);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj(
+ "selection owner didn't respond", -1));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "IGNORED", NULL);
retrPtr->result = TCL_ERROR;
} else {
retrPtr->timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc,
- (ClientData) retrPtr);
+ retrPtr);
}
}
@@ -788,10 +796,13 @@ ConvertSelection(
* request; may not be selection's current
* owner, be we set it to the current
* owner. */
- register XSelectionRequestEvent *eventPtr)
+ 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. */
@@ -805,25 +816,25 @@ ConvertSelection(
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- errorHandler = Tk_CreateErrorHandler(eventPtr->display, -1, -1,-1,
- (int (*)()) NULL, NULL);
+ errorHandler = Tk_CreateErrorHandler(eventPtr->display, -1, -1,
+ -1, NULL, NULL);
/*
* 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) {
@@ -846,8 +857,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 {
@@ -861,8 +872,9 @@ ConvertSelection(
goto refuse;
}
result = XGetWindowProperty(eventPtr->display, eventPtr->requestor,
- eventPtr->property, 0, MAX_PROP_WORDS, False, XA_ATOM,
- &type, &format, &incr.numConversions, &bytesAfter,
+ eventPtr->property, 0, MAX_PROP_WORDS, False,
+ winPtr->dispPtr->atomPairAtom, &type, &format,
+ &incr.numConversions, &bytesAfter,
(unsigned char **) multAtomsPtr);
if ((result != Success) || (bytesAfter != 0) || (format != 32)
|| (type == None)) {
@@ -871,7 +883,7 @@ ConvertSelection(
}
goto refuse;
}
- incr.numConversions /= 2; /* Two atoms per conversion. */
+ incr.numConversions /= 2; /* Two atoms per conversion. */
}
/*
@@ -881,13 +893,12 @@ ConvertSelection(
* below).
*/
- incr.converts = (ConvertInfo *)
- ckalloc((unsigned) incr.numConversions * sizeof(ConvertInfo));
+ incr.converts = (ConvertInfo *)ckalloc(incr.numConversions * sizeof(ConvertInfo));
incr.numIncrs = 0;
for (i = 0; i < incr.numConversions; i++) {
Atom target, property, type;
long buffer[TK_SEL_WORDS_AT_ONCE];
- register TkSelHandler *selPtr;
+ TkSelHandler *selPtr;
int numItems, format;
char *propPtr;
@@ -908,7 +919,7 @@ ConvertSelection(
/*
* Nobody seems to know about this kind of request. If it's of a
* sort that we can handle without any help, do it. Otherwise mark
- * the request as an errror.
+ * the request as an error.
*/
numItems = TkSelDefaultSelection(infoPtr, target, (char *) buffer,
@@ -922,8 +933,8 @@ ConvertSelection(
ip.nextPtr = TkSelGetInProgress();
TkSelSetInProgress(&ip);
type = selPtr->format;
- numItems = (*selPtr->proc)(selPtr->clientData, 0,
- (char *) buffer, TK_SEL_BYTES_AT_ONCE);
+ numItems = selPtr->proc(selPtr->clientData, 0, (char *) buffer,
+ TK_SEL_BYTES_AT_ONCE);
TkSelSetInProgress(ip.nextPtr);
if ((ip.selPtr == NULL) || (numItems < 0)) {
incr.multAtoms[2*i + 1] = None;
@@ -956,7 +967,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) {
@@ -965,8 +976,9 @@ ConvertSelection(
* allows us to pass our utf-8 information untouched.
*/
- XChangeProperty(reply.display, reply.requestor, property, type, 8,
- PropModeReplace, (unsigned char *) buffer, numItems);
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
+ property, type, 8, PropModeReplace,
+ (unsigned char *) buffer, numItems);
} else if ((type == XA_STRING)
|| (type == winPtr->dispPtr->compoundTextAtom)) {
Tcl_DString ds;
@@ -984,8 +996,9 @@ ConvertSelection(
encoding = Tcl_GetEncoding(NULL, "iso2022");
}
Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds);
- XChangeProperty(reply.display, reply.requestor, property, type, 8,
- PropModeReplace, (unsigned char *) Tcl_DStringValue(&ds),
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
+ property, type, 8, PropModeReplace,
+ (unsigned char *) Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds));
if (encoding) {
Tcl_FreeEncoding(encoding);
@@ -998,9 +1011,9 @@ ConvertSelection(
goto refuse;
}
format = 32;
- XChangeProperty(reply.display, reply.requestor, property, type,
- format, PropModeReplace, (unsigned char *) propPtr,
- numItems);
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
+ property, type, format, PropModeReplace,
+ (unsigned char *) propPtr, numItems);
ckfree(propPtr);
}
}
@@ -1012,19 +1025,19 @@ 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,
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) incr.multAtoms,
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
+ reply.xsel.property, winPtr->dispPtr->atomPairAtom,
+ 32, PropModeReplace, (unsigned char *) incr.multAtoms,
(int) incr.numConversions*2);
} else {
/*
@@ -1032,9 +1045,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);
/*
@@ -1051,8 +1064,8 @@ ConvertSelection(
}
Tcl_DeleteTimerHandler(incr.timeout);
errorHandler = Tk_CreateErrorHandler(winPtr->display,
- -1, -1,-1, (int (*)()) NULL, NULL);
- XSelectInput(reply.display, reply.requestor, 0L);
+ -1, -1, -1, NULL, NULL);
+ XSelectInput(reply.xsel.display, reply.xsel.requestor, 0L);
Tk_DeleteErrorHandler(errorHandler);
if (tsdPtr->pendingIncrs == &incr) {
tsdPtr->pendingIncrs = incr.nextPtr;
@@ -1071,7 +1084,7 @@ ConvertSelection(
* All done. Cleanup and return.
*/
- ckfree((char *) incr.converts);
+ ckfree(incr.converts);
if (multiple) {
XFree((char *) incr.multAtoms);
}
@@ -1082,8 +1095,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;
}
@@ -1111,9 +1124,9 @@ ConvertSelection(
static void
SelRcvIncrProc(
ClientData clientData, /* Information about retrieval. */
- register XEvent *eventPtr) /* X PropertyChange event. */
+ XEvent *eventPtr) /* X PropertyChange event. */
{
- register TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *) clientData;
+ TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *)clientData;
char *propInfo, **propInfoPtr = &propInfo;
Atom type;
int format, result;
@@ -1134,8 +1147,9 @@ SelRcvIncrProc(
return;
}
if (bytesAfter != 0) {
- Tcl_SetResult(retrPtr->interp, "selection property too large",
- TCL_STATIC);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj(
+ "selection property too large", -1));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "SIZE", NULL);
retrPtr->result = TCL_ERROR;
goto done;
}
@@ -1149,17 +1163,16 @@ SelRcvIncrProc(
Tcl_DString *dstPtr, temp;
if (format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf,
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
"bad format for string selection: wanted \"8\", got \"%d\"",
- format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
goto done;
}
interp = retrPtr->interp;
- Tcl_Preserve((ClientData) interp);
+ Tcl_Preserve(interp);
if (type == retrPtr->winPtr->dispPtr->compoundTextAtom) {
encoding = Tcl_GetEncoding(NULL, "iso2022");
@@ -1190,7 +1203,7 @@ SelRcvIncrProc(
*/
retrPtr->result = TCL_OK;
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
goto done;
} else {
src = propInfo;
@@ -1231,9 +1244,9 @@ SelRcvIncrProc(
}
Tcl_DStringSetLength(dstPtr, soFar);
- result = (*retrPtr->proc)(retrPtr->clientData, interp,
+ result = retrPtr->proc(retrPtr->clientData, interp,
Tcl_DStringValue(dstPtr));
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
/*
* Copy any unused data into the destination buffer so we can pick it
@@ -1256,11 +1269,11 @@ SelRcvIncrProc(
Tcl_DString ds;
if (format != 32 && format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf, "bad format for selection: wanted \"32\" or "
- "\"8\", got \"%d\"", format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
+ "bad format for selection: wanted \"32\" or "
+ "\"8\", got \"%d\"", format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
goto done;
}
@@ -1273,10 +1286,10 @@ SelRcvIncrProc(
(Tk_Window) retrPtr->winPtr, &ds);
}
interp = retrPtr->interp;
- Tcl_Preserve((ClientData) interp);
- result = (*retrPtr->proc)(retrPtr->clientData, interp,
+ Tcl_Preserve(interp);
+ result = retrPtr->proc(retrPtr->clientData, interp,
Tcl_DStringValue(&ds));
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
Tcl_DStringFree(&ds);
if (result != TCL_OK) {
retrPtr->result = result;
@@ -1322,7 +1335,7 @@ SelectionSize(
TkSelSetInProgress(&ip);
do {
- chunkSize = (*selPtr->proc)(selPtr->clientData, size, (char *) buffer,
+ chunkSize = selPtr->proc(selPtr->clientData, size, (char *) buffer,
TK_SEL_BYTES_AT_ONCE);
if (ip.selPtr == NULL) {
size = 0;
@@ -1361,14 +1374,14 @@ IncrTimeoutProc(
* retrieval for which we are selection
* owner. */
{
- register IncrInfo *incrPtr = (IncrInfo *) clientData;
+ IncrInfo *incrPtr = (IncrInfo *)clientData;
incrPtr->idleTime++;
if (incrPtr->idleTime >= 5) {
incrPtr->numIncrs = 0;
} else {
incrPtr->timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc,
- (ClientData) incrPtr);
+ incrPtr);
}
}
@@ -1422,7 +1435,7 @@ SelCvtToX(
if (Tcl_SplitList(NULL, string, &numFields, &field) != TCL_OK) {
return NULL;
}
- propPtr = (long *) ckalloc((unsigned) numFields*sizeof(long));
+ propPtr = (long *)ckalloc(numFields * sizeof(long));
/*
* Convert the fields one-by-one.
@@ -1447,7 +1460,7 @@ SelCvtToX(
* Release the parsed list.
*/
- ckfree((char *) field);
+ ckfree(field);
*numLongsPtr = i;
return propPtr;
}
@@ -1474,7 +1487,7 @@ SelCvtToX(
static void
SelCvtFromX32(
- register long *propPtr, /* Property value from X. */
+ long *propPtr, /* Property value from X. */
int numValues, /* Number of 32-bit values in property. */
Atom type, /* Type of property Should not be XA_STRING
* (if so, don't bother calling this function
@@ -1507,12 +1520,12 @@ SelCvtFromX32(
static void
SelCvtFromX8(
- register char *propPtr, /* Property value from X. */
+ char *propPtr, /* Property value from X. */
int numValues, /* Number of 8-bit values in property. */
- Atom type, /* Type of property Should not be XA_STRING
+ TCL_UNUSED(Atom), /* Type of property Should not be XA_STRING
* (if so, don't bother calling this function
* at all). */
- Tk_Window tkwin, /* Window to use for atom conversion. */
+ TCL_UNUSED(Tk_Window), /* Window to use for atom conversion. */
Tcl_DString *dsPtr) /* Where to store the converted string. */
{
/*