From f17daf6cc715c93566dfd377f30e9ba8ea2e77cd Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 7 Apr 2023 07:51:17 +0100 Subject: [PATCH] Remove a completely unused loop in RTF pasting. In commit d07d7d66f662b67 I rewrote the code that constructs RTF paste data so that it uses a strbuf, in place of the previous ad-hoc code that counted up the lengths of pieces of RTF in advance in order to realloc the buffer. But apparently I left in an entire loop whose job was to count up one of those lengths, failing to notice that it's now completely pointless because its output value is never needed! Happily a clang upgrade has just improved the 'variable set but not used' warning to the point where it can spot that. I expect previously the variable still counted as 'used' because each increment of it used the previous value. (cherry picked from commit 6a27ae772c6fb27f8ddb2bec508e3e403be2a516) --- windows/window.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/windows/window.c b/windows/window.c index 50ed35ac..83600add 100644 --- a/windows/window.c +++ b/windows/window.c @@ -5042,7 +5042,7 @@ static void wintw_clip_write( unsigned char *tdata = (unsigned char *)lock2; wchar_t *udata = (wchar_t *)lock; int uindex = 0, tindex = 0; - int multilen, blen, alen, totallen, i; + int multilen, blen, alen, i; char before[16], after[4]; int fgcolour, lastfgcolour = -1; int bgcolour, lastbgcolour = -1; @@ -5330,19 +5330,6 @@ static void wintw_clip_write( } } assert(tindex + multilen <= len2); - totallen = blen + alen; - for (i = 0; i < multilen; i++) { - if (tdata[tindex+i] == '\\' || - tdata[tindex+i] == '{' || - tdata[tindex+i] == '}') - totallen += 2; - else if (tdata[tindex+i] == 0x0D || tdata[tindex+i] == 0x0A) - totallen += 6; /* \par\r\n */ - else if (tdata[tindex+i] > 0x7E || tdata[tindex+i] < 0x20) - totallen += 4; - else - totallen++; - } put_data(rtf, before, blen); for (i = 0; i < multilen; i++) {