]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0539: filetype: too many Bitbake include files are recognized v9.2.0539
authorMartin Schwan <m.schwan@phytec.de>
Tue, 26 May 2026 18:41:11 +0000 (18:41 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 26 May 2026 18:41:11 +0000 (18:41 +0000)
Problem:  filetype: too many Bitbake include files are recognized
          (Brahmajit Das, after v9.1.1732)
Solution: Tighten the pattern to detect BitBake include files, update
          tests (Martin Schwan).

Be more strict when detecting BitBake inc files. In particular, only
match include keywords and variable assignments at the beginning of a
line (excluding whitespace).

Use non-capturing groups to slightly improve performance.

Use regex or-operators to exactly match BitBake assignment operators.
The previous expression would falsely match

    FOO .=. "bar"

, which is not valid BitBake syntax. The new capturing group is more
specific and matches only valid assignments.

fixes:  #20288
closes: #20335

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/ft.vim
src/testdir/test_filetype.vim
src/version.c

index c2f3e2afd0612623baeb93f7191effe228f8bfba..f7d42d7f9917b6d9d603b0322ed1ade1dae563f1 100644 (file)
@@ -920,7 +920,7 @@ export def FTinc()
       elseif line =~ '^\s*\%({\|(\*\)' || line =~? ft_pascal_keywords
         setf pascal
         return
-      elseif line =~# '\<\%(require\|inherit\)\>' || line =~# '[A-Z][A-Za-z0-9_:${}/]*\(\[[A-Za-z0-9_:/]\+\]\)*\s\+\%(??\|[?:+.]\)\?=.\? '
+      elseif line =~# '^\s*\<\%(require\|inherit\)\>' || line =~# '^\s*[A-Z][A-Za-z0-9_:${}/]*\%(\[[A-Za-z0-9_:/]\+\]\)*\s\+\%(??=\|[?:+.]=\|=[+.]\?\)\s\+'
         setf bitbake
         return
       endif
index 47df92d0bd915d69c131066d44dd19e355024546..23651f44b4bf2be5e0e71f4e220833ad84c3ec46 100644 (file)
@@ -2831,11 +2831,17 @@ endfunc
 func Test_inc_file()
   filetype on
 
+  " pov
   call writefile(['this is the fallback'], 'Xfile.inc', 'D')
   split Xfile.inc
   call assert_equal('pov', &filetype)
   bwipe!
 
+  call writefile(['!Comment with formular a = b/c'], 'Xfile.inc')
+  split Xfile.inc
+  call assert_equal('pov', &filetype)
+  bwipe!
+
   " ObjectScript routine
   call writefile(['ROUTINE Sample [Type=INC]'], 'Xfile.inc', 'D')
   split Xfile.inc
@@ -2888,6 +2894,11 @@ func Test_inc_file()
   call assert_equal('bitbake', &filetype)
   bwipe!
 
+  call writefile(['MACHINE ?= "qemu"'], 'Xfile.inc')
+  split Xfile.inc
+  call assert_equal('bitbake', &filetype)
+  bwipe!
+
   call writefile(['MACHINE ??= "qemu"'], 'Xfile.inc')
   split Xfile.inc
   call assert_equal('bitbake', &filetype)
index 0707c875de63589bdd4c1795b163a6bdaf326ac0..3be49ccbc34820816d09e11912a0b48a1d4b2ea5 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    539,
 /**/
     538,
 /**/