File plugin/includefixer.vim changed (mode: 100644) (index dac6348..c5fb7d0) |
... |
... |
function! s:IsCustom(list, include) |
170 |
170 |
return 0 |
return 0 |
171 |
171 |
endfunction |
endfunction |
172 |
172 |
|
|
|
173 |
|
function! s:IncludeCompare(i1, i2) |
|
174 |
|
" extract paths |
|
175 |
|
let l:i1 = substitute(a:i1, '.*["<]\([^">]\+\)[">].*', '\1', '') |
|
176 |
|
let l:i2 = substitute(a:i2, '.*["<]\([^">]\+\)[">].*', '\1', '') |
|
177 |
|
|
|
178 |
|
while 1 |
|
179 |
|
" check for presence of slashes in both paths |
|
180 |
|
let l:s1 = (stridx(l:i1, '/') != -1) |
|
181 |
|
let l:s2 = (stridx(l:i2, '/') != -1) |
|
182 |
|
" path without slashes is greater than path with them |
|
183 |
|
if l:s1 != l:s2 |
|
184 |
|
return l:s1 ? -1 : 1 |
|
185 |
|
endif |
|
186 |
|
|
|
187 |
|
" extract next entries from both paths |
|
188 |
|
let l:e1 = substitute(l:i1, '\([^/\\]\+\).*', '\1', '') |
|
189 |
|
let l:e2 = substitute(l:i2, '\([^/\\]\+\).*', '\1', '') |
|
190 |
|
let l:i1 = l:i1[len(l:e1) + 1:] |
|
191 |
|
let l:i2 = l:i2[len(l:e2) + 1:] |
|
192 |
|
|
|
193 |
|
" compare entries and exit if they differ |
|
194 |
|
if l:e1 !=# l:e2 |
|
195 |
|
return l:e1 ># l:e2 ? 1 : -1 |
|
196 |
|
endif |
|
197 |
|
endwhile |
|
198 |
|
endfunction |
|
199 |
|
|
173 |
200 |
function! s:WriteOut(start,list) |
function! s:WriteOut(start,list) |
174 |
201 |
" check the list is empty |
" check the list is empty |
175 |
202 |
if len(a:list) == 0 |
if len(a:list) == 0 |
|
... |
... |
function! s:WriteOut(start,list) |
179 |
206 |
let l:end = a:start + len(a:list) |
let l:end = a:start + len(a:list) |
180 |
207 |
|
|
181 |
208 |
" sort the list |
" sort the list |
182 |
|
call sort(a:list) |
|
|
209 |
|
call sort(a:list, "<SID>IncludeCompare") |
183 |
210 |
|
|
184 |
211 |
" write out the list and an empty line |
" write out the list and an empty line |
185 |
212 |
call append(a:start,a:list) |
call append(a:start,a:list) |