Skip to content

Commit

Permalink
Fix problem interrupting the line number calculation for initial prompt.
Browse files Browse the repository at this point in the history
Get rid of nasty lnloop boolean.
  • Loading branch information
gwsw committed Mar 27, 2009
1 parent 6a57cbc commit 8b57a2b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
2 changes: 2 additions & 0 deletions NEWS.VER
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

* Fix display problems with long lines on "ignaw" terminals.

* Fix problem interrupting the line number calculation for initial prompt.

======================================================================

Major changes between "less" versions 418 and 424
Expand Down
41 changes: 28 additions & 13 deletions linenum.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ struct linenum_info
* when we have a new one to insert and the table is full.
*/

#define NPOOL 50 /* Size of line number pool */
#define NPOOL 200 /* Size of line number pool */

#define LONGTIME (2) /* In seconds */

public int lnloop = 0; /* Are we in the line num loop? */

static struct linenum_info anchor; /* Anchor of the list */
static struct linenum_info *freelist; /* Anchor of the unused entries */
static struct linenum_info pool[NPOOL]; /* The pool itself */
Expand All @@ -70,6 +68,7 @@ static struct linenum_info *spare; /* We always keep one spare entry */
extern int linenums;
extern int sigs;
extern int sc_height;
extern int screen_trashed;

/*
* Initialize the line number structures.
Expand Down Expand Up @@ -214,12 +213,6 @@ add_lnum(linenum, pos)
longloopmessage()
{
ierror("Calculating line numbers", NULL_PARG);
/*
* Set the lnloop flag here, so if the user interrupts while
* we are calculating line numbers, the signal handler will
* turn off line numbers (linenums=0).
*/
lnloop = 1;
}

static int loopcount;
Expand Down Expand Up @@ -249,6 +242,22 @@ longish()
#endif
}

/*
* Turn off line numbers because the user has interrupted
* a lengthy line number calculation.
*/
static void
turnoff_linenums()
{
if (linenums == OPT_ONPLUS)
/*
* We were displaying line numbers, so need to repaint.
*/
screen_trashed = 1;
linenums = 0;
error("Line numbers turned off", NULL_PARG);
}

/*
* Find the line number associated with a given position.
* Return 0 if we can't figure it out.
Expand Down Expand Up @@ -315,11 +324,14 @@ find_linenum(pos)
* Allow a signal to abort this loop.
*/
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
if (ABORT_SIGS()) {
turnoff_linenums();
return (0);
}
if (cpos == NULL_POSITION)
return (0);
longish();
}
lnloop = 0;
/*
* We might as well cache it.
*/
Expand All @@ -344,11 +356,14 @@ find_linenum(pos)
* Allow a signal to abort this loop.
*/
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
if (ABORT_SIGS()) {
turnoff_linenums();
return (0);
}
if (cpos == NULL_POSITION)
return (0);
longish();
}
lnloop = 0;
/*
* We might as well cache it.
*/
Expand Down
20 changes: 1 addition & 19 deletions signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ u_interrupt(type)
#endif
if (reading)
intread();
bell();
}

#ifdef SIGTSTP
Expand Down Expand Up @@ -251,24 +252,5 @@ psignals()
{
if (quit_on_intr)
quit(QUIT_OK);
bell();
/*
* {{ You may wish to replace the bell() with
* error("Interrupt", NULL_PARG); }}
*/

/*
* If we were interrupted while in the "calculating
* line numbers" loop, turn off line numbers.
*/
if (lnloop)
{
lnloop = 0;
if (linenums == 2)
screen_trashed = 1;
linenums = 0;
error("Line numbers turned off", NULL_PARG);
}

}
}

0 comments on commit 8b57a2b

Please sign in to comment.