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_match.c,v 8.7 1993/12/09 17:05:51 bostic Exp $ (Berkeley) $Date: 1993/12/09 17:05:51 $";
12 #include <sys/types.h>
21 * Search to matching character.
24 v_match(sp
, ep
, vp
, fm
, tm
, rp
)
30 register int cnt
, matchc
, startc
;
34 int (*gc
)__P((SCR
*, EXF
*, VCS
*));
37 if ((p
= file_gline(sp
, ep
, fm
->lno
, &len
)) == NULL
) {
38 if (file_lline(sp
, ep
, &lno
))
42 GETLINE_ERR(sp
, fm
->lno
);
48 * Historical practice was to search in the forward direction only.
50 for (off
= fm
->cno
;; ++off
) {
52 nomatch
: msgq(sp
, M_BERR
, "No match character on this line.");
55 switch (startc
= p
[off
]) {
88 if (cs_init(sp
, ep
, &cs
))
93 if (cs
.cs_flags
!= 0) {
94 if (cs
.cs_flags
== CS_EOF
|| cs
.cs_flags
== CS_SOF
)
98 if (cs
.cs_ch
== startc
)
100 else if (cs
.cs_ch
== matchc
&& --cnt
== 0)
104 msgq(sp
, M_BERR
, "Matching character not found.");
111 * Movement commands go one space further. Increment the return
112 * MARK or from MARK depending on the direction of the search.
114 if (F_ISSET(vp
, VC_C
| VC_D
| VC_Y
)) {
115 if (file_gline(sp
, ep
, rp
->lno
, &len
) == NULL
) {
116 GETLINE_ERR(sp
, rp
->lno
);