r699 - /trunk/runtime/ftplugin/debchangelog.vim

madcoder at users.alioth.debian.org madcoder at users.alioth.debian.org
Tue May 23 13:19:20 UTC 2006


Author: madcoder
Date: Tue May 23 13:19:19 2006
New Revision: 699

URL: http://svn.debian.org/wsvn/?sc=1&rev=699
Log:
make s:getAuthor avoid infinite 'while' loops:
 - let it take a range of line to scan
 - return [unknown] if author name is not found.


Modified:
    trunk/runtime/ftplugin/debchangelog.vim

Modified: trunk/runtime/ftplugin/debchangelog.vim
URL: http://svn.debian.org/wsvn/trunk/runtime/ftplugin/debchangelog.vim?rev=699&op=diff
==============================================================================
--- trunk/runtime/ftplugin/debchangelog.vim (original)
+++ trunk/runtime/ftplugin/debchangelog.vim Tue May 23 13:19:19 2006
@@ -227,21 +227,22 @@
 " }}}
 " {{{1 folding
 
-" look for an author name searching backward from a given line number
-function! s:getAuthor(lnum)
-  let line = getline(a:lnum)
-  let backsteps = 0
-  while line !~ '^ --'
-    let backsteps += 1
-    let line = getline(a:lnum - backsteps)
+" look for an author name in the [zonestart zoneend] lines searching backward
+function! s:getAuthor(zonestart, zoneend)
+  let linepos = a:zoneend
+  while linepos >= a:zonestart
+    let line = getline(linepos)
+    if line =~ '^ --'
+      return substitute(line, '^ --\s*\([^<]\+\)\s*.*', '\1', '')
+    endif
+    let linepos -= 1
   endwhile
-  let author = substitute(line, '^ --\s*\([^<]\+\)\s*.*', '\1', '')
-  return author
+  return '[unknown]'
 endfunction
 
 function! DebChangelogFoldText()
   if v:folddashes == '-'  " changelog entry fold
-    return foldtext() . ' -- ' . s:getAuthor(v:foldend) . ' '
+    return foldtext() . ' -- ' . s:getAuthor(v:foldstart, v:foldend) . ' '
   endif
   return foldtext()
 endfunction




More information about the pkg-vim-maintainers mailing list