summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-12-23 17:53:21 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-12-23 17:53:21 (GMT)
commitefce992c9a86e2e12f0142274afa9d58012b5870 (patch)
tree94a25cd0a1f31aa5532c59bd74202b7469ab8311
parent14d329d47289cb067dc22eba521ef517a4a8ec15 (diff)
downloadtcl-efce992c9a86e2e12f0142274afa9d58012b5870.zip
tcl-efce992c9a86e2e12f0142274afa9d58012b5870.tar.gz
tcl-efce992c9a86e2e12f0142274afa9d58012b5870.tar.bz2
Support TCL_ENCODING_CHAR_LIMIT in TableToUtfProc and EscapeToUtfProc drivers.dgp_encoding_flags
-rw-r--r--generic/tclEncoding.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 3df720d..179ca17 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2595,12 +2595,15 @@ TableToUtfProc(
{
const char *srcStart, *srcEnd;
const char *dstEnd, *dstStart, *prefixBytes;
- int result, byte, numChars;
+ int result, byte, numChars, charLimit = INT_MAX;
Tcl_UniChar ch;
const unsigned short *const *toUnicode;
const unsigned short *pageZero;
TableEncodingData *dataPtr = clientData;
+ if (flags & TCL_ENCODING_CHAR_LIMIT) {
+ charLimit = *dstCharsPtr;
+ }
srcStart = src;
srcEnd = src + srcLen;
@@ -2612,7 +2615,7 @@ TableToUtfProc(
pageZero = toUnicode[0];
result = TCL_OK;
- for (numChars = 0; src < srcEnd; numChars++) {
+ for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
if (dst > dstEnd) {
result = TCL_CONVERT_NOSPACE;
break;
@@ -3054,9 +3057,12 @@ EscapeToUtfProc(
const char *prefixBytes, *tablePrefixBytes, *srcStart, *srcEnd;
const unsigned short *const *tableToUnicode;
const Encoding *encodingPtr;
- int state, result, numChars;
+ int state, result, numChars, charLimit = INT_MAX;
const char *dstStart, *dstEnd;
+ if (flags & TCL_ENCODING_CHAR_LIMIT) {
+ charLimit = *dstCharsPtr;
+ }
result = TCL_OK;
tablePrefixBytes = NULL; /* lint. */
tableToUnicode = NULL; /* lint. */
@@ -3074,7 +3080,7 @@ EscapeToUtfProc(
state = 0;
}
- for (numChars = 0; src < srcEnd; ) {
+ for (numChars = 0; src < srcEnd && numChars <= charLimit; ) {
int byte, hi, lo, ch;
if (dst > dstEnd) {