Remove detect requirement and detect in jinja file

Ref #1415
This commit is contained in:
Zachary Yedidia
2019-12-28 22:27:44 -05:00
parent 4b0348f64a
commit bd83c6a8a9
5 changed files with 19 additions and 19 deletions

View File

@@ -6,7 +6,7 @@ import "regexp"
// to determine the filetype of the file
// It will return the corresponding syntax definition for the filetype
func MatchFiletype(ftdetect [2]*regexp.Regexp, filename string, firstLine []byte) bool {
if ftdetect[0].MatchString(filename) {
if ftdetect[0] != nil && ftdetect[0].MatchString(filename) {
return true
}

View File

@@ -106,10 +106,6 @@ func MakeHeader(data []byte) (*Header, error) {
fnameRgx := string(lines[1])
headerRgx := string(lines[2])
if fnameRgx == "" && headerRgx == "" {
return nil, errors.New("Syntax file must include at least one detection regex")
}
if fnameRgx != "" {
header.FtDetect[0], err = regexp.Compile(fnameRgx)
}
@@ -136,10 +132,6 @@ func MakeHeaderYaml(data []byte) (*Header, error) {
header := new(Header)
header.FileType = hdrYaml.FileType
if hdrYaml.Detect.FNameRgx == "" && hdrYaml.Detect.HeaderRgx == "" {
return nil, errors.New("Syntax file must include at least one detection regex")
}
if hdrYaml.Detect.FNameRgx != "" {
header.FtDetect[0], err = regexp.Compile(hdrYaml.Detect.FNameRgx)
}