]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0972: filetype: TI linker map files are not recognized v9.1.0972
authorWu, Zhenyu <wuzhenyu@ustc.edu>
Sun, 29 Dec 2024 14:28:46 +0000 (15:28 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 29 Dec 2024 14:28:46 +0000 (15:28 +0100)
Problem:  filetype: TI linker map files are not recognized
Solution: detect TI linker map files as lnkmap filetype
          (Wu, Zhenyu)

References:
https://downloads.ti.com/docs/esd/SPRUI03A/Content/SPRUI03A_HTML/linker_description.html

closes: #16324

Signed-off-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/filetype.vim
runtime/ftplugin/lnkmap.vim [new file with mode: 0644]
runtime/syntax/lnkmap.vim [new file with mode: 0644]
src/testdir/test_filetype.vim
src/version.c

index 2a11f261cd495b23dec2d0878b362cd2b8edc980..754857683009ae21218ef61a99a56cb5c98299c5 100644 (file)
@@ -1493,7 +1493,12 @@ au BufNewFile,BufRead */etc/man.conf,man.config  setf manconf
 au BufNewFile,BufRead *.mv,*.mpl,*.mws         setf maple
 
 " Map (UMN mapserver config file)
-au BufNewFile,BufRead *.map                    setf map
+au BufNewFile,BufRead *.map
+       \ if getline(1) =~ '^\*\+$' |
+       \   setf lnkmap |
+       \ else |
+       \   setf map |
+       \ endif
 
 " Markdown
 au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md
diff --git a/runtime/ftplugin/lnkmap.vim b/runtime/ftplugin/lnkmap.vim
new file mode 100644 (file)
index 0000000..46fb070
--- /dev/null
@@ -0,0 +1,16 @@
+" Vim filetype plugin file
+" Language:    TI Linker map
+" Document:    https://downloads.ti.com/docs/esd/SPRUI03A/Content/SPRUI03A_HTML/linker_description.html
+" Maintainer:  Wu, Zhenyu <wuzhenyu@ustc.edu>
+" Last Change: 2024 Dec 25
+
+if exists("b:did_ftplugin")
+  finish
+endif
+
+" Don't load another plugin for this buffer
+let b:did_ftplugin = 1
+
+let b:undo_ftplugin = "setl iskeyword<"
+
+setl iskeyword+=.
diff --git a/runtime/syntax/lnkmap.vim b/runtime/syntax/lnkmap.vim
new file mode 100644 (file)
index 0000000..a1d109e
--- /dev/null
@@ -0,0 +1,35 @@
+" Vim syntax file
+" Language:    TI Linker map
+" Document:    https://downloads.ti.com/docs/esd/SPRUI03A/Content/SPRUI03A_HTML/linker_description.html
+" Maintainer:  Wu, Zhenyu <wuzhenyu@ustc.edu>
+" Last Change: 2024 Dec 25
+
+if exists("b:current_syntax")
+  finish
+endif
+
+syn match lnkmapTime                   ">> .*$"
+syn region lnkmapHeadline              start="^\*\+$" end="^\*\+$"
+syn match lnkmapHeadline               "^[A-Z][-A-Z0-9 ']*\ze\%(:\|$\)"
+syn match lnkmapSectionDelim           "^=\+$"
+syn match lnkmapTableDelim             "\%(^\|\s\)\zs---*\ze\%($\|\s\)"
+syn match lnkmapNumber                 "\%(^\|\s\)\zs[0-9a-f]\+\ze\%($\|\s\)"
+syn match lnkmapSections               '\<\.\k\+\>'
+syn match lnkmapFile                   '[^ =]\+\%(\.\S\+\)\+\>'
+syn match lnkmapLibFile                        '[^ =]\+\.lib\>'
+syn match lnkmapAttrib                 '\<[RWIX]\+\>'
+syn match lnkmapAttrib                 '\s\zs--HOLE--\ze\%\(\s\|$\)'
+syn keyword lnkmapAttrib               UNINITIALIZED
+
+
+hi def link lnkmapTime                 Comment
+hi def link lnkmapHeadline             Title
+hi def link lnkmapSectionDelim         PreProc
+hi def link lnkmapTableDelim           PreProc
+hi def link lnkmapNumber               Number
+hi def link lnkmapSections             Macro
+hi def link lnkmapFile                 String
+hi def link lnkmapLibFile              Special
+hi def link lnkmapAttrib               Type
+
+let b:current_syntax = "lnkmap"
index f449d0d86a7e80ff17639d56d5460755c49def72..0f05d19df8c83605a65629c8ecb958b1b333f441 100644 (file)
@@ -463,7 +463,6 @@ def s:GetFilenameChecks(): dict<list<string>>
     mallard: ['file.page'],
     man: ['file.man'],
     manconf: ['/etc/man.conf', 'man.config', 'any/etc/man.conf'],
-    map: ['file.map'],
     maple: ['file.mv', 'file.mpl', 'file.mws'],
     markdown: ['file.markdown', 'file.mdown', 'file.mkd', 'file.mkdn', 'file.mdwn', 'file.md'],
     masm: ['file.masm'],
@@ -2774,6 +2773,24 @@ func Test_make_file()
   filetype off
 endfunc
 
+func Test_map_file()
+  filetype on
+
+  " TI linker map file
+  call writefile(['******************************************************************************', '               TMS320C6x Linker Unix v7.4.24                   ', '******************************************************************************'], 'Xfile.map', 'D')
+  split Xfile.map
+  call assert_equal('lnkmap', &filetype)
+  bwipe!
+
+  " TI linker map file
+  call writefile(['MAP', 'NAME "local-demo"', 'END'], 'Xfile.map', 'D')
+  split Xfile.map
+  call assert_equal('map', &filetype)
+  bwipe!
+
+  filetype off
+endfunc
+
 func Test_org_file()
   filetype on
 
index b1ce2cce0b3327cc75f98a98975a9e16af957434..18a736c6e8f6b4c612b18b3a618e8d149c9ca3e3 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    972,
 /**/
     971,
 /**/