[DUMP] VIM custom folding for Rational Purify's plog files
Dump.
"
" Fold (collapse) the Purify problem descriptions into single line
" As the comment to the fold, Purify message would appear with
" list of files/libraries in the call stack.
" "-CHAIN_LENGTH=32" parameter in PURIFYOPTIONS is highly recommended
"
" custom fold function for Purify's .plog files
function! PuriFold(lnum)
let l = getline(a:lnum)
" fold starts at 'XXX:' marker (though exclude File In Use)
if l =~ '^[A-Z][A-Z][A-Z]:' && l !~ '^FIU:'
return 1
endif
" store fold level of previous line
let pfl = foldlevel(a:lnum-1) > 0
" check whether it is a continuation of a fold
if pfl && (l =~ '^\t' || l =~ '^ \*' || l =~ '^ ')
return 1
endif
if pfl
return '<1' " close fold if open
else
return 0 " not a fold otherwise
endif
endfunction
" custom fold text function to quickly see the approx location of the problem
function! Puri_GatherNames(fl, ll)
let l:i = a:fl
let l:x = ''
let l:count = 0
while l:i <= a:ll && l:count < 10
let l:l = getline( i )
if l:l =~ '\*unknown func\*'
let l:l = ''
endif
let l:tmp = matchstr( l:l, '\[[^\]]\+\]$' )
if strlen(l:tmp) == 0
let l:i = l:i+1
continue
endif
if l:tmp =~ '^\[libclntsh\.so'
let l:tmp = '[*ORA*]'
endif
if l:tmp =~ '^\[libstlport\.so' ||
\ l:tmp =~ '^\[_\(pair\|tree\|alloc\|map\|construct\)\.h:' ||
\ l:tmp =~ '^\[_\(tree\)\.c:'
let l:tmp = '[*STL*]'
endif
if strlen(l:tmp)>0 && l:tmp!=strpart(l:x,strlen(l:x)-strlen(l:tmp))
if l:tmp == '[crt1.o]' || l:tmp == '[rtlib.o]' ||
\ l:tmp == '[crti.o]' || l:tmp == '[libCrun.a]' ||
\ l:tmp == '[libc.so.1]' || l:tmp == '[libnsl.so.1]' ||
\ l:tmp == '[libsocket.so.1]'
" nothing, ignore system libraries
else
let l:x = l:x.' '.l:tmp
let l:count = l:count+1
endif
endif
"echo x
let l:i = l:i+1
endwhile
return l:x
endfunction
function! Puri_FoldText()
return foldtext().Puri_GatherNames(v:foldstart, v:foldend)
endfunction
" activate the folds when .plog file is opened
au BufReadPost *.plog set foldexpr=PuriFold(v:lnum)
au BufReadPost *.plog set foldmethod=expr
" use custom fold text function
au BufReadPost *.plog set foldtext=Puri_FoldText()
P.S. WT Rational Purify?
No comments:
Post a Comment