diff options
Diffstat (limited to 'unix/tkUnixSelect.c')
-rw-r--r-- | unix/tkUnixSelect.c | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c index aec6c31..13c2b30 100644 --- a/unix/tkUnixSelect.c +++ b/unix/tkUnixSelect.c @@ -3,7 +3,7 @@ * * This file contains X specific routines for manipulating selections. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. + * Copyright © 1995-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -90,17 +90,17 @@ static TkSelRetrievalInfo *pendingRetrievals = NULL; static void ConvertSelection(TkWindow *winPtr, XSelectionRequestEvent *eventPtr); -static void IncrTimeoutProc(ClientData clientData); -static void SelCvtFromX32(long *propPtr, int numValues, Atom type, +static void IncrTimeoutProc(void *clientData); +static void SelCvtFromX32(long *propPtr, unsigned long numValues, Atom type, Tk_Window tkwin, Tcl_DString *dsPtr); -static void SelCvtFromX8(char *propPtr, int numValues, Atom type, +static void SelCvtFromX8(char *propPtr, unsigned long numValues, Atom type, Tk_Window tkwin, Tcl_DString *dsPtr); static long * SelCvtToX(char *string, Atom type, Tk_Window tkwin, - int *numLongsPtr); + Tcl_Size *numLongsPtr); static int SelectionSize(TkSelHandler *selPtr); -static void SelRcvIncrProc(ClientData clientData, +static void SelRcvIncrProc(void *clientData, XEvent *eventPtr); -static void SelTimeoutProc(ClientData clientData); +static void SelTimeoutProc(void *clientData); /* *---------------------------------------------------------------------- @@ -131,7 +131,7 @@ TkSelGetSelection( * returned. */ Tk_GetSelProc *proc, /* Function to call to process the selection, * once it has been retrieved. */ - ClientData clientData) /* Arbitrary value to pass to proc. */ + void *clientData) /* Arbitrary value to pass to proc. */ { TkSelRetrievalInfo retr; TkWindow *winPtr = (TkWindow *) tkwin; @@ -244,7 +244,8 @@ TkSelPropProc( { IncrInfo *incrPtr; TkSelHandler *selPtr; - int length, numItems; + int length; + Tcl_Size numItems; unsigned long i; Atom target, formatType; long buffer[TK_SEL_WORDS_AT_ONCE]; @@ -345,7 +346,7 @@ TkSelPropProc( return; } - if (numItems < 0) { + if (numItems == TCL_INDEX_NONE) { numItems = 0; } numItems += length; @@ -376,7 +377,7 @@ TkSelPropProc( * this is the first and/or last chunk. */ - encodingCvtFlags = 0; + encodingCvtFlags = TCL_ENCODING_PROFILE_TCL8; if (incrPtr->converts[i].offset == 0) { encodingCvtFlags |= TCL_ENCODING_START; } @@ -479,7 +480,7 @@ TkSelPropProc( */ if (numItems < TK_SEL_BYTES_AT_ONCE) { - if (numItems <= 0) { + if (numItems < 1) { incrPtr->converts[i].offset = -1; incrPtr->numIncrs--; } else { @@ -581,7 +582,7 @@ TkSelEventProc( } if (bytesAfter != 0) { Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj( - "selection property too large", -1)); + "selection property too large", TCL_INDEX_NONE)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "SIZE",NULL); retrPtr->result = TCL_ERROR; XFree(propInfo); @@ -620,13 +621,12 @@ TkSelEventProc( } else { encoding = Tcl_GetEncoding(NULL, "iso8859-1"); } - Tcl_ExternalToUtfDString(encoding, propInfo, (int)numItems, &ds); + char *str = Tcl_ExternalToUtfDString(encoding, propInfo, numItems, &ds); if (encoding) { Tcl_FreeEncoding(encoding); } - retrPtr->result = retrPtr->proc(retrPtr->clientData, interp, - Tcl_DStringValue(&ds)); + retrPtr->result = retrPtr->proc(retrPtr->clientData, interp, str); Tcl_DStringFree(&ds); Tcl_Release(interp); } else if (type == dispPtr->utf8Atom) { @@ -690,10 +690,10 @@ TkSelEventProc( } Tcl_DStringInit(&ds); if (format == 32) { - SelCvtFromX32((long *) propInfo, (int) numItems, type, + SelCvtFromX32((long *) propInfo, numItems, type, (Tk_Window) winPtr, &ds); } else { - SelCvtFromX8((char *) propInfo, (int) numItems, type, + SelCvtFromX8((char *) propInfo, numItems, type, (Tk_Window) winPtr, &ds); } interp = retrPtr->interp; @@ -740,7 +740,7 @@ TkSelEventProc( static void SelTimeoutProc( - ClientData clientData) /* Information about retrieval in progress. */ + void *clientData) /* Information about retrieval in progress. */ { TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *)clientData; @@ -761,7 +761,7 @@ SelTimeoutProc( */ Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj( - "selection owner didn't respond", -1)); + "selection owner didn't respond", TCL_INDEX_NONE)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "IGNORED", NULL); retrPtr->result = TCL_ERROR; } else { @@ -879,7 +879,7 @@ ConvertSelection( if ((result != Success) || (bytesAfter != 0) || (format != 32) || (type == None)) { if (incr.multAtoms != NULL) { - XFree((char *) incr.multAtoms); + XFree(incr.multAtoms); } goto refuse; } @@ -899,7 +899,8 @@ ConvertSelection( Atom target, property, type; long buffer[TK_SEL_WORDS_AT_ONCE]; TkSelHandler *selPtr; - int numItems, format; + Tcl_Size numItems; + int format; char *propPtr; target = incr.multAtoms[2*i]; @@ -924,7 +925,7 @@ ConvertSelection( numItems = TkSelDefaultSelection(infoPtr, target, (char *) buffer, TK_SEL_BYTES_AT_ONCE, &type); - if (numItems < 0) { + if (numItems == TCL_INDEX_NONE) { incr.multAtoms[2*i + 1] = None; continue; } @@ -936,7 +937,7 @@ ConvertSelection( numItems = selPtr->proc(selPtr->clientData, 0, (char *) buffer, TK_SEL_BYTES_AT_ONCE); TkSelSetInProgress(ip.nextPtr); - if ((ip.selPtr == NULL) || (numItems < 0)) { + if ((ip.selPtr == NULL) || (numItems == TCL_INDEX_NONE)) { incr.multAtoms[2*i + 1] = None; continue; } @@ -995,10 +996,10 @@ ConvertSelection( } else { encoding = Tcl_GetEncoding(NULL, "iso2022"); } - Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds); + unsigned char *str = (unsigned char *)Tcl_UtfToExternalDString(encoding, + (char *) buffer, TCL_INDEX_NONE, &ds); XChangeProperty(reply.xsel.display, reply.xsel.requestor, - property, type, 8, PropModeReplace, - (unsigned char *) Tcl_DStringValue(&ds), + property, type, 8, PropModeReplace, str, Tcl_DStringLength(&ds)); if (encoding) { Tcl_FreeEncoding(encoding); @@ -1038,7 +1039,7 @@ ConvertSelection( XChangeProperty(reply.xsel.display, reply.xsel.requestor, reply.xsel.property, winPtr->dispPtr->atomPairAtom, 32, PropModeReplace, (unsigned char *) incr.multAtoms, - (int) incr.numConversions*2); + incr.numConversions*2); } else { /* * Not a MULTIPLE request. The first property in "multAtoms" got set @@ -1086,7 +1087,7 @@ ConvertSelection( ckfree(incr.converts); if (multiple) { - XFree((char *) incr.multAtoms); + XFree(incr.multAtoms); } return; @@ -1123,7 +1124,7 @@ ConvertSelection( static void SelRcvIncrProc( - ClientData clientData, /* Information about retrieval. */ + void *clientData, /* Information about retrieval. */ XEvent *eventPtr) /* X PropertyChange event. */ { TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *)clientData; @@ -1148,7 +1149,7 @@ SelRcvIncrProc( } if (bytesAfter != 0) { Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj( - "selection property too large", -1)); + "selection property too large", TCL_INDEX_NONE)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "SIZE", NULL); retrPtr->result = TCL_ERROR; goto done; @@ -1225,8 +1226,8 @@ SelRcvIncrProc( while (1) { result = Tcl_ExternalToUtf(NULL, encoding, src, srcLen, - retrPtr->encFlags, &retrPtr->encState, - dst, dstLen, &srcRead, &dstWrote, NULL); + TCL_ENCODING_PROFILE_TCL8|retrPtr->encFlags, + &retrPtr->encState, dst, dstLen, &srcRead, &dstWrote, NULL); soFar = dst + dstWrote - Tcl_DStringValue(dstPtr); retrPtr->encFlags &= ~TCL_ENCODING_START; src += srcRead; @@ -1279,10 +1280,10 @@ SelRcvIncrProc( } Tcl_DStringInit(&ds); if (format == 32) { - SelCvtFromX32((long *) propInfo, (int) numItems, type, + SelCvtFromX32((long *) propInfo, numItems, type, (Tk_Window) retrPtr->winPtr, &ds); } else { - SelCvtFromX8((char *) propInfo, (int) numItems, type, + SelCvtFromX8((char *) propInfo, numItems, type, (Tk_Window) retrPtr->winPtr, &ds); } interp = retrPtr->interp; @@ -1370,7 +1371,7 @@ SelectionSize( static void IncrTimeoutProc( - ClientData clientData) /* Information about INCR-mode selection + void *clientData) /* Information about INCR-mode selection * retrieval for which we are selection * owner. */ { @@ -1416,11 +1417,11 @@ SelCvtToX( * XA_STRING (if so, don't bother calling this * function at all). */ Tk_Window tkwin, /* Window that governs atom conversion. */ - int *numLongsPtr) /* Number of 32-bit words contained in the + Tcl_Size *numLongsPtr) /* Number of 32-bit words contained in the * result. */ { const char **field; - int numFields, i; + Tcl_Size numFields, i; long *propPtr; /* @@ -1488,7 +1489,7 @@ SelCvtToX( static void SelCvtFromX32( long *propPtr, /* Property value from X. */ - int numValues, /* Number of 32-bit values in property. */ + unsigned long 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 * at all). */ @@ -1521,7 +1522,7 @@ SelCvtFromX32( static void SelCvtFromX8( char *propPtr, /* Property value from X. */ - int numValues, /* Number of 8-bit values in property. */ + unsigned long numValues, /* Number of 8-bit values in property. */ TCL_UNUSED(Atom), /* Type of property Should not be XA_STRING * (if so, don't bother calling this function * at all). */ |