carroll@s.cs.uiuc.edu (07/19/89)
Below is the function _updateline_ from x11term.c, GNU-Emacs 18.52. Embedded
are comments about what appears to me to be a bug, although I could just be
missing something.
Bug : updateline is passed an offset into the current line to start plotting
at. Internally, it calculates temp_length as the number of characters that
must be plotted, i.e. line->length - first. It then uses this later on when
it should use line->length to clear the rest of the line past the end. The
only reason it doesn't fail is that updateline() appears to only ever be
called with first==0, so temp_length==line->length. If first==0 is implied in
the use of the function, why does it even take a parameter?
updateline (first)
int first;
{
register int temp_length;
BLOCK_INPUT_DECLARE ();
#ifdef XDEBUG
fprintf(stderr, "updateline\n");
#endif XDEBUG
BLOCK_INPUT ();
if ((cursY < 0) || (cursY >= screen_height)
|| updated[cursY]) {
UNBLOCK_INPUT ();
return;
}
if (!first)
updated[cursY] = 1;
if (CursorExists)
CursorToggle ();
if (DesiredScreen && DesiredScreen[cursY + 1])
temp_length = DesiredScreen[cursY + 1]->length-first;
else
temp_length = 0;
/* ok, temp_length is how much of the line we actually want to update */
if (temp_length > 0) {
XDrawImageString (XXdisplay, XXwindow,
CurHL ? XXgc_rev : XXgc_norm,
first*XXfontw+XXInternalBorder,
cursY*XXfonth+XXInternalBorder+XXbase,
&DesiredScreen[cursY + 1]->body[first],
temp_length);
/* plot what we need of the line. Note that we start _first_ characters over,
* so characters before _first_ still count as part of the line
*/
if (temp_length < screen_width)
/* here's where I lose it - shouldn't this be line->length? What difference
* does it make if the amount that was updated was wider than the screen?
*/
x_clear_end_of_line (temp_length);
/* and of course, this seems wrong too - suppose line->length == 10 and
* first == 8. Therefore temp_length == 2.
* We'd plot 2 characters at positions 8 and 9, and then erase
* from 2 on over, wiping out the chars we just plotted.
*/
XTtopos (cursY, temp_length);
/* still wrong - see above */
}
else {
x_clear_end_of_line (0);
XTtopos (cursY, 0);
}
UNBLOCK_INPUT ();
}