]> granicus.if.org Git - vim/commitdiff
patch 8.1.1017: off-by-one error in filetype detection v8.1.1017
authorBram Moolenaar <Bram@vim.org>
Sun, 17 Mar 2019 16:16:12 +0000 (17:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 Mar 2019 16:16:12 +0000 (17:16 +0100)
Problem:    Off-by-one error in filetype detection.
Solution:   Also check the last line of the file.

runtime/autoload/dist/ft.vim
src/version.c

index de45faa4f8df799d75cf2400909ad07c84aeb1ec..a97bad3b56fc94ebbe6b23faa6d510691fd101a6 100644 (file)
@@ -197,7 +197,7 @@ func dist#ft#FTe()
     exe 'setf ' . g:filetype_euphoria
   else
     let n = 1
-    while n < 100 && n < line("$")
+    while n < 100 && n <= line("$")
       if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
        setf specman
        return
@@ -211,7 +211,7 @@ endfunc
 " Distinguish between HTML, XHTML and Django
 func dist#ft#FThtml()
   let n = 1
-  while n < 10 && n < line("$")
+  while n < 10 && n <= line("$")
     if getline(n) =~ '\<DTD\s\+XHTML\s'
       setf xhtml
       return
@@ -222,13 +222,13 @@ func dist#ft#FThtml()
     endif
     let n = n + 1
   endwhile
-  setf html
+  setf FALLBACK html
 endfunc
 
 " Distinguish between standard IDL and MS-IDL
 func dist#ft#FTidl()
   let n = 1
-  while n < 50 && n < line("$")
+  while n < 50 && n <= line("$")
     if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
       setf msidl
       return
@@ -699,7 +699,7 @@ endfunc
 
 func dist#ft#FTxml()
   let n = 1
-  while n < 100 && n < line("$")
+  while n < 100 && n <= line("$")
     let line = getline(n)
     " DocBook 4 or DocBook 5.
     let is_docbook4 = line =~ '<!DOCTYPE.*DocBook'
@@ -725,7 +725,7 @@ endfunc
 
 func dist#ft#FTy()
   let n = 1
-  while n < 100 && n < line("$")
+  while n < 100 && n <= line("$")
     let line = getline(n)
     if line =~ '^\s*%'
       setf yacc
index ff3628a8c554d0bd0a78495790cb926f16d8d043..a49f6fb0c6bd6ef275876ffb53a471551895f67a 100644 (file)
@@ -779,6 +779,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1017,
 /**/
     1016,
 /**/