]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0731: inconsistent case sensitive extension matching v9.1.0731
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>
Sun, 15 Sep 2024 17:23:25 +0000 (19:23 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 15 Sep 2024 17:23:25 +0000 (19:23 +0200)
Problem:  inconsistent case sensitive extension matching
Solution: unify case sensitive extension matching (Evgeni Chasnovski).

There are different approaches of how extensions are matched with
respect to case sensitivity. In particular, '\c' flag is used in pattern
whereas in most places case sensitive matching is guarded behind
`has("fname_case")` condition.

Replace all instances of '\c' with an explicit case sensitive pattern
variants guarded by `has("fname_case")`. Strictly speaking, this is a
breaking change because only two (most common and prevailingly tested)
variants are now matched: upper first letter and upper all letters.

closes: #15672

Signed-off-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/filetype.vim
src/testdir/test_filetype.vim
src/version.c

index 3af6d03eac5de90a84d350de3b98abf637bad812..3441518e580442a1b7c5941496527beb9fc5a4d7 100644 (file)
@@ -237,7 +237,10 @@ au BufNewFile,BufRead *.bat                        setf dosbatch
 au BufNewFile,BufRead *.cmd
        \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
 " ABB RAPID or Batch file for MSDOS.
-au BufNewFile,BufRead *.sys\c                  call dist#ft#FTsys()
+au BufNewFile,BufRead *.sys                    call dist#ft#FTsys()
+if has("fname_case")
+  au BufNewFile,BufRead *.Sys,*.SYS                    call dist#ft#FTsys()
+endif
 
 " Batch file for 4DOS
 au BufNewFile,BufRead *.btm                    call dist#ft#FTbtm()
@@ -455,7 +458,10 @@ au BufNewFile,BufRead *.ent                        call dist#ft#FTent()
 au BufNewFile,BufRead .cling_history           setf cpp
 
 " Clipper, FoxPro, ABB RAPID or eviews
-au BufNewFile,BufRead *.prg\c                  call dist#ft#FTprg()
+au BufNewFile,BufRead *.prg                    call dist#ft#FTprg()
+if has("fname_case")
+  au BufNewFile,BufRead *.Prg,*.PRG                    call dist#ft#FTprg()
+endif
 
 " Clojure
 au BufNewFile,BufRead *.clj,*.cljs,*.cljx,*.cljc               setf clojure
@@ -602,7 +608,10 @@ au BufNewFile,BufRead */tex/latex/**.cfg           setf tex
 au BufNewFile,BufRead .wakatime.cfg            setf dosini
 
 " Configure files
-au BufNewFile,BufRead *.cfg\c                  call dist#ft#FTcfg()
+au BufNewFile,BufRead *.cfg                    call dist#ft#FTcfg()
+if has("fname_case")
+  au BufNewFile,BufRead *.Cfg,*.CFG                    call dist#ft#FTcfg()
+endif
 
 " Cucumber
 au BufNewFile,BufRead *.feature                        setf cucumber
@@ -1227,9 +1236,14 @@ au BufNewFile,BufRead *.kdl                      setf kdl
 au BufNewFile,BufRead *.kix                    setf kix
 
 " Kuka Robot Language
-au BufNewFile,BufRead *.src\c                  call dist#ft#FTsrc()
-au BufNewFile,BufRead *.dat\c                  call dist#ft#FTdat()
-au BufNewFile,BufRead *.sub\c                  setf krl
+au BufNewFile,BufRead *.src                    call dist#ft#FTsrc()
+au BufNewFile,BufRead *.dat                    call dist#ft#FTdat()
+au BufNewFile,BufRead *.sub                    setf krl
+if has("fname_case")
+   au BufNewFile,BufRead *.Src,*.SRC                   call dist#ft#FTsrc()
+   au BufNewFile,BufRead *.Dat,*.DAT                   call dist#ft#FTdat()
+   au BufNewFile,BufRead *.Sub,*.SUB                   setf krl
+endif
 
 " Kimwitu[++]
 au BufNewFile,BufRead *.k                      setf kwt
@@ -1479,7 +1493,10 @@ au BufNewFile,BufRead .msmtprc                   setf msmtp
 au BufNewFile,BufRead *.mmp                    setf mmp
 
 " ABB Rapid, Modula-2, Modsim III or LambdaProlog
-au BufNewFile,BufRead *.mod\c                  call dist#ft#FTmod()
+au BufNewFile,BufRead *.mod                    call dist#ft#FTmod()
+if has("fname_case")
+   au BufNewFile,BufRead *.Mod,*.MOD                   call dist#ft#FTmod()
+endif
 
 " Modula-3 (.m3, .i3, .mg, .ig)
 au BufNewFile,BufRead *.[mi][3g]               setf modula3
index c10023d94cc5eed5f58a382f1152730a467bbc9f..45a5df2dc3450b8ac5d4d7ba7cb19f4c1c7181ca 100644 (file)
@@ -1155,15 +1155,14 @@ func Test_cfg_file()
   unlet g:filetype_cfg
 
   " RAPID cfg
-  let ext = 'cfg'
   for i in ['EIO', 'MMC', 'MOC', 'PROC', 'SIO', 'SYS']
-    call writefile([i .. ':CFG'], 'cfgfile.' .. ext)
-    execute "split cfgfile." .. ext
-    call assert_equal('rapid', &filetype)
-    bwipe!
-    call delete('cfgfile.' .. ext)
-    " check different case of file extension
-    let ext = substitute(ext, '\(\l\)', '\u\1', '')
+    for ext in ['cfg', 'Cfg', 'CFG']
+      call writefile([i .. ':CFG'], 'cfgfile.' .. ext)
+      execute "split cfgfile." .. ext
+      call assert_equal('rapid', &filetype)
+      bwipe!
+      call delete('cfgfile.' .. ext)
+    endfor
   endfor
 
   " clean up
index 4f6375bd3bb95fcaa05f83bdf6802ea588f1c548..a2d6bfd37f5e86129209abeec25764e5094e94da 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    731,
 /**/
     730,
 /**/