1
1
function ! s: line_to_file_full (line , is_posix) abort
2
- let separator = a: is_posix ? ' /' : ' \'
3
- let pattern = printf (' \c\%(^\$\%(env:\)\?\)\?[[:fname:]\ %s]*$' , separator)
2
+ let separator = a: is_posix ? ' /' : ' \\ '
3
+ let pattern = printf (' \c\%% (^\$\%% (env:\)\?\)\?[[:fname:]%s]*$' , separator)
4
4
return matchlist (a: line , pattern)[0 ]
5
5
endfunction
6
6
7
7
function ! s: full_to_base_prefix (full, chars, is_posix) abort
8
8
let separator = a: is_posix ? ' /' : ' \'
9
- let pattern = printf (' \%(.*\%s\|^\)\(.*[^%s%s]\)[%s]*$' ,
10
- \ separator, a: chars , separator, a: chars )
9
+ let separator2 = a: is_posix ? ' /' : ' \\'
10
+ let pattern = printf (' \%%(.*\%s\|^\)\(.*[^%s%s]\)[%s]*$' ,
11
+ \ separator, a: chars , separator2, a: chars )
11
12
return get (matchlist (a: full , pattern), 1 , ' ' )
12
13
endfunction
13
14
@@ -31,107 +32,156 @@ function! ddc_file#internal#info(input_line, chars, is_posix) abort
31
32
\ ]
32
33
endfunction
33
34
35
+ function ! ddc_file#internal#get_pos (input_line, chars) abort
36
+ return match (a: input_line , printf (' [%s]*$' , a: chars ))
37
+ endfunction
38
+
34
39
function ! ddc_file#internal#_test () abort
35
40
let isk_s = &isk
36
41
let isf_s = &isf
37
42
let errors_s = v: errors
38
43
try
39
44
let v: errors = []
45
+ let chars = ' [:keyword:]'
40
46
41
47
" posix
42
48
let &isk = ' @,48-57,_,192-255'
43
49
let &isf = ' @,48-57,/,.,-,_,+,,,#,$,%,~,='
44
- call assert_equal (' ' , s: line_to_file_full (' ' , v: true ))
45
- call assert_equal (' .' , s: line_to_file_full (' .' , v: true ))
46
- call assert_equal (' .' , s: line_to_file_full (' . .' , v: true ))
47
- call assert_equal (' abc' , s: line_to_file_full (' abc' , v: true ))
48
- call assert_equal (' bb' , s: line_to_file_full (' aa bb' , v: true ))
49
- call assert_equal (' bb' , s: line_to_file_full (' aa bb' , v: true ))
50
- call assert_equal (' bb/aa' , s: line_to_file_full (' aa ff bb/aa' , v: true ))
51
- call assert_equal (' .bb/aa' , s: line_to_file_full (' aa ff .bb/aa' , v: true ))
52
- call assert_equal (' ./bb/aa' , s: line_to_file_full (' aa ff ./bb/aa' , v: true ))
53
- call assert_equal (' ../bb/aa' , s: line_to_file_full (' aa ff ../bb/aa' , v: true ))
54
- call assert_equal (' a' , s: line_to_file_full (' \a' , v: true ))
55
- call assert_equal (' ./a' , s: line_to_file_full (' \./a' , v: true ))
56
- call assert_equal (' $Foo/bar' , s: line_to_file_full (' $Foo/bar' , v: true ))
57
- call assert_equal (' /bar' , s: line_to_file_full (' $Foo /bar' , v: true ))
58
- call assert_equal (' Foo/bar' , s: line_to_file_full (' $ Foo/bar' , v: true ))
59
- call assert_equal (' ' , s: full_to_base_prefix (' ' , v: true ))
60
- call assert_equal (' ' , s: full_to_base_prefix (' a' , v: true ))
61
- call assert_equal (' ' , s: full_to_base_prefix (' abc' , v: true ))
62
- call assert_equal (' ' , s: full_to_base_prefix (' /abc' , v: true ))
63
- call assert_equal (' .' , s: full_to_base_prefix (' .' , v: true ))
64
- call assert_equal (' .' , s: full_to_base_prefix (' .a' , v: true ))
65
- call assert_equal (' .' , s: full_to_base_prefix (' .abc' , v: true ))
66
- call assert_equal (' ' , s: full_to_base_prefix (' ./abc' , v: true ))
67
- call assert_equal (' ' , s: full_to_base_prefix (' ./' , v: true ))
68
- call assert_equal (' ' , s: full_to_base_prefix (' //' , v: true ))
69
- call assert_equal (' .' , s: full_to_base_prefix (' /.' , v: true ))
70
- call assert_equal (' .' , s: full_to_base_prefix (' ./.' , v: true ))
71
- call assert_equal (' .' , s: full_to_base_prefix (' ./.a' , v: true ))
72
- call assert_equal (' .a.' , s: full_to_base_prefix (' ./.a.' , v: true ))
73
- call assert_equal (' .a.' , s: full_to_base_prefix (' ./.a.b' , v: true ))
74
- call assert_equal (' .a.b.' , s: full_to_base_prefix (' ./.a.b.' , v: true ))
75
- call assert_equal (' ' , s: full_to_base_prefix (' ./a' , v: true ))
76
- call assert_equal (' a.' , s: full_to_base_prefix (' ./a.' , v: true ))
77
- call assert_equal (' a.' , s: full_to_base_prefix (' ./a.b' , v: true ))
78
- call assert_equal (' a.b.' , s: full_to_base_prefix (' ./a.b.' , v: true ))
79
- call assert_equal (' .' , s: full_to_base_prefix (' .' , v: true ))
80
- call assert_equal (' .' , s: full_to_base_prefix (' .a' , v: true ))
81
- call assert_equal (' .a.' , s: full_to_base_prefix (' .a.' , v: true ))
82
- call assert_equal (' .a.' , s: full_to_base_prefix (' .a.b' , v: true ))
83
- call assert_equal (' .a.b.' , s: full_to_base_prefix (' .a.b.' , v: true ))
84
- call assert_equal (' ' , s: full_to_base_prefix (' a' , v: true ))
85
- call assert_equal (' a.' , s: full_to_base_prefix (' a.' , v: true ))
86
- call assert_equal (' a.' , s: full_to_base_prefix (' a.b' , v: true ))
87
- call assert_equal (' a.b.' , s: full_to_base_prefix (' a.b.' , v: true ))
88
- call assert_equal (' a.b.' , s: full_to_base_prefix (' a.b.' , v: true ))
50
+ call assert_equal (' ' ,
51
+ \ s: line_to_file_full (' ' , v: true ))
52
+ call assert_equal (' .' ,
53
+ \ s: line_to_file_full (' .' , v: true ))
54
+ call assert_equal (' .' ,
55
+ \ s: line_to_file_full (' . .' , v: true ))
56
+ call assert_equal (' abc' ,
57
+ \ s: line_to_file_full (' abc' , v: true ))
58
+ call assert_equal (' bb' ,
59
+ \ s: line_to_file_full (' aa bb' , v: true ))
60
+ call assert_equal (' bb' ,
61
+ \ s: line_to_file_full (' aa bb' , v: true ))
62
+ call assert_equal (' bb/aa' ,
63
+ \ s: line_to_file_full (' aa ff bb/aa' , v: true ))
64
+ call assert_equal (' .bb/aa' ,
65
+ \ s: line_to_file_full (' aa ff .bb/aa' , v: true ))
66
+ call assert_equal (' ./bb/aa' ,
67
+ \ s: line_to_file_full (' aa ff ./bb/aa' , v: true ))
68
+ call assert_equal (' ../bb/aa' ,
69
+ \ s: line_to_file_full (' aa ff ../bb/aa' , v: true ))
70
+ call assert_equal (' a' ,
71
+ \ s: line_to_file_full (' \a' , v: true ))
72
+ call assert_equal (' ./a' ,
73
+ \ s: line_to_file_full (' \./a' , v: true ))
74
+ call assert_equal (' $Foo/bar' ,
75
+ \ s: line_to_file_full (' $Foo/bar' , v: true ))
76
+ call assert_equal (' /bar' ,
77
+ \ s: line_to_file_full (' $Foo /bar' , v: true ))
78
+ call assert_equal (' Foo/bar' ,
79
+ \ s: line_to_file_full (' $ Foo/bar' , v: true ))
80
+ call assert_equal (' ' ,
81
+ \ s: full_to_base_prefix (' ' , chars, v: true ))
82
+ call assert_equal (' ' ,
83
+ \ s: full_to_base_prefix (' a' , chars, v: true ))
84
+ call assert_equal (' ' ,
85
+ \ s: full_to_base_prefix (' abc' , chars, v: true ))
86
+ call assert_equal (' ' ,
87
+ \ s: full_to_base_prefix (' /abc' , chars, v: true ))
88
+ call assert_equal (' .' ,
89
+ \ s: full_to_base_prefix (' .' , chars, v: true ))
90
+ call assert_equal (' .' ,
91
+ \ s: full_to_base_prefix (' .a' , chars, v: true ))
92
+ call assert_equal (' .' ,
93
+ \ s: full_to_base_prefix (' .abc' , chars, v: true ))
94
+ call assert_equal (' ' ,
95
+ \ s: full_to_base_prefix (' ./abc' , chars, v: true ))
96
+ call assert_equal (' ' ,
97
+ \ s: full_to_base_prefix (' ./' , chars, v: true ))
98
+ call assert_equal (' ' ,
99
+ \ s: full_to_base_prefix (' //' , chars, v: true ))
100
+ call assert_equal (' .' ,
101
+ \ s: full_to_base_prefix (' /.' , chars, v: true ))
102
+ call assert_equal (' .' ,
103
+ \ s: full_to_base_prefix (' ./.' , chars, v: true ))
104
+ call assert_equal (' .' ,
105
+ \ s: full_to_base_prefix (' ./.a' , chars, v: true ))
106
+ call assert_equal (' .a.' ,
107
+ \ s: full_to_base_prefix (' ./.a.' , chars, v: true ))
108
+ call assert_equal (' .a.' ,
109
+ \ s: full_to_base_prefix (' ./.a.b' , chars, v: true ))
110
+ call assert_equal (' .a.b.' ,
111
+ \ s: full_to_base_prefix (' ./.a.b.' , chars, v: true ))
112
+ call assert_equal (' ' ,
113
+ \ s: full_to_base_prefix (' ./a' , chars, v: true ))
114
+ call assert_equal (' a.' ,
115
+ \ s: full_to_base_prefix (' ./a.' , chars, v: true ))
116
+ call assert_equal (' a.' ,
117
+ \ s: full_to_base_prefix (' ./a.b' , chars, v: true ))
118
+ call assert_equal (' a.b.' ,
119
+ \ s: full_to_base_prefix (' ./a.b.' , chars, v: true ))
120
+ call assert_equal (' .' ,
121
+ \ s: full_to_base_prefix (' .' , chars, v: true ))
122
+ call assert_equal (' .' ,
123
+ \ s: full_to_base_prefix (' .a' , chars, v: true ))
124
+ call assert_equal (' .a.' ,
125
+ \ s: full_to_base_prefix (' .a.' , chars, v: true ))
126
+ call assert_equal (' .a.' ,
127
+ \ s: full_to_base_prefix (' .a.b' , chars, v: true ))
128
+ call assert_equal (' .a.b.' ,
129
+ \ s: full_to_base_prefix (' .a.b.' , chars, v: true ))
130
+ call assert_equal (' ' ,
131
+ \ s: full_to_base_prefix (' a' , chars, v: true ))
132
+ call assert_equal (' a.' ,
133
+ \ s: full_to_base_prefix (' a.' , chars, v: true ))
134
+ call assert_equal (' a.' ,
135
+ \ s: full_to_base_prefix (' a.b' , chars, v: true ))
136
+ call assert_equal (' a.b.' ,
137
+ \ s: full_to_base_prefix (' a.b.' , chars, v: true ))
138
+ call assert_equal (' a.b.' ,
139
+ \ s: full_to_base_prefix (' a.b.' , chars, v: true ))
89
140
90
141
" win32
91
142
" NOTE: '/' is included as well as '\'.
92
143
let &isk = ' @,48-57,_,128-167,224-235'
93
144
let &isf = ' @,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,='
94
- let chars = ' [:keyword:]'
95
145
call assert_equal (' ' ,
96
- \ s: line_to_file_full (' ' , chars, v: false ))
146
+ \ s: line_to_file_full (' ' , v: false ))
97
147
call assert_equal (' .' ,
98
- \ s: line_to_file_full (' .' , chars, v: false ))
148
+ \ s: line_to_file_full (' .' , v: false ))
99
149
call assert_equal (' .' ,
100
- \ s: line_to_file_full (' . .' , chars, v: false ))
150
+ \ s: line_to_file_full (' . .' , v: false ))
101
151
call assert_equal (' abc' ,
102
- \ s: line_to_file_full (' abc' , chars, v: false ))
152
+ \ s: line_to_file_full (' abc' , v: false ))
103
153
call assert_equal (' bb' ,
104
- \ s: line_to_file_full (' aa bb' , chars, v: false ))
154
+ \ s: line_to_file_full (' aa bb' , v: false ))
105
155
call assert_equal (' bb' ,
106
- \ s: line_to_file_full (' aa bb' , chars, v: false ))
156
+ \ s: line_to_file_full (' aa bb' , v: false ))
107
157
call assert_equal (' bb\aa' ,
108
- \ s: line_to_file_full (' aa ff bb\aa' , chars, v: false ))
158
+ \ s: line_to_file_full (' aa ff bb\aa' , v: false ))
109
159
call assert_equal (' .bb\aa' ,
110
- \ s: line_to_file_full (' aa ff .bb\aa' , chars, v: false ))
160
+ \ s: line_to_file_full (' aa ff .bb\aa' , v: false ))
111
161
call assert_equal (' .\bb\aa' ,
112
- \ s: line_to_file_full (' aa ff .\bb\aa' , chars, v: false ))
162
+ \ s: line_to_file_full (' aa ff .\bb\aa' , v: false ))
113
163
call assert_equal (' ..\bb\aa' ,
114
- \ s: line_to_file_full (' aa ff ..\bb\aa' , chars, v: false ))
164
+ \ s: line_to_file_full (' aa ff ..\bb\aa' , v: false ))
115
165
call assert_equal (' /a' ,
116
- \ s: line_to_file_full (' /a' , chars, v: false ))
166
+ \ s: line_to_file_full (' /a' , v: false ))
117
167
call assert_equal (' /.\a' ,
118
- \ s: line_to_file_full (' /.\a' , chars, v: false ))
168
+ \ s: line_to_file_full (' /.\a' , v: false ))
119
169
call assert_equal (' $Foo/bar' ,
120
- \s : line_to_file_full (' $Foo/bar' , chars, v: false ))
170
+ \s : line_to_file_full (' $Foo/bar' , v: false ))
121
171
call assert_equal (' /bar' ,
122
- \s : line_to_file_full (' $Foo /bar' , chars, v: false ))
172
+ \s : line_to_file_full (' $Foo /bar' , v: false ))
123
173
call assert_equal (' Foo/bar' ,
124
- \s : line_to_file_full (' $ Foo/bar' , chars, v: false ))
174
+ \s : line_to_file_full (' $ Foo/bar' , v: false ))
125
175
call assert_equal (' $env:Foo/bar' ,
126
- \s : line_to_file_full (' $env:Foo/bar' , chars, v: false ))
176
+ \s : line_to_file_full (' $env:Foo/bar' , v: false ))
127
177
call assert_equal (' /root/$env:Foo/bar' ,
128
- \ s: line_to_file_full (' /root/$env:Foo/bar' , chars, v: false ))
178
+ \ s: line_to_file_full (' /root/$env:Foo/bar' , v: false ))
129
179
call assert_equal (' $Env:Foo/bar' ,
130
- \s : line_to_file_full (' $Env:Foo/bar' , chars, v: false ))
180
+ \s : line_to_file_full (' $Env:Foo/bar' , v: false ))
131
181
call assert_equal (' /bar' ,
132
- \s : line_to_file_full (' $env:Foo /bar' , chars, v: false ))
182
+ \s : line_to_file_full (' $env:Foo /bar' , v: false ))
133
183
call assert_equal (' Foo/bar' ,
134
- \s : line_to_file_full (' $env: Foo/bar' , chars, v: false ))
184
+ \s : line_to_file_full (' $env: Foo/bar' , v: false ))
135
185
call assert_equal (' ' ,
136
186
\s : full_to_base_prefix (' ' , chars, v: false ))
137
187
call assert_equal (' ' ,
0 commit comments