summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-12-23 17:26:07 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-12-23 17:26:07 (GMT)
commit5ca4f427ac2f26f0dd3aa77294b8c80ed44df14b (patch)
tree797b3c760758614ad840989e5d44200b5b75d003 /generic
parentc651e4542854ee537853e142517b71cc88471bc2 (diff)
downloadtcl-5ca4f427ac2f26f0dd3aa77294b8c80ed44df14b.zip
tcl-5ca4f427ac2f26f0dd3aa77294b8c80ed44df14b.tar.gz
tcl-5ca4f427ac2f26f0dd3aa77294b8c80ed44df14b.tar.bz2
Support TCL_ENCODING_CHAR_LIMIT in the UtfToUtfProc driver.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEncoding.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 5c5254b..f92cabb 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2294,7 +2294,7 @@ UtfToUtfProc(
{
const char *srcStart, *srcEnd, *srcClose;
const char *dstStart, *dstEnd;
- int result, numChars;
+ int result, numChars, charLimit = INT_MAX;
Tcl_UniChar ch;
result = TCL_OK;
@@ -2305,11 +2305,14 @@ UtfToUtfProc(
if ((flags & TCL_ENCODING_END) == 0) {
srcClose -= TCL_UTF_MAX;
}
+ if (flags & TCL_ENCODING_CHAR_LIMIT) {
+ charLimit = *dstCharsPtr;
+ }
dstStart = dst;
dstEnd = dst + dstLen - TCL_UTF_MAX;
- for (numChars = 0; src < srcEnd; numChars++) {
+ for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) {
/*
* If there is more string to follow, this will ensure that the