aboutsummaryrefslogtreecommitdiff
path: root/linenum.c
diff options
context:
space:
mode:
Diffstat (limited to 'linenum.c')
-rw-r--r--linenum.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/linenum.c b/linenum.c
index 46c315497ebd..00cac60d14d3 100644
--- a/linenum.c
+++ b/linenum.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2020 Mark Nudelman
+ * Copyright (C) 1984-2021 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -40,11 +40,11 @@
*/
struct linenum_info
{
- struct linenum_info *next; /* Link to next in the list */
- struct linenum_info *prev; /* Line to previous in the list */
- POSITION pos; /* File position */
- POSITION gap; /* Gap between prev and next */
- LINENUM line; /* Line number */
+ struct linenum_info *next; /* Link to next in the list */
+ struct linenum_info *prev; /* Line to previous in the list */
+ POSITION pos; /* File position */
+ POSITION gap; /* Gap between prev and next */
+ LINENUM line; /* Line number */
};
/*
* "gap" needs some explanation: the gap of any particular line number
@@ -55,14 +55,14 @@ struct linenum_info
* when we have a new one to insert and the table is full.
*/
-#define NPOOL 200 /* Size of line number pool */
+#define NPOOL 200 /* Size of line number pool */
-#define LONGTIME (2) /* In seconds */
+#define LONGTIME (2) /* In seconds */
-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 */
-static struct linenum_info *spare; /* We always keep one spare entry */
+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 */
+static struct linenum_info *spare; /* We always keep one spare entry */
extern int linenums;
extern int sigs;
@@ -248,6 +248,8 @@ longish(VOID_PARAM)
static void
abort_long(VOID_PARAM)
{
+ if (loopcount >= 0)
+ return;
if (linenums == OPT_ONPLUS)
/*
* We were displaying line numbers, so need to repaint.
@@ -308,6 +310,7 @@ find_linenum(pos)
#if HAVE_TIME
startime = get_time();
#endif
+ loopcount = 0;
if (p == &anchor || pos - p->prev->pos < p->pos - pos)
{
/*
@@ -316,7 +319,6 @@ find_linenum(pos)
p = p->prev;
if (ch_seek(p->pos))
return (0);
- loopcount = 0;
for (linenum = p->line, cpos = p->pos; cpos < pos; linenum++)
{
/*
@@ -348,7 +350,6 @@ find_linenum(pos)
*/
if (ch_seek(p->pos))
return (0);
- loopcount = 0;
for (linenum = p->line, cpos = p->pos; cpos > pos; linenum--)
{
/*
@@ -368,7 +369,7 @@ find_linenum(pos)
*/
add_lnum(linenum, cpos);
}
-
+ loopcount = 0;
return (linenum);
}