2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
9 static char sccsid
[] = "$Id: v_section.c,v 8.3 1993/08/31 17:15:26 bostic Exp $ (Berkeley) $Date: 1993/08/31 17:15:26 $";
12 #include <sys/types.h>
20 * In historic vi, the section commands ignored empty lines, unlike the
21 * paragraph commands, which was probably okay. However, they also moved
22 * to the start of the last line when there where no more sections instead
23 * of the end of the last line like the paragraph commands. I've changed
24 * the latter behaviore to match the paragraphs command.
26 * In historic vi, a "function" was defined as the first character of the
27 * line being an open brace, which could be followed by anything. This
28 * implementation follows that historic practice.
31 /* Macro to do a check on each line. */
43 if (p[0] != '.' || len < 3) \
45 for (lp = list; *lp; lp += 2) \
46 if (lp[0] == p[1] && \
47 (lp[1] == ' ' || lp[1] == p[2]) && !--cnt) { \
55 * v_sectionf -- [count]]]
56 * Move forward count sections/functions.
59 v_sectionf(sp
, ep
, vp
, fm
, tm
, rp
)
70 if ((list
= O_STR(sp
, O_SECTIONS
)) == NULL
)
73 cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1;
74 for (lno
= fm
->lno
; (p
= file_gline(sp
, ep
, ++lno
, &len
)) != NULL
;)
77 /* EOF is a movement sink. */
78 if (fm
->lno
!= lno
- 1) {
80 rp
->cno
= len
? len
- 1 : 0;
88 * v_sectionb -- [count][[
89 * Move backward count sections/functions.
92 v_sectionb(sp
, ep
, vp
, fm
, tm
, rp
)
108 /* Get macro list. */
109 if ((list
= O_STR(sp
, O_SECTIONS
)) == NULL
)
112 cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1;
113 for (lno
= fm
->lno
; (p
= file_gline(sp
, ep
, --lno
, &len
)) != NULL
;)
116 /* SOF is a movement sink. */