]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1820: Rexx files may not be recognised v9.0.1820
authorDoug Kearns <dougkearns@gmail.com>
Tue, 29 Aug 2023 20:21:35 +0000 (22:21 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 29 Aug 2023 20:21:35 +0000 (22:21 +0200)
Problem:  Rexx files may not be recognised
Solution: Add shebang detection and improve disambiguation of *.cls
  files

closes: #12951

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
runtime/autoload/dist/ft.vim
runtime/autoload/dist/script.vim
src/testdir/test_filetype.vim
src/version.c

index 6c15c29b5307ddfccc47ff701a57404ebc97dce4..2958f45d0a6857284f3b01d4d3fadaf216fffa22 100644 (file)
@@ -147,13 +147,19 @@ export def FTcls()
   endif
 
   var line1 = getline(1)
-
-  if line1 =~ '^\v%(\%|\\)'
-    setf tex
-  elseif line1[0] == '#' && line1 =~ 'rexx'
+  if line1 =~ '^#!.*\<\%(rexx\|regina\)\>'
     setf rexx
+    return
   elseif line1 == 'VERSION 1.0 CLASS'
     setf vb
+    return
+  endif
+
+  var nonblank1 = getline(nextnonblank(1))
+  if nonblank1 =~ '^\v%(\%|\\)'
+    setf tex
+  elseif nonblank1 =~ '^\s*\%(/\*\|::\w\)'
+    setf rexx
   else
     setf st
   endif
index 6163003aa4414f8f4127e1aa167a6d9bae32e8af..fca5dcdbe618ecbba05a2566155a95d5d9fde333 100644 (file)
@@ -213,6 +213,10 @@ export def Exe2filetype(name: string, line1: string): string
   elseif name =~ '^crystal\>'
     return 'crystal'
 
+    # Rexx
+  elseif name =~ '^\%(rexx\|regina\)\>'
+    return 'rexx'
+
   endif
 
   return ''
index aff66d89b1c90bfb652719dbc42246dcb50f8830..8285fa1e86e5adf41652909a09d9b54e4206b1a0 100644 (file)
@@ -945,6 +945,8 @@ def s:GetScriptChecks(): dict<list<list<string>>>
     forth:  [['#!/path/gforth']],
     icon:   [['#!/path/icon']],
     crystal: [['#!/path/crystal']],
+    rexx:   [['#!/path/rexx'],
+            ['#!/path/regina']],
   }
 enddef
 
@@ -2045,7 +2047,22 @@ func Test_cls_file()
 
   " Rexx
 
-  call writefile(['# rexx'], 'Xfile.cls')
+  call writefile(['#!/usr/bin/rexx'], 'Xfile.cls')
+  split Xfile.cls
+  call assert_equal('rexx', &filetype)
+  bwipe!
+
+  call writefile(['#!/usr/bin/regina'], 'Xfile.cls')
+  split Xfile.cls
+  call assert_equal('rexx', &filetype)
+  bwipe!
+
+  call writefile(['/* Comment */'], 'Xfile.cls')
+  split Xfile.cls
+  call assert_equal('rexx', &filetype)
+  bwipe!
+
+  call writefile(['::class Foo subclass Bar public'], 'Xfile.cls')
   split Xfile.cls
   call assert_equal('rexx', &filetype)
   bwipe!
index 8862ad479abdd999c33d15bed76dec3dc76b802e..c23c2575c00296c9ed8fe77729f35ca79990fa4f 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1820,
 /**/
     1819,
 /**/