5 * 14407 SW Teal Blvd. #C
11 /* This file contains functions which didn't seem happy anywhere else */
17 /* find a particular line & return a pointer to a copy of its text */
19 long line
; /* line number of the line to fetch */
22 REG
char *scan
; /* used to search for the line in a BLK */
23 long l
; /* line number counter */
24 static BLK buf
; /* holds ONLY the selected line (as string) */
25 REG
char *cpy
; /* used while copying the line */
26 static long nextline
; /* } These four variables are used */
27 static long chglevel
; /* } to implement a shortcut when */
28 static char *nextscan
; /* } consecutive lines are fetched */
29 static long nextlnum
; /* } */
31 /* can we do a shortcut? */
32 if (changes
== chglevel
&& line
== nextline
)
38 /* scan lnum[] to determine which block its in */
39 for (i
= 1; line
> lnum
[i
]; i
++)
44 /* fetch text of the block containing that line */
47 /* find the line in the block */
48 for (l
= lnum
[i
- 1]; ++l
< line
; )
50 while (*scan
++ != '\n')
56 /* copy it into a block by itself, with no newline */
57 for (cpy
= buf
.c
; *scan
!= '\n'; )
63 /* maybe speed up the next call to fetchline() ? */
75 /* Calls to fetchline() interfere with calls to pfetch(). Make sure
76 * that pfetch() resets itself on its next invocation.
80 /* Return a pointer to the line's text */
85 /* error message from the regexp code */
87 char *txt
; /* an error message */
89 msg("RE error: %s", txt
);
92 /* This function is equivelent to the pfetch() macro */
94 long l
; /* line number of line to fetch */
96 if(l
!= pline
|| changes
!= pchgs
)
99 ptext
= fetchline(pline
);
100 plen
= strlen(ptext
);