Article View: gnu.emacs.bug
Article #99007Bug in term.c re magic cookie terminals
From: Julian Cowley
Date: Thu, 20 Dec 1990 06:28
Date: Thu, 20 Dec 1990 06:28
133 lines
5016 bytes
5016 bytes
In ins_del_lines (term.c, v. 18.55) there are several bugs which
I've known about for a while now, but for some reason I've never
gotten around to reporting them. There are four bugs altogether
in this patch, although only the last is truly serious. Here is
an explanation of each:
1) The size of the copybuf array is specified as MScreenWidth,
but instead MScreenLength should be used since copybuf deals with
rows and not columns.
2) When sending the multiline insert/delete lines command, the
OUTPUT command should take into account the number of lines that
are being affected.
3) Same as 2), but when sending single insert/delete line
commands. Also, I removed the curious statement
if (TF_teleray)
curX = 0;
since a few statements earlier, curX is set to zero by a call to
raw_topos. (The intervening call to background_highlight does
not affect curX.)
4) The most serious bug. This affects terminals which use
scrolling to do inserting and deleting of lines since the wrong
variables (specifically, curY and screen_height) are used to
make the calculations. The problem is two-fold: firstly, curY
does not point to the upper limit of the scrolled lines (vpos
does, however). This is because a scrolling region was set, and
curY was thus set to -1 as a flag that the cursor position is
undefined. Secondly, the calculations use screen_height as the
lower limit of the scrolling. This is clearly wrong, as the
scroll region was set to specified_window when the scrolling
took place. To fix this I've introduced a new variable,
lower_limit, so that the copy routines know exactly where the
lower limit of the effect of the screen movements are. I
believe this bug might offer a clue as to the mysterious bug
that zeros core that is commented on in several files dealing
with redisplay.
Note: these patches are *untested*. Just found them by studying
the source code.
julian cowley | julian@uhccux.uhcc.hawaii.edu
*** term.c.orig Wed Dec 19 16:54:25 1990
--- term.c Wed Dec 19 16:58:23 1990
***************
*** 744,749 ****
register int i = n > 0 ? n : -n;
register char *buf;
! char copybuf[MScreenWidth];
if (ins_del_lines_hook)
--- 744,750 ----
register int i = n > 0 ? n : -n;
+ register lower_limit = scroll_region_ok ? specified_window : screen_height;
register char *buf;
! char copybuf[MScreenLength];
if (ins_del_lines_hook)
***************
*** 770,774 ****
background_highlight ();
buf = tparam (multi, 0, 0, i);
! OUTPUT (buf);
free (buf);
}
--- 771,775 ----
background_highlight ();
buf = tparam (multi, 0, 0, i);
! OUTPUTL (buf, lower_limit - vpos);
free (buf);
}
***************
*** 778,784 ****
background_highlight ();
while (--i >= 0)
! OUTPUT (single);
! if (TF_teleray)
! curX = 0;
}
else
--- 779,783 ----
background_highlight ();
while (--i >= 0)
! OUTPUTL (single, lower_limit - vpos);
}
else
***************
*** 791,795 ****
background_highlight ();
while (--i >= 0)
! OUTPUTL (scroll, specified_window - vpos);
set_scroll_region (0, specified_window);
}
--- 790,794 ----
background_highlight ();
while (--i >= 0)
! OUTPUTL (scroll, lower_limit - vpos);
set_scroll_region (0, specified_window);
}
***************
*** 799,810 ****
if (n < 0)
{
! bcopy (&chars_wasted[curY - n], &chars_wasted[curY], screen_height - curY + n);
! bzero (&chars_wasted[screen_height + n], - n);
}
else
{
! bcopy (&chars_wasted[curY], ©buf[curY], screen_height - curY - n);
! bcopy (©buf[curY], &chars_wasted[curY + n], screen_height - curY - n);
! bzero (&chars_wasted[curY], n);
}
}
--- 798,812 ----
if (n < 0)
{
! bcopy (&chars_wasted[vpos - n], &chars_wasted[vpos],
! lower_limit - vpos + n);
! bzero (&chars_wasted[lower_limit + n], -n);
}
else
{
! bcopy (&chars_wasted[vpos], ©buf[vpos],
! lower_limit - vpos - n);
! bcopy (©buf[vpos], &chars_wasted[vpos + n],
! lower_limit - vpos - n);
! bzero (&chars_wasted[vpos], n);
}
}
Technical Details
Message-ID:
<9012200628.AA18938@uhccux.uhcc.Hawaii.Edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!apple!usc!cs.utexas.edu!tut.cis.ohio-state.edu!UHCCUX.UHCC.HAWAII.EDU!julianShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,a6b7288d149f5053,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-12-19 22:28:13 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!apple!usc!cs.utexas.edu!tut.cis.ohio-state.edu!UHCCUX.UHCC.HAWAII.EDU!julian From: julian@UHCCUX.UHCC.HAWAII.EDU (Julian Cowley) Newsgroups: gnu.emacs.bug Subject: Bug in term.c re magic cookie terminals Message-ID: <9012200628.AA18938@uhccux.uhcc.Hawaii.Edu> Date: 20 Dec 90 06:28:13 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: University of Hawaii at Manoa Lines: 133 Approved: bug-gnu-emacs@prep.ai.mit.edu