summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-12-23 17:46:05 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-12-23 17:46:05 (GMT)
commitd6c73b078b083eaf42088b8350aeb628a0d96c0a (patch)
tree2570101eb6a2366cc9fefc11344864e22f6b131f /generic/tclEncoding.c
parent5ca4f427ac2f26f0dd3aa77294b8c80ed44df14b (diff)
downloadtcl-d6c73b078b083eaf42088b8350aeb628a0d96c0a.zip
tcl-d6c73b078b083eaf42088b8350aeb628a0d96c0a.tar.gz
tcl-d6c73b078b083eaf42088b8350aeb628a0d96c0a.tar.bz2
Support TCL_ENCODING_CHAR_LIMIT in the UnicodeToUtfProc driver.
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r--generic/tclEncoding.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index f92cabb..0fe224e 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2408,9 +2408,12 @@ UnicodeToUtfProc(
{
const char *srcStart, *srcEnd;
const char *dstEnd, *dstStart;
- int result, numChars;
+ int result, numChars, charLimit = INT_MAX;
Tcl_UniChar ch;
+ if (flags & TCL_ENCODING_CHAR_LIMIT) {
+ charLimit = *dstCharsPtr;
+ }
result = TCL_OK;
if ((srcLen % sizeof(Tcl_UniChar)) != 0) {
result = TCL_CONVERT_MULTIBYTE;
@@ -2424,7 +2427,7 @@ UnicodeToUtfProc(
dstStart = dst;
dstEnd = dst + dstLen - TCL_UTF_MAX;
- for (numChars = 0; src < srcEnd; numChars++) {
+ for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
if (dst > dstEnd) {
result = TCL_CONVERT_NOSPACE;
break;