summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-02-15 20:26:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-02-15 20:26:10 (GMT)
commitf06c5e7af1c85806bcbce3202000670b90ab4528 (patch)
tree60db88a86a34abcd731671a42c16357e79d8ebd2
parent4c2d834fca441a8d463e3bd1a06489f0b864cf73 (diff)
downloadtcl-f06c5e7af1c85806bcbce3202000670b90ab4528.zip
tcl-f06c5e7af1c85806bcbce3202000670b90ab4528.tar.gz
tcl-f06c5e7af1c85806bcbce3202000670b90ab4528.tar.bz2
Fix for [33ab6d08eb]: Inconsistent behavior with encoding convertfrom -failindex
-rw-r--r--generic/tclEncoding.c2
-rw-r--r--tests/encoding.test5
2 files changed, 5 insertions, 2 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index c4db314..af7f30a 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2433,7 +2433,7 @@ UtfToUtfProc(
const char *saveSrc = src;
size_t len = TclUtfToUCS4(src, &ch);
if ((len < 2) && (ch != 0) && (flags & ENCODING_INPUT)
- && (((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT))) {
+ && (((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT) || (flags & ENCODING_FAILINDEX))) {
result = TCL_CONVERT_SYNTAX;
break;
}
diff --git a/tests/encoding.test b/tests/encoding.test
index 916a84a..6f1a760 100644
--- a/tests/encoding.test
+++ b/tests/encoding.test
@@ -617,9 +617,12 @@ test encoding-19.3 {TableFromUtfProc} -body {
test encoding-19.4 {TableFromUtfProc} -body {
list [encoding convertfrom -failindex idx ascii AÁ] [set idx]
} -result {A 1}
-test encoding-19.4 {TableFromUtfProc} -body {
+test encoding-19.5 {TableFromUtfProc} -body {
list [encoding convertfrom -failindex idx -strict ascii AÁ] [set idx]
} -result {A 1}
+test encoding-19.6 {TableFromUtfProc} -body {
+ list [encoding convertfrom -failindex idx -strict ascii AÁB] [set idx]
+} -result {A 1}
test encoding-20.1 {TableFreefProc} {
} {}