0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

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>
This commit is contained in:
Eisuke Kawashima
2025-04-15 19:20:06 +02:00
committed by Christian Brabandt
parent 32f2bb6e1e
commit f35bd76b31
7 changed files with 126 additions and 28 deletions

View File

@@ -2857,15 +2857,48 @@ endfunc
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

View File

@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1307,
/**/
1306,
/**/