Compare commits
78
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a3567395e | ||
|
|
fc3837a30a | ||
|
|
dbddc6a2f8 | ||
|
|
6701945b81 | ||
|
|
b513d87d24 | ||
|
|
91c305a5f3 | ||
|
|
f608dc525e | ||
|
|
c3609d23d9 | ||
|
|
83776b137b | ||
|
|
2b094e49f6 | ||
|
|
4ae09b6572 | ||
|
|
cb008d57c8 | ||
|
|
32ef665a1f | ||
|
|
e808862660 | ||
|
|
2856f45d61 | ||
|
|
cdf2e470a4 | ||
|
|
e858a80613 | ||
|
|
fe77293e49 | ||
|
|
a8609aeb89 | ||
|
|
05e1eca301 | ||
|
|
cf3686df07 | ||
|
|
9e82399a14 | ||
|
|
337ab3f387 | ||
|
|
c09ca7ee60 | ||
|
|
4d44b91a10 | ||
|
|
c43d7064eb | ||
|
|
6138f9c868 | ||
|
|
3e8b4007cf | ||
|
|
00d74a5b5d | ||
|
|
93cc703cc9 | ||
|
|
f923b422e9 | ||
|
|
656d6d7b05 | ||
|
|
2a8ae1943e | ||
|
|
5102b0f3cf | ||
|
|
4f5c603784 | ||
|
|
0758324455 | ||
|
|
d960231479 | ||
|
|
5cd0b1d22a | ||
|
|
393fc22411 | ||
|
|
812c3e3103 | ||
|
|
594f1e7e76 | ||
|
|
aa00ed70ea | ||
|
|
7973edde00 | ||
|
|
2ffd05e703 | ||
|
|
de5eea858b | ||
|
|
76b980b1d8 | ||
|
|
3eefce40b9 | ||
|
|
2410f4ec9d | ||
|
|
5761d7e651 | ||
|
|
ea9abbf7ea | ||
|
|
34ecddb610 | ||
|
|
9291cbb6cf | ||
|
|
94dfe61832 | ||
|
|
3cc7a1e953 | ||
|
|
0625218c85 | ||
|
|
219cbfee38 | ||
|
|
59a954a7ae | ||
|
|
b6ccec9b3f | ||
|
|
5e75946997 | ||
|
|
0494380d8a | ||
|
|
3ac0d72dd6 | ||
|
|
4ea3b1ce77 | ||
|
|
ef949221f5 | ||
|
|
d023df8623 | ||
|
|
362a0e8ba6 | ||
|
|
e36b69fb4d | ||
|
|
c43f6e9701 | ||
|
|
a71ab1a3ea | ||
|
|
f5bd004df9 | ||
|
|
9e4ce6c3b9 | ||
|
|
5e73d72846 | ||
|
|
6e644e2a60 | ||
|
|
2ff0d1c5c1 | ||
|
|
5669c89824 | ||
|
|
8b4325141a | ||
|
|
716757e45f | ||
|
|
0eaea8713d | ||
|
|
f562be24c3 |
+6
-4
@@ -15,7 +15,7 @@ Tcl_CreateChannel, Tcl_GetChannelInstanceData, Tcl_GetChannelType, Tcl_GetChanne
|
||||
\fB#include <tcl.h>\fR
|
||||
.sp
|
||||
Tcl_Channel
|
||||
\fBTcl_CreateChannel\fR(\fItypePtr, channelName, instanceData, mask\fR)
|
||||
\fBTcl_CreateChannel\fR(\fItypePtr, channelName, instanceData, flags\fR)
|
||||
.sp
|
||||
void *
|
||||
\fBTcl_GetChannelInstanceData\fR(\fIchannel\fR)
|
||||
@@ -130,9 +130,11 @@ the assigned channel name will be the name of the standard channel.
|
||||
.AP void *instanceData in
|
||||
Arbitrary one-word value to be associated with this channel. This
|
||||
value is passed to procedures in \fItypePtr\fR when they are invoked.
|
||||
.AP int mask in
|
||||
.AP int flags in
|
||||
OR-ed combination of \fBTCL_READABLE\fR and \fBTCL_WRITABLE\fR to indicate
|
||||
whether a channel is readable and writable.
|
||||
whether a channel is readable and writable. Can also be combined with
|
||||
one of \fBTCL_ENCODING_PROFILE_STRICT\fR, \fBTCL_ENCODING_PROFILE_TCL8\fR,
|
||||
or \fBTCL_ENCODING_PROFILE_REPLACE\fR.
|
||||
.AP Tcl_Channel channel in
|
||||
The channel to operate on.
|
||||
.AP int direction in
|
||||
@@ -200,7 +202,7 @@ structure to perform operations on the channel.
|
||||
.PP
|
||||
\fBTcl_CreateChannel\fR opens a new channel and associates the supplied
|
||||
\fItypePtr\fR and \fIinstanceData\fR with it. The channel is opened in the
|
||||
mode indicated by \fImask\fR.
|
||||
mode indicated by \fIflags\fR.
|
||||
For a discussion of channel drivers, their operations and the
|
||||
\fBTcl_ChannelType\fR structure, see the section \fBTCL_CHANNELTYPE\fR, below.
|
||||
.PP
|
||||
|
||||
+4
-4
@@ -105,9 +105,9 @@ byte is converted and then to reset to an initial state. The
|
||||
\fBTCL_PROFILE_*\fR bits defined in the \fBPROFILES\fR section below
|
||||
control the encoding profile to be used for dealing with invalid data or
|
||||
other errors in the encoding transform.
|
||||
\fBTCL_ENCODING_STOPONERROR\fR is present for backward compatibility with
|
||||
Tcl 8.6 and forces the encoding profile to \fBstrict\fR.
|
||||
|
||||
The flag \fBTCL_ENCODING_STOPONERROR\fR has no effect,
|
||||
it only has meaning in Tcl 8.x.
|
||||
.PP
|
||||
Some flags bits may not be usable with some functions as noted in the
|
||||
function descriptions below.
|
||||
.AP Tcl_EncodingState *statePtr in/out
|
||||
@@ -590,7 +590,7 @@ with at most one of \fBTCL_ENCODING_PROFILE_TCL8\fR,
|
||||
\fBTCL_ENCODING_PROFILE_STRICT\fR or \fBTCL_ENCODING_PROFILE_REPLACE\fR.
|
||||
These correspond to the \fBtcl8\fR, \fBstrict\fR and \fBreplace\fR profiles
|
||||
respectively. If none are specified, a version-dependent default profile is used.
|
||||
For Tcl 9.0, the default profile is \fBtcl8\fR.
|
||||
For Tcl 9.0, the default profile is \fBstrict\fR.
|
||||
.PP
|
||||
For details about profiles, see the \fBPROFILES\fR section in
|
||||
the documentation of the \fBencoding\fR command.
|
||||
|
||||
+5
-3
@@ -21,7 +21,7 @@ Tcl_Channel
|
||||
\fBTcl_OpenCommandChannel\fR(\fIinterp, argc, argv, flags\fR)
|
||||
.sp
|
||||
Tcl_Channel
|
||||
\fBTcl_MakeFileChannel\fR(\fIhandle, readOrWrite\fR)
|
||||
\fBTcl_MakeFileChannel\fR(\fIhandle, mask\fR)
|
||||
.sp
|
||||
Tcl_Channel
|
||||
\fBTcl_GetChannel\fR(\fIinterp, channelName, modePtr\fR)
|
||||
@@ -137,9 +137,11 @@ is set, then such redirections cause an error.
|
||||
.AP void *handle in
|
||||
Operating system specific handle for I/O to a file. For Unix this is a
|
||||
file descriptor, for Windows it is a HANDLE.
|
||||
.AP int readOrWrite in
|
||||
.AP int mask in
|
||||
OR-ed combination of \fBTCL_READABLE\fR and \fBTCL_WRITABLE\fR to indicate
|
||||
what operations are valid on \fIhandle\fR.
|
||||
what operations are valid on \fIhandle\fR. Can also be combined with
|
||||
one of \fBTCL_ENCODING_PROFILE_STRICT\fR, \fBTCL_ENCODING_PROFILE_TCL8\fR,
|
||||
or \fBTCL_ENCODING_PROFILE_REPLACE\fR.
|
||||
.AP "const char" *channelName in
|
||||
The name of the channel.
|
||||
.AP int *modePtr out
|
||||
|
||||
+9
-7
@@ -111,9 +111,15 @@ encoding.
|
||||
The following profiles are currently implemented.
|
||||
.VS "TCL8.7 TIP656"
|
||||
.TP
|
||||
\fBstrict\fR
|
||||
.
|
||||
The default profile, unless the environment variable \fBTCL_PROFILE_DEFAULT\fR
|
||||
is set to either "tcl8" or "replace". The operation fails when invalid data for the encoding
|
||||
are encountered.
|
||||
.TP
|
||||
\fBtcl8\fR
|
||||
.
|
||||
The default profile. Provides for behaviour identical to that of Tcl 8.6: When
|
||||
Provides for behaviour identical to that of Tcl 8.6: When
|
||||
decoding, for encodings \fBother than utf-8\fR, each invalid byte is interpreted
|
||||
as the Unicode value given by that one byte. For example, the byte 0x80, which
|
||||
is invalid in the ASCII encoding would be mapped to the Unicode value U+0080.
|
||||
@@ -127,10 +133,6 @@ an additional special case, the sequence 0xC0 0x80 is mapped to U+0000.
|
||||
When encoding, each character that cannot be represented in the encoding is
|
||||
replaced by an encoding-dependent character, usually the question mark \fB?\fR.
|
||||
.TP
|
||||
\fBstrict\fR
|
||||
.
|
||||
The operation fails when invalid data for the encoding are encountered.
|
||||
.TP
|
||||
\fBreplace\fR
|
||||
.
|
||||
When decoding, invalid bytes are replaced by U+FFFD, the Unicode REPLACEMENT
|
||||
@@ -180,7 +182,7 @@ unexpected byte sequence starting at index 1: '\ex80'
|
||||
Example 3: Get partial data and the error location:
|
||||
.PP
|
||||
.CS
|
||||
% codepoints [encoding convertfrom -profile strict -failindex idx ascii AB\ex80]
|
||||
% codepoints [encoding convertfrom -failindex idx ascii AB\ex80]
|
||||
U+000041 U+000042
|
||||
% set idx
|
||||
2
|
||||
@@ -193,7 +195,7 @@ Example 4: Encode a character that is not representable in ISO8859-1:
|
||||
A?
|
||||
% encoding convertto -profile strict iso8859-1 A\eu0141
|
||||
unexpected character at index 1: 'U+000141'
|
||||
% encoding convertto -profile strict -failindex idx iso8859-1 A\eu0141
|
||||
% encoding convertto -failindex idx iso8859-1 A\eu0141
|
||||
A
|
||||
% set idx
|
||||
1
|
||||
|
||||
+2
-7
@@ -1972,14 +1972,9 @@ typedef struct Tcl_EncodingType {
|
||||
* changes, ensure ENCODING_PROFILE_* macros in tclInt.h are modified if
|
||||
* necessary.
|
||||
*/
|
||||
#define TCL_ENCODING_PROFILE_STRICT TCL_ENCODING_STOPONERROR
|
||||
#define TCL_ENCODING_PROFILE_TCL8 0x01000000
|
||||
#define TCL_ENCODING_PROFILE_STRICT 0x02000000
|
||||
#define TCL_ENCODING_PROFILE_REPLACE 0x03000000
|
||||
#if TCL_MAJOR_VERSION < 9
|
||||
#define TCL_ENCODING_PROFILE_DEFAULT TCL_ENCODING_PROFILE_TCL8
|
||||
#else
|
||||
#define TCL_ENCODING_PROFILE_DEFAULT TCL_ENCODING_PROFILE_TCL8
|
||||
#endif
|
||||
#define TCL_ENCODING_PROFILE_REPLACE 0x02000000
|
||||
|
||||
/*
|
||||
* The following definitions are the error codes returned by the conversion
|
||||
|
||||
+20
-1
@@ -883,7 +883,26 @@ Tcl_CreateInterp(void)
|
||||
iPtr->resolverPtr = NULL;
|
||||
iPtr->evalFlags = 0;
|
||||
iPtr->scriptFile = NULL;
|
||||
iPtr->flags = 0;
|
||||
iPtr->flags = TCL_ENCODING_PROFILE_STRICT;
|
||||
#ifdef _WIN32
|
||||
wchar_t *defaultProfile = getenv("TCL_PROFILE_DEFAULT");
|
||||
if (defaultProfile != NULL) {
|
||||
if (!wcscmp(defaultProfile, L"tcl8")) {
|
||||
iPtr->flags = TCL_ENCODING_PROFILE_TCL8;
|
||||
} else if (!wcscmp(defaultProfile, L"replace")) {
|
||||
iPtr->flags = TCL_ENCODING_PROFILE_REPLACE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
char *defaultProfile = getenv("TCL_PROFILE_DEFAULT");
|
||||
if (defaultProfile != NULL) {
|
||||
if (!strcmp(defaultProfile, "tcl8")) {
|
||||
iPtr->flags = TCL_ENCODING_PROFILE_TCL8;
|
||||
} else if (!strcmp(defaultProfile, "replace")) {
|
||||
iPtr->flags = TCL_ENCODING_PROFILE_REPLACE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
iPtr->tracePtr = NULL;
|
||||
iPtr->tracesForbiddingInline = 0;
|
||||
iPtr->activeCmdTracePtr = NULL;
|
||||
|
||||
+4
-1
@@ -435,7 +435,7 @@ EncodingConvertParseOptions (
|
||||
Tcl_Encoding encoding;
|
||||
Tcl_Obj *dataObj;
|
||||
Tcl_Obj *failVarObj;
|
||||
int profile = TCL_ENCODING_PROFILE_TCL8;
|
||||
int profile = -1;
|
||||
|
||||
/*
|
||||
* Possible combinations:
|
||||
@@ -494,6 +494,9 @@ numArgsError: /* ONLY jump here if nothing needs to be freed!!! */
|
||||
dataObj = objv[objc - 1];
|
||||
}
|
||||
|
||||
if (profile == -1) {
|
||||
profile = ENCODING_PROFILE_GET(((Interp *)interp)->flags);
|
||||
}
|
||||
*encPtr = encoding;
|
||||
*dataObjPtr = dataObj;
|
||||
*profilePtr = profile;
|
||||
|
||||
+5
-72
@@ -198,18 +198,11 @@ static struct TclEncodingProfiles {
|
||||
{"strict", TCL_ENCODING_PROFILE_STRICT},
|
||||
{"tcl8", TCL_ENCODING_PROFILE_TCL8},
|
||||
};
|
||||
#define PROFILE_TCL8(flags_) \
|
||||
((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_TCL8) \
|
||||
|| (ENCODING_PROFILE_GET(flags_) == 0 \
|
||||
&& TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_TCL8))
|
||||
#define PROFILE_STRICT(flags_) \
|
||||
((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_STRICT) \
|
||||
|| (ENCODING_PROFILE_GET(flags_) == 0 \
|
||||
&& TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_STRICT))
|
||||
(ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_STRICT)
|
||||
|
||||
#define PROFILE_REPLACE(flags_) \
|
||||
((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_REPLACE) \
|
||||
|| (ENCODING_PROFILE_GET(flags_) == 0 \
|
||||
&& TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_REPLACE))
|
||||
(ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_REPLACE)
|
||||
|
||||
#define UNICODE_REPLACE_CHAR ((Tcl_UniChar)0xFFFD)
|
||||
#define SURROGATE(c_) (((c_) & ~0x7FF) == 0xD800)
|
||||
@@ -1170,10 +1163,6 @@ Tcl_ExternalToUtfDString(
|
||||
* Possible flags values:
|
||||
* target encoding. It should be composed by OR-ing the following:
|
||||
* - *At most one* of TCL_ENCODING_PROFILE{DEFAULT,TCL8,STRICT}
|
||||
* - TCL_ENCODING_STOPONERROR: Backward compatibility. Sets the profile
|
||||
* to TCL_ENCODING_PROFILE_STRICT overriding any specified profile flags
|
||||
* Any other flag bits will cause an error to be returned (for future
|
||||
* compatibility)
|
||||
*
|
||||
* Results:
|
||||
* The return value is one of
|
||||
@@ -1500,8 +1489,6 @@ Tcl_UtfToExternalDString(
|
||||
* the source buffer are invalid or cannot be represented in the
|
||||
* target encoding. It should be composed by OR-ing the following:
|
||||
* - *At most one* of TCL_ENCODING_PROFILE{DEFAULT,TCL8,STRICT}
|
||||
* - TCL_ENCODING_STOPONERROR: Backward compatibility. Sets the profile
|
||||
* to TCL_ENCODING_PROFILE_STRICT overriding any specified profile flags
|
||||
*
|
||||
* Results:
|
||||
* The return value is one of
|
||||
@@ -2451,7 +2438,6 @@ BinaryProc(
|
||||
if (dstLen < 0) {
|
||||
dstLen = 0;
|
||||
}
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if ((flags & TCL_ENCODING_CHAR_LIMIT) && srcLen > *dstCharsPtr) {
|
||||
srcLen = *dstCharsPtr;
|
||||
}
|
||||
@@ -2519,7 +2505,6 @@ UtfToUtfProc(
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
srcClose = srcEnd;
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if ((flags & TCL_ENCODING_END) == 0) {
|
||||
srcClose -= 6;
|
||||
}
|
||||
@@ -2748,7 +2733,6 @@ Utf32ToUtfProc(
|
||||
int result, numChars, charLimit = INT_MAX;
|
||||
int ch = 0, bytesLeft = srcLen % 4;
|
||||
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
flags |= PTR2INT(clientData);
|
||||
if (flags & TCL_ENCODING_CHAR_LIMIT) {
|
||||
charLimit = *dstCharsPtr;
|
||||
@@ -2928,7 +2912,6 @@ UtfToUtf32Proc(
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
srcClose = srcEnd;
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if ((flags & TCL_ENCODING_END) == 0) {
|
||||
srcClose -= TCL_UTF_MAX;
|
||||
}
|
||||
@@ -3026,7 +3009,6 @@ Utf16ToUtfProc(
|
||||
int result, numChars, charLimit = INT_MAX;
|
||||
unsigned short ch = 0;
|
||||
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
flags |= PTR2INT(clientData);
|
||||
if (flags & TCL_ENCODING_CHAR_LIMIT) {
|
||||
charLimit = *dstCharsPtr;
|
||||
@@ -3115,7 +3097,7 @@ Utf16ToUtfProc(
|
||||
*dst++ = (ch & 0xFF);
|
||||
} else if (HIGH_SURROGATE(prev) || HIGH_SURROGATE(ch)) {
|
||||
dst += Tcl_UniCharToUtf(ch | TCL_COMBINE, dst);
|
||||
} else if (LOW_SURROGATE(ch) && !PROFILE_TCL8(flags)) {
|
||||
} else if (LOW_SURROGATE(ch) && (PROFILE_STRICT(flags) || PROFILE_REPLACE(flags))) {
|
||||
/* Lo surrogate not preceded by Hi surrogate and not tcl8 profile */
|
||||
if (PROFILE_STRICT(flags)) {
|
||||
result = TCL_CONVERT_UNKNOWN;
|
||||
@@ -3216,7 +3198,6 @@ UtfToUtf16Proc(
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
srcClose = srcEnd;
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if ((flags & TCL_ENCODING_END) == 0) {
|
||||
srcClose -= TCL_UTF_MAX;
|
||||
}
|
||||
@@ -3322,7 +3303,6 @@ UtfToUcs2Proc(
|
||||
int result, numChars, len;
|
||||
Tcl_UniChar ch = 0;
|
||||
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
flags |= PTR2INT(clientData);
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
@@ -3445,7 +3425,6 @@ TableToUtfProc(
|
||||
const unsigned short *pageZero;
|
||||
TableEncodingData *dataPtr = (TableEncodingData *)clientData;
|
||||
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if (flags & TCL_ENCODING_CHAR_LIMIT) {
|
||||
charLimit = *dstCharsPtr;
|
||||
}
|
||||
@@ -3588,7 +3567,6 @@ TableFromUtfProc(
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
srcClose = srcEnd;
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if ((flags & TCL_ENCODING_END) == 0) {
|
||||
srcClose -= TCL_UTF_MAX;
|
||||
}
|
||||
@@ -3695,7 +3673,6 @@ Iso88591ToUtfProc(
|
||||
const char *dstEnd, *dstStart;
|
||||
int result, numChars, charLimit = INT_MAX;
|
||||
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if (flags & TCL_ENCODING_CHAR_LIMIT) {
|
||||
charLimit = *dstCharsPtr;
|
||||
}
|
||||
@@ -3789,7 +3766,6 @@ Iso88591FromUtfProc(
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
srcClose = srcEnd;
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if ((flags & TCL_ENCODING_END) == 0) {
|
||||
srcClose -= TCL_UTF_MAX;
|
||||
}
|
||||
@@ -3937,7 +3913,6 @@ EscapeToUtfProc(
|
||||
int state, result, numChars, charLimit = INT_MAX;
|
||||
const char *dstStart, *dstEnd;
|
||||
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if (flags & TCL_ENCODING_CHAR_LIMIT) {
|
||||
charLimit = *dstCharsPtr;
|
||||
}
|
||||
@@ -4170,7 +4145,6 @@ EscapeFromUtfProc(
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
srcClose = srcEnd;
|
||||
flags = TclEncodingSetProfileFlags(flags);
|
||||
if ((flags & TCL_ENCODING_END) == 0) {
|
||||
srcClose -= TCL_UTF_MAX;
|
||||
}
|
||||
@@ -4599,6 +4573,7 @@ TclEncodingProfileIdToName(
|
||||
{
|
||||
size_t i;
|
||||
|
||||
profileValue &= ENCODING_PROFILE_MASK;
|
||||
for (i = 0; i < sizeof(encodingProfiles) / sizeof(encodingProfiles[0]); ++i) {
|
||||
if (profileValue == encodingProfiles[i].value) {
|
||||
return encodingProfiles[i].name;
|
||||
@@ -4616,48 +4591,6 @@ TclEncodingProfileIdToName(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------------
|
||||
*
|
||||
* TclEncodingSetProfileFlags --
|
||||
*
|
||||
* Maps the flags supported in the encoding C API's to internal flags.
|
||||
*
|
||||
* For backward compatibility reasons, TCL_ENCODING_STOPONERROR is
|
||||
* is mapped to the TCL_ENCODING_PROFILE_STRICT overwriting any profile
|
||||
* specified.
|
||||
*
|
||||
* If no profile or an invalid profile is specified, it is set to
|
||||
* the default.
|
||||
*
|
||||
* Results:
|
||||
* Internal encoding flag mask.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*------------------------------------------------------------------------
|
||||
*/
|
||||
int TclEncodingSetProfileFlags(int flags)
|
||||
{
|
||||
if (flags & TCL_ENCODING_STOPONERROR) {
|
||||
ENCODING_PROFILE_SET(flags, TCL_ENCODING_PROFILE_STRICT);
|
||||
} else {
|
||||
int profile = ENCODING_PROFILE_GET(flags);
|
||||
switch (profile) {
|
||||
case TCL_ENCODING_PROFILE_TCL8:
|
||||
case TCL_ENCODING_PROFILE_STRICT:
|
||||
case TCL_ENCODING_PROFILE_REPLACE:
|
||||
break;
|
||||
case 0: /* Unspecified by caller */
|
||||
default:
|
||||
ENCODING_PROFILE_SET(flags, TCL_ENCODING_PROFILE_DEFAULT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------------
|
||||
*
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "tclInt.h"
|
||||
#include "tclFileSystem.h"
|
||||
#include "tclIO.h"
|
||||
|
||||
/*
|
||||
* Declarations for local functions defined in this file:
|
||||
@@ -1457,6 +1458,8 @@ TclFileTemporaryCmd(
|
||||
|
||||
makeTemporary:
|
||||
chan = TclpOpenTemporaryFile(tempDirObj,tempBaseObj,tempExtObj, nameObj);
|
||||
ENCODING_PROFILE_SET(((Channel *)chan)->state->inputEncodingFlags, ((Interp *)interp)->flags);
|
||||
ENCODING_PROFILE_SET(((Channel *)chan)->state->outputEncodingFlags, ((Interp *)interp)->flags);
|
||||
|
||||
/*
|
||||
* If we created pieces of template, get rid of them now.
|
||||
|
||||
+2
-4
@@ -1679,12 +1679,10 @@ Tcl_CreateChannel(
|
||||
statePtr->encoding = Tcl_GetEncoding(NULL, name);
|
||||
statePtr->inputEncodingState = NULL;
|
||||
statePtr->inputEncodingFlags = TCL_ENCODING_START;
|
||||
ENCODING_PROFILE_SET(statePtr->inputEncodingFlags,
|
||||
TCL_ENCODING_PROFILE_DEFAULT);
|
||||
ENCODING_PROFILE_SET(statePtr->inputEncodingFlags, 0);
|
||||
statePtr->outputEncodingState = NULL;
|
||||
statePtr->outputEncodingFlags = TCL_ENCODING_START;
|
||||
ENCODING_PROFILE_SET(statePtr->outputEncodingFlags,
|
||||
TCL_ENCODING_PROFILE_DEFAULT);
|
||||
ENCODING_PROFILE_SET(statePtr->outputEncodingFlags, 0);
|
||||
|
||||
/*
|
||||
* Set the channel up initially in AUTO input translation mode to accept
|
||||
|
||||
@@ -682,6 +682,9 @@ TclChanCreateObjCmd(
|
||||
TclChannelPreserve(chan);
|
||||
chanPtr = (Channel *) chan;
|
||||
|
||||
ENCODING_PROFILE_SET(chanPtr->state->inputEncodingFlags, ((Interp *)interp)->flags);
|
||||
ENCODING_PROFILE_SET(chanPtr->state->outputEncodingFlags, ((Interp *)interp)->flags);
|
||||
|
||||
if ((methods & NULLABLE_METHODS) != NULLABLE_METHODS) {
|
||||
/*
|
||||
* Some of the nullable methods are not supported. We clone the
|
||||
|
||||
+2
-2
@@ -2329,6 +2329,7 @@ typedef struct Interp {
|
||||
* script in progress has been canceled thereby allowing
|
||||
* the evaluation stack for the interp to be fully
|
||||
* unwound.
|
||||
* Bits 24-32 are reserved to store the default encoding profile.
|
||||
*
|
||||
* WARNING: For the sake of some extensions that have made use of former
|
||||
* internal values, do not re-use the flag values 2 (formerly ERR_IN_PROGRESS)
|
||||
@@ -2868,7 +2869,7 @@ typedef struct ProcessGlobalValue {
|
||||
#define ENCODING_PROFILE_SET(flags_, profile_) \
|
||||
do { \
|
||||
(flags_) &= ~ENCODING_PROFILE_MASK; \
|
||||
(flags_) |= profile_; \
|
||||
(flags_) |= (profile_) & ENCODING_PROFILE_MASK; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
@@ -2893,7 +2894,6 @@ TclEncodingProfileNameToId(Tcl_Interp *interp,
|
||||
int *profilePtr);
|
||||
MODULE_SCOPE const char *TclEncodingProfileIdToName(Tcl_Interp *interp,
|
||||
int profileId);
|
||||
MODULE_SCOPE int TclEncodingSetProfileFlags(int flags);
|
||||
MODULE_SCOPE void TclGetEncodingProfiles(Tcl_Interp *interp);
|
||||
|
||||
/*
|
||||
|
||||
+22
-6
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include "tclInt.h"
|
||||
#include "tclIO.h"
|
||||
|
||||
/*
|
||||
* A pointer to a string that holds an initialization script that if non-NULL
|
||||
@@ -622,8 +623,8 @@ NRInterpCmd(
|
||||
"children", "create", "debug", "delete",
|
||||
"eval", "exists", "expose", "hide",
|
||||
"hidden", "issafe", "invokehidden",
|
||||
"limit", "marktrusted", "recursionlimit",
|
||||
"share",
|
||||
"limit", "marktrusted", "profile",
|
||||
"recursionlimit", "share",
|
||||
#ifndef TCL_NO_DEPRECATED
|
||||
"slaves",
|
||||
#endif
|
||||
@@ -634,16 +635,16 @@ NRInterpCmd(
|
||||
"children", "create", "debug", "delete",
|
||||
"eval", "exists", "expose",
|
||||
"hide", "hidden", "issafe",
|
||||
"invokehidden", "limit", "marktrusted", "recursionlimit",
|
||||
"share", "target", "transfer",
|
||||
"invokehidden", "limit", "marktrusted", "profile",
|
||||
"recursionlimit", "share", "target", "transfer",
|
||||
NULL
|
||||
};
|
||||
enum interpOptionEnum {
|
||||
OPT_ALIAS, OPT_ALIASES, OPT_BGERROR, OPT_CANCEL,
|
||||
OPT_CHILDREN, OPT_CREATE, OPT_DEBUG, OPT_DELETE,
|
||||
OPT_EVAL, OPT_EXISTS, OPT_EXPOSE, OPT_HIDE,
|
||||
OPT_HIDDEN, OPT_ISSAFE, OPT_INVOKEHID,
|
||||
OPT_LIMIT, OPT_MARKTRUSTED, OPT_RECLIMIT, OPT_SHARE,
|
||||
OPT_HIDDEN, OPT_ISSAFE, OPT_INVOKEHID, OPT_LIMIT,
|
||||
OPT_MARKTRUSTED, OPT_PROFILE, OPT_RECLIMIT, OPT_SHARE,
|
||||
#ifndef TCL_NO_DEPRECATED
|
||||
OPT_SLAVES,
|
||||
#endif
|
||||
@@ -1033,6 +1034,21 @@ NRInterpCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return ChildRecursionLimit(interp, childInterp, objc - 3, objv + 3);
|
||||
case OPT_PROFILE:
|
||||
if (objc != 2 && objc != 3) {
|
||||
Tcl_WrongNumArgs(interp, 2, objv, "?profile?");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Interp *iPtr = (Interp *)interp;
|
||||
if (objc == 3) {
|
||||
int newProfile;
|
||||
if (TclEncodingProfileNameToId(interp, Tcl_GetString(objv[2]), &newProfile) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
ENCODING_PROFILE_SET(iPtr->flags, newProfile);
|
||||
}
|
||||
Tcl_AppendResult(interp, TclEncodingProfileIdToName(NULL, iPtr->flags), NULL);
|
||||
return TCL_OK;
|
||||
#ifndef TCL_NO_DEPRECATED
|
||||
case OPT_SLAVES:
|
||||
#endif
|
||||
|
||||
@@ -1747,7 +1747,7 @@ proc http::OpenSocket {token DoLater} {
|
||||
fconfigure $sock -translation {auto crlf} \
|
||||
-buffersize $state(-blocksize)
|
||||
if {[package vsatisfies [package provide Tcl] 9.0-]} {
|
||||
fconfigure $sock -profile tcl8
|
||||
fconfigure $sock -profile replace \
|
||||
}
|
||||
##Log socket opened, DONE fconfigure - token $token
|
||||
}
|
||||
@@ -2168,7 +2168,7 @@ proc http::Connected {token proto phost srvurl} {
|
||||
fconfigure $sock -translation [list $trRead crlf] \
|
||||
-buffersize $state(-blocksize)
|
||||
if {[package vsatisfies [package provide Tcl] 9.0-]} {
|
||||
fconfigure $sock -profile tcl8
|
||||
fconfigure $sock -profile replace \
|
||||
}
|
||||
|
||||
# The following is disallowed in safe interpreters, but the socket is
|
||||
@@ -2561,7 +2561,7 @@ proc http::ReceiveResponse {token} {
|
||||
fconfigure $sock -translation [list auto $trWrite] \
|
||||
-buffersize $state(-blocksize)
|
||||
if {[package vsatisfies [package provide Tcl] 9.0-]} {
|
||||
fconfigure $sock -profile tcl8
|
||||
fconfigure $sock -profile replace \
|
||||
}
|
||||
Log ^D$tk begin receiving response - token $token
|
||||
|
||||
@@ -4555,7 +4555,7 @@ proc http::Eot {token {reason {}}} {
|
||||
set enc [CharsetToEncoding $state(charset)]
|
||||
if {$enc ne "binary"} {
|
||||
if {[package vsatisfies [package provide Tcl] 9.0-]} {
|
||||
set state(body) [encoding convertfrom -profile tcl8 $enc $state(body)]
|
||||
set state(body) [encoding convertfrom -profile replace $enc $state(body)]
|
||||
} else {
|
||||
set state(body) [encoding convertfrom $enc $state(body)]
|
||||
}
|
||||
@@ -4642,7 +4642,7 @@ proc http::GuessType {token} {
|
||||
return 0
|
||||
}
|
||||
if {[package vsatisfies [package provide Tcl] 9.0-]} {
|
||||
set state(body) [encoding convertfrom -profile tcl8 $enc $state(body)]
|
||||
set state(body) [encoding convertfrom -profile replace $enc $state(body)]
|
||||
} else {
|
||||
set state(body) [encoding convertfrom $enc $state(body)]
|
||||
}
|
||||
@@ -4727,7 +4727,7 @@ proc http::quoteString {string} {
|
||||
# than [regsub]/[subst]). [Bug 1020491]
|
||||
|
||||
if {[package vsatisfies [package provide Tcl] 9.0-]} {
|
||||
set string [encoding convertto -profile tcl8 $http(-urlencoding) $string]
|
||||
set string [encoding convertto -profile replace $http(-urlencoding) $string]
|
||||
} else {
|
||||
set string [encoding convertto $http(-urlencoding) $string]
|
||||
}
|
||||
|
||||
+1
-1
@@ -307,7 +307,7 @@ proc testfailindex {id converter enc data result failidx {profile default}} {
|
||||
}
|
||||
|
||||
# If this is the default profile, generate a test without specifying profile
|
||||
if {$profile eq $::encDefaultProfile} {
|
||||
if {$profile eq "strict"} {
|
||||
testconvert $id.$enc.default "list \[encoding $converter -failindex idx $enc [list $data]\] \[set idx]" [list $result $failidx]
|
||||
if {[set enc2 [endianUtf $enc]] ne ""} {
|
||||
# If utf{16,32}-{le,be}, also do utf{16,32}
|
||||
|
||||
+2
-2
@@ -780,7 +780,7 @@ test encoding-24.3 {EscapeFreeProc on open channels} {stdio} {
|
||||
} [list 3 "乎乞也 (\\u4E4E\\u4E5E\\u4E5F)"]
|
||||
|
||||
test encoding-24.4 {Parse valid or invalid utf-8} {
|
||||
string length [encoding convertfrom utf-8 "\xC0\x80"]
|
||||
string length [encoding convertfrom -profile tcl8 utf-8 "\xC0\x80"]
|
||||
} 1
|
||||
test encoding-24.5 {Parse valid or invalid utf-8} {
|
||||
string length [encoding convertfrom -profile tcl8 utf-8 "\xC0\x81"]
|
||||
@@ -822,7 +822,7 @@ test encoding-24.16 {Parse valid or invalid utf-8} -constraints testbytestring -
|
||||
encoding convertto utf-8 [testbytestring "Z\u4343\x80"]
|
||||
} -returnCodes 1 -result {expected byte sequence but character 1 was '䍃' (U+004343)}
|
||||
test encoding-24.17 {Parse valid or invalid utf-8} -constraints testbytestring -body {
|
||||
encoding convertto utf-8 [testbytestring "Z\xE0\x80"]
|
||||
encoding convertto -profile strict utf-8 [testbytestring "Z\xE0\x80"]
|
||||
} -result "Z\xC3\xA0\xE2\x82\xAC"
|
||||
test encoding-24.18 {Parse valid or invalid utf-8} -constraints testbytestring -body {
|
||||
encoding convertto utf-8 [testbytestring "Z\xE0\x80xxxxxx"]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
# List of defined encoding profiles
|
||||
set encProfiles {tcl8 strict replace}
|
||||
set encDefaultProfile tcl8; # Should reflect the default from implementation
|
||||
set encDefaultProfile [interp profile]
|
||||
|
||||
# encValidStrings - Table of valid strings.
|
||||
#
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ test interp-1.1 {options for interp command} -returnCodes error -body {
|
||||
} -result {wrong # args: should be "interp cmd ?arg ...?"}
|
||||
test interp-1.2 {options for interp command} -returnCodes error -body {
|
||||
interp frobox
|
||||
} -result {bad option "frobox": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, share, target, or transfer}
|
||||
} -result {bad option "frobox": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, profile, recursionlimit, share, target, or transfer}
|
||||
test interp-1.3 {options for interp command} {
|
||||
interp delete
|
||||
} ""
|
||||
@@ -50,13 +50,13 @@ test interp-1.6 {options for interp command} -returnCodes error -body {
|
||||
} -result {wrong # args: should be "interp children ?path?"}
|
||||
test interp-1.7 {options for interp command} -returnCodes error -body {
|
||||
interp hello
|
||||
} -result {bad option "hello": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, share, target, or transfer}
|
||||
} -result {bad option "hello": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, profile, recursionlimit, share, target, or transfer}
|
||||
test interp-1.8 {options for interp command} -returnCodes error -body {
|
||||
interp -froboz
|
||||
} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, share, target, or transfer}
|
||||
} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, profile, recursionlimit, share, target, or transfer}
|
||||
test interp-1.9 {options for interp command} -returnCodes error -body {
|
||||
interp -froboz -safe
|
||||
} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, share, target, or transfer}
|
||||
} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, profile, recursionlimit, share, target, or transfer}
|
||||
test interp-1.10 {options for interp command} -returnCodes error -body {
|
||||
interp target
|
||||
} -result {wrong # args: should be "interp target path alias"}
|
||||
|
||||
+4
-4
@@ -240,11 +240,11 @@ test iocmd-8.7 {fconfigure command} -setup {
|
||||
file delete $path(test1)
|
||||
} -body {
|
||||
set f1 [open $path(test1) w]
|
||||
fconfigure $f1 -translation lf -eofchar {} -encoding utf-16 -profile tcl8
|
||||
fconfigure $f1 -translation lf -eofchar {} -encoding utf-16
|
||||
fconfigure $f1
|
||||
} -cleanup {
|
||||
catch {close $f1}
|
||||
} -result {-blocking 1 -buffering full -buffersize 4096 -encoding utf-16 -eofchar {} -profile tcl8 -translation lf}
|
||||
} -result {-blocking 1 -buffering full -buffersize 4096 -encoding utf-16 -eofchar {} -profile strict -translation lf}
|
||||
test iocmd-8.8 {fconfigure command} -setup {
|
||||
file delete $path(test1)
|
||||
set x {}
|
||||
@@ -262,11 +262,11 @@ test iocmd-8.9 {fconfigure command} -setup {
|
||||
} -body {
|
||||
set f1 [open $path(test1) w]
|
||||
fconfigure $f1 -translation binary -buffering none -buffersize 4040 \
|
||||
-eofchar {} -encoding binary -profile tcl8
|
||||
-eofchar {} -encoding binary
|
||||
fconfigure $f1
|
||||
} -cleanup {
|
||||
catch {close $f1}
|
||||
} -result {-blocking 1 -buffering none -buffersize 4040 -encoding iso8859-1 -eofchar {} -profile tcl8 -translation lf}
|
||||
} -result {-blocking 1 -buffering none -buffersize 4040 -encoding iso8859-1 -eofchar {} -profile strict -translation lf}
|
||||
test iocmd-8.10 {fconfigure command} -returnCodes error -body {
|
||||
fconfigure a b
|
||||
} -result {can not find channel named "a"}
|
||||
|
||||
Reference in New Issue
Block a user