1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Remove a completely unused loop in RTF pasting.

In commit d07d7d66f6 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 6a27ae772c)
This commit is contained in:
Simon Tatham 2023-04-07 07:51:17 +01:00
parent c3aba5d959
commit f17daf6cc7

View File

@ -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++) {