summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdAH.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-04-01 14:55:22 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-04-01 14:55:22 (GMT)
commit684b9f01af31b898f57e7f05934043893186afc2 (patch)
tree46a66e6835019cd18d04bf1506f3338d343468e7 /generic/tclCmdAH.c
parent6941f99c78c730b92f232078e1aa3bad1b84ae1c (diff)
downloadtcl-684b9f01af31b898f57e7f05934043893186afc2.zip
tcl-684b9f01af31b898f57e7f05934043893186afc2.tar.gz
tcl-684b9f01af31b898f57e7f05934043893186afc2.tar.bz2
Set errorcode for STOPONERROR
Diffstat (limited to 'generic/tclCmdAH.c')
-rw-r--r--generic/tclCmdAH.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index ca8e939..cb5ef01 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -600,8 +600,12 @@ EncodingConvertfromObjCmd(
result = Tcl_ExternalToUtfDStringEx(encoding, bytesPtr, length,
stopOnError ? TCL_ENCODING_STOPONERROR : TCL_ENCODING_NO_THROW, &ds);
if (stopOnError && (result != (size_t)-1)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("unexpected byte at index %"
- TCL_LL_MODIFIER "u: '%c' (\\x%X)", (long long)result, UCHAR(bytesPtr[result]), UCHAR(bytesPtr[result])));
+ char buf[TCL_INTEGER_SPACE];
+ sprintf(buf, "%" TCL_Z_MODIFIER "u", result);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("unexpected byte at index %"
+ TCL_Z_MODIFIER "u: '%c' (\\x%X)", result, UCHAR(bytesPtr[result]), UCHAR(bytesPtr[result])));
+ Tcl_SetErrorCode(interp, "TCL", "ENCODING", "STOPONERROR",
+ buf, NULL);
Tcl_DStringFree(&ds);
return TCL_ERROR;
}
@@ -696,9 +700,13 @@ EncodingConverttoObjCmd(
if (stopOnError && (result != (size_t)-1)) {
size_t pos = Tcl_NumUtfChars(stringPtr, result);
int ucs4;
+ char buf[TCL_INTEGER_SPACE];
TclUtfToUCS4(&stringPtr[result], &ucs4);
+ sprintf(buf, "%" TCL_Z_MODIFIER "u", result);
Tcl_SetObjResult(interp, Tcl_ObjPrintf("unexpected character at index %"
- TCL_LL_MODIFIER "u: '%c' (U+%06X)", (long long)pos, ucs4, ucs4));
+ TCL_Z_MODIFIER "u: '%c' (U+%06X)", pos, ucs4, ucs4));
+ Tcl_SetErrorCode(interp, "TCL", "ENCODING", "STOPONERROR",
+ buf, NULL);
Tcl_DStringFree(&ds);
return TCL_ERROR;
}