From 6e7c474da78d60f2d601b3ce3e2e269fd086c9d4 Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 14 Mar 2018 17:17:44 +0000 Subject: TclTrim: special case for TrimRight on single char result of TrimLeft (this char is already verified within TrimLeft, so bypass TrimRight at all) --- generic/tclUtil.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tclUtil.c b/generic/tclUtil.c index a8791c5..fb5b21c 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1738,9 +1738,9 @@ TclTrim( int trimLeft; Tcl_DString bytesBuf, trimBuf; + *trimRight = 0; /* Empty strings -> nothing to do */ if ((numBytes == 0) || (numTrim == 0)) { - *trimRight = 0; return 0; } @@ -1754,8 +1754,8 @@ TclTrim( trimLeft = numBytes; } numBytes -= trimLeft; - *trimRight = 0; - if (numBytes) { + /* have to trim yet (first char was already verified within TrimLeft) */ + if (numBytes > 1) { bytes += trimLeft; *trimRight = TrimRight(bytes, numBytes, trim, numTrim); if (*trimRight > numBytes) { -- cgit v0.12