Skip to content

Commit 56bcf3d

Browse files
author
jan.nijtmans
committed
Merge 8.7
2 parents 95e7615 + 7faef9c commit 56bcf3d

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

doc/encoding.n

+6-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ formats.
2828
Performs one of several encoding related operations, depending on
2929
\fIoption\fR. The legal \fIoption\fRs are:
3030
.TP
31-
\fBencoding convertfrom\fR ?\fB-nocomplain\fR? ?\fB-failindex var\fR? ?\fB-strict\fR? ?\fIencoding\fR? \fIdata\fR
31+
\fBencoding convertfrom\fR ?\fB-nocomplain\fR|\fB-strict\fR|\fB-failindex var\fR? ?\fIencoding\fR? \fIdata\fR
3232
.
3333
Convert \fIdata\fR to a Unicode string from the specified \fIencoding\fR. The
3434
characters in \fIdata\fR are 8 bit binary data. The resulting
@@ -50,15 +50,15 @@ in case of a conversion error, the position of the input byte causing the error
5050
is returned in the given variable. The return value of the command are the
5151
converted characters until the first error position. No error condition is raised.
5252
In case of no error, the value \fI-1\fR is written to the variable. This option
53-
may not be used together with \fB-nocomplain\fR.
53+
may not be used together with \fB-nocomplain\fR or \fB-strict\fR.
5454
.PP
5555
The \fB-strict\fR option follows more strict rules in conversion. For the \fButf-8\fR
56-
encoder, it disallows the the sequence \fB\\xC0\\x80\fR and noncharacters (which -
56+
encoder, it disallows invalid byte sequences and surrogates (which -
5757
otherwise - are just passed through).
5858
.VE "TCL8.7 TIP346, TIP607, TIP601"
5959
.RE
6060
.TP
61-
\fBencoding convertto\fR ?\fB-nocomplain\fR? ?\fB-failindex var\fR? ?\fB-strict\fR? ?\fIencoding\fR? \fIstring\fR
61+
\fBencoding convertto\fR ?\fB-nocomplain\fR|\fB-strict\fR|\fB-failindex var\fR? ?\fIencoding\fR? \fIstring\fR
6262
.
6363
Convert \fIstring\fR from Unicode to the specified \fIencoding\fR.
6464
The result is a sequence of bytes that represents the converted
@@ -82,11 +82,10 @@ in case of a conversion error, the position of the input character causing the e
8282
is returned in the given variable. The return value of the command are the
8383
converted bytes until the first error position. No error condition is raised.
8484
In case of no error, the value \fI-1\fR is written to the variable. This option
85-
may not be used together with \fB-nocomplain\fR.
85+
may not be used together with \fB-nocomplain\fR or \fB-strict\fR.
8686
.PP
8787
The \fB-strict\fR option follows more strict rules in conversion. For the \fButf-8\fR
88-
encoder, it disallows the the sequence \fB\\xC0\\x80\fR and noncharacters (which -
89-
otherwise - are just passed through).
88+
encoder, it has no effect.
9089
.VE "TCL8.7 TIP346, TIP607, TIP601"
9190
.RE
9291
.TP

generic/tclCmdAH.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ EncodingConvertfromObjCmd(
456456
goto encConvFromError;
457457
}
458458
failVarObj = objv[2];
459+
flags = TCL_ENCODING_STOPONERROR;
459460
objcUnprocessed -= 2;
460461
}
461462
switch (objcUnprocessed) {
@@ -472,7 +473,7 @@ EncodingConvertfromObjCmd(
472473
}
473474
} else {
474475
encConvFromError:
475-
Tcl_WrongNumArgs(interp, 1, objv, "?-nocomplain? ?-strict? ?-failindex var? ?encoding? data");
476+
Tcl_WrongNumArgs(interp, 1, objv, "?-nocomplain|-strict|-failindex var? ?encoding? data");
476477
return TCL_ERROR;
477478
}
478479

@@ -585,6 +586,7 @@ EncodingConverttoObjCmd(
585586
goto encConvToError;
586587
}
587588
failVarObj = objv[2];
589+
flags = TCL_ENCODING_STOPONERROR;
588590
objcUnprocessed -= 2;
589591
}
590592
switch (objcUnprocessed) {
@@ -601,7 +603,7 @@ EncodingConverttoObjCmd(
601603
}
602604
} else {
603605
encConvToError:
604-
Tcl_WrongNumArgs(interp, 1, objv, "?-nocomplain? ?-strict? ?-failindex var? ?encoding? data");
606+
Tcl_WrongNumArgs(interp, 1, objv, "?-nocomplain|-strict|-failindex var? ?encoding? data");
605607
return TCL_ERROR;
606608
}
607609

tests/cmdAH.test

