summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-03-13 23:56:22 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-03-13 23:56:22 (GMT)
commit261fbdac7ec5b605a259cf6c4dc4c2470c7d099d (patch)
tree67520deb83b45bf7b3d45662c5a3b2f4265efaaf
parent64eaafad72c1c1c0a76fb1adffb7200f79debb04 (diff)
downloadtcl-261fbdac7ec5b605a259cf6c4dc4c2470c7d099d.zip
tcl-261fbdac7ec5b605a259cf6c4dc4c2470c7d099d.tar.gz
tcl-261fbdac7ec5b605a259cf6c4dc4c2470c7d099d.tar.bz2
A few minor revisions.
-rw-r--r--generic/tclUtil.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 96ab96d..58e4cd2 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -1499,9 +1499,10 @@ Tcl_Backslash(
/*
*----------------------------------------------------------------------
*
- * TclUtfWellFormedEnd --
+ * UtfWellFormedEnd --
* Checks the end of utf string is malformed, if yes - wraps bytes
- * to the given buffer (as well-formed NTS string).
+ * to the given buffer (as well-formed NTS string). The buffer
+ * argument should be initialized by the caller and ready to use.
*
* Results:
* The bytes with well-formed end of the string.
@@ -1513,7 +1514,7 @@ Tcl_Backslash(
*/
static inline const char*
-TclUtfWellFormedEnd(
+UtfWellFormedEnd(
Tcl_DString *buffer, /* Buffer used to hold well-formed string. */
CONST char *bytes, /* Pointer to the beginning of the string. */
int length) /* Length of the string. */
@@ -1522,14 +1523,12 @@ TclUtfWellFormedEnd(
CONST char *p = Tcl_UtfPrev(l, bytes);
if (Tcl_UtfCharComplete(p, l - p)) {
- buffer->string = buffer->staticSpace;
return bytes;
}
/*
* Malformed utf-8 end, be sure we've NTS to safe compare of end-character,
* avoid segfault by access violation out of range.
*/
- Tcl_DStringInit(buffer);
Tcl_DStringAppend(buffer, bytes, length);
return Tcl_DStringValue(buffer);
}
@@ -1607,8 +1606,10 @@ TclTrimRight(
return 0;
}
- bytes = TclUtfWellFormedEnd(&bytesBuf, bytes, numBytes);
- trim = TclUtfWellFormedEnd(&trimBuf, trim, numTrim);
+ Tcl_DStringInit(&bytesBuf);
+ Tcl_DStringInit(&trimBuf);
+ bytes = UtfWellFormedEnd(&bytesBuf, bytes, numBytes);
+ trim = UtfWellFormedEnd(&trimBuf, trim, numTrim);
res = TrimRight(bytes, numBytes, trim, numTrim);
if (res > numBytes) {
@@ -1694,8 +1695,10 @@ TclTrimLeft(
return 0;
}
- bytes = TclUtfWellFormedEnd(&bytesBuf, bytes, numBytes);
- trim = TclUtfWellFormedEnd(&trimBuf, trim, numTrim);
+ Tcl_DStringInit(&bytesBuf);
+ Tcl_DStringInit(&trimBuf);
+ bytes = UtfWellFormedEnd(&bytesBuf, bytes, numBytes);
+ trim = UtfWellFormedEnd(&trimBuf, trim, numTrim);
res = TrimLeft(bytes, numBytes, trim, numTrim);
if (res > numBytes) {
@@ -1740,8 +1743,10 @@ TclTrim(
return 0;
}
- bytes = TclUtfWellFormedEnd(&bytesBuf, bytes, numBytes);
- trim = TclUtfWellFormedEnd(&trimBuf, trim, numTrim);
+ Tcl_DStringInit(&bytesBuf);
+ Tcl_DStringInit(&trimBuf);
+ bytes = UtfWellFormedEnd(&bytesBuf, bytes, numBytes);
+ trim = UtfWellFormedEnd(&trimBuf, trim, numTrim);
trimLeft = TrimLeft(bytes, numBytes, trim, numTrim);
if (trimLeft > numBytes) {