patch 9.1.1307: make syntax does not reliably detect different flavors
Problem: GNU extensions, such as `ifeq` and `wildcard` function, are
highlighted in BSDmakefile
Solution: detect BSD, GNU, or Microsoft implementation according to
filename, user-defined global variables, or file contents
closes: #17089
Co-authored-by: Roland Hieber <rohieb@users.noreply.github.com>
Signed-off-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index 98dba23..d334282 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -2857,15 +2857,48 @@
func Test_make_file()
filetype on
+ " BSD Makefile
+ call writefile([''], 'BSDmakefile', 'D')
+ split BSDmakefile
+ call assert_equal('bsd', get(b:, 'make_flavor', ''))
+ bwipe!
+
+ call writefile(['.ifmake all', '.endif'], 'XMakefile.mak', 'D')
+ split XMakefile.mak
+ call assert_equal('bsd', get(b:, 'make_flavor', ''))
+ bwipe!
+
+ " GNU Makefile
+ call writefile([''], 'GNUmakefile', 'D')
+ split GNUmakefile
+ call assert_equal('gnu', get(b:, 'make_flavor', ''))
+ bwipe!
+
+ call writefile(['ifeq ($(foo),foo)', 'endif'], 'XMakefile.mak', 'D')
+ split XMakefile.mak
+ call assert_equal('gnu', get(b:, 'make_flavor', ''))
+ bwipe!
+
+ call writefile(['define foo', 'endef'], 'XMakefile.mak', 'D')
+ split XMakefile.mak
+ call assert_equal('gnu', get(b:, 'make_flavor', ''))
+ bwipe!
+
+ call writefile(['vim := $(wildcard *.vim)'], 'XMakefile.mak', 'D')
+ split XMakefile.mak
+ call assert_equal('gnu', get(b:, 'make_flavor', ''))
+ bwipe!
+
" Microsoft Makefile
call writefile(['# Makefile for Windows', '!if "$(VIMDLL)" == "yes"'], 'XMakefile.mak', 'D')
split XMakefile.mak
- call assert_equal(1, get(b:, 'make_microsoft', 0))
+ call assert_equal('microsoft', get(b:, 'make_flavor', ''))
bwipe!
+ " BSD or GNU
call writefile(['# get the list of tests', 'include testdir/Make_all.mak'], 'XMakefile.mak', 'D')
split XMakefile.mak
- call assert_equal(0, get(b:, 'make_microsoft', 0))
+ call assert_notequal('microsoft', get(b:, 'make_flavor', ''))
bwipe!
filetype off
diff --git a/src/version.c b/src/version.c
index 166c76d..bdfcde2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1307,
+/**/
1306,
/**/
1305,