[5334] in Athena Bugs
Fix to "vax 7.0F: xman"
daemon@ATHENA.MIT.EDU (vanharen@ATHENA.MIT.EDU)
Thu Jun 28 00:43:38 1990
From: vanharen@ATHENA.MIT.EDU
Date: Thu, 28 Jun 90 00:43:26 -0400
To: bugs@ATHENA.MIT.EDU
In-Reply-To: [5332] in bugs
The following fix was developed by Craig Fields. Why am I sending it?
Because I took his code and made some more enhancements, which I shall
send in a moment. Anyway, below are context diffs for fixing the
problem described in the referenced bug report.
A description of the bug:
- If the first line being displayed mod NLINES (66) was 1, a
flag "first" was set to TRUE. This flag was passed down to DumpText,
and is then cleared, after the first text on the page is printed (which
is usually about line 3. If scrolling through the manpage forward, line
1 is always encountered before any actual text on the page. When
scrolling backward, however, it is possible to begin display on line 2
or 3, so the above test fails and the text is drawn un-bolded.
Scrolling backward farther, though, you eventually display from line 1
down and then the text is re-drawn in bold.
A short description of the changes:
- When displaying the manpage text, it is assumed that the first
line is being displayed, then some code attempts to prove that
assumption false. A flag is set accordingly. This flag is passed to
DumpText, which uses the value to turn on or off boldface text.
- At one point, the original code checked if "current_line" mod
NLINES (66) equalled 1. If so, then you are actually on line 2 of the
text. This was changed to check if equal to 0.
- If no lines are to be drawn, PrintText returns immediately.
- If a tab or the end-of-file was reached, DumpText was called
with the "bold" flag set to FALSE. This was changed to "first", so that
if the tab or end-of-file occured in the first line, it would be printed
bold. Tabs are not present in the 'cat'ed version of our manpages, and
you won't often hit EOF in the first line of a page, so this doesn't
make much difference anyway, but...
- A post-increment is changed to a pre-increment in order to
avoid drawing an extra line of text that is outside of the expose
region. The actual number of lines requested is displayed rather than
one extra.
Having said all that, here are the context diffs:
==============================================================================
*** /tmp/,RCSt1027917 Wed Jun 27 23:17:51 1990
--- /tmp/,RCSt2027917 Wed Jun 27 23:17:53 1990
***************
*** 2,8 ****
* xman - X window system manual page display program.
*
* $XConsortium: ScrollByL.c,v 1.13 90/01/11 20:09:00 keith Exp $
! * $Header: /site/usr/local/xman.src/RCS/ScrollByL.c,v 1.1 90/06/09 00:24:58 vanharen Exp $
*
* Copyright 1987, 1988 Massachusetts Institute of Technology
*
--- 2,8 ----
* xman - X window system manual page display program.
*
* $XConsortium: ScrollByL.c,v 1.13 90/01/11 20:09:00 keith Exp $
! * $Header: /site/usr/local/xman.src/RCS/ScrollByL.c,v 1.2 90/06/09 00:40:37 vanharen Exp Locker: vanharen $
*
* Copyright 1987, 1988 Massachusetts Institute of Technology
*
***************
*** 894,909 ****
char buf[BUFSIZ]; /* Misc. characters */
int width; /* Width of a tab stop. */
Boolean italicflag = FALSE; /* Print text in italics?? */
! Boolean first = FALSE; /* First line of a manual page??? */
int x_loc, y_loc; /* x and y location of text. */
static int DumpText();
static Boolean Boldify();
/*
* Nothing loaded, take no action.
*/
! if (sblw->scroll.top_line == NULL)
return;
current_line = start_line;
--- 894,910 ----
char buf[BUFSIZ]; /* Misc. characters */
int width; /* Width of a tab stop. */
Boolean italicflag = FALSE; /* Print text in italics?? */
! Boolean first = TRUE; /* First line of a manual page??? */
int x_loc, y_loc; /* x and y location of text. */
static int DumpText();
static Boolean Boldify();
+ int peek;
/*
* Nothing loaded, take no action.
*/
! if (sblw->scroll.top_line == NULL || num_lines == 0)
return;
current_line = start_line;
***************
*** 933,940 ****
bufp = buf;
x_loc = sblw->scroll.offset + sblw->scroll.indent;
while(TRUE) {
! if (current_line % NLINES == 1)
first = TRUE;
/*
--- 934,952 ----
bufp = buf;
x_loc = sblw->scroll.offset + sblw->scroll.indent;
+ /*
+ * Assume that we are always starting to print on or before the
+ * first line of a page, and then prove it if we aren't.
+ */
+ for (peek = 1; peek <= (start_line % NLINES); peek++)
+ if (**(sblw->scroll.top_line + start_line - peek) != '\n')
+ {
+ first = FALSE;
+ break;
+ }
+
while(TRUE) {
! if (current_line % NLINES == 0)
first = TRUE;
/*
***************
*** 950,956 ****
switch(*c) {
case '\0': /* If we reach the end of the file then return */
! DumpText(w, x_loc, y_loc, buf, bufp - buf, italicflag, FALSE);
return;
case '\n':
--- 962,968 ----
switch(*c) {
case '\0': /* If we reach the end of the file then return */
! DumpText(w, x_loc, y_loc, buf, bufp - buf, italicflag, first);
return;
case '\n':
***************
*** 968,974 ****
/*
* If we have painted the required number of lines then we should now return.
*/
! if (current_line++ == start_line + num_lines )
return;
bufp = buf;
--- 980,986 ----
/*
* If we have painted the required number of lines then we should now return.
*/
! if (++current_line == start_line + num_lines )
return;
bufp = buf;
***************
*** 984,990 ****
*/
case '\t': /* TAB */
! x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, italicflag, FALSE);
bufp = buf;
italicflag = 0;
x_loc += width - (x_loc % width);
--- 996,1002 ----
*/
case '\t': /* TAB */
! x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, italicflag, first);
bufp = buf;
italicflag = 0;
x_loc += width - (x_loc % width);