1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
Tests for:
- "gf" on ${VAR},
- ":checkpath!" with various 'include' settings.
STARTTEST
:so small.vim
:if has("ebcdic")
: set isfname=@,240-249,/,.,-,_,+,,,$,:,~,{,}
:else
: set isfname=@,48-57,/,.,-,_,+,,,$,:,~,{,}
:endif
:if has("unix")
:let $CDIR = "."
/CDIR
:else
:if has("amiga")
:let $TDIR = "/testdir"
:else
:let $TDIR = "."
:endif
/TDIR
:endif
gf
:w! test.out
:brewind
ENDTEST
${CDIR}/test17a.in
$TDIR/test17a.in
STARTTEST
:" check for 'include' without \zs or \ze
:lang C
:!rm -f ./Xbase.a
:!rm -rf ./Xdir1
:!mkdir -p Xdir1/dir2
:e Xdir1/dir2/foo.a
i#include "bar.a"
:w
:e Xdir1/dir2/bar.a
i#include "baz.a"
:w
:e Xdir1/dir2/baz.a
i#include "foo.a"
:w
:e Xbase.a
:set path=Xdir1/dir2
i#include <foo.a>
:w
:redir! >>test.out
:checkpath!
:redir END
:brewind
ENDTEST
STARTTEST
:" check for 'include' with \zs and \ze
:!rm -f ./Xbase.b
:!rm -rf ./Xdir1
:!mkdir -p Xdir1/dir2
:let &include='^\s*%inc\s*/\zs[^/]\+\ze'
:function! DotsToSlashes()
: return substitute(v:fname, '\.', '/', 'g') . '.b'
:endfunction
:let &includeexpr='DotsToSlashes()'
:e Xdir1/dir2/foo.b
i%inc /bar/
:w
:e Xdir1/dir2/bar.b
i%inc /baz/
:w
:e Xdir1/dir2/baz.b
i%inc /foo/
:w
:e Xbase.b
:set path=Xdir1/dir2
i%inc /foo/
:w
:redir! >>test.out
:checkpath!
:redir END
:brewind
ENDTEST
STARTTEST
:" check for 'include' with \zs and no \ze
:!rm -f ./Xbase.c
:!rm -rf ./Xdir1
:!mkdir -p Xdir1/dir2
:let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
:function! StripNewlineChar()
: if v:fname =~ '\n$'
: return v:fname[:-2]
: endif
: return v:fname
:endfunction
:let &includeexpr='StripNewlineChar()'
:e Xdir1/dir2/foo.c
i%inc bar.c
:w
:e Xdir1/dir2/bar.c
i%inc baz.c
:w
:e Xdir1/dir2/baz.c
i%inc foo.c
:w
:e Xdir1/dir2/FALSE.c
i%inc foo.c
:w
:e Xbase.c
:set path=Xdir1/dir2
i%inc FALSE.c foo.c
:w
:redir! >>test.out
:checkpath!
:redir END
:brewind
:q
ENDTEST
|