+12-12
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ test cmdAH-4.2 {Tcl_EncodingObjCmd} -returnCodes error -body {
186186
} -result {unknown or ambiguous subcommand "foo": must be convertfrom, convertto, dirs, names, or system}
187187
test cmdAH-4.3 {Tcl_EncodingObjCmd} -returnCodes error -body {
188188
encoding convertto
189-
} -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
189+
} -result {wrong # args: should be "encoding convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"}
190190
test cmdAH-4.4 {Tcl_EncodingObjCmd} -returnCodes error -body {
191191
encoding convertto foo bar
192192
} -result {unknown encoding "foo"}
@@ -208,7 +208,7 @@ test cmdAH-4.6 {Tcl_EncodingObjCmd} -setup {
208208
} -result 8C
209209
test cmdAH-4.7 {Tcl_EncodingObjCmd} -returnCodes error -body {
210210
encoding convertfrom
211-
} -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
211+
} -result {wrong # args: should be "encoding convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"}
212212
test cmdAH-4.8 {Tcl_EncodingObjCmd} -returnCodes error -body {
213213
encoding convertfrom foo bar
214214
} -result {unknown encoding "foo"}
@@ -245,10 +245,10 @@ test cmdAH-4.13 {Tcl_EncodingObjCmd} -setup {
245245

246246
test cmdAH-4.14.1 {Syntax error, -nocomplain and -failindex, no encoding} -body {
247247
encoding convertfrom -nocomplain -failindex 2 ABC
248-
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
248+
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"}
249249
test cmdAH-4.14.2 {Syntax error, -nocomplain and -failindex, no encoding} -body {
250250
encoding convertto -nocomplain -failindex 2 ABC
251-
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
251+
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"}
252252
test cmdAH-4.15.1 {Syntax error, -failindex and -nocomplain, no encoding} -body {
253253
encoding convertfrom -failindex 2 -nocomplain ABC
254254
} -returnCodes 1 -result {unknown encoding "-nocomplain"}
@@ -257,40 +257,40 @@ test cmdAH-4.15.2 {Syntax error, -failindex and -nocomplain, no encoding} -body
257257
} -returnCodes 1 -result {unknown encoding "-nocomplain"}
258258
test cmdAH-4.16.1 {Syntax error, -nocomplain and -failindex, encoding} -body {
259259
encoding convertfrom -nocomplain -failindex 2 utf-8 ABC
260-
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
260+
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"}
261261
test cmdAH-4.16.2 {Syntax error, -nocomplain and -failindex, encoding} -body {
262262
encoding convertto -nocomplain -failindex 2 utf-8 ABC
263-
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
263+
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"}
264264
test cmdAH-4.17.1 {Syntax error, -failindex and -nocomplain, encoding} -body {
265265
encoding convertfrom -failindex 2 -nocomplain utf-8 ABC
266-
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
266+
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"}
267267
test cmdAH-4.17.2 {Syntax error, -failindex and -nocomplain, encoding} -body {
268268
encoding convertto -failindex 2 -nocomplain utf-8 ABC
269-
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
269+
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"}
270270
test cmdAH-4.18.1 {Syntax error, -failindex with no var, no encoding} -body {
271271
encoding convertfrom -failindex ABC
272-
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
272+
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"}
273273
test cmdAH-4.18.2 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup {
274274
proc encoding_test {} {
275275
encoding convertfrom -failindex ABC
276276
}
277277
} -body {
278278
# Compile and execute
279279
encoding_test
280-
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"} -cleanup {
280+
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"} -cleanup {
281281
rename encoding_test ""
282282
}
283283
test cmdAH-4.18.3 {Syntax error, -failindex with no var, no encoding} -body {
284284
encoding convertto -failindex ABC
285-
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
285+
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"}
286286
test cmdAH-4.18.4 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup {
287287
proc encoding_test {} {
288288
encoding convertto -failindex ABC
289289
}
290290
} -body {
291291
# Compile and execute
292292
encoding_test
293-
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"} -cleanup {
293+
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"} -cleanup {
294294
rename encoding_test ""
295295
}
296296
test cmdAH-4.19.1 {convertrom -failindex with correct data} -body {

tests/encoding.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -682,10 +682,10 @@ test encoding-24.21 {Parse with -nocomplain but without providing encoding} {
682682
} 1
683683
test encoding-24.22 {Syntax error, two encodings} -body {
684684
encoding convertfrom iso8859-1 utf-8 "ZX\uD800"
685-
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
685+
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"}
686686
test encoding-24.23 {Syntax error, two encodings} -body {
687687
encoding convertto iso8859-1 utf-8 "ZX\uD800"
688-
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
688+
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"}
689689
test encoding-24.24 {Parse invalid utf-8 with -strict} -body {
690690
encoding convertfrom -strict utf-8 "\xC0\x80\x00\x00"
691691
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC0'}

tests/safe.test

+4-4
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ test safe-11.7 {testing safe encoding} -setup {
14731473
interp eval $i encoding convertfrom
14741474
} -returnCodes error -cleanup {
14751475
safe::interpDelete $i
1476-
} -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
1476+
} -result {wrong # args: should be "encoding convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"}
14771477
test safe-11.7.1 {testing safe encoding} -setup {
14781478
set i [safe::interpCreate]
14791479
} -body {
@@ -1482,7 +1482,7 @@ test safe-11.7.1 {testing safe encoding} -setup {
14821482
} -match glob -cleanup {
14831483
unset -nocomplain m o
14841484
safe::interpDelete $i
1485-
} -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"
1485+
} -result {wrong # args: should be "encoding convertfrom ?-nocomplain|-strict|-failindex var? ?encoding? data"
14861486
while executing
14871487
"encoding convertfrom"
14881488
invoked from within
@@ -1495,7 +1495,7 @@ test safe-11.8 {testing safe encoding} -setup {
14951495
interp eval $i encoding convertto
14961496
} -returnCodes error -cleanup {
14971497
safe::interpDelete $i
1498-
} -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"}
1498+
} -result {wrong # args: should be "encoding convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"}
14991499
test safe-11.8.1 {testing safe encoding} -setup {
15001500
set i [safe::interpCreate]
15011501
} -body {
@@ -1504,7 +1504,7 @@ test safe-11.8.1 {testing safe encoding} -setup {
15041504
} -match glob -cleanup {
15051505
unset -nocomplain m o
15061506
safe::interpDelete $i
1507-
} -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-strict? ?-failindex var? ?encoding? data"
1507+
} -result {wrong # args: should be "encoding convertto ?-nocomplain|-strict|-failindex var? ?encoding? data"
15081508
while executing
15091509
"encoding convertto"
15101510
invoked from within

0 commit comments

Comments
 (0)