summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2022-08-18 20:16:05 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2022-08-18 20:16:05 (GMT)
commitdc113d8f285f5b53a9fa035527abe05704027ab4 (patch)
tree0ac476c94d4880df47cbda09de0a4bf46b0872f8
parent228c1134e28746ff7ea71d582ce3b80e68fe030a (diff)
downloadtcl-dc113d8f285f5b53a9fa035527abe05704027ab4.zip
tcl-dc113d8f285f5b53a9fa035527abe05704027ab4.tar.gz
tcl-dc113d8f285f5b53a9fa035527abe05704027ab4.tar.bz2
TIP633 fconfigure -tolerantencoding: start command arguments
-rw-r--r--generic/tclIO.c27
-rw-r--r--generic/tclIO.h2
2 files changed, 28 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 5313eed..4e3e41c 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -7905,7 +7905,20 @@ Tcl_GetChannelOption(
return TCL_OK;
}
}
- if (len == 0 || HaveOpt(1, "-translation")) {
+ if (len == 0 || HaveOpt(2, "-tolerantencoding")) {
+ if (len == 0) {
+ Tcl_DStringAppendElement(dsPtr, "-tolerantencoding");
+ }
+ Tcl_DStringAppendElement(dsPtr,
+ (flags & CHANNEL_TOLERANT_ENCODING) ? "1" : "0");
+ if (len > 0) {
+ return TCL_OK;
+ }
+ if (len > 0) {
+ return TCL_OK;
+ }
+ }
+ if (len == 0 || HaveOpt(2, "-translation")) {
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-translation");
}
@@ -8158,6 +8171,18 @@ Tcl_SetChannelOption(
ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_STICKY_EOF|CHANNEL_BLOCKED);
statePtr->inputEncodingFlags &= ~TCL_ENCODING_END;
return TCL_OK;
+ } else if (HaveOpt(2, "-tolerantencoding")) {
+ int newMode;
+
+ if (Tcl_GetBoolean(interp, newValue, &newMode) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ if (newMode) {
+ statePtr->flags |= CHANNEL_TOLERANT_ENCODING;
+ } else {
+ statePtr->flags &= ~CHANNEL_TOLERANT_ENCODING;
+ }
+ return TCL_OK;
} else if (HaveOpt(1, "-translation")) {
const char *readMode, *writeMode;
diff --git a/generic/tclIO.h b/generic/tclIO.h
index 54aa5af..1d63c0b 100644
--- a/generic/tclIO.h
+++ b/generic/tclIO.h
@@ -271,6 +271,8 @@ typedef struct ChannelState {
* changes. */
#define CHANNEL_RAW_MODE (1<<16) /* When set, notes that the Raw API is
* being used. */
+#define CHANNEL_TOLERANT_ENCODING (1<<17) /* set if option -tolerantencoding
+ * is set to 1 */
#define CHANNEL_INCLOSE (1<<19) /* Channel is currently being closed.
* Its structures are still live and