summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-08 16:44:21 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-08 16:44:21 (GMT)
commite502bcacc7dc47f6a6331b74318e0a6f8d4c9791 (patch)
treeb09d5c66bf37824bc0b4544dfb1096516d0631e1 /generic/tclIO.c
parent891c0fbcaa32b5904d233dff1b31b8c71077ae36 (diff)
parenta79de57d3737b8a2d0b80611521437585653f877 (diff)
downloadtcl-e502bcacc7dc47f6a6331b74318e0a6f8d4c9791.zip
tcl-e502bcacc7dc47f6a6331b74318e0a6f8d4c9791.tar.gz
tcl-e502bcacc7dc47f6a6331b74318e0a6f8d4c9791.tar.bz2
Merge 9.0
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c102
1 files changed, 63 insertions, 39 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index b292f5e..af3243a 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -28,7 +28,7 @@ typedef struct ChannelHandler {
int mask; /* Mask of desired events. */
Tcl_ChannelProc *proc; /* Procedure to call in the type of
* Tcl_CreateChannelHandler. */
- ClientData clientData; /* Argument to pass to procedure. */
+ void *clientData; /* Argument to pass to procedure. */
struct ChannelHandler *nextPtr;
/* Next one in list of registered handlers. */
} ChannelHandler;
@@ -142,7 +142,7 @@ static Tcl_ThreadDataKey dataKey;
typedef struct CloseCallback {
Tcl_CloseProc *proc; /* The procedure to call. */
- ClientData clientData; /* Arbitrary one-word data to pass
+ void *clientData; /* Arbitrary one-word data to pass
* to the callback. */
struct CloseCallback *nextPtr; /* For chaining close callbacks. */
} CloseCallback;
@@ -156,7 +156,7 @@ static void PreserveChannelBuffer(ChannelBuffer *bufPtr);
static void ReleaseChannelBuffer(ChannelBuffer *bufPtr);
static int IsShared(ChannelBuffer *bufPtr);
static void ChannelFree(Channel *chanPtr);
-static void ChannelTimerProc(ClientData clientData);
+static void ChannelTimerProc(void *clientData);
static int ChanRead(Channel *chanPtr, char *dst, int dstSize);
static int CheckChannelErrors(ChannelState *statePtr,
int direction);
@@ -178,12 +178,12 @@ static void MBCallback(CopyState *csPtr, Tcl_Obj *errObj);
static void MBError(CopyState *csPtr, int mask, int errorCode);
static int MBRead(CopyState *csPtr);
static int MBWrite(CopyState *csPtr);
-static void MBEvent(ClientData clientData, int mask);
+static void MBEvent(void *clientData, int mask);
-static void CopyEventProc(ClientData clientData, int mask);
+static void CopyEventProc(void *clientData, int mask);
static void CreateScriptRecord(Tcl_Interp *interp,
Channel *chanPtr, int mask, Tcl_Obj *scriptPtr);
-static void DeleteChannelTable(ClientData clientData,
+static void DeleteChannelTable(void *clientData,
Tcl_Interp *interp);
static void DeleteScriptRecord(Tcl_Interp *interp,
Channel *chanPtr, int mask);
@@ -832,7 +832,7 @@ Tcl_CreateCloseHandler(
* callback. */
Tcl_CloseProc *proc, /* The callback routine to call when the
* channel will be closed. */
- ClientData clientData) /* Arbitrary data to pass to the close
+ void *clientData) /* Arbitrary data to pass to the close
* callback. */
{
ChannelState *statePtr = ((Channel *) chan)->state;
@@ -870,7 +870,7 @@ Tcl_DeleteCloseHandler(
* callback. */
Tcl_CloseProc *proc, /* The procedure for the callback to
* remove. */
- ClientData clientData) /* The callback data for the callback to
+ void *clientData) /* The callback data for the callback to
* remove. */
{
ChannelState *statePtr = ((Channel *) chan)->state;
@@ -969,7 +969,7 @@ GetChannelTable(
static void
DeleteChannelTable(
- ClientData clientData, /* The per-interpreter data structure. */
+ void *clientData, /* The per-interpreter data structure. */
Tcl_Interp *interp) /* The interpreter being deleted. */
{
Tcl_HashTable *hTblPtr; /* The hash table. */
@@ -1583,7 +1583,7 @@ Tcl_Channel
Tcl_CreateChannel(
const Tcl_ChannelType *typePtr, /* The channel type record. */
const char *chanName, /* Name of channel to record. */
- ClientData instanceData, /* Instance specific data. */
+ void *instanceData, /* Instance specific data. */
int mask) /* TCL_READABLE & TCL_WRITABLE to indicate if
* the channel is readable, writable. */
{
@@ -1805,7 +1805,7 @@ Tcl_StackChannel(
const Tcl_ChannelType *typePtr,
/* The channel type record for the new
* channel. */
- ClientData instanceData, /* Instance specific data for the new
+ void *instanceData, /* Instance specific data for the new
* channel. */
int mask, /* TCL_READABLE & TCL_WRITABLE to indicate if
* the channel is readable, writable. */
@@ -2264,7 +2264,7 @@ Tcl_GetTopChannel(
*----------------------------------------------------------------------
*/
-ClientData
+void *
Tcl_GetChannelInstanceData(
Tcl_Channel chan) /* Channel for which to return client data. */
{
@@ -2403,10 +2403,10 @@ int
Tcl_GetChannelHandle(
Tcl_Channel chan, /* The channel to get file from. */
int direction, /* TCL_WRITABLE or TCL_READABLE. */
- ClientData *handlePtr) /* Where to store handle */
+ void **handlePtr) /* Where to store handle */
{
Channel *chanPtr; /* The actual channel. */
- ClientData handle;
+ void *handle;
int result;
chanPtr = ((Channel *) chan)->state->bottomChanPtr;
@@ -4360,13 +4360,14 @@ Write(
}
/*
- * Transfer encoding strict option to the encoding flags
+ * Transfer encoding strict/nocomplain option to the encoding flags
*/
- if (statePtr->flags & CHANNEL_ENCODING_NOCOMPLAIN) {
+
+ if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
+ statePtr->outputEncodingFlags |= TCL_ENCODING_STRICT;
+ } else if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
statePtr->outputEncodingFlags |= TCL_ENCODING_NOCOMPLAIN;
- } else {
- statePtr->outputEncodingFlags &= ~TCL_ENCODING_NOCOMPLAIN;
}
/*
@@ -4687,13 +4688,13 @@ Tcl_GetsObj(
}
/*
- * Transfer encoding strict option to the encoding flags
+ * Transfer encoding nocomplain/strict option to the encoding flags
*/
- if (statePtr->flags & CHANNEL_ENCODING_NOCOMPLAIN) {
+ if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
+ statePtr->inputEncodingFlags |= TCL_ENCODING_STRICT;
+ } else if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
statePtr->inputEncodingFlags |= TCL_ENCODING_NOCOMPLAIN;
- } else {
- statePtr->inputEncodingFlags &= ~TCL_ENCODING_NOCOMPLAIN;
}
/*
@@ -5455,13 +5456,13 @@ FilterInputBytes(
gsPtr->state = statePtr->inputEncodingState;
/*
- * Transfer encoding strict option to the encoding flags
+ * Transfer encoding nocomplain/strict option to the encoding flags
*/
- if (statePtr->flags & CHANNEL_ENCODING_NOCOMPLAIN) {
+ if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
+ statePtr->inputEncodingFlags |= TCL_ENCODING_STRICT;
+ } else if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
statePtr->inputEncodingFlags |= TCL_ENCODING_NOCOMPLAIN;
- } else {
- statePtr->inputEncodingFlags &= ~TCL_ENCODING_NOCOMPLAIN;
}
result = Tcl_ExternalToUtf(NULL, gsPtr->encoding, raw, rawLen,
@@ -6238,13 +6239,14 @@ ReadChars(
}
/*
- * Transfer encoding strict option to the encoding flags
+ * Transfer encoding nocomplain/strict option to the encoding flags
*/
- if (statePtr->flags & CHANNEL_ENCODING_NOCOMPLAIN) {
+
+ if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
+ statePtr->inputEncodingFlags |= TCL_ENCODING_STRICT;
+ } else if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
statePtr->inputEncodingFlags |= TCL_ENCODING_NOCOMPLAIN;
- } else {
- statePtr->inputEncodingFlags &= ~TCL_ENCODING_NOCOMPLAIN;
}
/*
@@ -7987,6 +7989,16 @@ Tcl_GetChannelOption(
return TCL_OK;
}
}
+ if (len == 0 || HaveOpt(1, "-strictencoding")) {
+ if (len == 0) {
+ Tcl_DStringAppendElement(dsPtr, "-strictencoding");
+ }
+ Tcl_DStringAppendElement(dsPtr,
+ (flags & CHANNEL_ENCODING_STRICT) ? "1" : "0");
+ if (len > 0) {
+ return TCL_OK;
+ }
+ }
if (len == 0 || HaveOpt(1, "-translation")) {
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-translation");
@@ -8257,9 +8269,21 @@ Tcl_SetChannelOption(
return TCL_ERROR;
}
if (newMode) {
- statePtr->flags |= CHANNEL_ENCODING_NOCOMPLAIN;
+ SetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN);
+ } else {
+ ResetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN);
+ }
+ return TCL_OK;
+ } else if (HaveOpt(1, "-strictencoding")) {
+ int newMode;
+
+ if (Tcl_GetBoolean(interp, newValue, &newMode) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ if (newMode) {
+ SetFlag(statePtr, CHANNEL_ENCODING_STRICT);
} else {
- statePtr->flags &= ~CHANNEL_ENCODING_NOCOMPLAIN;
+ ResetFlag(statePtr, CHANNEL_ENCODING_STRICT);
}
return TCL_OK;
} else if (HaveOpt(1, "-translation")) {
@@ -8719,7 +8743,7 @@ UpdateInterest(
static void
ChannelTimerProc(
- ClientData clientData)
+ void *clientData)
{
Channel *chanPtr = (Channel *)clientData;
@@ -8797,7 +8821,7 @@ Tcl_CreateChannelHandler(
* handler. */
Tcl_ChannelProc *proc, /* Procedure to call for each selected
* event. */
- ClientData clientData) /* Arbitrary data to pass to proc. */
+ void *clientData) /* Arbitrary data to pass to proc. */
{
ChannelHandler *chPtr;
Channel *chanPtr = (Channel *) chan;
@@ -8869,7 +8893,7 @@ Tcl_DeleteChannelHandler(
Tcl_Channel chan, /* The channel for which to remove the
* callback. */
Tcl_ChannelProc *proc, /* The procedure in the callback to delete. */
- ClientData clientData) /* The client data in the callback to
+ void *clientData) /* The client data in the callback to
* delete. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
@@ -9075,7 +9099,7 @@ CreateScriptRecord(
void
TclChannelEventScriptInvoker(
- ClientData clientData, /* The script+interp record. */
+ void *clientData, /* The script+interp record. */
TCL_UNUSED(int) /*mask*/)
{
EventScriptRecord *esPtr = (EventScriptRecord *)clientData;
@@ -9237,7 +9261,7 @@ Tcl_FileEventObjCmd(
static void
ZeroTransferTimerProc(
- ClientData clientData)
+ void *clientData)
{
/* calling CopyData with mask==0 still implies immediate invocation of the
* -command callback, and completion of the fcopy.
@@ -9459,7 +9483,7 @@ MBError(
static void
MBEvent(
- ClientData clientData,
+ void *clientData,
int mask)
{
CopyState *csPtr = (CopyState *) clientData;
@@ -10202,7 +10226,7 @@ DoRead(
static void
CopyEventProc(
- ClientData clientData,
+ void *clientData,
int mask)
{
(void) CopyData((CopyState *)clientData, mask);